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 InfosetOutputtervoidsave(WritableByteChannel output) Save the DataProcessorunparse(InfosetInputter input, WritableByteChannel output) Unparse (i.e serializes) data from an InfosetInputter to the outputvoidwalkMetadata(MetadataHandler handler) Walks the handler over the runtime metadata structureswithDebugger(Debugger dbg) Obtain a newDataProcessorwith a specified debugger or null to disable debugging.withExternalVariables(File extVars) Obtain a newDataProcessorwith external variables read from a Daffodil configuration filewithExternalVariables(Map<String, String> extVars) Obtain a newDataProcessorwith multiple DFDL variables set.default DataProcessorwithValidation(String kind) Obtain a newDataProcessorwith validation that does not require configuration.withValidation(String kind, URL config) Obtain a newDataProcessorwith validation using a URI for configuration.Methods inherited from interface org.apache.daffodil.api.WithDiagnostics
getDiagnostics, isError
-
Method Details
-
withDebugger
Obtain a newDataProcessorwith a specified debugger or null to disable debugging.- Parameters:
dbg- debugger to use or null to disable debugging- Returns:
- a new
DataProcessorwith a specified debugger.
-
withValidation
default DataProcessor withValidation(String kind) throws ValidatorNotRegisteredException, ValidatorInitializationException Obtain a newDataProcessorwith validation that does not require configuration.- Parameters:
kind- Kind of validation to use. Can be a custom validator name available via theValidatorFactorySPI or one of the built-in validators ("xerces", "daffodil", "off", "schematron")- Returns:
- a new
DataProcessorwith 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 newDataProcessorwith validation using a URI for configuration.- Parameters:
kind- Kind of validation to use. Can be a custom validator name available via theValidatorFactorySPI 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
DataProcessorwith a specified validator. - Throws:
ValidatorNotRegisteredException- if the validator cannot be foundValidatorInitializationException- if initializing the validator fails
-
withExternalVariables
Obtain a newDataProcessorwith external variables read from a Daffodil configuration file- Parameters:
extVars- file to read DFDL variables from.- Returns:
- a new
DataProcessorwith 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 newDataProcessorwith 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
DataProcessorwith 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 theDataProcessorto. 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
DaffodilParseXMLReaderfrom the currentDataProcessorfor SAX Parsing.
-
newContentHandlerInstance
- Parameters:
output- Writable Byte Channel for unparsing- Returns:
- a new
DaffodilUnparseContentHandlerfrom the currentDataProcessorfor 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
-