Package org.frankframework.parameters
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
,XmlParameter
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:
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static enum
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
boolean
consumesSessionVariable
(String sessionKey) org.springframework.context.ApplicationContext
This ClassLoader is set upon creation of the object, used to retrieve resources configured by the Ibis application.int
int
getMode()
getName()
getType()
getValue()
getValue
(ParameterValueList alreadyResolvedParameters, Message message, PipeLineSession session, boolean namespaceAware) determines the raw valueprotected Object
getValueAsType
(Message request, boolean namespaceAware) Converts raw data to configured parameter typeint
boolean
isHidden()
boolean
boolean
boolean
if this returns true, then the input value must be repeatable, as it might be used multiple times.void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) void
setAuthAlias
(String string) Alias used to obtain username and password, used when apattern
containing {username} or {password} is specifiedvoid
setContextKey
(String string) key of message context variable to use as source, instead of the message found from input message or sessionKey itselfvoid
setDefaultValue
(String string) If the result of sessionKey, xpathExpression and/or stylesheet returns null or an empty string, this value is returnedvoid
setDefaultValueMethods
(String string) Comma separated list of methods (defaultValue
,sessionKey
,pattern
,value
orinput
) to use as default value.void
setHidden
(boolean b) If set totrue
, the value of the parameter will not be shown in the log (replaced by asterisks)void
setIgnoreUnresolvablePatternElements
(boolean b) If settrue
pattern elements that cannot be resolved to a parameter or sessionKey are silently resolved to an empty stringvoid
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 lengthvoid
setMinLength
(int i) If set (>=0) and the length of the value of the parameter falls short of this minimum length, the value is paddedvoid
Set the mode of the parameter, which determines if the parameter is an INPUT, OUTPUT, or INOUT.void
Name of the parametervoid
setNamespaceDefs
(String namespaceDefs) Namespace definitions for xpathExpression.void
setPassword
(String string) Default password that is used when apattern
containing {password} is specifiedvoid
setPattern
(String string) Value of parameter is determined using substitution and formatting, following MessageFormat syntax with named parameters.void
setRemoveNamespaces
(boolean b) When settrue
namespaces (and prefixes) in the input message are removed before the stylesheet/xpathExpression is executedvoid
setSessionKey
(String string) Key of a PipelineSession-variable.void
setSessionKeyXPath
(String string) Instead of a fixedsessionKey
it's also possible to use a XPath expression applied to the input message to extract the name of the session-variable.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.protected void
setType
(ParameterType type) void
setUsername
(String string) Default username that is used when apattern
containing {username} is specifiedvoid
The value of the parameter, or the base for transformation using xpathExpression or stylesheet, or formatting.void
setXpathExpression
(String xpathExpression) the XPath expression to extract the parameter value from the (xml formatted) input or session-variable.void
setXsltVersion
(int xsltVersion) If set to2
or3
a Saxon (net.sf.saxon) xslt processor 2.0 or 3.0 respectively will be used, otherwise xslt processor 1.0 (org.apache.xalan).toString()
-
Field Details
-
FIXEDUID
- See Also:
-
FIXEDHOSTNAME
- See Also:
-
paramList
-
-
Constructor Details
-
AbstractParameter
public AbstractParameter()
-
-
Method Details
-
addParameter
- Specified by:
addParameter
in interfaceIWithParameters
-
getParameterList
- Specified by:
getParameterList
in interfaceIWithParameters
-
configure
- Specified by:
configure
in interfaceIConfigurable
- 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 interfaceIParameter
-
consumesSessionVariable
- Specified by:
consumesSessionVariable
in interfaceIParameter
-
getValue
public Object getValue(ParameterValueList alreadyResolvedParameters, Message message, PipeLineSession session, boolean namespaceAware) throws ParameterException determines the raw value- Specified by:
getValue
in interfaceIParameter
- Throws:
ParameterException
-
getValueAsType
protected Object getValueAsType(@Nonnull Message request, boolean namespaceAware) throws ParameterException, IOException Converts raw data to configured parameter type- Throws:
ParameterException
IOException
-
toString
-
setName
Name of the parameter- Specified by:
setName
in interfaceINamedObject
-
getName
- Specified by:
getName
in interfaceIConfigurationAware
- Specified by:
getName
in interfaceINamedObject
-
setType
-
setValue
The value of the parameter, or the base for transformation using xpathExpression or stylesheet, or formatting.- Specified by:
setValue
in interfaceIParameter
-
setSessionKey
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 interfaceIParameter
-
setContextKey
key of message context variable to use as source, instead of the message found from input message or sessionKey itself -
setSessionKeyXPath
Instead of a fixedsessionKey
it's also possible to use a XPath expression applied to the input message to extract the name of the session-variable. -
setStyleSheetName
URL to a stylesheet that wil be applied to the contents of the message or the value of the session-variable. -
setXpathExpression
the XPath expression to extract the parameter value from the (xml formatted) input or session-variable. -
setXsltVersion
public void setXsltVersion(int xsltVersion) If set to2
or3
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
Namespace definitions for xpathExpression. Must be in the form of a comma or space separated list ofprefix=namespaceuri
definitions. One entry can be without a prefix, that will define the default namespace. -
setRemoveNamespaces
public void setRemoveNamespaces(boolean b) When settrue
namespaces (and prefixes) in the input message are removed before the stylesheet/xpathExpression is executed- Default value
false
-
setDefaultValue
If the result of sessionKey, xpathExpression and/or stylesheet returns null or an empty string, this value is returned -
setDefaultValueMethods
Comma separated list of methods (defaultValue
,sessionKey
,pattern
,value
orinput
) to use as default value. Used in the order they appear until a non-null value is found.- Default value
defaultValue
-
setPattern
Value of parameter is determined using substitution and formatting, following MessageFormat syntax with named parameters. The expression can contain references tosession-variables
or otherparameters
using the {name-of-parameter} and is formatted using java.text.MessageFormat.
NB: When referencing otherparameters
these MUST be defined before the parameter using pattern substitution.
If for instancefname
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
When combining a date or timepattern
like {now} or {fixeddate} with a DATE, TIME, DATETIME or TIMESTAMPtype
, the effective value of the attributeformatString
must match the effective value of the formatString in thepattern
. -
setAuthAlias
Alias used to obtain username and password, used when apattern
containing {username} or {password} is specified -
setUsername
Default username that is used when apattern
containing {username} is specified -
setPassword
Default password that is used when apattern
containing {password} is specified -
setIgnoreUnresolvablePatternElements
public void setIgnoreUnresolvablePatternElements(boolean b) If settrue
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 totrue
, the value of the parameter will not be shown in the log (replaced by asterisks)- Default value
false
-
setMode
Set the mode of the parameter, which determines if the parameter is an INPUT, OUTPUT, or INOUT. This parameter only has effect forStoredProcedureQuerySender
. 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 theStoredProcedureQuerySender
. If not specified, the default is INPUT.- Parameters:
mode
- INPUT, OUTPUT or INOUT.
-
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 interfaceIScopeProvider
- Returns:
- returns the ClassLoader created by the
ClassLoaderManager
.
-
getApplicationContext
public org.springframework.context.ApplicationContext getApplicationContext()- Specified by:
getApplicationContext
in interfaceIConfigurationAware
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
-
getType
- Specified by:
getType
in interfaceIParameter
-
getSessionKey
- Specified by:
getSessionKey
in interfaceIParameter
-
getSessionKeyXPath
-
getContextKey
-
getXpathExpression
-
getNamespaceDefs
-
getStyleSheetName
-
getPattern
-
getAuthAlias
-
getUsername
-
getPassword
-
isIgnoreUnresolvablePatternElements
public boolean isIgnoreUnresolvablePatternElements() -
getDefaultValue
-
getDefaultValueMethods
-
getValue
- Specified by:
getValue
in interfaceIParameter
-
getMinLength
public int getMinLength() -
getMaxLength
public int getMaxLength() -
isHidden
public boolean isHidden()- Specified by:
isHidden
in interfaceIParameter
-
isRemoveNamespaces
public boolean isRemoveNamespaces() -
getXsltVersion
public int getXsltVersion() -
getMode
- Specified by:
getMode
in interfaceIParameter
-