Class TokenExpression

  • All Implemented Interfaces:
    TokenEvaluator
    Direct Known Subclasses:
    ItemExpression

    public class TokenExpression
    extends java.lang.Object
    implements TokenEvaluator
    The Class TokenExpression.

    Created: 2008. 03. 29 AM 12:59:16

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Activity activity  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected static <T> java.util.List<T> cast​(java.util.List<?> list)
      This method will cast Set<?> to List<T> assuming ? is castable to T.
      protected static <T> java.util.Set<T> cast​(java.util.Set<?> set)
      This method will cast Set<?> to Set<T> assuming ? is castable to T.
      java.lang.Object evaluate​(Token token)  
      java.lang.Object evaluate​(Token[] tokens)  
      void evaluate​(Token[] tokens, java.io.Writer writer)  
      java.lang.Object evaluate​(java.lang.String parameterName, Token[] tokens)  
      java.util.List<java.lang.Object> evaluateAsList​(java.lang.String parameterName, java.util.List<Token[]> tokensList)  
      java.util.Map<java.lang.String,​java.lang.Object> evaluateAsMap​(java.lang.String parameterName, java.util.Map<java.lang.String,​Token[]> tokensMap)  
      java.util.Properties evaluateAsProperties​(java.lang.String parameterName, java.util.Properties tokensProp)  
      java.util.Set<java.lang.Object> evaluateAsSet​(java.lang.String parameterName, java.util.Set<Token[]> tokensSet)  
      java.lang.String evaluateAsString​(Token[] tokens)  
      java.lang.String evaluateAsString​(java.lang.String parameterName, Token[] tokens)  
      protected java.lang.Object getAttribute​(Token token)
      Returns the value of the named attribute as an Object of the activity's request attributes or action results.
      protected java.lang.Object getBean​(Token token)
      Returns the bean instance that matches the given token.
      protected java.lang.Object getBeanProperty​(java.lang.Object object, java.lang.String propertyName)
      Invoke bean's property.
      protected FileParameter getFileParameter​(java.lang.String name)
      Returns a FileParameter object as a given activity's request parameter name, or null if the parameter does not exist.
      protected FileParameter[] getFileParameterValues​(java.lang.String name)
      Returns an array of FileParameter objects containing all of the values the given activity's request parameter has, or null if the parameter does not exist.
      protected java.lang.String getParameter​(java.lang.String name)
      Returns the value of an activity's request parameter as a String, or null if the parameter does not exist.
      protected java.lang.String[] getParameterValues​(java.lang.String name)
      Returns an array of String objects containing all of the values the given activity's request parameter has, or null if the parameter does not exist.
      protected java.lang.Object getProperty​(Token token)
      Returns an Environment variable that matches the given token.
      protected java.lang.String getTemplate​(Token token)
      Executes template, returns the generated output.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • activity

        protected final Activity activity
    • Constructor Detail

      • TokenExpression

        public TokenExpression​(Activity activity)
        Instantiates a new token expression parser.
        Parameters:
        activity - the current Activity
      • TokenExpression

        public TokenExpression​(ActivityContext context)
        Instantiates a new token expression parser.
        Parameters:
        context - the activity context
    • Method Detail

      • evaluate

        public void evaluate​(Token[] tokens,
                             java.io.Writer writer)
                      throws java.io.IOException
        Specified by:
        evaluate in interface TokenEvaluator
        Throws:
        java.io.IOException
      • evaluate

        public java.lang.Object evaluate​(java.lang.String parameterName,
                                         Token[] tokens)
        Specified by:
        evaluate in interface TokenEvaluator
      • evaluateAsString

        public java.lang.String evaluateAsString​(java.lang.String parameterName,
                                                 Token[] tokens)
        Specified by:
        evaluateAsString in interface TokenEvaluator
      • evaluateAsList

        public java.util.List<java.lang.Object> evaluateAsList​(java.lang.String parameterName,
                                                               java.util.List<Token[]> tokensList)
        Specified by:
        evaluateAsList in interface TokenEvaluator
      • evaluateAsSet

        public java.util.Set<java.lang.Object> evaluateAsSet​(java.lang.String parameterName,
                                                             java.util.Set<Token[]> tokensSet)
        Specified by:
        evaluateAsSet in interface TokenEvaluator
      • evaluateAsMap

        public java.util.Map<java.lang.String,​java.lang.Object> evaluateAsMap​(java.lang.String parameterName,
                                                                                    java.util.Map<java.lang.String,​Token[]> tokensMap)
        Specified by:
        evaluateAsMap in interface TokenEvaluator
      • evaluateAsProperties

        public java.util.Properties evaluateAsProperties​(java.lang.String parameterName,
                                                         java.util.Properties tokensProp)
        Specified by:
        evaluateAsProperties in interface TokenEvaluator
      • getParameter

        protected java.lang.String getParameter​(java.lang.String name)
        Returns the value of an activity's request parameter as a String, or null if the parameter does not exist.
        Parameters:
        name - a String specifying the name of the parameter
        Returns:
        a String representing the single value of the parameter
      • getParameterValues

        protected java.lang.String[] getParameterValues​(java.lang.String name)
        Returns an array of String objects containing all of the values the given activity's request parameter has, or null if the parameter does not exist.
        Parameters:
        name - a String specifying the name of the parameter
        Returns:
        an array of String objects containing the parameter's values
      • getFileParameter

        protected FileParameter getFileParameter​(java.lang.String name)
        Returns a FileParameter object as a given activity's request parameter name, or null if the parameter does not exist.
        Parameters:
        name - a String specifying the name of the parameter
        Returns:
        a FileParameter representing the single value of the parameter
      • getFileParameterValues

        protected FileParameter[] getFileParameterValues​(java.lang.String name)
        Returns an array of FileParameter objects containing all of the values the given activity's request parameter has, or null if the parameter does not exist.
        Parameters:
        name - a String specifying the name of the parameter
        Returns:
        an array of FileParameter objects containing the parameter's values
      • getAttribute

        protected java.lang.Object getAttribute​(Token token)
        Returns the value of the named attribute as an Object of the activity's request attributes or action results.
        Parameters:
        token - the token
        Returns:
        an Object containing the value of the attribute, or null if the attribute does not exist
      • getBean

        protected java.lang.Object getBean​(Token token)
        Returns the bean instance that matches the given token.
        Parameters:
        token - the token
        Returns:
        an instance of the bean
      • getBeanProperty

        protected java.lang.Object getBeanProperty​(java.lang.Object object,
                                                   java.lang.String propertyName)
        Invoke bean's property.
        Parameters:
        object - the object
        propertyName - the property name
        Returns:
        the object
      • getProperty

        protected java.lang.Object getProperty​(Token token)
        Returns an Environment variable that matches the given token.
           %{classpath:/com/aspectran/sample.properties}
           %{classpath:/com/aspectran/sample.properties^propertyName:defaultValue}
         
        Parameters:
        token - the token
        Returns:
        an environment variable
      • getTemplate

        protected java.lang.String getTemplate​(Token token)
        Executes template, returns the generated output.
        Parameters:
        token - the token
        Returns:
        the generated output as String
      • cast

        protected static <T> java.util.List<T> cast​(java.util.List<?> list)
        This method will cast Set<?> to List<T> assuming ? is castable to T.
        Type Parameters:
        T - the generic type
        Parameters:
        list - a List object
        Returns:
        a casted List object
      • cast

        protected static <T> java.util.Set<T> cast​(java.util.Set<?> set)
        This method will cast Set<?> to Set<T> assuming ? is castable to T.
        Type Parameters:
        T - the generic type
        Parameters:
        set - a Set object
        Returns:
        a casted Set object