Class AbstractParameter

java.lang.Object
org.frankframework.parameters.AbstractParameter
All Implemented Interfaces:
IConfigurable, IConfigurationAware, INamedObject, IScopeProvider, IWithParameters, IParameter, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
BooleanParameter, DateParameter, NumberParameter, Parameter

public abstract class AbstractParameter extends Object implements IConfigurable, IWithParameters, IParameter
Generic parameter definition. A parameter resembles an attribute. However, while attributes get their value at configuration-time, parameters get their value at the time of processing the message. Value can be retrieved from the message itself, a fixed value, or from the pipelineSession. If this does not result in a value (or if neither of these is specified), a default value can be specified. If an XPathExpression or stylesheet is specified, it will be applied to the message, the value retrieved from the pipelineSession or the fixed value specified. If the transformation produces no output, the default value of the parameter is taken if provided.

Examples:

 stored under SessionKey 'TransportInfo':
  <transportinfo>
   <to>***@zonnet.nl</to>
   <to>***@zonnet.nl</to>
   <cc>***@zonnet.nl</cc>
  </transportinfo>

 to obtain all 'to' addressees as a parameter:
 sessionKey="TransportInfo"
 xpathExpression="transportinfo/to"
 type="xml"

 Result:
   <to>***@zonnet.nl</to>
   <to>***@zonnet.nl</to>
 
N.B. to obtain a fixed value: a non-existing 'dummy' sessionKey in combination with the fixed value in defaultValue is used traditionally. The current version of parameter supports the 'value' attribute, that is sufficient to set a fixed value.
Author:
Gerrit van Brakel
Parameters
Parameters themselves can have parameters too, for instance if a XSLT transformation is used, that transformation can have parameters.
  • Field Details

  • Constructor Details

    • AbstractParameter

      public AbstractParameter()
  • Method Details

    • addParameter

      public void addParameter(IParameter p)
      Specified by:
      addParameter in interface IWithParameters
    • getParameterList

      public ParameterList getParameterList()
      Specified by:
      getParameterList in interface IWithParameters
    • configure

      public void configure() throws ConfigurationException
      Specified by:
      configure in interface IConfigurable
      Throws:
      ConfigurationException
    • requiresInputValueForResolution

      public boolean requiresInputValueForResolution()
      if this returns true, then the input value must be repeatable, as it might be used multiple times.
      Specified by:
      requiresInputValueForResolution in interface IParameter
    • consumesSessionVariable

      public boolean consumesSessionVariable(String sessionKey)
      Specified by:
      consumesSessionVariable in interface IParameter
    • getValue

      public Object getValue(ParameterValueList alreadyResolvedParameters, Message message, PipeLineSession session, boolean namespaceAware) throws ParameterException
      determines the raw value
      Specified by:
      getValue in interface IParameter
      Throws:
      ParameterException
    • getValueAsType

      protected Object getValueAsType(Object request, boolean namespaceAware) throws ParameterException, IOException
      Converts raw data to configured parameter type
      Throws:
      ParameterException
      IOException
    • toString

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

      public void setName(String parameterName)
      Name of the parameter
      Specified by:
      setName in interface INamedObject
    • getName

      public String getName()
      Specified by:
      getName in interface IConfigurationAware
      Specified by:
      getName in interface INamedObject
    • setType

      protected void setType(ParameterType type)
    • setValue

      public void setValue(String value)
      The value of the parameter, or the base for transformation using xpathExpression or stylesheet, or formatting.
      Specified by:
      setValue in interface IParameter
    • setSessionKey

      public void setSessionKey(String string)
      Key of a PipelineSession-variable.
      If specified, the value of the PipelineSession variable is used as input for the xpathExpression or stylesheet, instead of the current input message.
      If no xpathExpression or stylesheet are specified, the value itself is returned.
      If the value '*' is specified, all existing sessionkeys are added as parameter of which the name starts with the name of this parameter.
      If also the name of the parameter has the value '*' then all existing sessionkeys are added as parameter (except tsReceived)
      Specified by:
      setSessionKey in interface IParameter
    • setContextKey

      public void setContextKey(String string)
      key of message context variable to use as source, instead of the message found from input message or sessionKey itself
    • setSessionKeyXPath

      public void setSessionKeyXPath(String string)
      Instead of a fixed sessionKey it's also possible to use a XPath expression applied to the input message to extract the name of the session-variable.
    • setStyleSheetName

      public void setStyleSheetName(String stylesheetName)
      URL to a stylesheet that wil be applied to the contents of the message or the value of the session-variable.
    • setXpathExpression

      public void setXpathExpression(String xpathExpression)
      the XPath expression to extract the parameter value from the (xml formatted) input or session-variable.
    • setXsltVersion

      public void setXsltVersion(int xsltVersion)
      If set to 2 or 3 a Saxon (net.sf.saxon) xslt processor 2.0 or 3.0 respectively will be used, otherwise xslt processor 1.0 (org.apache.xalan). 0 will auto-detect
      Default value
      0
    • setNamespaceDefs

      public void setNamespaceDefs(String namespaceDefs)
      Namespace definitions for xpathExpression. Must be in the form of a comma or space separated list of prefix=namespaceuri-definitions. One entry can be without a prefix, that will define the default namespace.
    • setRemoveNamespaces

      public void setRemoveNamespaces(boolean b)
      When set true namespaces (and prefixes) in the input message are removed before the stylesheet/xpathExpression is executed
      Default value
      false
    • setDefaultValue

      public void setDefaultValue(String string)
      If the result of sessionKey, xpathExpression and/or stylesheet returns null or an empty string, this value is returned
    • setDefaultValueMethods

      public void setDefaultValueMethods(String string)
      Comma separated list of methods (defaultValue, sessionKey, pattern, value or input) to use as default value. Used in the order they appear until a non-null value is found.
      Default value
      defaultValue
    • setPattern

      public void setPattern(String string)
      Value of parameter is determined using substitution and formatting, following MessageFormat syntax with named parameters. The expression can contain references to session-variables or other parameters using the {name-of-parameter} and is formatted using java.text.MessageFormat.
      NB: When referencing other parameters these MUST be defined before the parameter using pattern substitution.

      If for instance fname is a parameter or session-variable that resolves to Eric, then the pattern 'Hi {fname}, how do you do?' resolves to 'Hi Eric, do you do?'.
      The following predefined reference can be used in the expression too:
      • {now}: the current system time
      • {uid}: an unique identifier, based on the IP address and java.rmi.server.UID
      • {uuid}: an unique identifier, based on the IP address and java.util.UUID
      • {hostname}: the name of the machine the application runs on
      • {username}: username from the credentials found using authAlias, or the username attribute
      • {password}: password from the credentials found using authAlias, or the password attribute
      • {fixeddate}: fake date, for testing only
      • {fixeduid}: fake uid, for testing only
      • {fixedhostname}: fake hostname, for testing only
      A guid can be generated using {hostname}_{uid}, see also http://java.sun.com/j2se/1.4.2/docs/api/java/rmi/server/uid.html for more information about (g)uid's or http://docs.oracle.com/javase/1.5.0/docs/api/java/util/uuid.html for more information about uuid's.
      When combining a date or time pattern like {now} or {fixeddate} with a DATE, TIME, DATETIME or TIMESTAMP type, the effective value of the attribute formatString must match the effective value of the formatString in the pattern.
    • setAuthAlias

      public void setAuthAlias(String string)
      Alias used to obtain username and password, used when a pattern containing {username} or {password} is specified
    • setUsername

      public void setUsername(String string)
      Default username that is used when a pattern containing {username} is specified
    • setPassword

      public void setPassword(String string)
      Default password that is used when a pattern containing {password} is specified
    • setIgnoreUnresolvablePatternElements

      public void setIgnoreUnresolvablePatternElements(boolean b)
      If set true pattern elements that cannot be resolved to a parameter or sessionKey are silently resolved to an empty string
    • setMinLength

      public void setMinLength(int i)
      If set (>=0) and the length of the value of the parameter falls short of this minimum length, the value is padded
      Default value
      -1
    • setMaxLength

      public void setMaxLength(int i)
      If set (>=0) and the length of the value of the parameter exceeds this maximum length, the length is trimmed to this maximum length
      Default value
      -1
    • setHidden

      public void setHidden(boolean b)
      If set to true, the value of the parameter will not be shown in the log (replaced by asterisks)
      Default value
      false
    • setMode

      public void setMode(AbstractParameter.ParameterMode mode)
      Set the mode of the parameter, which determines if the parameter is an INPUT, OUTPUT, or INOUT. This parameter only has effect for StoredProcedureQuerySender. An OUTPUT parameter does not need to have a value specified, but does need to have the type specified. Parameter values will not be updated, but output values will be put into the result of the StoredProcedureQuerySender. If not specified, the default is INPUT.
      Parameters:
      mode - INPUT, OUTPUT or INOUT.
    • getConfigurationClassLoader

      public ClassLoader getConfigurationClassLoader()
      Description copied from interface: IScopeProvider
      This ClassLoader is set upon creation of the object, used to retrieve resources configured by the Ibis application.
      Specified by:
      getConfigurationClassLoader in interface IScopeProvider
      Returns:
      returns the ClassLoader created by the ClassLoaderManager.
    • getApplicationContext

      public org.springframework.context.ApplicationContext getApplicationContext()
      Specified by:
      getApplicationContext in interface IConfigurationAware
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
    • getType

      public ParameterType getType()
      Specified by:
      getType in interface IParameter
    • getSessionKey

      public String getSessionKey()
      Specified by:
      getSessionKey in interface IParameter
    • getSessionKeyXPath

      public String getSessionKeyXPath()
    • getContextKey

      public String getContextKey()
    • getXpathExpression

      public String getXpathExpression()
    • getNamespaceDefs

      public String getNamespaceDefs()
    • getStyleSheetName

      public String getStyleSheetName()
    • getPattern

      public String getPattern()
    • getAuthAlias

      public String getAuthAlias()
    • getUsername

      public String getUsername()
    • getPassword

      public String getPassword()
    • isIgnoreUnresolvablePatternElements

      public boolean isIgnoreUnresolvablePatternElements()
    • getDefaultValue

      public String getDefaultValue()
    • getDefaultValueMethods

      public String getDefaultValueMethods()
    • getValue

      public String getValue()
      Specified by:
      getValue in interface IParameter
    • getMinLength

      public int getMinLength()
    • getMaxLength

      public int getMaxLength()
    • isHidden

      public boolean isHidden()
      Specified by:
      isHidden in interface IParameter
    • isRemoveNamespaces

      public boolean isRemoveNamespaces()
    • getXsltVersion

      public int getXsltVersion()
    • getMode

      Specified by:
      getMode in interface IParameter