FeaturesPluginsDocs & SupportCommunityPartners

org.netbeans.modules.jackpot/2 2 1

org.netbeans.api.jackpot
Class QueryOperations

java.lang.Object
  extended by org.netbeans.api.jackpot.QueryOperations
Direct Known Subclasses:
ConversionOperations

public class QueryOperations
extends Object

Utility methods for common query tasks.


Constructor Summary
QueryOperations(org.netbeans.api.java.source.CompilationInfo info)
          Create a QueryOperations instance.
 
Method Summary
static int blockLength(Tree a)
          Returns the number of statements in the tree.
static Tree deblock(Tree t)
          Removes unnecessary surrounding braces or parentheses.
static StatementTree getStatement(int index, StatementTree a)
          Returns a statement at a specified index in another statement.
 boolean isConstant(TreePath path)
          Returns true if the tree defines a constant variable, which in this context means that it is either a final instance variable, a String or a literal.
static boolean isEmpty(Tree t)
          Returns whether a tree is an empty block or statement.
static boolean isFalse(Tree tree)
          Return true if the tree is an IdentifierTree defining the string "false", a Boolean.FALSE literal, or a ParenthesizedExpression surrounding one of these.
static boolean isTrue(Tree tree)
          Return true if the tree is an IdentifierTree defining the string "true", a Boolean.TRUE literal, or a ParenthesizedExpression surrounding one of these.
static boolean sideEffectFree(List<Tree> list)
          Returns true if the list is free of side effects.
static boolean sideEffectFree(Tree t)
          Returns true if the tree is free of side effects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryOperations

public QueryOperations(org.netbeans.api.java.source.CompilationInfo info)
Create a QueryOperations instance.

Parameters:
info - the CompilationInfo used by the calling Query.
Method Detail

deblock

public static Tree deblock(Tree t)
Removes unnecessary surrounding braces or parentheses. For a TreeBlock with a single statement this will return that statement. For a ParenthesizedExpression, the expression will be returned. For all other cases the specified tree will be returned.

Parameters:
t - the tree to be deblocked
Returns:
the resulting tree, or t if it was not deblocked

sideEffectFree

public static boolean sideEffectFree(Tree t)
Returns true if the tree is free of side effects.

Parameters:
t - the tree to inspect
Returns:
true if the tree contains no nodes which cause side-effects

sideEffectFree

public static boolean sideEffectFree(List<Tree> list)
Returns true if the list is free of side effects.

Parameters:
list - the list of trees to inspect
Returns:
true if the list has no trees with side-effects

isEmpty

public static boolean isEmpty(Tree t)
Returns whether a tree is an empty block or statement.

Parameters:
t - the tree to inspect
Returns:
true if the tree is empty

isTrue

public static boolean isTrue(Tree tree)
Return true if the tree is an IdentifierTree defining the string "true", a Boolean.TRUE literal, or a ParenthesizedExpression surrounding one of these.

Parameters:
tree - the tree to inspect
Returns:
true if the tree evaluates to Boolean.true

isFalse

public static boolean isFalse(Tree tree)
Return true if the tree is an IdentifierTree defining the string "false", a Boolean.FALSE literal, or a ParenthesizedExpression surrounding one of these.

Parameters:
tree - the tree to inspect
Returns:
true if the tree evaluates to Boolean.false

blockLength

public static int blockLength(Tree a)
Returns the number of statements in the tree. If it is not a block, returns one for itself (0 for a null tree). Note: this routine does not recurse into the statements to find sub-statements.

Parameters:
a - the tree to inspect
Returns:
the number of statements in this tree

getStatement

public static StatementTree getStatement(int index,
                                         StatementTree a)
Returns a statement at a specified index in another statement. For BlockTree instances this is equivalent to tree.getStatements().get(index). For other statements, any index but zero will return null.

Parameters:
index - the statement index
a - the statement from which the sub-statement is fetched
Returns:
the sub-statement, or null if there is no statement at that index

isConstant

public boolean isConstant(TreePath path)
Returns true if the tree defines a constant variable, which in this context means that it is either a final instance variable, a String or a literal.

Parameters:
path - the tree to inspect
Returns:
true if the tree is constant

org.netbeans.modules.jackpot/2 2 1

Built on April 6 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
Companion
Projects:
MySQL Database Server   Open JDK: an Open SourceJDK   GlassFish Community: an Open Source Application Server    Mobile & Embedded Community    Open Solaris   java.net - The Source for Java Technology Collaboration   Virtual Box - full virtualizer  Open ESB - The Open Enterprise Service Bus Powered by