public class UpcastEngine
extends java.lang.Object
Follows a minimal skeleton showing how to do a single conversion from file /test/in/in.rtf to /test/out/out.xml:
String moduleID; UpcastEngine ucInst = new UpcastEngine( "one" ); ucInst.setPipelineBaseURI( "/path/to/rootfolder/" ); ucInst.setLicense( "/path/to/upcast.license" ); ucInst.initializeConversion(); ucInst.setPipelineVariable( "DestinationFolder", "/test/out/" ); ucInst.setPipelineVariable( "ImageDestinationFolder", "/test/out/" ); moduleID = ucInst.setModuleType( UpcastEngine.kRTFImporterType ); ucInst.setModuleParameter( moduleID, "OrigNumbering", Boolean.TRUE ); ucInst.setModuleParameter( moduleID, "SourceFile", "/test/in/in.rtf" ); ucInst.execute( moduleID ); moduleID = ucInst.setModuleType( UpcastEngine.kXMLRawExporterType ); ucInst.setModuleParameter( moduleID, "DeleteEmpties", Boolean.FALSE ); ucInst.setModuleParameter( moduleID, "DestinationFile", "${pipeline:DestinationFolder}/out.xml;" ); ucInst.execute( moduleID ); ucInst.cleanupConversion();
Modifier and Type | Field and Description |
---|---|
static int |
kCommandlineProcessorType
selector for the Commandline processor.
|
static int |
kCSSExporterType
selector for the CSS Exporter module.
|
static int |
kExternalPipelineProcessorType
selector for the External Pipeline Processor module.
|
static int |
kGroupingProcessorType
Deprecated.
Its functionality has been integrated into the
kUPLTreeProcessorType . |
static int |
kPipelineVariablesProcessorType
selector for the Pipeline Variables Processor module.
|
static int |
kRTFExporterType
selector for the RTF Exporter module.
|
static int |
kRTFImporterType
selector for the RTF 1.6 Specification compliant import module.
|
static int |
kSectionProcessorType
selector for the Section Processor module.
|
static int |
kUnicodeTranslationProcessorType
selector for the Unicode Translation Processor module.
|
static int |
kUPLProcessorType
selector for the UPL Processor module.
|
static int |
kUPLTreeProcessorType
selector for the UPL Tree Processor module.
|
static int |
kValidationProcessorType
selector for the Validation Processor module.
|
static int |
kXMLExporterType
selector for the XML Exporter module.
|
static int |
kXMLImporterType
selector for the XML Importer module.
|
static int |
kXMLRawExporterType
Deprecated.
Use
kXMLExporterType instead. |
static int |
kXSLTProcessorType
selector for the XSLT Processor module.
|
Constructor and Description |
---|
UpcastEngine(boolean debug,
java.lang.String userInstanceId)
Deprecated.
use
UpcastEngine(String, String) instead |
UpcastEngine(int loggingLevel,
java.lang.String userInstanceId)
Deprecated.
use
UpcastEngine(String, String) instead |
UpcastEngine(java.lang.String userInstanceId)
Creates a new instance of the UpcastEngine object.
|
UpcastEngine(java.lang.String logfilterspec,
java.lang.String userInstanceId)
Creates a new instance of the UpcastEngine object.
|
Modifier and Type | Method and Description |
---|---|
void |
addCatalog(java.lang.String catalogFile)
Adds an (XML-) Catalog to the system.
|
void |
addCustomEncoding(java.io.InputStream customEncodingStream)
Adds a custom encoding to the collection of known encodings.
|
void |
addCustomEncoding(java.lang.String customEncodingName)
Adds a custom encoding to the collection of known encodings.
|
void |
cleanupConversion()
Cleans up the engine after a conversion.
|
void |
clearCollectedMessages()
Clears any collected messages in this object instance's message collector.
|
void |
debugMessage(java.lang.String msg)
Makes debugging output
Writes a string to the console when gDebug = true.
|
void |
discardCatalogs()
Removes all previously registered catalogs from the pipeline's catalog setup.
|
void |
errorMessage(java.lang.String msg)
Makes error output.
|
static de.infinityloop.upcast.core.AppFacelessLayer |
getApplicationObject()
The object of the owning application.
|
org.apache.xml.resolver.tools.CatalogResolver |
getCatalogResolver()
Returns the Catalog resolver used by the system.
|
UpcastException |
getCollectedMessages()
Retrieves the message collector which holds the current list of errors and/or warnings.
|
java.lang.String |
getEnvironmentValue(java.lang.String key)
Returns the value of the environment property specified by the key integer.
|
java.lang.String |
getInstanceNameUser()
Returns the user instance id/name passed in on construction time for this object.
|
protected LogSource |
getLogger()
Returns the most appropriate logger depending on the current state of this UpcastEngine instance
|
java.lang.String |
getPipelineBaseURI()
Retrieve the current value of this UpcastEngine object.
|
java.lang.Object |
getPipelineResult()
Returns the (current) pipeline result object, which is the one that was last set by a module during pipeline execution when this function is called.
|
java.lang.String |
getPipelineVariable(java.lang.String name)
Retrieve the current value of the specified pipeline variable as a String.
|
void |
infoMessage(java.lang.String msg)
Makes info output.
|
void |
initializeConversion()
Initializes the engine for a new conversion.
|
static UpcastPipeline |
makePipeline(java.lang.String docPath)
This method creates an UpcastPipeline object from an *.ucdoc or *.ucpar file existing on disk.
|
java.lang.Object |
runModule(java.lang.String moduleType)
Runs the currently active module.
|
static java.lang.Object |
runPipeline(java.lang.String docPath,
java.util.Map parameters)
This method lets you run a Pipeline (*.ucdoc or *.ucpar) file existing on disk with the specified set of pipeline parameters.
|
static java.lang.Object |
runPipeline(java.lang.String docPath,
java.util.Map parameters,
java.lang.String licenseOverride)
This method lets you run a Pipeline (*.ucdoc or *.ucpar) file existing on disk with the specified set of pipeline parameters.
|
static void |
setCatalog(java.lang.String catalogFile)
Adds an (XML-) Catalog to the system.
|
void |
setCustomFontConfiguration(java.io.Reader customFontConfigReader)
Loads a new custom stdfonts.config configuration.
|
void |
setCustomFontConfiguration(java.lang.String customFontConfigName)
Loads a new custom font configuration.
|
void |
setDebuggingMode(boolean on)
Deprecated.
use
setLoggingFilter instead |
boolean |
setLicense(java.io.InputStream inStream)
Sets a specified License file for use as license.
|
boolean |
setLicense(java.lang.String licenseFile)
Sets a specified License file for use as license.
|
static void |
setLogfile(java.lang.String absolutePath)
(Re-)set the destination file to write log messages to.
|
static void |
setLogfile(java.lang.String absolutePath,
int sizelimitBytes)
(Re-)set the destination file to write log messages to and set the maximum size (in bytes) for that file at the same time.
|
static void |
setLoggingFilter(java.lang.String filterDescription)
Lets you set a detailed filter description for filtering logging events that go to the external logger.
|
void |
setLoggingLevel(int level)
Deprecated.
use
setLoggingFilter instead |
void |
setModuleParameter(java.lang.String moduleInstance,
java.lang.String moduleParameter,
java.lang.Object parameterValue)
Sets a module parameter.
|
java.lang.String |
setModuleType(int moduleType)
Instantiates a new, then current module, replacing the previous one.
|
java.lang.String |
setModuleType(java.lang.String moduleTypeName)
Instantiates a new, then current module, replacing the previous one.
|
void |
setPipelineBaseURI(java.lang.String url)
Sets the pipeline base URL.
|
void |
setPipelineParameter(java.lang.String parameter,
java.lang.Object value)
Sets a pipeline parameter that controls the behaviour of the pipeline during execution of modules.
|
void |
setPipelineVariable(java.lang.String parameter,
java.lang.Object value)
Set a pipeline variable for conversion process.
|
void |
warningMessage(java.lang.String msg)
Makes warning output.
|
public static final int kRTFImporterType
public static final int kUPLTreeProcessorType
public static final int kUPLProcessorType
@Deprecated public static final int kGroupingProcessorType
kUPLTreeProcessorType
.public static final int kSectionProcessorType
public static final int kXMLExporterType
@Deprecated public static final int kXMLRawExporterType
kXMLExporterType
instead.public static final int kCommandlineProcessorType
public static final int kXSLTProcessorType
public static final int kUnicodeTranslationProcessorType
public static final int kCSSExporterType
public static final int kValidationProcessorType
public static final int kPipelineVariablesProcessorType
public static final int kXMLImporterType
public static final int kExternalPipelineProcessorType
public static final int kRTFExporterType
public UpcastEngine(java.lang.String userInstanceId) throws UpcastException
Debugging mode is automatically set to false.
If your license allows, you may instantiate several objects of this kind. They are completely independent from each other, so you may run them in separate threads. However, they share some synchronized code sequences and each instance keeps its document in memory for processing. We recommend serializing any conversion jobs you might have pending (except when you have multi-processor machines).
userInstanceId
- you may pass an arbitrary string here which helps to identify the class instance in log file and debug message output.UpcastException
public UpcastEngine(java.lang.String logfilterspec, java.lang.String userInstanceId) throws UpcastException
Debugging mode is automatically set to false.
If your license allows, you may instantiate several objects of this kind. They are completely independent from each other, so you may run them in separate threads. However, they share some synchronized code sequences and each instance keeps its document in memory for processing. We recommend serializing any conversion jobs you might have pending (except when you have multi-processor machines).
userInstanceId
- you may pass an arbitrary string here which helps to identify the class instance in log file and debug message output.UpcastException
@Deprecated public UpcastEngine(boolean debug, java.lang.String userInstanceId) throws UpcastException
UpcastEngine(String, String)
insteaddebug
- pass true if you want debug messages output to the logging system, false otherwise.userInstanceId
- you may pass an arbitrary string here which helps to identify the class instance in log file and debug message output.UpcastException
@Deprecated public UpcastEngine(int loggingLevel, java.lang.String userInstanceId) throws UpcastException
UpcastEngine(String, String)
insteadloggingLevel
- Set the logging threshold for the external logger; see also setLoggingLevel
userInstanceId
- you may pass an arbitrary string here which helps to identify the server instance in log file and debug message output.UpcastException
protected LogSource getLogger()
public java.lang.Object runModule(java.lang.String moduleType) throws UpcastException
Any errors during export will be reported as Exceptions of the respective type.
moduleType
- the type of the module to run as obtained by setModuleType
method.UpcastException
- Throws an appropriate exception if anything goes wrong.public java.lang.String setModuleType(int moduleType) throws UpcastException
moduleType
- the type of the filter. Use one of the following:
kRTFImporterType
kUPLTreeProcessorType
kUPLProcessorType
kSectionProcessorType
kXMLExporterType
kCommandlineProcessorType
kXSLTProcessorType
kUnicodeTranslationProcessorType
kCSSExporterType
kValidationProcessorType
kPipelineVariablesProcessorType
kXMLImporterType
kExternalPipelineProcessorType
kRTFExporterType
A previously installed module will be replaced by the newly set one.
setModuleParameter
.UpcastException
- thrown if an invalid module type is specifiedsetModuleParameter(java.lang.String, java.lang.String, java.lang.Object)
public java.lang.String setModuleType(java.lang.String moduleTypeName) throws UpcastException
moduleTypeName
- the identification name of the module.
A previously installed module will be replaced by the newly set one.
setModuleParameter
.UpcastException
- thrown if an invalid module type name is specifiedsetModuleParameter(java.lang.String, java.lang.String, java.lang.Object)
public void setModuleParameter(java.lang.String moduleInstance, java.lang.String moduleParameter, java.lang.Object parameterValue) throws UpcastException
moduleInstance
- the module instance for which this parameter is to be set. The module instance is retrieved from setModuleType
.moduleParameter
- the name of the parameter to be set. For available parameter names of each module, see the upCast manual.parameterValue
- the value of the parameter. For valid parameter values and value ranges as well as Object types, see the
upCast manual.UpcastException
- Throws an appropriate exception if anything goes wrong.public void setPipelineParameter(java.lang.String parameter, java.lang.Object value) throws UpcastException
parameter
- the name of the parameter to be set. For available parameter names, see the
upCast manual.value
- the value of the parameter. For valid parameter values and value ranges and Object types, see the
upCast manual.UpcastException
- Throws an appropriate exception if anything goes wrong.public void setPipelineVariable(java.lang.String parameter, java.lang.Object value) throws UpcastException
parameter
- the name of the parameter to be set. For available parameter names, see the
upCast manual.value
- the value of the parameter. For valid parameter values and value ranges and Object types, see the
upCast manual.UpcastException
- Throws an appropriate exception if anything goes wrong.public java.lang.String getPipelineVariable(java.lang.String name) throws UpcastException
name
- the name of the variable to be queried.UpcastException
- Throws an appropriate exception if anything goes wrong.public java.lang.String getPipelineBaseURI() throws UpcastException
UpcastException
- Throws an appropriate exception if anything goes wrong.public void setPipelineBaseURI(java.lang.String url) throws UpcastException
${pipeline:base}
variable reference notation.
Note that this also sets the variable ${pipeline:ParamBase}
to the same value, as UpcastEngine instances
cannot and do not differentiate between those two kinds of files and therefore paths.
You should set this at the beginning of a conversion, directly after the instantiation of a new UpcastEngine object if you use that specific variable in your pipelines to keep them portable. In GUI mode, this value is established by the save location of the pipeline document (*.ucdoc). Since this does not exist in the API, a value must be specified explicitly using this function.
The default (when not explicitly set) is the highly unreliable and unpredictable (especially in a server environment) Java current directory.
url
- the base url for that pipelineUpcastException
- Throws an appropriate exception if anything goes wrong.public void debugMessage(java.lang.String msg)
public void errorMessage(java.lang.String msg)
Writes a string to the log file.
msg
- the error messagepublic void warningMessage(java.lang.String msg)
Writes a string to the log file.
msg
- the warning messagepublic void infoMessage(java.lang.String msg)
Writes a string to the log file.
msg
- the info message@Deprecated public void setDebuggingMode(boolean on)
setLoggingFilter
insteadon
- if true, debugging output to the log file is turned on, if false, it is turned off.@Deprecated public void setLoggingLevel(int level)
setLoggingFilter
insteadlevel
- the logging level in the range from {0..7}, with higher numbers being more verbose. The default (INFO level) is 3.public static void setLoggingFilter(java.lang.String filterDescription)
filterDescription
- a textual filter description conforming to the following syntax:
The syntax is an arbitrary sequence of the following, whitespace- or comma-separated tokens, which are executed in the specified sequence:
+off, +fatal, +error, +warn, +info, +debug, +verbose, +detail, +all : enable the respective message type
-off, -fatal, -error, -warn, -info, -debug, -verbose, -detail, -all : disable the respective message type
+msgconstantname : enable that message
-msgconstantname : disable that messagepublic java.lang.String getInstanceNameUser()
public org.apache.xml.resolver.tools.CatalogResolver getCatalogResolver()
public boolean setLicense(java.io.InputStream inStream)
inStream
- an input stream containing the license data. This might be a FileInputStream if you read from a file or some other stream (e.g. from
getResourceAsStream()
when reading from the application's Jar file).public boolean setLicense(java.lang.String licenseFile)
licenseFile
- an absolute path to the license file. This is a convenience function for setLicense( new FileInputStream( inStream ) );
public void addCustomEncoding(java.io.InputStream customEncodingStream) throws UpcastException
Encodings are global and shared by all concurrent UpcastEngine instances.
customEncodingStream
- the custom encodingUpcastException
public void addCustomEncoding(java.lang.String customEncodingName) throws UpcastException
addCustomEncoding(java.io.InputStream)
for details.customEncodingName
- file name of a custom encoding fileUpcastException
public void setCustomFontConfiguration(java.io.Reader customFontConfigReader) throws UpcastException
Information is not added to existing mappings and definitions, but replaces any existing configuration. The character stream must be all-ASCII and conform to the specification laid out in the upCast manual. The data is prepended to the default font configuration delivered with the application internally. This gives the custom configuration higher precedence with still the default fallbacks and definitions in place.
This configuration is held separately per UpcastEngine instance.
customFontConfigReader
- the custom font configuration file resp. character streamUpcastException
public void setCustomFontConfiguration(java.lang.String customFontConfigName) throws UpcastException
Information is not added to existing mappings and definitions, but replaces any existing configuration. The character stream must be all-ASCII and conform to the specification laid out in the upCast manual. The data is prepended to the default font configuration delivered with the application internally. This gives the custom configuration higher precedence with still the default fallbacks and definitions in place.
This configuration is held separately per UpcastEngine instance.
customFontConfigName
- the custom font configuration file nameUpcastException
public void addCatalog(java.lang.String catalogFile)
catalogFile
- the absolute path to the catalog filepublic static void setCatalog(java.lang.String catalogFile)
catalogFile
- the absolute path to the catalog filepublic void discardCatalogs()
public UpcastException getCollectedMessages()
cleanupConversion()
, but can be cleared manually also using the clearCollectedMessages()
method.
For convenience, the result is wrapped into an UpcastException
object, so you can re-use the code already existing for real exception handling.UpcastException
object wrapping the messages collected until now.public void clearCollectedMessages()
cleanupConversion()
.public java.lang.String getEnvironmentValue(java.lang.String key)
gui (batch) java-api
"
null
when WordLink is not available
null
when WordLink is not available or no installed Word application can be found
il-gw.exe
iloop.dll
servicing the C/C++/VB/VBA APIs
null
when MathLink is not available
mt.dll
used; returns null
when MathLink is not available or the mt.dll
is not found
""
if this is the most recent build, or null
if the latest build information could not be determined
java.system.property
key
- a String indicating the desired bit of information.public void initializeConversion() throws UpcastException
UpcastException
public void cleanupConversion()
public static UpcastPipeline makePipeline(java.lang.String docPath) throws UpcastException
docPath
- the (possibly relative to user.dir) path to the ucdoc or ucpar file to runUpcastPipeline
object representing the loaded pipelineUpcastException
- when errors occurred during creationpublic static java.lang.Object runPipeline(java.lang.String docPath, java.util.Map parameters) throws UpcastException
docPath
- the full, absolute path to the ucdoc file to runparameters
- a Map of parameters, with the key being the name of the pipeline parameter as String and the value being the
(Java-) object to set, i.e. a String, Boolean or an ArrayList.UpcastException
- when errors occurred during executionpublic static java.lang.Object runPipeline(java.lang.String docPath, java.util.Map parameters, java.lang.String licenseOverride) throws UpcastException
upcast.jar
file instead of the license specified in the pipeline document, use the following absolute URL for the licenseOverride
parameter: "jar:file:!/de/infinityloop/upcast/resources/licenses/upcast-eval.uclicense"
docPath
- the full, absolute path to the ucdoc or ucpar file to runparameters
- a Map of parameters, with the key being the name of the pipeline parameter as String and the value being the
(Java-) object to set, i.e. a String, Boolean or an ArrayList.licenseOverride
- an absolute path to an alternate license file to use instead of the one supplied by the pipeline documentUpcastException
- when errors occurred during executionpublic java.lang.Object getPipelineResult()
public static de.infinityloop.upcast.core.AppFacelessLayer getApplicationObject()
public static void setLogfile(java.lang.String absolutePath)
absolutePath
- the absolute path to the log filepublic static void setLogfile(java.lang.String absolutePath, int sizelimitBytes)
absolutePath
- the absolute path to the log filesizelimitBytes
- the maximum size limit in bytes for the log file