Class: AbstractFile
Last update: 22.06.2026Package: com.phoenix_int.aserver.util.scriptwrapper.api
Class Hierarchy
↳ java.lang.Object
↳ com.phoenix_int.aserver.util.scriptwrapper.api.AbstractFile
Implemented Interfaces
ParseableFile,java.io.Closeable,java.lang.AutoCloseable
Direct Known Subclasses
CAEOutputFile,PHXRowFieldFile,XPathFile
Declaration
public abstract class AbstractFile
extends java.lang.Object
implements ParseableFile, java.io.Closeable
Common implementation for files (not file variables) used in script wrappers.
Nested Class Summary
Nested classes/interfaces inherited from interface com.phoenix_int.aserver.util.scriptwrapper.api.ParseableFile
ParseableFile.Mode
Field Summary
| Modifier and Type | Field and Description |
|---|---|
protected com.phoenix_int.util.PHXFileUtils.Encoding |
encoding |
protected java.lang.String |
fileName |
protected ParseableFile.Mode |
mode |
protected Parser |
parser |
protected java.lang.String |
templateFileName |
protected PHXScriptWrapperObject |
wrapper |
Constructor Summary
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractFile(java.io.File baseDir, ParseableFile.Mode mode)Pre-QuickWrap PHXRowFieldFile constructor did not have a PHXScriptWrapperObject argument. |
protected |
AbstractFile(PHXScriptWrapperObject wrapper, ParseableFile.Mode mode) |
protected |
AbstractFile(PHXScriptWrapperObject wrapper, java.io.File dir, ParseableFile.Mode mode) |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
protected void |
actionByMode(ParseableFile.Mode mode)Perform an action consistent with ParseableFile.Mode |
void |
backup()Backup the file on disk. |
void |
close()Close the file and free up resources |
void |
delete()Delete the file from disk. |
protected void |
ensureFileParser(ParseableFile.Mode mode)Ensure there is a valid parser |
com.phoenix_int.util.PHXFileUtils.Encoding |
getEncoding() |
protected java.io.File |
getRealFile(java.lang.String fileName)Get the file on disk, possibly relative to the current run-share directory |
protected abstract Parser |
newParser(java.io.File rFile, Parser.Mode pmode)Generate a new parser for the given file and mode |
void |
readTemplate()Read the template. |
void |
setEncoding(com.phoenix_int.util.PHXFileUtils.Encoding enc) |
void |
setEncoding(java.lang.String enc) |
void |
setFileToGenerateOrParse(java.lang.String fileName)Set the file to generate or to parse, depending on the mode |
void |
setTempEmbedded(java.lang.String option)This method applies only to ModelCenter and has no function in ModelCenter Remote Execution |
void |
setTemplateFile(java.lang.String templateFileName)Set the template file to read. |
void |
setVariable(java.lang.String name, java.lang.String value)Sets the value of a variable |
protected abstract void |
transferVars(ParseableFile.Mode mode)Transfer values for variables that have been defined using methods from the concrete implementation |
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
mode
protected final ParseableFile.Mode mode
wrapper
protected final PHXScriptWrapperObject wrapper
parser
protected Parser parser
templateFileName
protected java.lang.String templateFileName
fileName
protected java.lang.String fileName
encoding
protected com.phoenix_int.util.PHXFileUtils.Encoding encoding
Constructor Detail
AbstractFile
protected AbstractFile(java.io.File baseDir,
ParseableFile.Mode mode)
Pre-QuickWrap PHXRowFieldFile constructor did not have a PHXScriptWrapperObject argument. This constructor handles the legacy case, which, in all likelihood, will continue to be used.
Parameters:
baseDir- base directory containing template files, etc.mode- parsing mode
AbstractFile
protected AbstractFile(PHXScriptWrapperObject wrapper,
ParseableFile.Mode mode)
AbstractFile
protected AbstractFile(PHXScriptWrapperObject wrapper,
java.io.File dir,
ParseableFile.Mode mode)
Parameters:
wrapper- may be null for legacy constructor compatibilitydir-mode-
Method Detail
backup
public void backup()
Backup the file on disk. File is at the same location with ".bac" appended to the end. If a file by that name already exists, it is deleted prior to moving.
Specified by:
backupin interfaceParseableFile
close
public void close()
Close the file and free up resources
Specified by:
closein interfaceParseableFileclosein interfacejava.io.Closeableclosein interfacejava.lang.AutoCloseable
delete
public void delete()
Delete the file from disk.
Specified by:
deletein interfaceParseableFile
newParser
protected abstract Parser newParser(java.io.File rFile,
Parser.Mode pmode)
throws java.io.IOException
Generate a new parser for the given file and mode
Parameters:
rFile- The file to openpmode- caching mode for underlying parser
Throws:
java.io.IOException
ensureFileParser
protected void ensureFileParser(ParseableFile.Mode mode)
throws java.io.IOException
Ensure there is a valid parser
Parameters:
mode- parser mode in current context
Throws:
java.io.IOException
getEncoding
public com.phoenix_int.util.PHXFileUtils.Encoding getEncoding()
setEncoding
public void setEncoding(com.phoenix_int.util.PHXFileUtils.Encoding enc)
setEncoding
public void setEncoding(java.lang.String enc)
getRealFile
protected java.io.File getRealFile(java.lang.String fileName)
Get the file on disk, possibly relative to the current run-share directory
Parameters:
fileName-
Returns:
actionByMode
protected void actionByMode(ParseableFile.Mode mode)
throws java.io.IOException,
com.phoenix_int.aserver.util.PHXInvalidFormatException,
PHXNoSuchTokenException,
java.lang.IllegalAccessException,
java.lang.InstantiationException,
PHXNumberFormatException,
PHXBookmarkNotFoundException,
PHXSectionNotFoundException
Perform an action consistent with ParseableFile.Mode
Parameters:
mode-
Throws:
java.io.IOExceptioncom.phoenix_int.aserver.util.PHXInvalidFormatExceptionPHXNoSuchTokenExceptionjava.lang.IllegalAccessExceptionjava.lang.InstantiationExceptionPHXNumberFormatExceptionPHXBookmarkNotFoundExceptionPHXSectionNotFoundException
readTemplate
public void readTemplate()
throws java.io.IOException,
com.phoenix_int.aserver.util.PHXInvalidFormatException,
PHXNoSuchTokenException,
java.lang.IllegalAccessException,
java.lang.InstantiationException,
PHXNumberFormatException,
PHXBookmarkNotFoundException,
PHXSectionNotFoundException
Read the template. In MCRE 7.1, this method was changed to never throw any exceptions. Reading the templates allows you to fill in default values if you can, but is not mandatory.
Specified by:
readTemplatein interfaceParseableFile
Throws:
java.io.IOExceptioncom.phoenix_int.aserver.util.PHXInvalidFormatExceptionPHXNoSuchTokenExceptionjava.lang.IllegalAccessExceptionjava.lang.InstantiationExceptionPHXNumberFormatExceptionPHXBookmarkNotFoundExceptionPHXSectionNotFoundException
setFileToGenerateOrParse
public void setFileToGenerateOrParse(java.lang.String fileName)
Set the file to generate or to parse, depending on the mode
Specified by:
setFileToGenerateOrParsein interfaceParseableFile
setTempEmbedded
public void setTempEmbedded(java.lang.String option)
This method applies only to ModelCenter and has no function in ModelCenter Remote Execution
Specified by:
setTempEmbeddedin interfaceParseableFile
setTemplateFile
public void setTemplateFile(java.lang.String templateFileName)
Set the template file to read. If the template file is not specified, it defaults to the file that is parsed or generated, for Mode.PARSE or Mode.GENERATE, respectively.
Specified by:
setTemplateFilein interfaceParseableFile
Parameters:
templateFileName- file name
setVariable
public void setVariable(java.lang.String name,
java.lang.String value)
throws PHXNoSuchObjectException
Sets the value of a variable
Specified by:
setVariablein interfaceParseableFile
Parameters:
name- variable namevalue- variable value as a string
Throws:
PHXNoSuchObjectException
transferVars
protected abstract void transferVars(ParseableFile.Mode mode)
throws java.io.IOException,
com.phoenix_int.aserver.util.PHXInvalidFormatException,
PHXNoSuchTokenException,
java.lang.IllegalAccessException,
java.lang.InstantiationException,
PHXNumberFormatException,
PHXBookmarkNotFoundException,
PHXSectionNotFoundException
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
Parameters:
mode-
Throws:
java.io.IOExceptioncom.phoenix_int.aserver.util.PHXInvalidFormatExceptionPHXNoSuchTokenExceptionjava.lang.IllegalAccessExceptionjava.lang.InstantiationExceptionPHXNumberFormatExceptionPHXBookmarkNotFoundExceptionPHXSectionNotFoundException