java.lang.Object
com.aspectran.core.context.asel.token.Token
All Implemented Interfaces:
BeanReferenceable, Replicable<Token>

public class Token extends 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 Details

  • Constructor Details

    • Token

      public Token(String defaultValue)
      Instantiates a new Token.
      Parameters:
      defaultValue - the default value
    • Token

      public Token(TokenType type, String name)
      Instantiates a new Token.
      Parameters:
      type - the token type
      name - the token name
    • Token

      public Token(TokenType type, TokenDirectiveType directiveType, String value)
      Instantiates a new Token.
      Parameters:
      type - the token type
      directiveType - the token directive type
      value - the token value
  • Method Details

    • 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:
    • getName

      public String getName()
      Gets the token name.
      Returns:
      the token name
    • getValue

      public 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(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 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 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(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(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 String getDefaultValue()
      Gets the default value.
      Returns:
      the default value
    • setDefaultValue

      public void setDefaultValue(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 interface BeanReferenceable
      Returns:
      the Bean Referrer Type
    • stringify

      public String stringify()
      Convert a Token object into a string.
      Returns:
      a string representation of the token
    • equals

      public boolean equals(Object token)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class 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 interface Replicable<Token>
      Returns:
      replicated rule or new instance of Object
    • replicate

      public Token[] replicate(Token[] tokens)
    • toString

      public String toString()
      Overrides:
      toString in class 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(@NonNull String expression)
    • 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, ClassLoader classLoader)
    • format

      public static String format(TokenType type, String expression)