Class Token
- java.lang.Object
-
- com.aspectran.core.context.expr.token.Token
-
- All Implemented Interfaces:
BeanReferenceable
,Replicable<Token>
public class Token extends java.lang.Object implements BeanReferenceable, Replicable<Token>
A token has a string value of its own or contains information for fetching a specific value from another provider.The following symbols are used to distinguish the providers of values:
- #
Refers to a bean specified by the Bean Registry.
ex)- #{beanId}
- #{beanId^getterName}
- #{beanId^getterName:defaultString}
- #{class:className}
- #{class:className^getterName}
- #{class:className^getterName:defaultString}
- ~
Refers to a string formatted from the Template Rule Registry.
ex)- ~{templateId}
- ~{templateId:defaultString}
- $
Refers to a parameter value.
ex)- ${parameterName}
- ${parameterName:defaultString}
- @
Refers to an attribute value.
ex)- @{attributeName}
- @{attributeName:defaultString}
- @{attributeName^getterName:defaultString}
- %
Refers to a property from the specified Properties file or environment variables.
ex)- %{environmentPropertyName}
- %{classpath:propertiesPath^getterName}
- %{classpath:propertiesPath^getterName:defaultString}
Created: 2008. 03. 27 PM 10:20:06
-
-
Field Summary
Fields Modifier and Type Field Description static char
ATTRIBUTE_SYMBOL
static char
BEAN_SYMBOL
static char
BRACKET_CLOSE
static char
BRACKET_OPEN
static char
GETTER_SEPARATOR
static char
PARAMETER_SYMBOL
static char
PROPERTY_SYMBOL
static char
TEMPLATE_SYMBOL
static char
VALUE_SEPARATOR
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object token)
java.lang.Object
getAlternativeValue()
Gets the alternative value.BeanRefererType
getBeanRefererType()
Returns the Bean Referrer Type.java.lang.String
getDefaultValue()
Gets the default value.TokenDirectiveType
getDirectiveType()
Gets the token directive type.java.lang.String
getGetterName()
Gets the name of the property whose value is to be retrieved.java.lang.String
getName()
Gets the token name.TokenType
getType()
Gets the token type.java.lang.String
getValue()
Returns the class name of the bean or the classpath of the Properties file, depending on the type of token.int
hashCode()
static boolean
hasToken(java.lang.String str)
static boolean
isTokenSymbol(char c)
Returns whether a specified character is the token symbol.Token
replicate()
Creates and returns a new instance after replicating a rule or Object.Token[]
replicate(Token[] tokens)
static void
resolveAlternativeValue(Token token, java.lang.ClassLoader classLoader)
static TokenType
resolveTypeAsSymbol(char symbol)
Returns the token type for the specified character.void
setAlternativeValue(java.lang.Object value)
Sets the alternative value.void
setDefaultValue(java.lang.String defaultValue)
Sets the default value.void
setGetterName(java.lang.String getterName)
Sets the name of the property whose value is to be retrieved.void
setValue(java.lang.String value)
Sets the class name of the bean or the classpath of the Properties file, depending on the type of the token.java.lang.String
stringify()
Convert a Token object into a string.java.lang.String
toString()
-
-
-
Field Detail
-
BEAN_SYMBOL
public static final char BEAN_SYMBOL
- See Also:
- Constant Field Values
-
TEMPLATE_SYMBOL
public static final char TEMPLATE_SYMBOL
- See Also:
- Constant Field Values
-
PARAMETER_SYMBOL
public static final char PARAMETER_SYMBOL
- See Also:
- Constant Field Values
-
ATTRIBUTE_SYMBOL
public static final char ATTRIBUTE_SYMBOL
- See Also:
- Constant Field Values
-
PROPERTY_SYMBOL
public static final char PROPERTY_SYMBOL
- See Also:
- Constant Field Values
-
BRACKET_OPEN
public static final char BRACKET_OPEN
- See Also:
- Constant Field Values
-
BRACKET_CLOSE
public static final char BRACKET_CLOSE
- See Also:
- Constant Field Values
-
VALUE_SEPARATOR
public static final char VALUE_SEPARATOR
- See Also:
- Constant Field Values
-
GETTER_SEPARATOR
public static final char GETTER_SEPARATOR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Token
public Token(java.lang.String defaultValue)
Instantiates a new Token.- Parameters:
defaultValue
- the default value
-
Token
public Token(TokenType type, java.lang.String name)
Instantiates a new Token.- Parameters:
type
- the token typename
- the token name
-
Token
public Token(TokenType type, TokenDirectiveType directiveType, java.lang.String value)
Instantiates a new Token.- Parameters:
type
- the token typedirectiveType
- the token directive typevalue
- the token value
-
-
Method Detail
-
getType
public TokenType getType()
Gets the token type.- Returns:
- the token type
-
getDirectiveType
public TokenDirectiveType getDirectiveType()
Gets the token directive type.- Returns:
- the token directive type
- See Also:
TokenDirectiveType
-
getName
public java.lang.String getName()
Gets the token name.- Returns:
- the token name
-
getValue
public java.lang.String getValue()
Returns the class name of the bean or the classpath of the Properties file, depending on the type of token. For example, if the token type is "bean" and the token name is "class", the value of the token is the class name of the bean. Also, if the token type is "property" and the token name is "classpath", the value of the token is the path to reference in the Properties file.- Returns:
- the default value or bean's class name
-
setValue
public void setValue(java.lang.String value)
Sets the class name of the bean or the classpath of the Properties file, depending on the type of the token.- Parameters:
value
- the class name of the bean or the classpath of the Properties file
-
getGetterName
public java.lang.String getGetterName()
Gets the name of the property whose value is to be retrieved.- Returns:
- the name of the property whose value is to be retrieved
-
getAlternativeValue
public java.lang.Object getAlternativeValue()
Gets the alternative value. It is a value corresponding to class name or class path according to token directive.- Returns:
- the alternative value
-
setAlternativeValue
public void setAlternativeValue(java.lang.Object value)
Sets the alternative value. It is a value corresponding to class name or class path according to token directive.- Parameters:
value
- the new alternative value
-
setGetterName
public void setGetterName(java.lang.String getterName)
Sets the name of the property whose value is to be retrieved.- Parameters:
getterName
- the name of the property whose value is to be retrieved
-
getDefaultValue
public java.lang.String getDefaultValue()
Gets the default value.- Returns:
- the default value
-
setDefaultValue
public void setDefaultValue(java.lang.String defaultValue)
Sets the default value.- Parameters:
defaultValue
- the new default value
-
getBeanRefererType
public BeanRefererType getBeanRefererType()
Description copied from interface:BeanReferenceable
Returns the Bean Referrer Type.- Specified by:
getBeanRefererType
in interfaceBeanReferenceable
- Returns:
- the Bean Referrer Type
-
stringify
public java.lang.String stringify()
Convert a Token object into a string.- Returns:
- a string representation of the token
-
equals
public boolean equals(java.lang.Object token)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
replicate
public Token replicate()
Description copied from interface:Replicable
Creates and returns a new instance after replicating a rule or Object.- Specified by:
replicate
in interfaceReplicable<Token>
- Returns:
- replicated rule or new instance of Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isTokenSymbol
public static boolean isTokenSymbol(char c)
Returns whether a specified character is the token symbol.- Parameters:
c
- a character- Returns:
- true, if a specified character is one of the token symbols
-
hasToken
public static boolean hasToken(java.lang.String str)
-
resolveTypeAsSymbol
public static TokenType resolveTypeAsSymbol(char symbol)
Returns the token type for the specified character.- Parameters:
symbol
- the token symbol character- Returns:
- the token type
-
resolveAlternativeValue
public static void resolveAlternativeValue(Token token, java.lang.ClassLoader classLoader)
-
-