Package com.priint.pubserver.parameterparser


package com.priint.pubserver.parameterparser
Parser and interpreter for pubserver parameter strings.

ParameterInterpreter will call the internal parameter parser to parse the input string.

If the parse fails it will throw a ParameterInterpreterException that has to be handled by the calling method. Some error information may also be seen in the server log.

Input strings can either represent a single parameter or a static call or a plugin call.

There are three types of parameters: numbers, texts, constants.

  • Texts - i.e. string literals - have to be enclosed in simple quotes, like 'WERK II'.
  • Numbers can be integer or decimal.
  • Constants or "tags" are terms enclosed in angle brackets containig only alphanumerics, underscore and dot characters, like <Entity.Id>.

It is recommended to prefer tag constants over string literals, since it will create much fewer parser runs and consume less memory.

There are two types of calls: static and plugin.

  • A static call is a call to static library method reachable to the classloader. This is not used very often.
  • A plugin call is a call to a public method of a plugin instance. The plugin instance will later be found via JNDI lookup in ParameterInterpreter.
For both types you have to specify the object to work with: className in case of static calls, globalName in case of plugins.
Also you have to specify the method by name. You must specify the className or globalName first folloed by the method name.

Both call type can have a list of parameters. A parameter list is enclosed in square brackets. And the parameters are delimited by comma. The exact method is searched for by ParameterInterpreter using the name and the number of parameters. So if you have variants of one method with same parameter number but different paramter types the parser may throw type cast exceptions because the parameter list and given arguments may not match.

It is recommended not to use any whitespace in a call string except within string literals, though this is currently not strictly required.

The following examples are valid call strings:

  • plugin(globalName='myPluginMappedName',methodName='myMethod')[<Session.SessionID>,'Hello World',157]
    Calling "myMethod" on a plugin with mapped name "myPluginMappedName", where myMethod is expected to have three arguments of type (String, String, Integer). The first will be replaced by the actual sessionId - this is a job of the DataProviderManager. The other two are used in there literal value.
  • static(className='java.util.Locale',methodName='forLanguageTag')['de-at']
    Calling static method "forLanguageTag" on "java.util.Locale" with one static argument (String). This will result in an Object - actually the Locale.de_DE.
Valid input strings for single parameters are:
  • 89898981.08
    a single number
  • 'Hello World'
    a single text in simple quotes
  • 'Hello\'World'
    a single text in simple quotes with and escaped quote inside
  • <Entity.Id>
    a single "constant" in angle brackets
  • <08.15.47_elf>
    another single "constant"
Invalid input strings for calls are:
  • Empty or null input will lead to an exception.
  • plugin(globalName='my Plugin Mapped Name',methodName='myMethod')[]
    globalName or className must be valid Java class names.
  • plugin(globalName='myPluginMappedName',methodName='my.Method')[]
    method must be valid Java method names.
  • <pä, am>
    Constants allow only ascii alphanumeric characters plus underscore and dot, no umlauts, whitespace etc.
  • [eins,'zwei','drei']
    is no parameter list because first argument is neither text, nor number or constant
  • xyz(xyzName='g',methodName='m')['t',<x>]
    xyz is no defined call type, only static and plugin are

Calling interpret() on ParameterInterpreter

An exception wil be thrown if either the class could not be found, or the method could not be found, or the parameters do not match, or the parameter casting failed. Additionally a warning will be written to the server log.

Also if the method invocation fails there will be a warning in ther server log and the exception will bubble up to the caller.

Since:
4.0.0