Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.1.0)

E13403-02

oracle.javatools.parser.java.v1.symbol
Class StatementSymbol

java.lang.Object
  extended by oracle.javatools.parser.util.ArrayListHeap
      extended by oracle.javatools.parser.java.v1.symbol.JavaSymbol
          extended by oracle.javatools.parser.java.v1.symbol.StatementSymbol
All Implemented Interfaces:
JavaSyntaxCodes, JavaTokens, Scope
Direct Known Subclasses:
ControlStatement, SqlStatement

public class StatementSymbol
extends JavaSymbol
implements Scope, JavaTokens

A statement can be only one of the following: an expression statement, a block, or a control statement. Blocks and control statements may also have one break/continue label applied.


Field Summary
protected  java.util.ArrayList labels
           
static int PREFIX_ASSERT
          This is an 'assert' expression statement.
static int PREFIX_BREAK
          This is a 'break' expression statement.
static int PREFIX_CONTINUE
          This is a 'continue' expression statement.
static int PREFIX_RETURN
          This is a 'return' expression statement.
static int PREFIX_THROW
          This is a 'throw' expression statement.
static int TYPE_BLOCK
          This statement is a block.
static int TYPE_CONTROL
          This statement is an instance of a ControlStatement.
static int TYPE_EXPRESSION
          This statement is an expression statement.
static int TYPE_SQL
          This statement is a sql statement for SQLJ sources and is an instance of a SqlStatement.
static int TYPE_SWITCH_CASE
          This statement is a case/default label for switch blocks.
 
Fields inherited from interface oracle.javatools.parser.java.v1.symbol.Scope
SCOPE_BLOCK, SCOPE_CATCH, SCOPE_CLASS, SCOPE_MEMBER, SCOPE_METHOD, SCOPE_ROOT, SCOPE_STATEMENT, SCOPE_TRY
 
Fields inherited from interface oracle.javatools.parser.java.v1.JavaTokens
TK_ABSTRACT, TK_AND_ASG, TK_ASG, TK_ASSERT, TK_BINAND, TK_BINNOT, TK_BINOR, TK_BINXOR, TK_BOOLEAN, TK_BOOLEAN_LITERAL, TK_BREAK, TK_BYTE, TK_CASE, TK_CATCH, TK_CHAR, TK_CHAR_LITERAL, TK_CLASS, TK_COLON, TK_COMMA, TK_CONST, TK_CONTINUE, TK_DEC, TK_DEFAULT, TK_DIV, TK_DIV_ASG, TK_DO, TK_DOC_COMMENT, TK_DOT, TK_DOUBLE, TK_ELSE, TK_EQ, TK_EXTENDS, TK_FINAL, TK_FINALLY, TK_FLOAT, TK_FLOAT_LITERAL, TK_FOR, TK_GE, TK_GOTO, TK_GT, TK_IDENTIFIER, TK_IF, TK_IMPLEMENTS, TK_IMPORT, TK_INC, TK_INSTANCEOF, TK_INT, TK_INT_LITERAL, TK_INTERFACE, TK_LBRACE, TK_LBRACKET, TK_LE, TK_LOGAND, TK_LOGNOT, TK_LOGOR, TK_LONG, TK_LPAREN, TK_LSH, TK_LSH_ASG, TK_LT, TK_MINUS, TK_MINUS_ASG, TK_MOD, TK_MOD_ASG, TK_MUL, TK_MUL_ASG, TK_MULTI_COMMENT, TK_NATIVE, TK_NE, TK_NEW, TK_NULL_LITERAL, TK_OR_ASG, TK_PACKAGE, TK_PLUS, TK_PLUS_ASG, TK_PRIVATE, TK_PROTECTED, TK_PUBLIC, TK_QUES, TK_RBRACE, TK_RBRACKET, TK_RETURN, TK_RPAREN, TK_RSH, TK_RSH_ASG, TK_SEMI, TK_SHORT, TK_SINGLE_COMMENT, TK_SQLJ_STATEMENT, TK_STATIC, TK_STRICTFP, TK_STRING_LITERAL, TK_SUPER, TK_SWITCH, TK_SYNCHRONIZED, TK_THIS, TK_THROW, TK_THROWS, TK_TRANSIENT, TK_TRY, TK_URSH, TK_URSH_ASG, TK_VOID, TK_VOLATILE, TK_WHILE, TK_XOR_ASG
 
Fields inherited from interface oracle.javatools.parser.java.v1.JavaSyntaxCodes
SYNTAX_ARGUMENTS, SYNTAX_ARRAY_CREATOR, SYNTAX_ARRAY_INITIALIZER, SYNTAX_ASG_OPERATOR, SYNTAX_BLOCK, SYNTAX_BRACKET_EXPRESSION, SYNTAX_BRACKETS_OPT, SYNTAX_BROKEN, SYNTAX_CATCH_CLAUSE, SYNTAX_CATCH_PAREN_EXPRESSION, SYNTAX_CLASS_CREATOR, SYNTAX_CLASS_DECLARATION, SYNTAX_CLASS_INITIALIZER, SYNTAX_CODE_ELEMENT, SYNTAX_CONSTRUCTOR_DECLARATION, SYNTAX_CONTROL_PAREN_EXPRESSION, SYNTAX_CREATOR, SYNTAX_DO_STATEMENT, SYNTAX_DOC_COMMENT, SYNTAX_ELSE_CLAUSE, SYNTAX_EXP_WRAPPER, SYNTAX_EXPRESSION, SYNTAX_EXPRESSION_OR_DECL, SYNTAX_EXTENDS, SYNTAX_FIELD_DECLARATION, SYNTAX_FINALLY_CLAUSE, SYNTAX_FOR_CONDITIONAL, SYNTAX_FOR_INIT, SYNTAX_FOR_PAREN_EXPRESSION, SYNTAX_FOR_STATEMENT, SYNTAX_FOR_UPDATE, SYNTAX_FORMAL_PARAMETER, SYNTAX_FORMAL_PARAMETER_LIST, SYNTAX_IDENTIFIER_PRIMARY, SYNTAX_IF_STATEMENT, SYNTAX_IMPLEMENTS, SYNTAX_IMPORT_DECLARATION, SYNTAX_INFIX_OPERATOR, SYNTAX_INIT_ARRAY_CREATOR, SYNTAX_INNER_CLASS_OR_INTERFACE, SYNTAX_INNER_CREATOR, SYNTAX_INTERFACE_DECLARATION, SYNTAX_JAVA_ROOT, SYNTAX_MEMBER_DECLARATION, SYNTAX_METHOD_DECLARATION, SYNTAX_MODIFIERS, SYNTAX_PACKAGE_DECLARATION, SYNTAX_PAREN_EXPRESSION, SYNTAX_POSTFIX_OPERATOR, SYNTAX_PREFIX_OPERATOR, SYNTAX_PRIMARY, SYNTAX_PRIMARY_BRACKETS, SYNTAX_PRIMARY_WORD, SYNTAX_QUALIFIED_IMPORT_NAME, SYNTAX_QUALIFIED_NAME, SYNTAX_QUALIFIED_PRIMARY, SYNTAX_QUES_OPERATOR, SYNTAX_SIMPLE_NAME, SYNTAX_SQLJ_CONTEXT, SYNTAX_SQLJ_STATEMENT, SYNTAX_STATEMENT, SYNTAX_SWITCH_BLOCK, SYNTAX_SWITCH_CASE, SYNTAX_SWITCH_STATEMENT, SYNTAX_SYNCH_STATEMENT, SYNTAX_THROWS, SYNTAX_TRY_STATEMENT, SYNTAX_TYPE, SYNTAX_TYPE_BODY, SYNTAX_TYPE_DECLARATION, SYNTAX_UNINIT_ARRAY_CREATOR, SYNTAX_UNPARSED_BLOCK, SYNTAX_UNPARSED_EXPRESSION, SYNTAX_UNPARSED_PAREN_EXPRESSION, SYNTAX_VARIABLE_DECLARATOR, SYNTAX_VARIABLE_INITIALIZER, SYNTAX_WHILE_STATEMENT
 
Method Summary
 boolean findLabel(java.lang.String name)
          Note that only STATEMENT scopes may return true for findLabel.
 ClassSymbol findType(java.lang.String name)
          If this scope contains local classes or declared member inner classes, check to see if one exists that matches the given name.
 VariableSymbol findVariable(java.lang.String name)
          If this scope contains local variables, method parameters, or declared member fields, check to see if one exists that matches the given name.
 CodeBlockSymbol getBlock()
          If this is a block statement, get the block for this statement.
 CatchClause[] getCatchClauses()
           
 ClassSymbol[] getClasses()
           
 Scope getEnclosingScope()
          Retrieves the most tightly enclosing scope object.
 int getExprPrefix()
          Returns a nonzero value if this is a return, throw, break, or continue expression statement.
 ExpressionSymbol getExprSymbol()
          Returns the expression for this expression statement.
 NameSymbol[] getLabels()
           
 int getModifiers()
          If this is a ClassSymbol or a MemberSymbol, return the modifiers.
 ExpressionSymbol getOptionalExpr()
          Only valid for the 'assert' expression statement.
 int getScopeType()
          Returns the type of this scope according to the enumeration.
 int getStmtType()
           
 VariableSymbol[] getVariables()
           
 void setEnclosingScope(Scope scope)
          Sets the enclosing scope to the given Scope object.
 
Methods inherited from class oracle.javatools.parser.java.v1.symbol.JavaSymbol
getCode, getEndOffset, getParent, getStartOffset
 
Methods inherited from class oracle.javatools.parser.util.ArrayListHeap
allocArrayList, freeArrayList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_EXPRESSION

public static final int TYPE_EXPRESSION
This statement is an expression statement. getExprSymbol() will return non-null and getExprPrefix() will return something meaningful.

See Also:
Constant Field Values

TYPE_CONTROL

public static final int TYPE_CONTROL
This statement is an instance of a ControlStatement.

See Also:
Constant Field Values

TYPE_BLOCK

public static final int TYPE_BLOCK
This statement is a block. getBlock() will return non-null.

See Also:
Constant Field Values

TYPE_SWITCH_CASE

public static final int TYPE_SWITCH_CASE
This statement is a case/default label for switch blocks. getExprSymbol() will return non-null if it's a case label and null if it's a default label.

See Also:
Constant Field Values

TYPE_SQL

public static final int TYPE_SQL
This statement is a sql statement for SQLJ sources and is an instance of a SqlStatement.

See Also:
Constant Field Values

PREFIX_RETURN

public static final int PREFIX_RETURN
This is a 'return' expression statement. The expression should be the return value.

See Also:
Constant Field Values

PREFIX_THROW

public static final int PREFIX_THROW
This is a 'throw' expression statement. The expression should be a Throwable object.

See Also:
Constant Field Values

PREFIX_BREAK

public static final int PREFIX_BREAK
This is a 'break' expression statement. The expression should be an identifier, the block/loop label.

See Also:
Constant Field Values

PREFIX_CONTINUE

public static final int PREFIX_CONTINUE
This is a 'continue' expression statement. The expression should be an identifier, the block/loop label.

See Also:
Constant Field Values

PREFIX_ASSERT

public static final int PREFIX_ASSERT
This is an 'assert' expression statement. The expression is the boolean expression that is being asserted.

See Also:
Constant Field Values

labels

protected java.util.ArrayList labels
Method Detail

getStmtType

public int getStmtType()
Returns:
the type of this statement, see enumerated constants

getBlock

public CodeBlockSymbol getBlock()
If this is a block statement, get the block for this statement.


getExprSymbol

public ExpressionSymbol getExprSymbol()
Returns the expression for this expression statement. Empty statements, i.e. ";", may return null here. Simple statements (e.g. "return;", "break;", etc) will also return null here but will return nonzero for getExprPrefix().

Returns:
the ExpressionSymbol for this expression symbol. Null if this is an empty expression statement.

getOptionalExpr

public ExpressionSymbol getOptionalExpr()
Only valid for the 'assert' expression statement. Non-null if there was a output expression (i.e. "assert boolean-expr: output-exr;"). Null otherwise.


getExprPrefix

public int getExprPrefix()
Returns a nonzero value if this is a return, throw, break, or continue expression statement.

Returns:
the expression prefix, if any. See enumerated constants.

getLabels

public NameSymbol[] getLabels()
Specified by:
getLabels in interface Scope
Returns:
The NameSymbol array corresponding to this statement's label. Unlike all the other parse tree API array calls, this returns null if there are no labels. This is because labels rarely occur and there's no point creating a zero-length array for each statement.

getScopeType

public int getScopeType()
Returns the type of this scope according to the enumeration. Yes, this is kind of redundant, but it's much faster than an if-else instanceof test.

Specified by:
getScopeType in interface Scope

getEnclosingScope

public Scope getEnclosingScope()
Retrieves the most tightly enclosing scope object.

Specified by:
getEnclosingScope in interface Scope

setEnclosingScope

public void setEnclosingScope(Scope scope)
Sets the enclosing scope to the given Scope object.

Specified by:
setEnclosingScope in interface Scope

getModifiers

public int getModifiers()
If this is a ClassSymbol or a MemberSymbol, return the modifiers. Else return zero.

Specified by:
getModifiers in interface Scope

findLabel

public boolean findLabel(java.lang.String name)
Description copied from interface: Scope
Note that only STATEMENT scopes may return true for findLabel. Memory-efficient operation.

Specified by:
findLabel in interface Scope
Returns:
True if the given label applies to this scope instance.

findVariable

public VariableSymbol findVariable(java.lang.String name)
If this scope contains local variables, method parameters, or declared member fields, check to see if one exists that matches the given name. If yes, return it. Return null, otherwise.

Specified by:
findVariable in interface Scope

findType

public ClassSymbol findType(java.lang.String name)
If this scope contains local classes or declared member inner classes, check to see if one exists that matches the given name. If yes, return it. Return null otherwise.

Specified by:
findType in interface Scope

getVariables

public VariableSymbol[] getVariables()
Specified by:
getVariables in interface Scope
Returns:
Retrieves all variables at this scope.

getClasses

public ClassSymbol[] getClasses()
Specified by:
getClasses in interface Scope
Returns:
Retrieves all classes at this scope.

getCatchClauses

public CatchClause[] getCatchClauses()
Specified by:
getCatchClauses in interface Scope
Returns:
Retrieves all catch clauses. Only TRY scopes should return a non-zero length array here.

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.1.0)

E13403-02

Copyright © 1997, 2009, Oracle. All rights reserved.