public class Compiler
extends java.lang.Object
ProcessorFactory
's or reload saved parsers into DataProcessor
's.
Do not use the Compiler constructor to create a Compiler. Instead, use Daffodil.compiler()
.
Constructor and Description |
---|
Compiler(org.apache.daffodil.compiler.Compiler sCompiler) |
Modifier and Type | Method and Description |
---|---|
ProcessorFactory |
compileFile(java.io.File schemaFile)
Compile DFDL schema file into a
ProcessorFactory |
ProcessorFactory |
compileFile(java.io.File schemaFile,
java.lang.String rootName,
java.lang.String rootNamespace)
Compile DFDL schema file into a
ProcessorFactory |
ProcessorFactory |
compileSource(java.net.URI uri)
Compile DFDL schema source into a
ProcessorFactory |
ProcessorFactory |
compileSource(java.net.URI uri,
java.lang.String rootName,
java.lang.String rootNamespace)
Compile DFDL schema source into a
ProcessorFactory |
DataProcessor |
reload(java.io.File savedParser)
Reload a saved parser from a file
|
DataProcessor |
reload(java.nio.channels.ReadableByteChannel savedParser)
Reload a saved parser from a
ReadableByteChannel |
void |
setDistinguishedRootNode(java.lang.String name,
java.lang.String namespace)
Deprecated.
Pass arguments to compileSource, or compileFile. Since 2.6.0.
|
void |
setExternalDFDLVariable(java.lang.String name,
java.lang.String namespace,
java.lang.String value)
Deprecated.
Use DataProcessor.withExternalVariable. Since 2.6.0.
|
void |
setExternalDFDLVariables(java.util.AbstractMap<java.lang.String,java.lang.String> extVarsMap)
Deprecated.
Use DataProcessor.withExternalVariables. Since 2.6.0.
|
void |
setExternalDFDLVariables(java.io.File extVarsFile)
Deprecated.
Use DataProcessor.withExternalVariables. Since 2.6.0.
|
void |
setTunable(java.lang.String tunable,
java.lang.String value)
Deprecated.
Use withTunable. Since 2.6.0.
|
void |
setTunables(java.util.AbstractMap<java.lang.String,java.lang.String> tunables)
Deprecated.
Use withTunables. Since 2.6.0.
|
void |
setValidateDFDLSchemas(boolean value)
Deprecated.
Do not use this method. DFDL schema validation should be performed. Since 2.6.0.
|
Compiler |
withTunable(java.lang.String tunable,
java.lang.String value)
Create a new Compiler instance having a specific Daffodil tunable parameter value.
|
Compiler |
withTunables(java.util.AbstractMap<java.lang.String,java.lang.String> tunables)
Create a new Compiler instance having specific Daffodil tunable parameter values.
|
public ProcessorFactory compileFile(java.io.File schemaFile) throws java.io.IOException
ProcessorFactory
To allow jar-file packaging, (where schema files might be part of a jar),
it is recommended to use compileSource(java.net.URI)
instead.
schemaFile
- DFDL schema file used to create a ProcessorFactory
.ProcessorFactory
used to create DataProcessor
(s). Must check WithDiagnostics.isError()
before using it.java.io.IOException
- if an I/O error occurs while reading the schemaFilepublic ProcessorFactory compileFile(java.io.File schemaFile, java.lang.String rootName, java.lang.String rootNamespace) throws java.io.IOException
ProcessorFactory
To allow jar-file packaging, (where schema files might be part of a jar),
it is recommended to use compileSource(java.net.URI)
instead.
schemaFile
- DFDL schema file used to create a ProcessorFactory
.rootName
- name of root element, or null to choose automatically from first element of schema.rootNamespace
- String of namespace of the root element, or null to infer automatically when unambiguous. Pass "" (empty string) for No Namespace.*ProcessorFactory
used to create DataProcessor
(s). Must check WithDiagnostics.isError()
before using it.java.io.IOException
- if an I/O error occurs while reading the schemaFilepublic ProcessorFactory compileSource(java.net.URI uri) throws java.io.IOException
ProcessorFactory
uri
- URI of DFDL schema file used to create a ProcessorFactory
.ProcessorFactory
used to create DataProcessor
(s). Must check WithDiagnostics.isError()
before using it.java.io.IOException
- if an I/O error occurs while reading the uripublic ProcessorFactory compileSource(java.net.URI uri, java.lang.String rootName, java.lang.String rootNamespace) throws java.io.IOException
ProcessorFactory
uri
- URI of DFDL schema file used to create a ProcessorFactory
.rootName
- name of root element, or null to choose automatically from first element of schema.rootNamespace
- String of namespace of the root element, or null to infer automatically when unambiguous. Pass "" (empty string) for No Namespace.ProcessorFactory
used to create DataProcessor
(s). Must check WithDiagnostics.isError()
before using it.java.io.IOException
- if an I/O error occurs while reading the uripublic DataProcessor reload(java.io.File savedParser) throws InvalidParserException
To allow jar-file packaging, (where the savedParser might be part of a jar),
it is recommended to use the other version of reload(java.nio.channels.ReadableByteChannel)
where the argument is
a ReadableByteChannel
for a saved parser.
savedParser
- file of a saved parser, created with DataProcessor.save(java.nio.channels.WritableByteChannel)
DataProcessor
used to parse data. Must check WithDiagnostics.isError()
before using it.
InvalidParserException
- if the file is not a valid saved parser.public DataProcessor reload(java.nio.channels.ReadableByteChannel savedParser) throws InvalidParserException
ReadableByteChannel
savedParser
- ReadableByteChannel
of a saved parser, created with DataProcessor.save(java.nio.channels.WritableByteChannel)
DataProcessor
used to parse data. Must check WithDiagnostics.isError()
before using it.
InvalidParserException
- if the file is not a valid saved parser.public void setDistinguishedRootNode(java.lang.String name, java.lang.String namespace)
name
- name of the root nodenamespace
- namespace of the root node. Set to empty string to specify
no namespace. Set to to NULL to figure out the namespace.public void setExternalDFDLVariable(java.lang.String name, java.lang.String namespace, java.lang.String value)
name
- name of the variablenamespace
- namespace of the variable. Set to empty string to specify
no namespace. Set to to NULL to figure out the namespace.value
- value to so the variable topublic void setExternalDFDLVariables(java.util.AbstractMap<java.lang.String,java.lang.String> extVarsMap)
extVarsMap
- a may 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. With not preceded by "{namespace}",
then Daffodil will figure out the namespace.public void setExternalDFDLVariables(java.io.File extVarsFile)
extVarsFile
- file to read DFDL variables from.public void setTunable(java.lang.String tunable, java.lang.String value)
tunable
- name of the tunable parameter to set.value
- value of the tunable parameter to setpublic void setTunables(java.util.AbstractMap<java.lang.String,java.lang.String> tunables)
tunables
- a map of key/value pairs, where the key is the tunable name and the value is the value to set it topublic void setValidateDFDLSchemas(boolean value)
value
- true to enable validation, false to disabledpublic Compiler withTunable(java.lang.String tunable, java.lang.String value)
tunable
- name of the tunable parametervalue
- value of the tunable parameterpublic Compiler withTunables(java.util.AbstractMap<java.lang.String,java.lang.String> tunables)
tunables
- a map of key/value pairs, where the key is the tunable name and the value is the value it will get.