Package org.apache.daffodil.api
Interface DataProcessor
- All Superinterfaces:
Serializable
,WithDiagnostics
Compiled version of a DFDL Schema, used to parse data and get the DFDL infoset
-
Method Summary
Modifier and TypeMethodDescriptionparse
(InputSourceDataInputStream input, InfosetOutputter output) Parse input data from an InputSourceDataInputStream and output the infoset to an InfosetOutputtervoid
save
(WritableByteChannel output) Save the DataProcessorunparse
(InfosetInputter input, WritableByteChannel output) Unparse (i.e serializes) data from an InfosetInputter to the outputvoid
walkMetadata
(MetadataHandler handler) Walks the handler over the runtime metadata structureswithDebugger
(Debugger dbg) Obtain a newDataProcessor
with a specified debugger or null to disable debugging.withExternalVariables
(File extVars) Obtain a newDataProcessor
with external variables read from a Daffodil configuration filewithExternalVariables
(Map<String, String> extVars) Obtain a newDataProcessor
with multiple DFDL variables set.default DataProcessor
withValidation
(String kind) Obtain a newDataProcessor
with validation that does not require configuration.withValidation
(String kind, URL config) Obtain a newDataProcessor
with validation using a URI for configuration.Methods inherited from interface org.apache.daffodil.api.WithDiagnostics
getDiagnostics, isError
-
Method Details
-
withDebugger
Obtain a newDataProcessor
with a specified debugger or null to disable debugging.- Parameters:
dbg
- debugger to use or null to disable debugging- Returns:
- a new
DataProcessor
with a specified debugger.
-
withValidation
default DataProcessor withValidation(String kind) throws ValidatorNotRegisteredException, ValidatorInitializationException Obtain a newDataProcessor
with validation that does not require configuration.- Parameters:
kind
- Kind of validation to use. Can be a custom validator name available via theValidatorFactory
SPI or one of the built-in validators ("xerces", "daffodil", "off", "schematron")- Returns:
- a new
DataProcessor
with a specified validator. - Throws:
ValidatorNotRegisteredException
- if the validator cannot be foundValidatorInitializationException
- if initializing the validator fails
-
withValidation
DataProcessor withValidation(String kind, URL config) throws ValidatorNotRegisteredException, ValidatorInitializationException Obtain a newDataProcessor
with validation using a URI for configuration.- Parameters:
kind
- Kind of validation to use. Can be a custom validator name available via theValidatorFactory
SPI or one of the built-in validators ("xerces", "daffodil", "off", "schematron")config
- URL to use for validation configuration. If the URL path ends with .conf or .properties it is treated as a java.util.Properties file that is loaded and provided to the validator. Otherwise, the URL is provided as a single property to the validator. Can be null if a URL is not known or the validator does not need additional configuration--this could cause an exception if a validator requires properties.- Returns:
- a new
DataProcessor
with a specified validator. - Throws:
ValidatorNotRegisteredException
- if the validator cannot be foundValidatorInitializationException
- if initializing the validator fails
-
withExternalVariables
Obtain a newDataProcessor
with external variables read from a Daffodil configuration file- Parameters:
extVars
- file to read DFDL variables from.- Returns:
- a new
DataProcessor
with external variables read from a Daffodil configuration file - Throws:
ExternalVariableException
- if an error occurs while setting an external variable- See Also:
-
- Daffodil Configuration File - Daffodil configuration file format
-
withExternalVariables
Obtain a newDataProcessor
with multiple DFDL variables set.- Parameters:
extVars
- a map of key/value pairs, where the key is the variable name, and the value is the value of the variable. The key may be preceded by a string of the form "{namespace}" to define a namespace for the variable. If preceded with "{}", then no namespace is used. If not preceded by anything, then Daffodil will figure out the namespace.- Returns:
- a new
DataProcessor
with multiple DFDL variables set. - Throws:
ExternalVariableException
- if an error occurs while setting an external variable
-
save
Save the DataProcessorThe resulting output can be reloaded by
Compiler.reload(savedParser:java\.nio\.channels\.ReadableByteChannel)* Compiler.reload
. Note that any changes due to withValidator, withDebugger, and any compile diagnostics are not saved- Parameters:
output
- the byte channel to write theDataProcessor
to. Note that external variable settings are not saved.
-
walkMetadata
Walks the handler over the runtime metadata structures- Parameters:
handler
- - the handler is called-back during the walk as each metadata structure is encountered.
-
newXMLReaderInstance
DaffodilParseXMLReader newXMLReaderInstance()- Returns:
- a new
DaffodilParseXMLReader
from the currentDataProcessor
for SAX Parsing.
-
newContentHandlerInstance
- Parameters:
output
- Writable Byte Channel for unparsing- Returns:
- a new
DaffodilUnparseContentHandler
from the currentDataProcessor
for SAX Unparsing.
-
parse
Parse input data from an InputSourceDataInputStream and output the infoset to an InfosetOutputter- Parameters:
input
- data to be parsedoutput
- the InfosetOutputter that will be used to output the infoset- Returns:
- an object which contains the result, and/or diagnostic information.
-
unparse
Unparse (i.e serializes) data from an InfosetInputter to the output- Parameters:
input
- the infoset inputter to use for unparsingoutput
- the byte channel to write the data to- Returns:
- an object with contains diagnostic information
-