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 JavaLexer

java.lang.Object
  extended by oracle.javatools.parser.AbstractLexer
      extended by oracle.javatools.parser.java.v1.JavaLexer
All Implemented Interfaces:
JavaTokens, Lexer

public class JavaLexer
extends AbstractLexer
implements JavaTokens

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

See Also:
Lexer, JavaTokens

Nested Class Summary
 
Nested classes/interfaces inherited from class oracle.javatools.parser.AbstractLexer
AbstractLexer.DefaultLexerToken
 
Field Summary
 
Fields inherited from class oracle.javatools.parser.AbstractLexer
currentPos, textBuffer
 
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.Lexer
TK_EOF, TK_NOT_FOUND
 
Constructor Summary
JavaLexer()
          Constructs a default JavaLexer with a starting position of 0.
 
Method Summary
 void backup()
          Unlexes the last found token.
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(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 Java.)
 void setSkipComments(boolean skipComments)
          Sets whether the JavaLexer should generate tokens for Java comments.
static java.lang.String tokenToString(int token)
          Utility routine to map the token to a string representation of the token (for debug printing.)
static java.lang.String tokenToText(int token)
          Utility routine to map the token to the original text (if retrievable) of the token (for debug printing.)
 
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
 

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().

Method Detail

setSkipComments

public void setSkipComments(boolean skipComments)
Sets whether the JavaLexer should generate tokens for Java comments.

Parameters:
skipComments - true to ignore comments in token generation

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 Java.)

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

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 AbstractLexer
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()
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
Specified by:
backup in class AbstractLexer

setPosition

public void setPosition(int offset)
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.

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

tokenToString

public static java.lang.String tokenToString(int token)
Utility routine to map the token to a string representation of the token (for debug printing.)

Parameters:
token - the token to map
Returns:
a printable representation of the token

tokenToText

public static java.lang.String tokenToText(int token)
Utility routine to map the token to the original text (if retrievable) of the token (for debug printing.)

Parameters:
token - the token to map
Returns:
a printable representation of the token

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.