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
Class JavaParser

java.lang.Object
  extended by oracle.javatools.parser.java.v1.JavaParser

public class JavaParser
extends java.lang.Object

The JavaParser is the entry point for the Java parser API. It presents a clean API (hiding the parsing algorithm) for clients who want to do Java parsing. Clients pass in a ReadTextBuffer object (usually a TextBuffer object) and sometimes ParsingOptions. The JavaParser may return any of the following based on the parsing options: RootSymbol, CodeBlockSymbol, ExpressionSymbol, or null.

See Also:
JavaLexer, RootSymbol, CodeBlockSymbol, ExpressionSymbol

Nested Class Summary
static class JavaParser.ParsingOptions
          ParsingOptions is an encapsulation of the various parsing options available in the JavaParser.
 
Field Summary
static int DEPTH_FULL
          Parse depth.
static int DEPTH_IMPORTS
          Parse depth.
static int DEPTH_MEMBERS
          Parse depth.
static boolean ERRORS_CHOKE
          Error handling.
static boolean ERRORS_REPORT
          Error handling.
static int INPUT_BLOCK
          Input type.
static int INPUT_EXPR
          Input type.
static int INPUT_JAVA_FILE
          Input type.
 
Constructor Summary
JavaParser()
           
 
Method Summary
static RootSymbol parse(ReadTextBuffer buffer)
          This is the simple default parse call that will be used by most clients.
static JavaSymbol parse(ReadTextBuffer buffer, JavaParser.ParsingOptions options)
          This will parse the buffer with the provided options.
static CodeBlockSymbol parseInto(ReadTextBuffer buffer, CodeBlockSymbol symbol, boolean reportErrors)
          This will parse into the specified CodeBlockSymbol from a previous DEPTH_MEMBERS parse.
static ExpressionSymbol parseInto(ReadTextBuffer buffer, ExpressionSymbol symbol, boolean reportErrors)
          This will parse into the specified ExpressionSymbol from a previous DEPTH_MEMBERS parse.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERRORS_CHOKE

public static final boolean ERRORS_CHOKE
Error handling. If there are any syntax errors, the parser will return null. Otherwise, the parser will return a well-formed parse tree.

See Also:
Constant Field Values

ERRORS_REPORT

public static final boolean ERRORS_REPORT
Error handling. If there are any syntax errors, the parser will generate error Strings and generate as much of the parse tree as possible. The client will be able to retrieve the array of error Strings from the returned parse tree JavaSymbol. If there are any errors, it is almost guaranteed the tree will NOT be well-formed. In rare cases, the parser may simply return null.

See Also:
Constant Field Values

INPUT_JAVA_FILE

public static final int INPUT_JAVA_FILE
Input type. The input is a full java file. The parser will return a RootSymbol.

See Also:
Constant Field Values

INPUT_BLOCK

public static final int INPUT_BLOCK
Input type. The input is a code block. The parser will return a CodeBlockSymbol.

See Also:
Constant Field Values

INPUT_EXPR

public static final int INPUT_EXPR
Input type. The input is an expression. The parser will return a ExpressionSymbol.

See Also:
Constant Field Values

DEPTH_MEMBERS

public static final int DEPTH_MEMBERS
Parse depth. Parses for imports and packages and classes. Within classes, only parses for member types and names as well as into inner classes. Variable initializers and code blocks are not parsed into.

See Also:
Constant Field Values

DEPTH_IMPORTS

public static final int DEPTH_IMPORTS
Parse depth. Parses only for package and imports. Does not parse classes or interfaces.

See Also:
Constant Field Values

DEPTH_FULL

public static final int DEPTH_FULL
Parse depth. Fully parses the input.

See Also:
Constant Field Values
Constructor Detail

JavaParser

public JavaParser()
Method Detail

parse

public static RootSymbol parse(ReadTextBuffer buffer)
This is the simple default parse call that will be used by most clients. The buffer should contain a full Java file. This will do a complete parse of the input from the beginning.

Parameters:
buffer - the ReadTextBuffer input
Returns:
the RootSymbol to the generated parse tree. Null if any syntax errors found.

parse

public static JavaSymbol parse(ReadTextBuffer buffer,
                               JavaParser.ParsingOptions options)
This will parse the buffer with the provided options. If a client only have one type of parsing need, he/she may instantiate a single ParsingOptions, initialize it, and simply pass it in with each call to parse().

Parameters:
buffer - the ReadTextBuffer input
options - the parsing options to use
Returns:
the appropriate JavaSymbol given options.inputType.

parseInto

public static CodeBlockSymbol parseInto(ReadTextBuffer buffer,
                                        CodeBlockSymbol symbol,
                                        boolean reportErrors)
This will parse into the specified CodeBlockSymbol from a previous DEPTH_MEMBERS parse. Only the start offset of the CodeBlockSymbol is used.

Clients may utilize this for reparsing if the contents of the buffer change so long as they track the starting offset of the code block.

Parameters:
buffer - the ReadTextBuffer input
symbol - the symbol to parse into.
reportErrors - same as ParsingOptions.reportErrors
Returns:
a different CodeBlockSymbol from the parameter. May be null.

parseInto

public static ExpressionSymbol parseInto(ReadTextBuffer buffer,
                                         ExpressionSymbol symbol,
                                         boolean reportErrors)
This will parse into the specified ExpressionSymbol from a previous DEPTH_MEMBERS parse. Note that only CATEGORY_WRAPPER CATEGORY_UNPARSED ExpressionSymbol's can be parsed into. If an ExpressionSymbol of the wrong type is passed in, null is returned. The start offset of the ExpressionSymbol is used, the end offset is ignored.

Clients may utilize this for rparsing if the contents of the buffer change so long as they track the starting offset of the expression.

Parameters:
buffer - the ReadTextBuffer input
symbol - the symbol to parse into.
reportErrors - same as ParsingOptions.reportErrors
Returns:
a different ExpressionSymbol from the parameter. May be null.

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.