Package com.adobe.xfa.service.storage
Class XMLStorage
- java.lang.Object
-
- com.adobe.xfa.service.Service
-
- com.adobe.xfa.service.storage.StorageService
-
- com.adobe.xfa.service.storage.XMLStorage
-
public final class XMLStorage extends StorageService
The XML storage service. Many of these methods take an optional parameter called either loadOptions or saveOptions. These specify extra options, separated by blanks. These appear as they would in an input file, e.g. name="value" name="value"...Options
- "processXSL" (boolean, '1' or '0')
- '1' if XSL processing instructions encountered in the file should be applied, '0' if not.
- "XSL" (string)
- The filename of an XSL script to apply to the input stream.
- "incrementalLoad" (boolean, '1' or '0')
- '1' if incremental loading (or lazy loading) should be used to load this file, '0' if the entire file should be loaded into memory at once.
- "Model" (string)
- Name of model to load, if stream contains multiple models.
- "setPI" (string)
- A processing instruction to set. The format is setPI="name value". The name of the processing instruction is the set of characters before the first whitespace. The value is everything after the first whitespace.
- "Option" (string)
- An XFA option to set. The value should be of the form name="value" or name='value'.
- "format" (string, "raw" or "simple" or "pretty")
- Set to "raw" to save with no whitespace or carriage returns; "simple" to add carriage returns but no whitespace; "pretty" to add carriage returns and whitespace to show the hierarchy of the XML file.
- "encoding" (string)
- The character set to use when writing the XML file.
- "indentLevel" (integer)
- the number of spaces to indent each nested level, only applied to pretty output
- "attributeQuoteChar" (char, " or ' )
- if ' attributes are enclosed in single quotes, if " attributes are enclosed by double quotes (default)
- "entityChars" (string)
- A list of individual characters to be represent with entity references. The default list will vary according to whether we're writing attributes or text values. This list will be added to the default list. e.g. "\x0A\x09" for linefeed and cr.
- "minEntityCharRange" (int)
- Any character value greater than or equal to this int are encoded with their entity references.
- "maxEntityCharRange" (int)
- Any character value less than or equal to this int are encoded with their entity references.
-
-
Constructor Summary
Constructors Constructor Description XMLStorage()
XMLStorage(java.io.File xmlFile)
Constructs an XMLStorage object, specifying a data file name that will be used for loading or saving data.XMLStorage(java.net.URL url)
Constructs an XMLStorage object, specifying a data file URL that will be used for loading or saving data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getAPIVersion()
Returns the API version tag from the XML file.java.lang.String
getGenerator()
Returns the "generator" tag from the XML file.Node
loadModel(AppModel model, java.io.File file, java.lang.String loadOptions, java.lang.String saveXSLFile)
Loads the contents of an InputStream into an AppModel, creating an Node hierarchy.Node
loadModel(AppModel model, java.io.InputStream inputStream, java.lang.String loadOptions, java.lang.String saveXSLFile)
Loads the contents of an InputStream into an AppModel, creating an Node hierarchy.Node
loadModel(AppModel model, java.io.InputStream inputStream, java.lang.String source, java.lang.String loadOptions, java.lang.String saveXSLFile)
Loads the contents of an InputStream into an AppModel, creating an Node hierarchy.Node
loadModel(AppModel model, java.lang.String loadOptions, java.lang.String saveXSLFile)
Loads the file/datasource specified in the constructor into a model and creates an Node hierarchy for it.boolean
loadXDP(AppModel oAppModel, Document oDoc, PacketHandler handler, java.lang.Object handlerData, boolean bProcessXFAOnly)
boolean
loadXDP(AppModel appModel, java.io.InputStream file, PacketHandler handler, java.lang.Object handlerData, boolean bProcessXFAOnly)
Loads the contents of a XDP stream into an AppModel, creating an Node hierarchy.void
processXSL(boolean process)
Specifies whether or not to automatically process inline XSL statements when loading the XML file.void
saveAggregate(java.lang.String sRoot, java.io.OutputStream outStream, NodeList oNodes, java.lang.String saveOptions)
Save a group of nodes under an aggregating tag.void
saveModel(Model model, java.lang.String saveOptions)
Saves a model into a file/datasource, starting at the root.void
saveModelAs(Model model, java.io.OutputStream file, java.lang.String saveOptions)
Saves a model to an open stream file.void
setGenerator(java.lang.String newGeneratorTag)
setGenerator is a static routine which specifies the generator tag to be written out when a model is saved to an XML file.void
setOption(java.lang.String optionName, java.lang.String optionValue, boolean bCritical)
Sets an option.void
XFAModelLoader(Model model, Node configKey, java.io.InputStream oStreamFile)
-
-
-
Constructor Detail
-
XMLStorage
public XMLStorage()
-
XMLStorage
public XMLStorage(java.io.File xmlFile)
Constructs an XMLStorage object, specifying a data file name that will be used for loading or saving data.- Parameters:
xmlFile
- the name of the file containing the source XML.
-
XMLStorage
public XMLStorage(java.net.URL url)
Constructs an XMLStorage object, specifying a data file URL that will be used for loading or saving data.- Parameters:
url
- the URL containing the source XML.
-
-
Method Detail
-
setGenerator
public void setGenerator(java.lang.String newGeneratorTag)
setGenerator is a static routine which specifies the generator tag to be written out when a model is saved to an XML file. It should be called once by any application that will be saving files.
If this routine is not invoked, the default value will be XFA2_0.- Parameters:
newGeneratorTag
- the new value for the generator tag.
-
getAPIVersion
public java.lang.String getAPIVersion()
Returns the API version tag from the XML file. This allows an application to determine which version of the XFA API was used to write the XML file. If not specified in the file, this will return an empty string.- Returns:
- The value of the APIVersion tag, or an empty string if no APIVersion tag was encountered.
-
getGenerator
public java.lang.String getGenerator()
Returns the "generator" tag from the XML file. This allows an application to determine which application wrote the XML file. If not specified in the file, this will return an empty string.- Returns:
- The value of the generator tag, or an empty string if no generator tag was encountered.
-
loadModel
public Node loadModel(AppModel model, java.io.InputStream inputStream, java.lang.String loadOptions, java.lang.String saveXSLFile)
Loads the contents of an InputStream into an AppModel, creating an Node hierarchy. This overload does not provide the source of the document, so any capabilities that may rely on this (e.g., resolving external fragments that use relative references) will not work. If the source of the input stream is known, theloadModel(AppModel, InputStream, String, String, String)
overload should be used instead.- Parameters:
model
- the AppModel to be populated.inputStream
- an open file to be read in.loadOptions
- see the comment in the class description.saveXSLFile
- specifies the name of a file to save intermediate XSL output. This is intended as an aid to debugging only.
-
loadModel
public Node loadModel(AppModel model, java.io.InputStream inputStream, java.lang.String source, java.lang.String loadOptions, java.lang.String saveXSLFile)
Loads the contents of an InputStream into an AppModel, creating an Node hierarchy.- Parameters:
model
- the AppModel to be populated.inputStream
- an open file to be read in.source
- the absolute file or URL name that inputStream was loaded from.loadOptions
- see the comment in the class description.saveXSLFile
- specifies the name of a file to save intermediate XSL output. This is intended as an aid to debugging only.
-
loadModel
public Node loadModel(AppModel model, java.io.File file, java.lang.String loadOptions, java.lang.String saveXSLFile)
Loads the contents of an InputStream into an AppModel, creating an Node hierarchy.- Parameters:
model
- the XFAModel to be populated.file
- a file to be read in.loadOptions
- see the comment in the class description.saveXSLFile
- specifies the name of a file to save intermediate XSL output. This is intended as an aid to debugging only.
-
loadModel
public Node loadModel(AppModel model, java.lang.String loadOptions, java.lang.String saveXSLFile)
Loads the file/datasource specified in the constructor into a model and creates an Node hierarchy for it.- Parameters:
model
- the AppModel to be populated with the data from the datasource.loadOptions
- see the comment in the class description.saveXSLFile
- specifies the name of a file to save intermediate XSL output. This is intended as an aid to debugging only.- Returns:
- The root node of the hierarchy
-
loadXDP
public boolean loadXDP(AppModel appModel, java.io.InputStream file, PacketHandler handler, java.lang.Object handlerData, boolean bProcessXFAOnly)
Loads the contents of a XDP stream into an AppModel, creating an Node hierarchy.- Parameters:
appModel
- the AppModel to be populated.file
- an open file to be read in. We assume the file is positioned appropriately.handler
- Handler to do any special processing of packets before XFA DOM is created.handlerData
- Handler data.
-
loadXDP
public boolean loadXDP(AppModel oAppModel, Document oDoc, PacketHandler handler, java.lang.Object handlerData, boolean bProcessXFAOnly)
-
processXSL
public void processXSL(boolean process)
Specifies whether or not to automatically process inline XSL statements when loading the XML file.- Parameters:
process
- TRUE if XSL should be automatically processed, FALSE if not. This flag is simply stored and passed toDocument.load
when one of the load routines is called.
-
saveAggregate
public void saveAggregate(java.lang.String sRoot, java.io.OutputStream outStream, NodeList oNodes, java.lang.String saveOptions)
Save a group of nodes under an aggregating tag.- Parameters:
sRoot
- The name to use for the aggregating tag. If sRoot is empty, then the standard xdp:xdp with appropriate namespace will be used.outStream
- The output stream to write to.oNodes
- The list of XFA Nodes to writesaveOptions
- (optional) see the comment in the class description.
-
saveModel
public void saveModel(Model model, java.lang.String saveOptions)
Saves a model into a file/datasource, starting at the root.- Parameters:
model
- the XFAModel to be saved into the datasource.saveOptions
- see the comment in the class description.
-
saveModelAs
public void saveModelAs(Model model, java.io.OutputStream file, java.lang.String saveOptions)
Saves a model to an open stream file.- Parameters:
model
- the XFAModel to be saved.file
- the open streamfile to write to.saveOptions
- see the comment in the class description.
-
setOption
public void setOption(java.lang.String optionName, java.lang.String optionValue, boolean bCritical)
Description copied from class:Service
Sets an option.
-
-