|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.safs.staf.service.SAFSInputService
public class SAFSInputService
Copyright 2003 SAS Institute GNU General Public License (GPL) http://www.opensource.org/licenses/gpl-license.php
This SAFSInputService class is an external STAF service run by the JSTAF Service Proxy.
The intention is to provide global services for reading the content of text files in a
manner suitable for a SAFS Drivers(like SAFSDRIVER) and Engines. For example, two different
processes (or machines?) can share the file read operations as necessary. However, there
will certainly be an array of other uses.
It is important to note that in a normal SAFS environment, Input services may make use of SAFS Variable services (SAFSVARS). This is because some commands may need to evaluate variable values or resolve expressions.
The SAFSInputService service provides the following commands:
OPEN | Open a file for use |
NEXT | Get the next line from the file |
GOTO | Goto a defined position in the file |
BEGIN | Reset a file reader back to the first line |
CLOSE | Close and release resources on a file |
QUERY | Get information on a file |
LIST | List information for all open files |
RESET | Close and release all files and resources |
HELP | Display this help information |
Each instance of the service must be registered via the STAF Service service.
Example showing comandline registration:
STAF LOCAL SERVICE ADD SERVICE SAFSINPUT LIBRARY JSTAF / EXECUTE c:/safs/lib/SAFSINPUT.JAR [PARMS <Parameters>] STAF LOCAL SERVICE ADD SERVICE SAFSINPUT LIBRARY JSTAF / EXECUTE c:/safs/lib/SAFSINPUT.JAR STAF LOCAL SERVICE ADD SERVICE SAFSINPUT LIBRARY JSTAF / EXECUTE c:/safs/lib/SAFSINPUT.JAR PARMS DIR "c:/repo/Datapool"
By default, the service expects a "SAFSVARS" SAFSVariableService to handle Variable calls. A future release may add a parameter allowing a different variable service handler.
1.1 Valid Parameters when registering the service:
1.1.1 DIR <default directory>
If provided, the DIR parameter specifies a default directory to use if the OPEN
request provides relative path information or no path information at all. File
searches do not use system PATH information. The OPEN request expects a
full filename path, or a path relative to this DIR option.
EX: <PARMS> DIR "c:/testproject/Datapool"
The OPEN command attempts to open a file for read operations.
Syntax:
OPEN <FileID> FILE <Filename>
2.1.1 FileID is a unique ID for this file reader instance.
2.1.2 FILE is the filename of the file to load.
If a default Directory was specified when the service was launched, then the filename
can be relative to that directory.
Example: staf local safsinput open myfile file TIDTest.CDD
Example: staf local safsinput open myfile file c:/testproject/datapool/Bench/TIDTest.txt
The NEXT command reads the next line from the file matching FileID.
Syntax:
NEXT <FileID>
2.2.1 FileID is the unique ID for the file reader instance.
Example: staf local safsinput next myfile
The GOTO command moves the file reader pointer to a defined place in the file.
Currently, the "defined place" must take the form of a SAFS BlockID record. Future
releases may allow you to specify specific line numbers.
A SAFS BlockID record is a line with two fields separated by a delimiter as shown below:
B, MyBlockID
The first field contains "B" which specifies a BlockID record. The second field specifies the name or label of the BlockID record. This label is the value identifying this "defined place" in the file.
This command will use the variables service to evaluate SAFS variables and process SAFS expressions in field #1 and/or field #2 in order to accurately locate the target BlockID.
The command will return STAFResult.OK and a (linenum:record) result string if successful; or an error code and error description upon failure.
Syntax:
GOTO <FileID> LOCATE <BlockID> SEPARATOR <SepChar>
2.3.1 FileID is the unique ID for the file reader instance.
2.3.2 BlockID is the target block ID label to locate.
2.3.3 SepChar is the character that delimits the two fields.
Example: staf local safsinput goto myfile locate MyBlockID separator ","
The BEGIN command resets the file reader matching the FileID back to the beginning of the file.
Syntax:
BEGIN <FileID>
2.4.1 FileID is the unique ID for the file reader instance.
Example: staf local safsinput begin myfile
The CLOSE command closes the file matching FileID and releases its resources.
Syntax:
CLOSE <FileID>
2.5.1 FileID is the unique ID for the file reader instance.
Example: staf local safsinput close myfile
The QUERY command returns information about the file matching FileID.
Syntax:
QUERY <FileID> [ STATUS | FILENAME | FULLPATH ]
2.6.1 FileID is the unique ID for the file reader instance.
2.6.2 STATUS request status info on this file.
2.6.3 FILENAME request the simple filename of this file.
2.6.4 FULLPATH request the full path and filename of this file.
Example: staf local safsinput query myfile STATUS FULLPATH
The LIST command returns information on ALL files.
Syntax:
LIST
Example: staf local safsinput list
The RESET command closes all files and resets all resources.
Syntax:
RESET
Example: staf local safsinput reset
The HELP command returns a quick reference of supported commands and syntax.
Syntax:
HELP
Example: staf local safsinput list
Software Automation Framework Support (SAFS) http://safsdev.sourceforge.net
Software Testing Automation Framework (STAF) http://staf.sourceforge.net
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.ibm.staf.service.STAFServiceInterfaceLevel3 |
---|
com.ibm.staf.service.STAFServiceInterfaceLevel3.InitInfo, com.ibm.staf.service.STAFServiceInterfaceLevel3.RequestInfo |
Field Summary | |
---|---|
protected com.ibm.staf.service.STAFCommandParser |
beginParser
|
protected static java.lang.String |
c
a single colon |
protected com.ibm.staf.service.STAFCommandParser |
closeParser
|
protected java.lang.String |
dir
|
protected java.lang.String |
ext
|
protected boolean |
file_extension_available
|
protected com.ibm.staf.service.STAFCommandParser |
gotoParser
|
protected com.ibm.staf.service.STAFCommandParser |
nextParser
|
protected com.ibm.staf.service.STAFCommandParser |
openParser
|
protected com.ibm.staf.service.STAFCommandParser |
parser
|
protected static java.lang.String |
r
a single newline |
protected boolean |
relative_path_allowed
|
protected com.ibm.staf.service.STAFCommandParser |
resetParser
|
protected com.ibm.staf.service.STAFCommandParser |
routeParser
|
protected static java.lang.String |
s
a single space |
protected static java.util.ResourceBundle |
safsfilereader_resources
|
protected java.lang.String |
servicename
|
protected java.lang.String |
serviceparams
|
protected java.lang.String |
servicevars
Stores the name of the actual service used to resolve variable expressions. |
java.lang.String |
SI_DEFAULT_RESOLVE_SERVICE
"SAFSVARS" -- default service used to resolve variable expressions for GOTO |
static java.lang.String |
SI_RBKEY_ERROR_NOT_INTEGER
|
static java.lang.String |
SI_RBKEY_NOT_IMPLEMENTED
|
static java.lang.String |
SI_RBKEY_OPEN_FILES
|
static java.lang.String |
SI_RBKEY_REQUIRED
|
static java.lang.String |
SI_RBKEY_SYNC_ERROR
|
static java.lang.String |
SI_RBKEY_UCPATH
|
static java.lang.String |
SI_SERVICE_FILE_STATE_CLOSED
|
static java.lang.String |
SI_SERVICE_FILE_STATE_EOF
|
static java.lang.String |
SI_SERVICE_FILE_STATE_ERROR
|
static java.lang.String |
SI_SERVICE_FILE_STATE_OPEN
|
protected int |
SI_SERVICE_INIT_PARMS_MAX
The maximum number of options/parameters we expect a service initialization request to receive. |
static java.lang.String |
SI_SERVICE_OPTION_DIR
|
static java.lang.String |
SI_SERVICE_OPTION_EXT
|
static java.lang.String |
SI_SERVICE_PARM_FILE
|
static java.lang.String |
SI_SERVICE_PARM_FILENAME
|
static java.lang.String |
SI_SERVICE_PARM_FULLPATH
|
static java.lang.String |
SI_SERVICE_PARM_LASTERROR
|
static java.lang.String |
SI_SERVICE_PARM_LOCATE
|
static java.lang.String |
SI_SERVICE_PARM_SEPARATOR
|
static java.lang.String |
SI_SERVICE_PARM_STATUS
|
protected int |
SI_SERVICE_REQUEST_ARGS_MAX
The maximum number of options/parameters we expect a running service to receive in a request. |
static java.lang.String |
SI_SERVICE_REQUEST_BEGIN
|
static java.lang.String |
SI_SERVICE_REQUEST_CLOSE
|
static java.lang.String |
SI_SERVICE_REQUEST_GOTO
|
static java.lang.String |
SI_SERVICE_REQUEST_HELP
|
static java.lang.String |
SI_SERVICE_REQUEST_LIST
|
static java.lang.String |
SI_SERVICE_REQUEST_NEXTLINE
|
static java.lang.String |
SI_SERVICE_REQUEST_OPEN
|
static java.lang.String |
SI_SERVICE_REQUEST_QUERY
|
static java.lang.String |
SI_SERVICE_REQUEST_RESET
|
static java.lang.String |
SI_SERVICE_SAFSFILE_BUNDLE_NAME
The fully qualified name of the localizable ResourceBundle for this class. |
protected java.lang.String |
SI_SERVICE_SAFSFILE_LISTINFO
The text substring identifying the file type in each file LIST response. |
Constructor Summary | |
---|---|
SAFSInputService()
|
Method Summary | |
---|---|
com.ibm.staf.STAFResult |
acceptRequest(com.ibm.staf.service.STAFServiceInterfaceLevel3.RequestInfo info)
|
protected java.lang.String |
buildHELPInfo()
|
protected java.lang.String |
getHELPInfo(java.lang.String info)
Add your HELP text response here. |
protected java.lang.String |
getOPENInfo(com.ibm.staf.service.STAFCommandParseResult parsedData,
java.lang.String info)
Handle any added OPEN options here. |
protected SAFSTextFile |
getParsedDataTextFile(com.ibm.staf.STAFResult result,
java.lang.String fileid)
|
int |
init(com.ibm.staf.service.STAFServiceInterfaceLevel3.InitInfo info)
|
protected boolean |
isTargetBlock(java.lang.String inputBlockID,
java.lang.String inputRecord,
java.lang.String fieldsep)
|
protected void |
locateBlockID(com.ibm.staf.STAFResult result,
SAFSTextFile file,
java.lang.String inputBlockID,
java.lang.String fieldsep)
|
protected SAFSTextFile |
openFile(java.lang.String machine,
java.lang.String process,
int handle,
java.lang.String fileid,
java.io.File file,
com.ibm.staf.service.STAFCommandParseResult parsedData)
A subclass must override this function to instantiate its own file type. |
protected java.lang.String |
processExpression(java.lang.String expression)
|
protected com.ibm.staf.STAFResult |
processRequest(com.ibm.staf.STAFResult result,
java.lang.String machine,
java.lang.String process,
int handle,
com.ibm.staf.service.STAFCommandParseResult parseData)
A subclass must override this function to handle requests not handled by the superclass. |
protected int |
shutdown()
perform final termination cleanup operations for your service. |
int |
term()
|
java.lang.String |
text(java.lang.String resourcekey)
Retrieves potentially localized text from the resource bundle Localized subclasses should provide a similar function or override this function. |
protected int |
validateBaseServiceParseResult(com.ibm.staf.service.STAFCommandParseResult parsedData)
|
protected int |
validateServiceParseResult(com.ibm.staf.service.STAFCommandParseResult parsedData)
Use to validate the Service initialization string after a request for initialization has been received. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String SI_SERVICE_SAFSFILE_LISTINFO
public java.lang.String SI_DEFAULT_RESOLVE_SERVICE
protected java.lang.String servicevars
public static final java.lang.String SI_SERVICE_SAFSFILE_BUNDLE_NAME
protected int SI_SERVICE_INIT_PARMS_MAX
protected int SI_SERVICE_REQUEST_ARGS_MAX
protected static java.util.ResourceBundle safsfilereader_resources
public static final java.lang.String SI_RBKEY_NOT_IMPLEMENTED
public static final java.lang.String SI_RBKEY_OPEN_FILES
public static final java.lang.String SI_RBKEY_UCPATH
public static final java.lang.String SI_RBKEY_SYNC_ERROR
public static final java.lang.String SI_RBKEY_REQUIRED
public static final java.lang.String SI_RBKEY_ERROR_NOT_INTEGER
public static final java.lang.String SI_SERVICE_OPTION_DIR
public static final java.lang.String SI_SERVICE_OPTION_EXT
public static final java.lang.String SI_SERVICE_REQUEST_OPEN
public static final java.lang.String SI_SERVICE_REQUEST_NEXTLINE
public static final java.lang.String SI_SERVICE_REQUEST_GOTO
public static final java.lang.String SI_SERVICE_REQUEST_CLOSE
public static final java.lang.String SI_SERVICE_REQUEST_HELP
public static final java.lang.String SI_SERVICE_REQUEST_QUERY
public static final java.lang.String SI_SERVICE_REQUEST_BEGIN
public static final java.lang.String SI_SERVICE_REQUEST_RESET
public static final java.lang.String SI_SERVICE_REQUEST_LIST
public static final java.lang.String SI_SERVICE_PARM_FILE
public static final java.lang.String SI_SERVICE_PARM_STATUS
public static final java.lang.String SI_SERVICE_PARM_FILENAME
public static final java.lang.String SI_SERVICE_PARM_FULLPATH
public static final java.lang.String SI_SERVICE_PARM_LASTERROR
public static final java.lang.String SI_SERVICE_PARM_LOCATE
public static final java.lang.String SI_SERVICE_PARM_SEPARATOR
public static final java.lang.String SI_SERVICE_FILE_STATE_OPEN
public static final java.lang.String SI_SERVICE_FILE_STATE_CLOSED
public static final java.lang.String SI_SERVICE_FILE_STATE_EOF
public static final java.lang.String SI_SERVICE_FILE_STATE_ERROR
protected com.ibm.staf.service.STAFCommandParser parser
protected com.ibm.staf.service.STAFCommandParser routeParser
protected com.ibm.staf.service.STAFCommandParser openParser
protected com.ibm.staf.service.STAFCommandParser closeParser
protected com.ibm.staf.service.STAFCommandParser beginParser
protected com.ibm.staf.service.STAFCommandParser nextParser
protected com.ibm.staf.service.STAFCommandParser resetParser
protected com.ibm.staf.service.STAFCommandParser gotoParser
protected java.lang.String servicename
protected java.lang.String serviceparams
protected boolean relative_path_allowed
protected boolean file_extension_available
protected java.lang.String dir
protected java.lang.String ext
protected static java.lang.String c
protected static java.lang.String s
protected static java.lang.String r
Constructor Detail |
---|
public SAFSInputService()
Method Detail |
---|
public java.lang.String text(java.lang.String resourcekey)
text = super.text(resourceKey);
resourceKey
- the key name of the message to retrieve.
protected java.lang.String getOPENInfo(com.ibm.staf.service.STAFCommandParseResult parsedData, java.lang.String info)
return super.getOPENInfo( parsedData, info );
parsedData
- the parsed request to interrogate for OPEN option
parameter values.
info
- the status string that will be displayed for the
OPEN command.
protected int validateServiceParseResult(com.ibm.staf.service.STAFCommandParseResult parsedData)
This is where you check to see which options exist in the request, and act upon them. Make sure you also forward the validation request up the food chain so the superclasses can validate their service init options, too.
return super.validateServiceParseResult( parsedData );
parsedData
- the result object after parsing was performedprotected java.lang.String getHELPInfo(java.lang.String info)
info += MY_LONG_INVOLVED_FORMATTED_HELP_TEXT;
return super.getHELPInfo( info );
info
- the response string that will be displayed for the
HELP command.
protected SAFSTextFile openFile(java.lang.String machine, java.lang.String process, int handle, java.lang.String fileid, java.io.File file, com.ibm.staf.service.STAFCommandParseResult parsedData)
machine
- the machine initiating the request to open the file.
process
- the name of the Process initiating the request to open the file.
handle
- the Handle of the Process initiating the request to open the file.
fileid
- the unique fileid to be assigned the file. fileids should be
uniquely identifiable among all Handles for a given Process.
file
- the File object used to open the file.
parsedData
- the parsed result containing the OPEN command and any
of the user-supplied options that may be needed when
opening the file or setting options in the file handler.
protected final java.lang.String buildHELPInfo()
protected com.ibm.staf.STAFResult processRequest(com.ibm.staf.STAFResult result, java.lang.String machine, java.lang.String process, int handle, com.ibm.staf.service.STAFCommandParseResult parseData)
return super.processRequest(result, machine, process, handle, parsedData);
result
- the object containing the return code and response
string for the request.
machine
- the machine initiating the request.
process
- the name of the Process initiating the request.
handle
- the Handle of the Process initiating the request.
parsedData
- the parsed result containing the command and the
user-supplied options provided.
protected int shutdown()
return super.shutdown();
protected final int validateBaseServiceParseResult(com.ibm.staf.service.STAFCommandParseResult parsedData)
public int init(com.ibm.staf.service.STAFServiceInterfaceLevel3.InitInfo info)
init
in interface com.ibm.staf.service.STAFServiceInterfaceLevel3
public com.ibm.staf.STAFResult acceptRequest(com.ibm.staf.service.STAFServiceInterfaceLevel3.RequestInfo info)
acceptRequest
in interface com.ibm.staf.service.STAFServiceInterfaceLevel3
protected java.lang.String processExpression(java.lang.String expression)
protected boolean isTargetBlock(java.lang.String inputBlockID, java.lang.String inputRecord, java.lang.String fieldsep)
protected void locateBlockID(com.ibm.staf.STAFResult result, SAFSTextFile file, java.lang.String inputBlockID, java.lang.String fieldsep)
protected final SAFSTextFile getParsedDataTextFile(com.ibm.staf.STAFResult result, java.lang.String fileid)
public final int term()
term
in interface com.ibm.staf.service.STAFServiceInterfaceLevel3
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |