|
|||||||||
| Home >> All >> com >> trapezium >> [ parse overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.trapezium.parse
Class TokenFactory

java.lang.Objectcom.trapezium.parse.TokenFactory
- All Implemented Interfaces:
- TokenTypes
- public class TokenFactory
- extends java.lang.Object
- implements TokenTypes
- extends java.lang.Object
Assigns a range of characters within a line to a token of a particular type. Adapted from initial 1.0 strategy of creating Token objects. This approach abandoned due to OutOfMemory exception, tokens now managed within TokenEnumerator with arrays. The optimization that required this has complicated the code, since it was not initially designed this way. The TokenFactory is a single class that has taken the place of several classes in the previous architecture. The port from one architecture to the other was very straightforward, but has resulted in what appears to be very unusual and messy class.
- Since:
- 1.1
- Version:
- 1.1, 31 Dec 1997
| Field Summary | |
(package private) boolean |
allowUnterminatedString
|
(package private) int |
currentType
|
(package private) boolean |
firstQuoteFound
|
(package private) boolean |
prevCharWasEscape
|
(package private) boolean |
thatsAllFolks
|
(package private) boolean |
unterminatedString
|
| Fields inherited from interface com.trapezium.parse.TokenTypes |
BadNumber, CommentToken, EmptyLine, Keyword1Token, Keyword2Token, LeftBrace, LeftBracket, NameToken, NumberToken, QuotedString, QuotedStringContinuation, RightBrace, RightBracket, WhiteToken |
| Constructor Summary | |
TokenFactory()
class constructor |
|
TokenFactory(boolean allowUnterminatedString)
|
|
| Method Summary | |
(package private) void |
BlackToken_Factory(com.trapezium.util.ByteString s,
int offset,
com.trapezium.util.ReturnInteger offsetReturn,
com.trapezium.util.ReturnInteger typeReturn,
com.trapezium.util.ReturnInteger sizeReturn)
create the next token, already known to exist when this is called |
void |
CommentToken_Factory(com.trapezium.util.ByteString s,
int offset,
com.trapezium.util.ReturnInteger offsetReturn,
com.trapezium.util.ReturnInteger sizeReturn)
create a comment token |
boolean |
CommentToken_isAppropriate(char x)
is the character appropriate for a comment token |
(package private) void |
createToken(com.trapezium.util.ByteString s,
int offset,
com.trapezium.util.ReturnInteger sizeReturn)
create a token |
boolean |
firstQuoteLocated()
has a quote been located? |
int |
getNumberDigits(com.trapezium.util.ByteString s,
int offset,
int size)
|
int |
getNumberValue(com.trapezium.util.ByteString s,
int offset,
int size)
|
int |
getNumberValue2(com.trapezium.util.ByteString s,
int offset,
int size)
|
(package private) boolean |
isAppropriate(char x)
is the character appropriate for the token currently being created? |
(package private) boolean |
isBadValue(int ndigits,
com.trapezium.util.ByteString s,
int offset,
int size,
boolean eAllowed,
boolean dotAllowed)
|
static boolean |
isBlackChar(char x)
is the character black space? |
static boolean |
isBraceChar(char x)
|
static boolean |
isBracketChar(char x)
is the character a bracket [] |
static boolean |
isCommentChar(char x)
is the character a vrml comment character # |
(package private) boolean |
isDigit(char x)
is the character a digit? |
(package private) boolean |
isFirstNumberChar(char x)
can the character be the first character in a numeric token? |
static boolean |
isLeftBrace(char x)
is the character a left brace? |
static boolean |
isLeftBracket(char x)
is the character a left bracket? |
static boolean |
isNumberChar(char x)
could the character be part of a number? |
(package private) boolean |
isNumberSequence(com.trapezium.util.ByteString s,
int offset)
is this a number sequence? |
static boolean |
isQuoteChar(char x)
is the character a vrml quote character " |
static boolean |
isRightBrace(char x)
is the character a right brace? |
static boolean |
isRightBracket(char x)
is the character a right bracket? |
static boolean |
isSpecialChar(char x)
is the character a special vrml character #[]{}" |
static boolean |
isWhiteChar(char x)
is the character white space? |
(package private) void |
keywordCheck(com.trapezium.util.ByteString s,
com.trapezium.util.ReturnInteger typeReturn,
int offset,
int size)
convert the type to Keyword1Token or Keyword2Token of appropriate |
void |
NameToken_Factory(com.trapezium.util.ByteString s,
int offset,
com.trapezium.util.ReturnInteger offsetReturn,
com.trapezium.util.ReturnInteger sizeReturn)
create a name token |
boolean |
NameToken_isAppropriate(char x)
is the character appropriate for a name token |
void |
NumberToken_Factory(com.trapezium.util.ByteString s,
int offset,
com.trapezium.util.ReturnInteger offsetReturn,
com.trapezium.util.ReturnInteger sizeReturn,
com.trapezium.util.ReturnInteger typeReturn)
create a number token |
boolean |
NumberToken_isAppropriate(char x)
is the character appropriate for a number token |
void |
QuotedString_Factory(com.trapezium.util.ByteString s,
int offset,
com.trapezium.util.ReturnInteger offsetReturn,
com.trapezium.util.ReturnInteger sizeReturn)
create a quoted string token |
boolean |
QuotedString_isAppropriate(char x)
is the character valid for a quoted string? |
void |
QuotedStringContinuation_Factory(com.trapezium.util.ByteString s,
int offset,
com.trapezium.util.ReturnInteger offsetReturn,
com.trapezium.util.ReturnInteger sizeReturn)
create a quoted string continuation token |
void |
setNumberTypeReturn(com.trapezium.util.ByteString s,
int offset,
int size,
com.trapezium.util.ReturnInteger typeReturn)
|
(package private) void |
setUnterminatedString(boolean value)
|
void |
tokenize(com.trapezium.util.ByteString s,
int offset,
com.trapezium.util.ReturnInteger offsetReturn,
com.trapezium.util.ReturnInteger typeReturn,
com.trapezium.util.ReturnInteger sizeReturn)
create token information for the next token in a string |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
unterminatedString
boolean unterminatedString
allowUnterminatedString
boolean allowUnterminatedString
currentType
int currentType
firstQuoteFound
boolean firstQuoteFound
prevCharWasEscape
boolean prevCharWasEscape
thatsAllFolks
boolean thatsAllFolks
| Constructor Detail |
TokenFactory
public TokenFactory()
- class constructor
TokenFactory
public TokenFactory(boolean allowUnterminatedString)
| Method Detail |
setUnterminatedString
void setUnterminatedString(boolean value)
tokenize
public void tokenize(com.trapezium.util.ByteString s, int offset, com.trapezium.util.ReturnInteger offsetReturn, com.trapezium.util.ReturnInteger typeReturn, com.trapezium.util.ReturnInteger sizeReturn)
- create token information for the next token in a string
isWhiteChar
public static boolean isWhiteChar(char x)
- is the character white space?
isBlackChar
public static boolean isBlackChar(char x)
- is the character black space?
isSpecialChar
public static boolean isSpecialChar(char x)
- is the character a special vrml character #[]{}"
isCommentChar
public static boolean isCommentChar(char x)
- is the character a vrml comment character #
isQuoteChar
public static boolean isQuoteChar(char x)
- is the character a vrml quote character "
isBracketChar
public static boolean isBracketChar(char x)
- is the character a bracket []
isLeftBracket
public static boolean isLeftBracket(char x)
- is the character a left bracket?
isRightBracket
public static boolean isRightBracket(char x)
- is the character a right bracket?
isLeftBrace
public static boolean isLeftBrace(char x)
- is the character a left brace?
isRightBrace
public static boolean isRightBrace(char x)
- is the character a right brace?
isBraceChar
public static boolean isBraceChar(char x)
isNumberChar
public static boolean isNumberChar(char x)
- could the character be part of a number?
BlackToken_Factory
void BlackToken_Factory(com.trapezium.util.ByteString s, int offset, com.trapezium.util.ReturnInteger offsetReturn, com.trapezium.util.ReturnInteger typeReturn, com.trapezium.util.ReturnInteger sizeReturn)
- create the next token, already known to exist when this is called
keywordCheck
void keywordCheck(com.trapezium.util.ByteString s, com.trapezium.util.ReturnInteger typeReturn, int offset, int size)
- convert the type to Keyword1Token or Keyword2Token of appropriate
isFirstNumberChar
boolean isFirstNumberChar(char x)
- can the character be the first character in a numeric token?
isDigit
boolean isDigit(char x)
- is the character a digit?
isNumberSequence
boolean isNumberSequence(com.trapezium.util.ByteString s, int offset)
- is this a number sequence?
createToken
void createToken(com.trapezium.util.ByteString s, int offset, com.trapezium.util.ReturnInteger sizeReturn)
- create a token
isAppropriate
boolean isAppropriate(char x)
- is the character appropriate for the token currently being created?
QuotedString_Factory
public void QuotedString_Factory(com.trapezium.util.ByteString s, int offset, com.trapezium.util.ReturnInteger offsetReturn, com.trapezium.util.ReturnInteger sizeReturn)
- create a quoted string token
firstQuoteLocated
public boolean firstQuoteLocated()
- has a quote been located?
QuotedString_isAppropriate
public boolean QuotedString_isAppropriate(char x)
- is the character valid for a quoted string?
QuotedStringContinuation_Factory
public void QuotedStringContinuation_Factory(com.trapezium.util.ByteString s, int offset, com.trapezium.util.ReturnInteger offsetReturn, com.trapezium.util.ReturnInteger sizeReturn)
- create a quoted string continuation token
CommentToken_Factory
public void CommentToken_Factory(com.trapezium.util.ByteString s, int offset, com.trapezium.util.ReturnInteger offsetReturn, com.trapezium.util.ReturnInteger sizeReturn)
- create a comment token
CommentToken_isAppropriate
public boolean CommentToken_isAppropriate(char x)
- is the character appropriate for a comment token
NumberToken_Factory
public void NumberToken_Factory(com.trapezium.util.ByteString s, int offset, com.trapezium.util.ReturnInteger offsetReturn, com.trapezium.util.ReturnInteger sizeReturn, com.trapezium.util.ReturnInteger typeReturn)
- create a number token
isBadValue
boolean isBadValue(int ndigits,
com.trapezium.util.ByteString s,
int offset,
int size,
boolean eAllowed,
boolean dotAllowed)
getNumberValue
public int getNumberValue(com.trapezium.util.ByteString s, int offset, int size)
getNumberValue2
public int getNumberValue2(com.trapezium.util.ByteString s, int offset, int size)
getNumberDigits
public int getNumberDigits(com.trapezium.util.ByteString s, int offset, int size)
setNumberTypeReturn
public void setNumberTypeReturn(com.trapezium.util.ByteString s, int offset, int size, com.trapezium.util.ReturnInteger typeReturn)
NumberToken_isAppropriate
public boolean NumberToken_isAppropriate(char x)
- is the character appropriate for a number token
NameToken_Factory
public void NameToken_Factory(com.trapezium.util.ByteString s, int offset, com.trapezium.util.ReturnInteger offsetReturn, com.trapezium.util.ReturnInteger sizeReturn)
- create a name token
NameToken_isAppropriate
public boolean NameToken_isAppropriate(char x)
- is the character appropriate for a name token
|
|||||||||
| Home >> All >> com >> trapezium >> [ parse overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.trapezium.parse.TokenFactory