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 JavaSymbolFactory

java.lang.Object
  extended by oracle.javatools.parser.java.v1.symbol.JavaSymbolFactory
All Implemented Interfaces:
JavaSyntaxCodes

public class JavaSymbolFactory
extends java.lang.Object
implements JavaSyntaxCodes

The JavaSymbolFactory is the layer between the JavaTreeGenerator and the Java API. It completely hides the parse data structure from the TreeGenerator. The abstraction also works the other way. The JavaTreeGenerator hides the syntax stream from the data structure. The JavaSymbolFactory is heavily dependent on the JavaTreeGenerator. If the TreeGenerator is changed to support different children for certain nodes, the JavaSymbolFactory should be inspected to ascertain if there is any impact.

General inter-workings

This static factory class is responsible for both creating the new JavaSymbols as well as wiring them up. A client could probably explicity wire in symbols into the tree to their liking, but that's not officially supported and should be left up to the JavaTreeGenerator.

A lot of this code could be taken care of by having a JavaSymbol.wireSelfIntoTree method, but there are some useless nodes that are created during the tree generation. These nodes serve as necessary placeholders during the parsing stage but are useless afterwards. Thus, I decided not to create custom JavaSymbol subclasses for them. There is not really any appropriate place to put the code for wiring them into the tree, so all the node-to-node communication is here instead of being 70% in the nodes and 30% in here.

The factory basically two calls: create and finish. The create call creates an empty node and sets the parent node. The finish call wires the node into the parent node. The parse tree generation process works in depth-first fashion by creating skeletal structures while going down to the leaves and filling out and wiring up these structures on the way up. So, the create and finish simply map to enter and leave abstract operations on a tree node.

Unused JavaSymbols after parse tree generation

Many of the nodes created during parse tree generation will actually be picked up by the garbage collector. Parents, in general, do not point to children. Thus, if a particular node doesn't wire itself into its parent's structure, it will go away after the final parse tree is generated.


Field Summary
 
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
 
Constructor Summary
JavaSymbolFactory(ReadTextBuffer buffer, Scope scope)
           
 
Method Summary
 JavaSymbol createAndFinishErrorSymbol(SyntaxToken token, CommonRoot root)
           
 JavaSymbol createSymbol(int syntaxCode, int startOffset, int endOffset, JavaSymbol parent)
          Creates an empty symbol.
 JavaSymbol createSymbol(SyntaxToken token, JavaSymbol parent)
          Creates an empty symbol.
 void finishSymbol(JavaSymbol symbol)
          Finishes a symbol's setup by looking at the symbol's syntax code and doing the appropriate wiring.
 void finishSymbol(JavaSymbol symbol, SyntaxToken token)
          Finishes a symbol's setup by looking at the symbol's syntax code and doing the appropriate wiring.
 boolean forceFinishSymbol(JavaSymbol symbol, int endOffset)
          Attempts to finish a symbol.
static void postProcess(RootSymbol rootSym)
           
static void processJavadoc(RootSymbol rootSymbol)
          Traverses the parse tree processing deprecated flags.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaSymbolFactory

public JavaSymbolFactory(ReadTextBuffer buffer,
                         Scope scope)
Method Detail

createAndFinishErrorSymbol

public JavaSymbol createAndFinishErrorSymbol(SyntaxToken token,
                                             CommonRoot root)
Parameters:
token - The offending syntax token in the parse.
error - The string message for this error
root - The RootSymbol for this parse.
Returns:
The created and finished error symbol.

createSymbol

public JavaSymbol createSymbol(SyntaxToken token,
                               JavaSymbol parent)
Creates an empty symbol.

Parameters:
token - The syntax token to be used for creation parameters.
parent - The parent node for this symbol. If unknown, set to null.
Returns:
The newly created albeit empty symbol.

createSymbol

public JavaSymbol createSymbol(int syntaxCode,
                               int startOffset,
                               int endOffset,
                               JavaSymbol parent)
Creates an empty symbol.

Parameters:
syntaxCode - The syntax code of this symbol
startOffset - The start offset into the ReadTextBuffer. (inclusive)
endOffset - The end offset into the ReadTextBuffer. (exclusive) If unknown, set to -1.
parent - The parent node for this symbol. If unknown, set to null.
Returns:
The newly created albeit empty symbol.

finishSymbol

public void finishSymbol(JavaSymbol symbol,
                         SyntaxToken token)
Finishes a symbol's setup by looking at the symbol's syntax code and doing the appropriate wiring. Should be called when a symbol's innards have been filled out and it's ready to be wired into the parse tree.

In some case, especially during parsing, the end offset of the symbol is not known until the innards have been hooked up. Thus, this finishSymbol sets the end offset and wires up the symbol.

The buffer is used only to create the name string for the NameSymbols.

Parameters:
symbol - The symbol to be finished.
token - The syntax token to be referenced for the end offset.
buffer - The ReadTextBuffer that this symbol was parsed from.

forceFinishSymbol

public boolean forceFinishSymbol(JavaSymbol symbol,
                                 int endOffset)
Attempts to finish a symbol.

Returns:
True, finished without mishap. False, threw an exception.

finishSymbol

public void finishSymbol(JavaSymbol symbol)
Finishes a symbol's setup by looking at the symbol's syntax code and doing the appropriate wiring. Should be called when a symbol's innards have been filled out and it's ready to be wired into the parse tree.

The buffer is used only to create the name string for the NameSymbols.

Parameters:
symbol - The symbol to be finished.
buffer - The ReadTextBuffer that this symbol was parsed from.

postProcess

public static void postProcess(RootSymbol rootSym)

processJavadoc

public static void processJavadoc(RootSymbol rootSymbol)
Traverses the parse tree processing deprecated flags. May work on error-tolerant parse trees (i.e. those with null symbols).


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.