com.phoenix_int.aserver.util.scriptwrapper.api
Class XPathFile
java.lang.Object
com.phoenix_int.aserver.util.scriptwrapper.api.AbstractFile
com.phoenix_int.aserver.util.scriptwrapper.api.XPathFile
- All Implemented Interfaces:
- InputFile, OutputFile, ParseableFile, java.io.Closeable
-
public class XPathFile
- extends AbstractFile
- implements OutputFile, InputFile
Represents an XML file (not a file variable) used in a script wrapper, with access to the XML node values via XPath statements
| Method Summary |
void |
addVariable(java.lang.String name, java.lang.String type, boolean isInput, java.lang.String xpath)
Add a variable to the wrapper. |
void |
generate()
Generate the input file |
com.phoenix_int.aserver.util.XPathParser |
getParser()
Get the XPath parser |
protected com.phoenix_int.aserver.util.XPathParser |
newParser(java.io.File file)
Allow a sub-class to form a parser using custom options/features, such as handling DTD and entities |
protected Parser |
newParser(java.io.File rFile, Parser.Mode pmode)
Generate a new parser for the given file and mode |
void |
parse()
Parse the output file |
void |
setFileToGenerate(java.lang.String fileName)
Set the file to be generated |
void |
setFileToParse(java.lang.String fileName)
Set the file to be parsed |
void |
transferArray(PHXSimpleArray var, java.lang.String exp)
Transfer an array of values, either from the file to the variable, or vice-versa, depending on ParseableFile.Mode |
void |
transferVar(IPHXType var, java.lang.String exp)
Transfer a value, either from the file to the variable, or vice-versa, depending on ParseableFile.Mode |
protected void |
transferVars(ParseableFile.Mode mode)
Transfer values for variables that have been defined using methods from the concrete implementation, i.e. |
| Methods inherited from class com.phoenix_int.aserver.util.scriptwrapper.api.AbstractFile |
actionByMode, backup, close, delete, ensureFileParser, getEncoding, getRealFile, readTemplate, setEncoding, setEncoding, setFileToGenerateOrParse, setTempEmbedded, setTemplateFile, setVariable |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
XPathFile
public XPathFile(PHXScriptWrapperObject wrapper,
ParseableFile.Mode mode)
- Construct a new XPathFile
- Parameters:
wrapper - script wrapper object
mode - parser mode
addVariable
public void addVariable(java.lang.String name,
java.lang.String type,
boolean isInput,
java.lang.String xpath)
throws PHXNameAlreadyInUseException,
PHXInvalidNameException,
PHXInvalidTypeException
- Add a variable to the wrapper. The transfer of variable values will be handled automatically during any call to
generate(), parse(), or AbstractFile.readTemplate()
-
- Parameters:
name - variable name
type - variable type
isInput - whether variable is an input
xpath - XPath expression
- Throws:
PHXNameAlreadyInUseException
PHXInvalidNameException
PHXInvalidTypeException
newParser
protected Parser newParser(java.io.File rFile,
Parser.Mode pmode)
throws java.io.IOException
- Generate a new parser for the given file and mode
-
- Specified by:
newParser in class AbstractFile
-
- Parameters:
rFile - The file to open
pmode - caching mode for underlying parser
- Throws:
java.io.IOException
newParser
protected com.phoenix_int.aserver.util.XPathParser newParser(java.io.File file)
throws java.io.IOException,
org.xml.sax.SAXException,
javax.xml.parsers.ParserConfigurationException
- Allow a sub-class to form a parser using custom options/features, such as handling DTD and entities
-
- Parameters:
file -
- Returns:
- Throws:
java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
getParser
public com.phoenix_int.aserver.util.XPathParser getParser()
throws java.io.IOException
- Get the XPath parser
-
- Returns:
- Throws:
java.io.IOException
transferVars
protected void transferVars(ParseableFile.Mode mode)
throws java.io.IOException,
com.phoenix_int.aserver.util.PHXInvalidFormatException,
PHXNoSuchTokenException,
java.lang.IllegalAccessException,
java.lang.InstantiationException,
PHXNumberFormatException
- Transfer values for variables that have been defined using methods from the concrete implementation, i.e.
PHXRowFieldFile.defineVar(String, String, boolean, String)
Variables defined using PHXScriptWrapperObject.addVariable(String, String, boolean) must be explicitly transferred using methods of the concrete implementation class
-
- Specified by:
transferVars in class AbstractFile
-
- Throws:
java.io.IOException
com.phoenix_int.aserver.util.PHXInvalidFormatException
PHXNoSuchTokenException
java.lang.IllegalAccessException
java.lang.InstantiationException
PHXNumberFormatException
transferArray
public void transferArray(PHXSimpleArray var,
java.lang.String exp)
throws PHXNoSuchTokenException,
java.io.IOException,
javax.xml.xpath.XPathExpressionException
- Transfer an array of values, either from the file to the variable, or vice-versa, depending on
ParseableFile.Mode
-
- Parameters:
var - array variable
exp - XPath expression
- Throws:
PHXNoSuchTokenException
java.io.IOException
javax.xml.xpath.XPathExpressionException
transferVar
public void transferVar(IPHXType var,
java.lang.String exp)
throws javax.xml.xpath.XPathExpressionException,
PHXNoSuchTokenException,
java.io.IOException
- Transfer a value, either from the file to the variable, or vice-versa, depending on
ParseableFile.Mode
-
- Parameters:
var - variable
exp - XPath expression
- Throws:
javax.xml.xpath.XPathExpressionException
PHXNoSuchTokenException
java.io.IOException
parse
public void parse()
throws java.io.IOException,
com.phoenix_int.aserver.util.PHXInvalidFormatException,
PHXNoSuchTokenException,
java.lang.IllegalAccessException,
java.lang.InstantiationException,
PHXNumberFormatException
- Parse the output file
-
- Specified by:
parse in interface OutputFile
-
- Throws:
java.io.IOException
com.phoenix_int.aserver.util.PHXInvalidFormatException
PHXNoSuchTokenException
java.lang.IllegalAccessException
java.lang.InstantiationException
PHXNumberFormatException
setFileToParse
public void setFileToParse(java.lang.String fileName)
- Set the file to be parsed
-
- Specified by:
setFileToParse in interface OutputFile
-
- Parameters:
fileName - file name
generate
public void generate()
throws java.io.IOException,
com.phoenix_int.aserver.util.PHXInvalidFormatException,
PHXNoSuchTokenException,
java.lang.IllegalAccessException,
java.lang.InstantiationException,
PHXNumberFormatException
- Generate the input file
-
- Specified by:
generate in interface InputFile
-
- Throws:
java.io.IOException
com.phoenix_int.aserver.util.PHXInvalidFormatException
PHXNoSuchTokenException
java.lang.IllegalAccessException
java.lang.InstantiationException
PHXNumberFormatException
setFileToGenerate
public void setFileToGenerate(java.lang.String fileName)
- Set the file to be generated
-
- Specified by:
setFileToGenerate in interface InputFile
-
- Parameters:
fileName - file name