In this section: |
Environmental functions return information about or from the environment in which the document is being processed.
The _sreg() function uses the following format:
_sreg(name [,default])
name | string | Name of the register |
default | string | Default value |
Special registers contain context information. The information can be configured on the runtime system, reflect the processing state of the current message, or be explicitly set by services in a process flow.
Special registers exist in scopes, and are looked up from the local scope to the outermost scope (the system context). The value returned is that of the nearest scope in which the register is found. If the register is not found in any scope, the default is returned. If the default is not specified, null is returned.
The _sreg() function searches in a case sensitive manner. Consider the following examples:
Register Name | Value | _sreg('a','def1') |
a | hello | hello |
A | hello | defl |
The _property() function loads the value for the desired property from a Java properties object file. It uses the following format:
_property(file, attribute [, default [,control] [,evaluate]] )
file | file name | Path to the properties file. |
attribute | string | Name of the desired property. |
default | string | Default if property does not exist. |
control | string | Keyword to control operation:
|
evaluate | keyword | The keyword to control the result evaluation:
|
Load the value for the desired property from a Java properties object file. The check control option causes the properties file modification timestamp to be examined on each request. This is to determine whether the file has changed since the last load. If so, the properties file is reloaded. The keep control option prevents this check for cases in which it is known that changes will not be made or should not be loaded. Avoiding the check can result in file read time savings. The keep option is the default.
For example, assume file test.properties contains:
one=first two=second
The following function call causes the value first to be returned:
_property('test','one','notfound','check')
Next, change the properties file to the following:
one=next two=second
In this case, the following function call returns next:
_property('test','one','notfound','check')
If the control option is omitted or keep is used, the following function call returns first as before:
_property('test','one','notfound',’keep')
The value of the property can also by stored using the Advanced Encryption Standard (AES), by configuring the set property command. For more information on using the set property command, see the iWay Service Manager User's Guide.
The value can be decrypted during a read using the _aes() function applied to the result of the _property() function. For example:
_aes('decrypt',_sreg('mykey'),_property('file',key'))
A properties file contains key=value pairs consisting of a regular expression and a value. An input string is matched against the patterns in the properties file, and the value associated with the first pattern to match the input is returned.
The properties file is loaded once, cached for the channel, and is not reloaded for each use. If any changes are made in the properties file, the channel must be restarted to reflect these changes.
The _propertymatch() function uses the following format:
_propertymatch(file,input,[,default [,control [,encoding]]]
file | path | Path to the properties file. The suffix is optional. |
input | string | The candidate to be matched against the regular expressions in the properties file. |
default | string | The value to be returned if none of the patterns are matched by the candidate input string. |
control | keyword | Keyword to control operation:
|
encoding | string | IANA encoding of the properties file. |
The properties file consists of one or more regular expressions (keys), each with an associated value. Standard properties file comments (lines starting with #) and blank lines are allowed. Continuation lines are not supported.
The check control option causes the properties file modification timestamp to be examined on each request to determine whether the file has changed since the last load, and if so, the properties file is reloaded. The keep control option prevents this check for cases in which it is known that changes will not be made or should not be loaded. Avoiding the check can result in file read time savings. The keep option is the default.
In the following example, an input ZIP code must be matched to select an appropriate subflow to handle the location. The file stored at /appdata/zip.properties might be structured as follows:
# zip code flow selection file 00.*=zip00 01.*=zip01 10.*=zipnyc 20500=zipwhitehouse 20.*=zipwashdc
Since the patterns are matched in the order specified in the file, the ZIP code for the White House will match before the general Washington, D.C. ZIP codes are matched.
Assume that the ZIP code is located in an input document and stored in a Special Register (SREG) called INZIP. The following function call does the matching:
_propertymatch('/appdata.zip',sreg(INZIP),'zipother')
If the INZIP SREG holds 10121, then the function returns zipnyc. If the INZIP SREG holds 11570, then the function returns zipother.
The value of the property can also by stored using the Advanced Encryption Standard (AES), by configuring the set property command. For more information on using the set property command, see the iWay Service Manager User's Guide.
The value can be decrypted during a read using the _aes() function applied to the result of the _propertymatch() function. For example:
_aes('decrypt',_sreg('mykey'),_propertymatch('file',key'))
The _inlist() function checks whether a key value is in a list. This function uses the following format:
_inlist(list, key [,control])
list | string or path | Source of the list, which is under control of the control operand. This can either be the path to the file containing the list values, or a string directly in the function. |
key | string | The value to be checked. |
control | keyword | Specifies how the list is interpreted. The following controls are supported:
|
The _inlist() function facilitates checking whether a value is in a list of valid values (for example, a set of medical codes). If the control is set to string, then the list is direct (for example, 1987,4567,3334). The check control option causes the list file modification timestamp to be examined on each request. This is to determine whether the file has changed since the last load. If this is the case, then the list is reloaded. The keep control option prevents this check for cases where it is known that changes will not be made or should not be loaded. Avoiding the check can decrease file read times. The keep control option is set by default. For more detailed examples using the keep and check control options, see _property(): Retrieve a Value from a Java Property Object File and _propertymatch(): Match a String Against a File of Regular Expression Patterns.
If a file is being used, then it takes the form of an iWay list file consisting of single tokens delineated by a separator or an end of line. A line that starts with a hash character (#) is considered to be a comment and is ignored. For example, listfile.txt may look like the following example:
# example list file, first lines have one token each 1234 2345 # now a line with multiple entries 5678,8764
Examples:
The following _inlist() function evaluates as true:
_inlist(listfile.txt,2345,keep)
The following _inlist() function evaluates as false:
_inlist("washington,adams,jefferson","cohen",string)
The _setreg() function sets the specified special register to the value that is entered and returns the previous value, if any. This function uses the following format:
_setreg(name,value[,type [,scope [,action] ]])
name | string | The name of the register. |
value | string | The value to be set. |
type | keyword | The register type. The following types are supported:
|
scope | keyword | The scope of the specified register. The query on the former value is performed at this scope. The following scopes are supported:
|
action | keyword | Determines how to interpret the value operand. The following actions are supported:
|
Use caution with the _setreg() function, since this function can change the contents of the local special register manager.
The action operand controls how the value is handled. Normally, it is a string and inserted into the register. If set to parse, the string is treated as a flat XML tree, which is parsed and set into the register. The register can be used in an _xpath() function to allow XPATH evaluation of the XML. The tree can also be set into the current document by using the _restoredoc() iFL function.
The selected scope must be appropriate to the context in which the function is used. For example, a flow scope is not present in non-flow contexts.
When deleting a register, the delete takes place at the identified scope. Registers are normally looked up by the nearest scope, so the register may continue to exist at lower scopes. This function can be used effectively as an operand of the _if() function.
If you need to set multiple registers in parallel, you can consider using the _concat() function. The following example sets registers ra and rb if register rt is true:
_if(sreg('rt')='true',_concat(_setreg('ra','1'),_setreg('rb','2'))
If you are setting multiple registers using this technique, then you may need to consider the _lock() function as a part of the setting clause. For example:
_lock('lock1',_concat(,_concat(_setreg('ra','1'),_setreg('rb','2')))
The value parameter is not recommended to be a literal value, but rather a function to obtain the value, such as _xpath() or _jdbc().
iWay Software |