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

E13403-07

oracle.javatools.parser.java.v2.scanner
Class JavaLexer

java.lang.Object
  extended by oracle.javatools.parser.AbstractLexer
      extended by oracle.javatools.parser.java.v2.scanner.FastLexer
          extended by oracle.javatools.parser.java.v2.scanner.JavaLexer
All Implemented Interfaces:
JavaTokens, Lexer, LexerToken

public class JavaLexer
extends FastLexer
implements JavaTokens, LexerToken

The JavaLexer is an implementation of the Lexer interface for the Source language. Details of the Source Language taken from Source Language Specification

See Also:
Lexer, JavaTokens

Nested Class Summary
 
Nested classes/interfaces inherited from class oracle.javatools.parser.AbstractLexer
AbstractLexer.DefaultLexerToken
 
Field Summary
static KeywordTable keyword13Table
          The keyword table for j2se 1.3.
static KeywordTable keyword14Table
          The keyword table for j2se 1.4.
static KeywordTable keyword15Table
          The keyword table for j2se 1.5.
 
Fields inherited from class oracle.javatools.parser.java.v2.scanner.FastLexer
skipComments
 
Fields inherited from class oracle.javatools.parser.AbstractLexer
currentPos, textBuffer
 
Fields inherited from interface oracle.javatools.parser.java.v2.JavaTokens
DW_values, DW_words, J2SE_13, J2SE_14, J2SE_15, J2SE_16, J2SE_17, J2SE_MAX, J2SE_MIN, KW_ABSTRACT, KW_ASSERT, KW_base, KW_BOOLEAN, KW_BREAK, KW_BYTE, KW_CASE, KW_CATCH, KW_CHAR, KW_CLASS, KW_CONST, KW_CONTINUE, KW_DEFAULT, KW_DO, KW_DOUBLE, KW_ELSE, KW_ENUM, KW_EXTENDS, KW_FINAL, KW_FINALLY, KW_FLOAT, KW_FOR, KW_GOTO, KW_IF, KW_IMPLEMENTS, KW_IMPORT, KW_INSTANCEOF, KW_INT, KW_INTERFACE, KW_j2se13_max, KW_j2se14_max, KW_j2se15_max, KW_j2se16_max, KW_LONG, KW_max, KW_NATIVE, KW_NEW, KW_PACKAGE, KW_PRIVATE, KW_PROTECTED, KW_PUBLIC, KW_RETURN, KW_SHORT, KW_STATIC, KW_STRICTFP, KW_SUPER, KW_SWITCH, KW_SYNCHRONIZED, KW_THIS, KW_THROW, KW_THROWS, KW_TRANSIENT, KW_TRY, KW_VOID, KW_VOLATILE, KW_WHILE, KW_words, OP_AND_ASG, OP_ASG, OP_AT, OP_base, OP_BINAND, OP_binary, OP_BINNOT, OP_BINOR, OP_BINXOR, OP_COLON, OP_COMMA, OP_DEC, OP_DIV, OP_DIV_ASG, OP_DOT, OP_ELLIPSIS, OP_EQ, OP_GE, OP_GT, OP_HASH, OP_INC, OP_LBRACE, OP_LBRACKET, OP_LE, OP_LOGAND, OP_LOGNOT, OP_LOGOR, OP_LPAREN, OP_LSH, OP_LSH_ASG, OP_LT, OP_max, OP_MINUS, OP_MINUS_ASG, OP_MOD, OP_MOD_ASG, OP_MUL, OP_MUL_ASG, OP_NE, OP_OR_ASG, OP_PLUS, OP_PLUS_ASG, OP_prefix, OP_QUES, OP_RBRACE, OP_RBRACKET, OP_RPAREN, OP_RSH, OP_RSH_ASG, OP_SEMI, OP_URSH, OP_URSH_ASG, OP_words, OP_XOR_ASG, TK_BOOLEAN_LITERAL, TK_CHAR_LITERAL, TK_DOC_COMMENT, TK_DOUBLE_LITERAL, TK_FLOAT_LITERAL, TK_IDENTIFIER, TK_INT_LITERAL, TK_LITERAL_base, TK_LITERAL_max, TK_LONG_LITERAL, TK_max, TK_MULTI_COMMENT, TK_NULL_LITERAL, TK_SINGLE_COMMENT, TK_SQLJ, TK_STRING_LITERAL, TK_WHITESPACE
 
Fields inherited from interface oracle.javatools.parser.Lexer
TK_NOT_FOUND
 
Constructor Summary
JavaLexer()
          Constructs a default JavaLexer with a starting position of 0.
JavaLexer(byte j2se)
          Constructs a default JavaLexer with a starting position of 0.
 
Method Summary
 void backup()
          Unlexes the last found token.
 int getEndOffset()
          Fetches the end offset of the token (offset relative to the original ReadTextBuffer being lexed.
 int getStartOffset()
          Fetches the start offset of the token (offset relative to the original ReadTextBuffer being lexed.
 int getToken()
          Fetches the (language-specific) token represented by this LexerToken.
protected  boolean isComment(int tk)
          Used by the ArrayedLexer.
static boolean isDecimalDigit(char digit)
          Utility routine to check whether the given digit is a decimal digit.
static boolean isHexDigit(char digit)
          Utility routine to check whether the given digit is a hexadecimal digit.
static boolean isOctalDigit(char digit)
          Utility routine to check whether the given digit is an octal digit.
 int lex()
          Calls lex( LexerToken ) but does not call fillLexerToken.
 int lex(LexerToken lexedToken)
          Scans the text buffer at the current position and returns the token that was found.
 void setPosition(int offset)
          Sets the current lex (read) position to the given offset in the buffer.
 void setRecognizeSQLJ(boolean recognizeSQLJ)
          Sets whether the JavaLexer should recognize SQLJ statements and return a single token for them (instead of trying to lex it as Source.)
 
Methods inherited from class oracle.javatools.parser.java.v2.scanner.FastLexer
setSkipComments
 
Methods inherited from class oracle.javatools.parser.AbstractLexer
createLexerToken, getTextBuffer, setTextBuffer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

keyword13Table

public static final KeywordTable keyword13Table
The keyword table for j2se 1.3.


keyword14Table

public static final KeywordTable keyword14Table
The keyword table for j2se 1.4.


keyword15Table

public static final KeywordTable keyword15Table
The keyword table for j2se 1.5.

Constructor Detail

JavaLexer

public JavaLexer()
Constructs a default JavaLexer with a starting position of 0. Clients must call setTextBuffer() to initialize the text buffer used for the Lexer. To start lexing from an offset other than 0, call setPosition().


JavaLexer

public JavaLexer(byte j2se)
Constructs a default JavaLexer with a starting position of 0. Clients must call setTextBuffer() to initialize the text buffer used for the Lexer. To start lexing from an offset other than 0, call setPosition().

Parameters:
j2se - Indicates which j2se version this lexer will support.
Method Detail

setPosition

public void setPosition(int offset)
Description copied from class: AbstractLexer
Sets the current lex (read) position to the given offset in the buffer. It is the clients responsibility to ensure that this offset corresponds to the start of a token, otherwise unexpected (and incorrect) results may occur.

Specified by:
setPosition in interface Lexer
Overrides:
setPosition in class AbstractLexer
Parameters:
offset - the offset for the next lex() operation.

setRecognizeSQLJ

public void setRecognizeSQLJ(boolean recognizeSQLJ)
Sets whether the JavaLexer should recognize SQLJ statements and return a single token for them (instead of trying to lex it as Source.)

Parameters:
recognizeSQLJ - true to recognize SQLJ statements as a token

isComment

protected boolean isComment(int tk)
Description copied from class: FastLexer
Used by the ArrayedLexer.

Overrides:
isComment in class FastLexer
Returns:
True if the indicated token value is considered to be a comment.

getToken

public int getToken()
Description copied from interface: LexerToken
Fetches the (language-specific) token represented by this LexerToken. You must refer to the language-specific Lexer that was responsible for filling this LexerToken instance to interpret the token.

Specified by:
getToken in interface LexerToken
Specified by:
getToken in class FastLexer
Returns:
the lexer token

getStartOffset

public int getStartOffset()
Description copied from interface: LexerToken
Fetches the start offset of the token (offset relative to the original ReadTextBuffer being lexed. Note that the start offset is inclusive (compare to end offset which is exclusive), to match the behavior in the String class.

Specified by:
getStartOffset in interface LexerToken
Specified by:
getStartOffset in class FastLexer
Returns:
the starting offset

getEndOffset

public int getEndOffset()
Description copied from interface: LexerToken
Fetches the end offset of the token (offset relative to the original ReadTextBuffer being lexed. Note that the end offset is exclusive (similar to end offsets in the String class.)

Specified by:
getEndOffset in interface LexerToken
Specified by:
getEndOffset in class FastLexer
Returns:
the ending offset

lex

public int lex()
Calls lex( LexerToken ) but does not call fillLexerToken.

Specified by:
lex in class FastLexer

lex

public int lex(LexerToken lexedToken)
Scans the text buffer at the current position and returns the token that was found. The token and offset information is also stored in the lexedToken instance passed in to the call.

Specified by:
lex in interface Lexer
Specified by:
lex in class FastLexer
Parameters:
lexedToken - the instance passed in where token info is stored
Returns:
the token that was found, same as calling lexedToken.getToken() (for convenience)

backup

public void backup()
Description copied from class: FastLexer
Unlexes the last found token. The next call to lex() will return the last token and offset information found.

Specified by:
backup in interface Lexer
Overrides:
backup in class FastLexer

isDecimalDigit

public static boolean isDecimalDigit(char digit)
Utility routine to check whether the given digit is a decimal digit.

Parameters:
digit - the digit to check

isOctalDigit

public static boolean isOctalDigit(char digit)
Utility routine to check whether the given digit is an octal digit.

Parameters:
digit - the digit to check

isHexDigit

public static boolean isHexDigit(char digit)
Utility routine to check whether the given digit is a hexadecimal digit.

Parameters:
digit - the digit to check

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

E13403-07

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