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 ExpressionSymbol

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.ExpressionSymbol
All Implemented Interfaces:
JavaSyntaxCodes, JavaTokens, Nameable, ExpressionObject
Direct Known Subclasses:
CreatorExpressionSymbol, ExpressionList

public class ExpressionSymbol
extends JavaSymbol
implements Nameable, ExpressionObject, JavaTokens

The ExpressionSymbol is essentially the union of all the various operators and primaries. If it is a primary, selector, or method invocation, it has a name. Otherwise, it is an operator of some sort and has operands. With each enumerated constant is a description of which fields are non-null and useful.


Field Summary
static int CATEGORY_ARGUMENTS
          This is an argument list and is an ExpressionList object.
static int CATEGORY_ARRAY_CONSTANT
          This is an array constant and is an ExpressionList object.
static int CATEGORY_ASG_OPERATOR
          This is an assignment operator and has two operands.
static int CATEGORY_BRACKET_DEREFERENCE
          This is an array dereference and has two operands.
static int CATEGORY_CONSTANT
          This is a primary (or a selector) that is a literal.
static int CATEGORY_CREATOR
          This is a creator (the 'new' operator) and is a CreatorExpressionSymbol.
static int CATEGORY_DOT_OPERATOR
          This is the dot operator and has two operands.
static int CATEGORY_INFIX_OPERATOR
          This is an infix operator and has two operands.
static int CATEGORY_PAREN_WRAPPER
          This is an expression wrapper indicating that the single operand of this expression is contained within a matched set of parenthesis.
static int CATEGORY_POSTFIX_OPERATOR
          This is a postfix operator and has one operand.
static int CATEGORY_PREFIX_OPERATOR
          This is a prefix operator (but not a typecast) and has one operand.
static int CATEGORY_PRIMARY
          This is a primary (or a selector) that is not a literal: an identifier, 'class', 'super', 'this', 'void', or a primitive type.
static int CATEGORY_PRIMARY_BRACKETS
          These are empty brackets used to indicate a type and has one operand which is the primary.
static int CATEGORY_QUES_OPERATOR
          This is the question-colon operator and has three operands.
static int CATEGORY_TYPECAST
          Though the typecast is a prefix operator in Java, it has been separated into a different category to make this API a little easier to use.
static int CATEGORY_UNPARSED
          This is an unparsed expression.
static int CATEGORY_WRAPPER
          This is an expression wrapper and has one operand which is the actual expression tree.
protected  ExpressionSymbol firstOperand
          The direct operand that we're wrapping.
 
Fields inherited from interface oracle.javatools.parser.util.ExpressionObject
ATOM, INFIX_OP, LEFT_ASSOC, MAX_PRECEDENCE, NON_ASSOC, POSTFIX_OP, PREFIX_OP, RIGHT_ASSOC, TERNARY_OP
 
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
 void addOperand(ExpressionObject o)
          Adds an operand to this operator object.
 int classify()
          Returns the whether an ExpressionObject is an atom, a prefix operator, an infix operator, or a postfix operator.
 void closeOperator(java.lang.Object o)
          Called after all operands have been added to allow post-processing.
 int getAssociativity()
          Returns the associativity of this operator according to the above constants.
 int getCategory()
           
 int getDataValue()
           
 int getExactCode()
           
 ExpressionSymbol[] getExpressions()
           
 ExpressionSymbol getFirstOperand()
           
 int getIndex()
           
 NameSymbol getName()
          Gets the name symbol.
 int getPrecedence()
          Returns a positive number representing the precedence of this ExpressionObject operator.
static int getPrecedence(int value, boolean prefix)
           
 ExpressionSymbol getSecondOperand()
           
 ExpressionSymbol getThirdOperand()
           
 TypeSymbol getTypecast()
           
 boolean isFilledIn()
          Depending on the type of parse the client requested, ExpressionSymbols for variable initializers may be unfilled.
 void setName(NameSymbol name)
          Sets the name symbol.
 
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

CATEGORY_UNPARSED

public static final int CATEGORY_UNPARSED
This is an unparsed expression. It may or may not be a valid expression. Use JavaParser.parseInto to parse this expression symbol.

See Also:
Constant Field Values

CATEGORY_WRAPPER

public static final int CATEGORY_WRAPPER
This is an expression wrapper and has one operand which is the actual expression tree. This wrapper provides the start and end offsets for the entire expression.

See Also:
Constant Field Values

CATEGORY_ASG_OPERATOR

public static final int CATEGORY_ASG_OPERATOR
This is an assignment operator and has two operands. getExactCode() returns the exact operator listed in JavaTokens. You may want to also refer to JavaSyntaxRecognizer.isAssignmentOperator().

See Also:
Constant Field Values

CATEGORY_QUES_OPERATOR

public static final int CATEGORY_QUES_OPERATOR
This is the question-colon operator and has three operands. getExactCode() just returns JavaTokens.TK_QUES.

See Also:
Constant Field Values

CATEGORY_INFIX_OPERATOR

public static final int CATEGORY_INFIX_OPERATOR
This is an infix operator and has two operands. getExactCode() returns the exact operator listed in JavaTokens. You may also want to refer to JavaSyntaxRecognizer.isInfixOperator().

See Also:
Constant Field Values

CATEGORY_PREFIX_OPERATOR

public static final int CATEGORY_PREFIX_OPERATOR
This is a prefix operator (but not a typecast) and has one operand. getExactCode() returns the exact operator listed in JavaTokens. You may also want to refer to JavaSyntaxRecognizer.isPrefixOperator().

See Also:
Constant Field Values

CATEGORY_TYPECAST

public static final int CATEGORY_TYPECAST
Though the typecast is a prefix operator in Java, it has been separated into a different category to make this API a little easier to use. A typecast has one operand and getTypecast() returns a non-null expression. getExactCode() just returns JavaTokens.TK_LPAREN.

See Also:
Constant Field Values

CATEGORY_POSTFIX_OPERATOR

public static final int CATEGORY_POSTFIX_OPERATOR
This is a postfix operator and has one operand. getExactCode() returns either JavaTokens.TK_INC or JavaTokens.TK_DEC. You may also want to refer to JavaSyntaxRecognizer.isPostfixOperator().

See Also:
Constant Field Values

CATEGORY_DOT_OPERATOR

public static final int CATEGORY_DOT_OPERATOR
This is the dot operator and has two operands. The first operand is the primary and the second operand is the selector. Note that the selector may be either a PRIMARY or a CREATOR. getExactCode() just returns JavaTokens.TK_DOT.

See Also:
Constant Field Values

CATEGORY_ARGUMENTS

public static final int CATEGORY_ARGUMENTS
This is an argument list and is an ExpressionList object. getExactCode() returns JavaTokens.TK_LPAREN if this is for a method/constructor invocation or JavaTokens.TK_LBRACKET if this is a list of bracket expressions for an array creator. Calling getFirstOperand() will return null. In the old code, you had to cast this object to be an ExpressionList and then call getExpressions(). Now, you can just call getExpressions() directly on this ExpressionSymbol.

See Also:
Constant Field Values

CATEGORY_BRACKET_DEREFERENCE

public static final int CATEGORY_BRACKET_DEREFERENCE
This is an array dereference and has two operands. The first operand is the primary and the second operand is the bracket expression. getExactCode() just returns JavaTokens.TK_LBRACKET.

See Also:
Constant Field Values

CATEGORY_PRIMARY

public static final int CATEGORY_PRIMARY
This is a primary (or a selector) that is not a literal: an identifier, 'class', 'super', 'this', 'void', or a primitive type. getExactCode() returns the the exact code listed in JavaTokens of the LAST name in the name.name.name.name chain. You may also want to refer to JavaSyntaxRecognizer.isPrimitiveType(). You can call getName() to get the name string for this primary. If this is a method invocation, the first operand will be non-null.

See Also:
Constant Field Values

CATEGORY_CREATOR

public static final int CATEGORY_CREATOR
This is a creator (the 'new' operator) and is a CreatorExpressionSymbol. getExactCode() just returns JavaTokens.TK_NEW.

See Also:
Constant Field Values

CATEGORY_PRIMARY_BRACKETS

public static final int CATEGORY_PRIMARY_BRACKETS
These are empty brackets used to indicate a type and has one operand which is the primary. getExactCode() returns gibberish while getDataValue() returns the array dimension. For example, the expression "int [].class" will generate a DOT_OPERATOR which has (1st, 2nd) operands equal to (PRIMARY_BRACKETS getDataValue()==1 with first operand PRIMARY "int", PRIMARY "class").

See Also:
Constant Field Values

CATEGORY_CONSTANT

public static final int CATEGORY_CONSTANT
This is a primary (or a selector) that is a literal. You can getName() to get the name string for this primary. getExactCode() returns the exact code listed in JavaTokens. You may also want to refer to JavaSyntaxRecognizer.isLiteral().

See Also:
Constant Field Values

CATEGORY_ARRAY_CONSTANT

public static final int CATEGORY_ARRAY_CONSTANT
This is an array constant and is an ExpressionList object. getExactCode() returns JavaTokens.TK_LBRACE. Calling getFirstOperand() will return null. In the old code, you had to cast this object to be an ExpressionList and then call getExpressions(). Now, you can just call getExpressions() directly on this ExpressionSymbol.

See Also:
Constant Field Values

CATEGORY_PAREN_WRAPPER

public static final int CATEGORY_PAREN_WRAPPER
This is an expression wrapper indicating that the single operand of this expression is contained within a matched set of parenthesis. This wrapper provides the start and end offsets for the entire parenthesis-contained expression.

See Also:
Constant Field Values

firstOperand

protected ExpressionSymbol firstOperand
The direct operand that we're wrapping.

Method Detail

isFilledIn

public boolean isFilledIn()
Depending on the type of parse the client requested, ExpressionSymbols for variable initializers may be unfilled.


getCategory

public int getCategory()
Returns:
the category of this expression. See enumerated constants below. Each constant describes which fields are non-null.

getExactCode

public int getExactCode()
Returns:
the exact token value of this expression symbol as listed in JavaTokens. Used to gather more specific information beyond the category.

getTypecast

public TypeSymbol getTypecast()
Returns:
the TypeSymbol for the typecast. Non-null if this is of CATEGORY_TYPECAST.

getFirstOperand

public ExpressionSymbol getFirstOperand()
Returns:
the ExpressionSymbol representing the first operand. Non-null if this expression is an operator (and hence has operands).

getSecondOperand

public ExpressionSymbol getSecondOperand()
Returns:
the ExpressionSymbol representing the second operand. Non-null if this operator has a second operand.

getThirdOperand

public ExpressionSymbol getThirdOperand()
Returns:
the ExpressionSymbol representing the third operand. Non-null if this is the conditional operator.

getExpressions

public ExpressionSymbol[] getExpressions()
Returns:
the array of ExpressionSymbols. Non-null if this is an ExpressionList symbol.

getDataValue

public int getDataValue()
Returns:
a data value for this expression. Useful only when this is of type CATEGORY_PRIMARY_BRACKETS.

getIndex

public int getIndex()
Returns:
The unique identifier for this ExpressionSymbol within this parse tree.

classify

public int classify()
Description copied from interface: ExpressionObject
Returns the whether an ExpressionObject is an atom, a prefix operator, an infix operator, or a postfix operator.

Specified by:
classify in interface ExpressionObject

getPrecedence

public int getPrecedence()
Description copied from interface: ExpressionObject
Returns a positive number representing the precedence of this ExpressionObject operator. The smaller the value, the more tightly binding this operator is. No precedence should exceed MAX_PRECEDENCE. Prefix and postfix operators should not have the same precedence. If so, you may get an incorrect tree.

Specified by:
getPrecedence in interface ExpressionObject

getAssociativity

public int getAssociativity()
Description copied from interface: ExpressionObject
Returns the associativity of this operator according to the above constants. Any two operators that have the same precedence must also share the same associativity. If not, you may get an incorrect tree.

Specified by:
getAssociativity in interface ExpressionObject

addOperand

public void addOperand(ExpressionObject o)
Description copied from interface: ExpressionObject
Adds an operand to this operator object.

Specified by:
addOperand in interface ExpressionObject

closeOperator

public void closeOperator(java.lang.Object o)
Description copied from interface: ExpressionObject
Called after all operands have been added to allow post-processing.

Specified by:
closeOperator in interface ExpressionObject
Parameters:
o - The closing argument passed to the ExpressionStack.

getName

public NameSymbol getName()
Description copied from interface: Nameable
Gets the name symbol.

Specified by:
getName in interface Nameable
Returns:
The NameSymbol associated with this object. Null if none.

setName

public void setName(NameSymbol name)
Description copied from interface: Nameable
Sets the name symbol.

Specified by:
setName in interface Nameable

getPrecedence

public static int getPrecedence(int value,
                                boolean prefix)

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.