Package cruise.umple.parser
Class Token
java.lang.Object
cruise.umple.parser.Token
public class Token
extends java.lang.Object
Fundamental to all parsing, used in conjunction with rules and their definitions.
As parsing is taking place these will indicate what is currently being looked for
(such as a class definition or attribute) and helps to keep
track of the positions that the input parser parsed things at.
Copyright: All contributers to the Umple Project
This file is made available subject to the open source license found at:
https://umple.org/license
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description boolean
addOrMoveSubTokenAt(Token aSubToken, int index)
void
addSubToken(int index, Token aSubToken)
boolean
addSubToken(Token aSubToken)
boolean
addSubTokenAt(Token aSubToken, int index)
Token
copy()
void
delete()
Token
detach(java.lang.String newName, java.lang.String newValue)
Return a copy of the current token with all its SubTokens Removes all SubTokens from the current Token and sets new name and valuevoid
flatten()
Set name to flattened string of all child sub-tokens and remove themvoid
flattenNameRecursive(java.lang.String tokenName)
Recursively flattens a particular token name from bottom upjava.lang.StringBuffer
flattenValues(java.lang.StringBuffer stringSoFar)
Return string buffer with flattened value of tokensPosition
getEndPosition()
int
getInnerLength()
int
getIntValue(java.lang.String tokenName)
int
getIntValue(java.lang.String tokenName, int defaultIfInvalid)
int
getLength()
java.lang.String
getName()
The name of the token.Token
getParentToken()
Position
getPosition()
Position
getPosition(java.lang.String tokenName)
Token
getSubToken(int index)
Token
getSubToken(java.lang.String tokenName)
Token
getSubToken(java.lang.String tokenName, int offset)
java.util.List<Token>
getSubTokens()
java.lang.String
getValue()
The value of the token.java.lang.String
getValue(java.lang.String tokenName)
Get the value of the named subtokenboolean
hasEndPosition()
boolean
hasParentToken()
boolean
hasPosition()
boolean
hasSubTokens()
int
indexOfSubToken(Token aSubToken)
boolean
is(java.lang.String aName)
boolean
isStatic()
boolean
isStatic(java.lang.String aName)
static boolean
isValidIdentifier(java.lang.String identifier)
static boolean
isValidIdentifier(java.lang.String identifier, java.lang.String prefix)
boolean
isValue(java.lang.String compareTo)
static int
minimumNumberOfSubTokens()
int
numberOfSubTokens()
void
remove(int index)
boolean
removeSubToken(Token aSubToken)
boolean
removeSubTokenNotSetParentToken(Token aSubToken)
for issue#1521boolean
setEndPosition(Position aNewEndPosition)
boolean
setName(java.lang.String aName)
boolean
setParentToken(Token aParentToken)
boolean
setPosition(Position aNewPosition)
boolean
setValue(java.lang.String aValue)
java.lang.String
toString()
java.lang.StringBuffer
toString(java.lang.StringBuffer stringSoFar, Token parserRoot)
Code refactored from Parser class to Token class
-
Constructor Details
-
Method Details
-
setName
public boolean setName(java.lang.String aName) -
setValue
public boolean setValue(java.lang.String aValue) -
getName
public java.lang.String getName()The name of the token. -
getValue
public java.lang.String getValue()The value of the token. -
getSubToken
-
getSubTokens
-
numberOfSubTokens
public int numberOfSubTokens() -
hasSubTokens
public boolean hasSubTokens() -
indexOfSubToken
-
getPosition
-
hasPosition
public boolean hasPosition() -
getEndPosition
-
hasEndPosition
public boolean hasEndPosition() -
getParentToken
-
hasParentToken
public boolean hasParentToken() -
minimumNumberOfSubTokens
public static int minimumNumberOfSubTokens() -
addSubToken
-
removeSubToken
-
addSubTokenAt
-
addOrMoveSubTokenAt
-
setPosition
-
setEndPosition
-
setParentToken
-
delete
public void delete() -
isValidIdentifier
public static boolean isValidIdentifier(java.lang.String identifier, java.lang.String prefix) -
isValidIdentifier
public static boolean isValidIdentifier(java.lang.String identifier) -
addSubToken
-
getPosition
-
getInnerLength
public int getInnerLength() -
getLength
public int getLength() -
getIntValue
public int getIntValue(java.lang.String tokenName) -
getIntValue
public int getIntValue(java.lang.String tokenName, int defaultIfInvalid) -
getSubToken
-
getSubToken
-
getValue
public java.lang.String getValue(java.lang.String tokenName)Get the value of the named subtoken -
is
public boolean is(java.lang.String aName) -
isStatic
public boolean isStatic(java.lang.String aName) -
isStatic
public boolean isStatic() -
isValue
public boolean isValue(java.lang.String compareTo) -
remove
public void remove(int index) -
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
toString
Code refactored from Parser class to Token class -
flatten
public void flatten()Set name to flattened string of all child sub-tokens and remove them -
flattenValues
public java.lang.StringBuffer flattenValues(java.lang.StringBuffer stringSoFar)Return string buffer with flattened value of tokens -
flattenNameRecursive
public void flattenNameRecursive(java.lang.String tokenName)Recursively flattens a particular token name from bottom up -
detach
Return a copy of the current token with all its SubTokens Removes all SubTokens from the current Token and sets new name and value -
copy
-
removeSubTokenNotSetParentToken
for issue#1521
-