Class CoreTranslet

java.lang.Object
com.aspectran.core.activity.AbstractTranslet
com.aspectran.core.activity.CoreTranslet
All Implemented Interfaces:
Translet

public class CoreTranslet extends AbstractTranslet
The Class CoreTranslet.

This class is generally not thread-safe. It is primarily designed for use in a single thread only.

  • Constructor Details

    • CoreTranslet

      public CoreTranslet(@NonNull TransletRule transletRule, @NonNull CoreActivity activity)
      Instantiates a new CoreTranslet.
      Parameters:
      transletRule - the translet rule
      activity - the current Activity
  • Method Details

    • getContextPath

      @NonNull public String getContextPath()
    • getDescription

      public String getDescription()
      Description copied from interface: Translet
      Returns a description of this Translet.
      Returns:
      a description of this Translet
    • getEnvironment

      public Environment getEnvironment()
      Description copied from interface: Translet
      Returns the environment of the current activity context.
      Returns:
      the environment
    • getApplicationAdapter

      public ApplicationAdapter getApplicationAdapter()
      Description copied from interface: Translet
      Gets the application adapter.
      Returns:
      the application adapter
    • getSessionAdapter

      public SessionAdapter getSessionAdapter()
      Description copied from interface: Translet
      Gets the session adapter.
      Returns:
      the session adapter
    • getRequestAdapter

      public RequestAdapter getRequestAdapter()
      Description copied from interface: Translet
      Gets the request adapter.
      Returns:
      the request adapter
    • getResponseAdapter

      public ResponseAdapter getResponseAdapter()
      Description copied from interface: Translet
      Gets the response adapter.
      Returns:
      the response adapter
    • getSessionAdaptee

      public <V> V getSessionAdaptee()
      Description copied from interface: Translet
      Returns the adaptee object to provide session information.
      Type Parameters:
      V - the type of the session adaptee
      Returns:
      the session adaptee object
    • getRequestAdaptee

      public <V> V getRequestAdaptee()
      Description copied from interface: Translet
      Returns the adaptee object to provide request information.
      Type Parameters:
      V - the type of the request adaptee
      Returns:
      the request adaptee object
    • getResponseAdaptee

      public <V> V getResponseAdaptee()
      Description copied from interface: Translet
      Returns the adaptee object to provide response information.
      Type Parameters:
      V - the type of the response adaptee
      Returns:
      the response adaptee object
    • getIntendedRequestEncoding

      public String getIntendedRequestEncoding()
      Description copied from interface: Translet
      Returns the intended request encoding.
      Returns:
      the intended request encoding
    • getIntendedResponseEncoding

      public String getIntendedResponseEncoding()
      Description copied from interface: Translet
      Returns the intended response encoding.
      Returns:
      the intended response encoding
    • getProcessResult

      public ProcessResult getProcessResult()
      Description copied from interface: Translet
      Returns the process result.
      Returns:
      the process result
    • getProcessResult

      public Object getProcessResult(String actionId)
      Description copied from interface: Translet
      Returns an action result for the specified action id from the process result, or null if the action does not exist.
      Parameters:
      actionId - the specified action id
      Returns:
      the action result
    • setProcessResult

      public void setProcessResult(ProcessResult processResult)
      Description copied from interface: Translet
      Sets the process result.
      Parameters:
      processResult - the new process result
    • getActivityData

      public ActivityData getActivityData()
      Description copied from interface: Translet
      Returns an Activity Data containing the activity result data.
      Returns:
      the activity data
    • getSetting

      public <V> V getSetting(String settingName)
      Description copied from interface: Translet
      Gets the setting value in the translet scope.
      Type Parameters:
      V - the type of the value
      Parameters:
      settingName - the setting name
      Returns:
      the setting value
    • getProperty

      public <V> V getProperty(String name)
      Description copied from interface: Translet
      Returns the value of the property on environment.
      Type Parameters:
      V - the type of the value
      Parameters:
      name - the given property name
      Returns:
      the value of the property on environment
    • getParameter

      public String getParameter(String name)
      Description copied from interface: Translet
      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
      See Also:
    • getParameterValues

      public String[] getParameterValues(String name)
      Description copied from interface: Translet
      Returns an array of String objects containing all 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
      See Also:
    • getParameterNames

      public Collection<String> getParameterNames()
      Description copied from interface: Translet
      Returns a Collection of String objects containing the names of the parameters contained in this request. If the request has no parameters, the method returns an empty Collection.
      Returns:
      an Collection of String objects, each String containing the name of a request parameter; or an empty Collection if the request has no parameters
    • setParameter

      public void setParameter(String name, String value)
      Description copied from interface: Translet
      Sets the value to the parameter with the given name.
      Parameters:
      name - a String specifying the name of the parameter
      value - a String representing the single value of the parameter
      See Also:
    • setParameter

      public void setParameter(String name, String[] values)
      Description copied from interface: Translet
      Sets the value to the parameter with the given name.
      Parameters:
      name - a String specifying the name of the parameter
      values - an array of String objects containing the parameter's values
      See Also:
    • getAllParameters

      public Map<String,Object> getAllParameters()
      Description copied from interface: Translet
      Return a mutable Map of the request parameters, with parameter names as map keys and parameter values as map values. If the parameter value type is the String then map value will be of type String. If the parameter value type is the String array then map value will be of type String array.
      Returns:
      the mutable parameter map
    • extractParameters

      public void extractParameters(Map<String,Object> targetParameters)
      Description copied from interface: Translet
      Extracts all the parameters and fills in the specified map.
      Parameters:
      targetParameters - the target parameter map to be filled
    • getFileParameter

      public FileParameter getFileParameter(String name)
      Description copied from interface: Translet
      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 file parameter
      Returns:
      a FileParameter representing the single value of the parameter
      See Also:
    • getFileParameterValues

      public FileParameter[] getFileParameterValues(String name)
      Description copied from interface: Translet
      Returns an array of FileParameter objects containing all the values the given activity's request file parameter has, or null if the parameter does not exist.
      Parameters:
      name - a String specifying the name of the file parameter
      Returns:
      an array of FileParameter objects containing the parameter's values
      See Also:
    • getFileParameterNames

      public Collection<String> getFileParameterNames()
      Description copied from interface: Translet
      Returns a Collection of String objects containing the names of the file parameters contained in this request. If the request has no parameters, the method returns an empty Collection.
      Returns:
      an Collection of String objects, each String containing the name of a file parameter; or an empty Collection if the request has no file parameters
    • setFileParameter

      public void setFileParameter(String name, FileParameter fileParameter)
      Description copied from interface: Translet
      Sets the FileParameter object to the file parameter with the given name.
      Parameters:
      name - a String specifying the name of the file parameter
      fileParameter - a FileParameter representing the single value of the parameter
      See Also:
    • setFileParameter

      public void setFileParameter(String name, FileParameter[] fileParameters)
      Description copied from interface: Translet
      Sets the value to the file parameter with the given name.
      Parameters:
      name - a String specifying the name of the file parameter
      fileParameters - an array of FileParameter objects containing the file parameter's values
      See Also:
    • removeFileParameter

      public void removeFileParameter(String name)
      Description copied from interface: Translet
      Removes the file parameter with the specified name.
      Parameters:
      name - a String specifying the name of the file parameter
    • getAttribute

      public <V> V getAttribute(String name)
      Description copied from interface: Translet
      Returns the value of the named attribute as a given type, or null if no attribute of the given name exists.
      Type Parameters:
      V - the type of attribute retrieved
      Parameters:
      name - a String specifying the name of the attribute
      Returns:
      an Object containing the value of the attribute, or null if the attribute does not exist
    • setAttribute

      public void setAttribute(String name, Object value)
      Description copied from interface: Translet
      Stores an attribute in this request.
      Parameters:
      name - specifying the name of the attribute
      value - the Object to be stored
    • getAttributeNames

      public Collection<String> getAttributeNames()
      Description copied from interface: Translet
      Returns a Collection containing the names of the attributes available to this request. This method returns an empty Collection if the request has no attributes available to it.
      Returns:
      the attribute names
    • removeAttribute

      public void removeAttribute(String name)
      Description copied from interface: Translet
      Removes an attribute from this request.
      Parameters:
      name - a String specifying the name of the attribute to remove
    • transform

      public void transform(TransformRule transformRule)
      Description copied from interface: Translet
      Transformation according to a given rule, and transmits this response.
      Parameters:
      transformRule - the transformation rule
    • transform

      public void transform(CustomTransformer transformer)
    • dispatch

      public void dispatch(String name)
      Description copied from interface: Translet
      Dispatch to other resources as the given name.
      Parameters:
      name - the dispatch name
    • dispatch

      public void dispatch(String name, String dispatcherName)
      Description copied from interface: Translet
      Dispatch to other resources as the given name.
      Parameters:
      name - the dispatch name
      dispatcherName - the id or class name of the view dispatcher bean
    • dispatch

      public void dispatch(DispatchRule dispatchRule)
      Description copied from interface: Translet
      Dispatch to other resources as the given rule.
      Parameters:
      dispatchRule - the dispatch rule
    • forward

      public void forward(String transletName)
      Description copied from interface: Translet
      Forward to the specified translet immediately.
      Parameters:
      transletName - the translet name of the target to be forwarded
    • forward

      public void forward(ForwardRule forwardRule)
      Description copied from interface: Translet
      Forward according to a given rule.
      Parameters:
      forwardRule - the forward rule
    • redirect

      public void redirect(String path)
      Description copied from interface: Translet
      Redirect a client to a new target resource. If an intended redirect rule exists, that may be used.
      Parameters:
      path - the redirect path
    • redirect

      public void redirect(String path, Map<String,String> parameters)
      Description copied from interface: Translet
      Redirect to the other target resource.
      Parameters:
      path - the redirect path
      parameters - the parameters
    • redirect

      public void redirect(RedirectRule redirectRule)
      Description copied from interface: Translet
      Redirect a client according to the given rule.
      Parameters:
      redirectRule - the redirect rule
    • response

      public void response(Response response)
      Description copied from interface: Translet
      Respond immediately, and the remaining jobs will be canceled.
      Parameters:
      response - the response
    • response

      public void response()
      Description copied from interface: Translet
      Respond immediately, and the remaining jobs will be canceled.
    • getDeclaredResponse

      public Response getDeclaredResponse()
      Description copied from interface: Translet
      Returns the originally declared response.
      Returns:
      the declared response
    • isResponseReserved

      public boolean isResponseReserved()
      Description copied from interface: Translet
      Returns whether the response is reserved.
      Returns:
      true, if the response is reserved
    • isExceptionRaised

      public boolean isExceptionRaised()
      Description copied from interface: Translet
      Returns whether the exception was thrown.
      Returns:
      true, if is exception raised
    • getRaisedException

      public Throwable getRaisedException()
      Description copied from interface: Translet
      Returns the raised exception instance.
      Returns:
      the raised exception instance
    • removeRaisedException

      public void removeRaisedException()
      Description copied from interface: Translet
      Remove the raised exception.
    • getRootCauseOfRaisedException

      public Throwable getRootCauseOfRaisedException()
      Description copied from interface: Translet
      Returns the innermost one of the chained (wrapped) exceptions.
      Returns:
      the innermost one of the chained (wrapped) exceptions
    • getAspectAdviceBean

      public <V> V getAspectAdviceBean(String aspectId)
      Description copied from interface: Translet
      Gets the aspect advice bean.
      Type Parameters:
      V - the result type of the advice
      Parameters:
      aspectId - the aspect id
      Returns:
      the aspect advice bean
    • getBeforeAdviceResult

      public <V> V getBeforeAdviceResult(String aspectId)
      Description copied from interface: Translet
      Gets the before advice result.
      Type Parameters:
      V - the result type of the before advice
      Parameters:
      aspectId - the aspect id
      Returns:
      the before advice result
    • getAfterAdviceResult

      public <V> V getAfterAdviceResult(String aspectId)
      Description copied from interface: Translet
      Gets the after advice result.
      Type Parameters:
      V - the result type of the after advice
      Parameters:
      aspectId - the aspect id
      Returns:
      the after advice result
    • getAroundAdviceResult

      public <V> V getAroundAdviceResult(String aspectId)
      Description copied from interface: Translet
      Gets the around advice result.
      Type Parameters:
      V - the result type of the around advice
      Parameters:
      aspectId - the aspect id
      Returns:
      the around advice result
    • getFinallyAdviceResult

      public <V> V getFinallyAdviceResult(String aspectId)
      Description copied from interface: Translet
      Gets the final advice result.
      Type Parameters:
      V - the result type of the final advice
      Parameters:
      aspectId - the aspect id
      Returns:
      the result of final advice
    • hasPathVariables

      public boolean hasPathVariables()
      Description copied from interface: Translet
      Returns whether the translet name has tokens for extracting parameters or attributes.
      Returns:
      true if the translet name has tokens for extracting parameters or attributes
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • evaluate

      public <V> V evaluate(String expression)
      Description copied from interface: Translet
      Evaluates a token expression.
      Type Parameters:
      V - the type of evaluation result value
      Parameters:
      expression - the token expression to evaluate
      Returns:
      if there are multiple tokens, the result of evaluating them is returned as a string. If there is only one token, it is returned as is.
    • evaluate

      public <V> V evaluate(Token[] tokens)
      Description copied from interface: Translet
      Evaluates a token expression.
      Type Parameters:
      V - the type of evaluation result value
      Parameters:
      tokens - the tokens to evaluate
      Returns:
      if there are multiple tokens, the result of evaluating them is returned as a string. If there is only one token, it is returned as is.
    • getBean

      public <V> V getBean(String id)
      Description copied from interface: Translet
      Return an instance of the bean that matches the given id.
      Type Parameters:
      V - the type of bean object retrieved
      Parameters:
      id - the id of the bean to retrieve
      Returns:
      an instance of the bean
    • getBean

      public <V> V getBean(Class<V> type)
      Description copied from interface: Translet
      Return an instance of the bean that matches the given object type.
      Type Parameters:
      V - the type of bean object retrieved
      Parameters:
      type - the type the bean must match; can be an interface or superclass. null is disallowed.
      Returns:
      an instance of the bean
    • getBean

      public <V> V getBean(Class<V> type, String id)
      Description copied from interface: Translet
      Return an instance of the bean that matches the given object type.
      Type Parameters:
      V - the type of bean object retrieved
      Parameters:
      type - type the bean must match; can be an interface or superclass. null is allowed.
      id - the id of the bean to retrieve
      Returns:
      an instance of the bean
    • containsBean

      public boolean containsBean(String id)
      Description copied from interface: Translet
      Return whether a bean with the specified id is present.
      Parameters:
      id - the id of the bean to query
      Returns:
      whether a bean with the specified id is present
    • containsBean

      public boolean containsBean(Class<?> type)
      Description copied from interface: Translet
      Return whether a bean with the specified object type is present.
      Parameters:
      type - the object type of the bean to query
      Returns:
      whether a bean with the specified type is present
    • containsBean

      public boolean containsBean(Class<?> type, String id)
      Description copied from interface: Translet
      Returns whether the bean corresponding to the specified object type and ID exists.
      Parameters:
      type - the object type of the bean to query
      id - the id of the bean to query
      Returns:
      whether a bean with the specified type is present
    • getMessage

      public String getMessage(String code) throws NoSuchMessageException
      Description copied from interface: Translet
      Try to resolve the message. Treat as an error if the message can't be found.
      Parameters:
      code - the code to lookup up, such as 'calculator.noRateSet'
      Returns:
      the resolved message
      Throws:
      NoSuchMessageException - if the message wasn't found
      See Also:
    • getMessage

      public String getMessage(String code, Object[] args) throws NoSuchMessageException
      Description copied from interface: Translet
      Try to resolve the message. Treat as an error if the message can't be found.
      Parameters:
      code - the code to lookup up, such as 'calculator.noRateSet'
      args - Array of arguments that will be filled in for params within the message (params look like "{0}", "{1,date}", "{2,time}" within a message), or null if none.
      Returns:
      the resolved message
      Throws:
      NoSuchMessageException - if the message wasn't found
      See Also:
    • getMessage

      public String getMessage(String code, String defaultMessage)
      Description copied from interface: Translet
      Try to resolve the message. Return default message if no message was found.
      Parameters:
      code - the code to lookup up, such as 'calculator.noRateSet'. Users of this class are encouraged to base message names on the relevant fully qualified class name, thus avoiding conflict and ensuring maximum clarity.
      defaultMessage - String to return if the lookup fails
      Returns:
      the resolved message if the lookup was successful; otherwise the default message passed as a parameter
      See Also:
    • getMessage

      public String getMessage(String code, Object[] args, String defaultMessage)
      Description copied from interface: Translet
      Try to resolve the message. Return default message if no message was found.
      Parameters:
      code - the code to lookup up, such as 'calculator.noRateSet'. Users of this class are encouraged to base message names on the relevant fully qualified class name, thus avoiding conflict and ensuring maximum clarity.
      args - array of arguments that will be filled in for params within the message (params look like "{0}", "{1,date}", "{2,time}" within a message), or null if none.
      defaultMessage - String to return if the lookup fails
      Returns:
      the resolved message if the lookup was successful; otherwise the default message passed as a parameter
      See Also:
    • getMessage

      public String getMessage(String code, Locale locale) throws NoSuchMessageException
      Description copied from interface: Translet
      Try to resolve the message. Treat as an error if the message can't be found.
      Parameters:
      code - the code to lookup up, such as 'calculator.noRateSet'
      locale - the Locale in which to do the lookup
      Returns:
      the resolved message
      Throws:
      NoSuchMessageException - if the message wasn't found
      See Also:
    • getMessage

      public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException
      Description copied from interface: Translet
      Try to resolve the message. Treat as an error if the message can't be found.
      Parameters:
      code - the code to lookup up, such as 'calculator.noRateSet'
      args - Array of arguments that will be filled in for params within the message (params look like "{0}", "{1,date}", "{2,time}" within a message), or null if none.
      locale - the Locale in which to do the lookup
      Returns:
      the resolved message
      Throws:
      NoSuchMessageException - if the message wasn't found
      See Also:
    • getMessage

      public String getMessage(String code, String defaultMessage, Locale locale)
      Description copied from interface: Translet
      Try to resolve the message. Return default message if no message was found.
      Parameters:
      code - the code to lookup up, such as 'calculator.noRateSet'. Users of this class are encouraged to base message names on the relevant fully qualified class name, thus avoiding conflict and ensuring maximum clarity.
      defaultMessage - String to return if the lookup fails
      locale - the Locale in which to do the lookup
      Returns:
      the resolved message if the lookup was successful; otherwise the default message passed as a parameter
      See Also:
    • getMessage

      public String getMessage(String code, Object[] args, String defaultMessage, Locale locale)
      Description copied from interface: Translet
      Try to resolve the message. Return default message if no message was found.
      Parameters:
      code - the code to lookup up, such as 'calculator.noRateSet'. Users of this class are encouraged to base message names on the relevant fully qualified class name, thus avoiding conflict and ensuring maximum clarity.
      args - array of arguments that will be filled in for params within the message (params look like "{0}", "{1,date}", "{2,time}" within a message), or null if none.
      defaultMessage - String to return if the lookup fails
      locale - the Locale in which to do the lookup
      Returns:
      the resolved message if the lookup was successful; otherwise the default message passed as a parameter
      See Also: