Script Parser
Overview
The script Parser allows you to write your own Parser using a script you are
familiar with.
A script Parser must implement a few functions in order to operate. The
functions do not use parameters. The reason for this is that some scripting
languages will not neccessarily support this. Passing data between the hosting Connector
and the script is obtained by using predefined objects. One of these
predefined objects is the result object which is used to communicate
status information. Upon entry in either function the status field is set to
"normal" which will cause the hosting Parser to continue calls.
Signaling end-of-input or errors is done by setting the status and message
fields in this object. The entry object is populated on calls to writeEntry
and is expected to be populated in the readEntry function. When
reading entries you have the inp BufferedReader object available for reading character
data from a stream. When writing entries you have the out BufferedWriter object
available for writing character data to a stream.
You can add your own parameters to the configuration and obtain these by
using the parser object.
Objects
The following objects are the only ones accessible to the script Parser:
The result object
Function |
Description |
setStatus (code) |
0 - End of Input
1 - Status OK
2 - Error |
setMessage (text) |
|
The entry object
Function |
Description |
addAttributeValue (name, value) |
Adds a value to an Attribute. |
getAttribute (name) |
Returns the named Attribute. |
For a complete list of available methods, including parameters and return
values, see here.
The inp object
Function |
Description |
read() |
Returns next character from stream |
readLine() |
Returns next CRLF terminated line from the input stream. |
The out object
Function |
Description |
write (str) |
Writes a string to the output stream |
writeln (str) |
Writes a string followed by CRLF to the output stream. |
The parser object
Function |
Description |
getParam(str) |
Returns the parameter value associated with parameter name str |
setParam(str, value) |
Sets the parameter str to value value |
logmsg(str) |
Writes the parameter str in the log file |
See here for a complete list of
methods.
The connector object
See here for more information.
Functions
The Parser must supply these functions
Function |
Description |
readEntry() |
Read the next logical entry from the input stream and
populate the entry object. |
writeEntry() |
Write the contents of the entry object to the output
stream. |
Configuration
The Parser needs the following parameters:
Parameter |
Description |
class |
com.architech.parser.rspScriptParser |
scriptEngine |
[javascript | vbscript | jscript | perlscript |
......] |
script |
[user defined script] |
includeFiles |
[files extending the script] |
Downloads
Example AssemblyLine
using script parser.
See Also
Script Connector, Sample
Script Parser
|