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 booleanaddOrMoveSubTokenAt(Token aSubToken, int index)voidaddSubToken(int index, Token aSubToken)booleanaddSubToken(Token aSubToken)booleanaddSubTokenAt(Token aSubToken, int index)Tokencopy()voiddelete()Tokendetach(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 valuevoidflatten()Set name to flattened string of all child sub-tokens and remove themvoidflattenNameRecursive(java.lang.String tokenName)Recursively flattens a particular token name from bottom upjava.lang.StringBufferflattenValues(java.lang.StringBuffer stringSoFar)Return string buffer with flattened value of tokensPositiongetEndPosition()intgetInnerLength()intgetIntValue(java.lang.String tokenName)intgetIntValue(java.lang.String tokenName, int defaultIfInvalid)intgetLength()java.lang.StringgetName()The name of the token.TokengetParentToken()PositiongetPosition()PositiongetPosition(java.lang.String tokenName)TokengetSubToken(int index)TokengetSubToken(java.lang.String tokenName)TokengetSubToken(java.lang.String tokenName, int offset)java.util.List<Token>getSubTokens()java.lang.StringgetValue()The value of the token.java.lang.StringgetValue(java.lang.String tokenName)Get the value of the named subtokenbooleanhasEndPosition()booleanhasParentToken()booleanhasPosition()booleanhasSubTokens()intindexOfSubToken(Token aSubToken)booleanis(java.lang.String aName)booleanisStatic()booleanisStatic(java.lang.String aName)static booleanisValidIdentifier(java.lang.String identifier)static booleanisValidIdentifier(java.lang.String identifier, java.lang.String prefix)booleanisValue(java.lang.String compareTo)static intminimumNumberOfSubTokens()intnumberOfSubTokens()voidremove(int index)booleanremoveSubToken(Token aSubToken)booleanremoveSubTokenNotSetParentToken(Token aSubToken)for issue#1521booleansetEndPosition(Position aNewEndPosition)booleansetName(java.lang.String aName)booleansetParentToken(Token aParentToken)booleansetPosition(Position aNewPosition)booleansetValue(java.lang.String aValue)java.lang.StringtoString()java.lang.StringBuffertoString(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:
toStringin 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
-