|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.infinityloop.upcast.UpcastEngine
public class UpcastEngine
This class provides all necessary methods to access upCast functionality programmatically via a simple Java API.
Follows a minimal skeleton showing how to do a single conversion from file in.rtf to out.xml (debugging turned on):
String filterID; UpcastEngine.setLicense( "/path/to/upcast.license" ); UpcastEngine ucInst = new UpcastEngine( true, "one" ); ucInst.setGlobalParameter( "outputDir", new String( "/someproject/somefolder/someoutputdir/" ); filterID = ucInst.setImportFilterType( UpcastEngine.kRTFImportType ); ucInst.setImportFilterParameter( filterID, "OrigNumbering", new Boolean( true ) ); ucInst.importFile( "in.rtf" ); filterID = ucInst.setExportFilterType( UpcastEngine.kXMLExportType ); ucInst.setExportFilterParameter( filterID, "DeleteEmpties", new Boolean( false ) ); ucInst.exportFile( "out.xml" );
Field Summary | |
---|---|
static int |
kCommandlineExportType
selector for the Command Line Export Filter. |
static int |
kCSSExportType
selector for the CSS2 Export Filter Export style information to CSS2 ( Cascading Style Sheet Level 2 ). |
static int |
kDocBookExportType
selector for the DocBook 4.2 Export Filter. |
static int |
kNoopImportType
selector for the No-op (None) import filter. |
static int |
kRawTreeDumperExportType
selector for the Raw Tree Dumper. |
static int |
kRTFImportType
selector for the RTF 1.6 Specification compliant import filter. |
static int |
kUnicodeTranslatorExportType
selector for the Unicode Mapper post processing export filter. |
static int |
kXHTMLExportType
selector for the XHTML Export Filter. |
static int |
kXHTMLTransitionalExportType
selector for the XHTML Transitional Export Filter. |
static int |
kXMLExportType
selector for the XML (upCast DTD) Export Filter. |
static int |
kXMLRawExportType
selector for the XML Raw export filter. |
static int |
kXMLValidatorExportType
selector for the Validator Export Filter. |
static int |
kXSLTProcessorExportType
selector for the XSLT post processing Export Filter. |
Constructor Summary | |
---|---|
UpcastEngine(boolean debug,
java.lang.String instanceIDUser)
Creates a new instance of the UpcastEngine object. |
|
UpcastEngine(java.lang.String instanceIDUser)
Creates a new instance of the UpcastEngine object. |
Method Summary | |
---|---|
static 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 |
convertDocumentWithConfiguration(java.lang.String srcFile,
java.lang.String destDir,
java.lang.String configFile)
Convert a document using the settings as defined in a specified upCast Configuration file. |
void |
debugMessage(java.lang.String msg)
Makes debugging output Writes a string to the console when gDebug = true. |
static void |
discardCatalogs()
Removes all previously registered catalogs from the catalog system. |
void |
dispose()
**BROKEN** This method is broken. |
void |
errorMessage(java.lang.String msg)
Makes error output. |
void |
exportFile(java.lang.String outFile)
Exports a document to a file. |
void |
exportStream(java.io.OutputStream outStream)
Exports a document to a stream. |
com.sun.resolver.tools.CatalogResolver |
getCatalogResolver()
Returns the Catalog resolver used by the system. |
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. |
void |
importFile(java.lang.String srcFile)
Reads document from file. |
void |
importStream(java.io.InputStream inStream)
Reads document from stream. |
void |
infoMessage(java.lang.String msg)
Makes info output. |
void |
setCustomFontConfiguration(java.io.InputStream customFontConfigStream)
Loads a new custom stdfonts.config configuration. |
void |
setCustomFontConfiguration(java.lang.String customFontConfigName)
Loads a new custom stdfonts.config configuration. |
void |
setDebuggingMode(boolean on)
Sets debugging mode. |
void |
setExportFilterParameter(java.lang.String filterInstance,
java.lang.String filterParameter,
java.lang.Object parameterValue)
Sets an export filter parameter. |
java.lang.String |
setExportFilterType(int filterType)
Set export filter Type Sets the type of the export filter for exporting the internally held document. |
void |
setGlobalParameter(java.lang.String parameter,
java.lang.Object value)
Set global parameter for conversion process. |
void |
setImportFilterParameter(java.lang.String filterInstance,
java.lang.String filterParameter,
java.lang.Object parameterValue)
Set import filter parameter. |
java.lang.String |
setImportFilterType(int filterType)
Set import filter Type Sets the type of the import filter for data to be read by importStream or importFile . |
static boolean |
setLicense(java.io.InputStream inStream)
Sets a specified License file for use as license. |
static boolean |
setLicense(java.lang.String licenseFile)
Sets a specified License file for use as license. |
void |
warningMessage(java.lang.String msg)
Makes warning output. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int kRTFImportType
setImportFilterType(int)
,
Constant Field Valuespublic static final int kNoopImportType
setImportFilterType(int)
,
Constant Field Valuespublic static final int kXHTMLExportType
Export to XHTML, optionally including detailed visual markup (works in tandem with kCSSExportType
)
setExportFilterType(int)
,
Constant Field Valuespublic static final int kCSSExportType
Export style information to CSS2 ( Cascading Style Sheet Level 2 ).
setExportFilterType(int)
,
Constant Field Valuespublic static final int kXMLValidatorExportType
validate the specified file
setExportFilterType(int)
,
Constant Field Valuespublic static final int kXMLExportType
Export to XML, logical/visual markup selectable, valid according to the upCast DTD.
setExportFilterType(int)
,
Constant Field Valuespublic static final int kCommandlineExportType
Runs a command at command line level.
setExportFilterType(int)
,
Constant Field Valuespublic static final int kXSLTProcessorExportType
Runs a stylesheet on the specified file output. Does not work with streaming data.
setExportFilterType(int)
,
Constant Field Valuespublic static final int kDocBookExportType
Export to DocBook 4.2 DTD (XML)
setExportFilterType(int)
,
Constant Field Valuespublic static final int kXMLRawExportType
Export to a raw tree to be processed with a custom XSLT stylesheet (inline transformation).
setExportFilterType(int)
,
Constant Field Valuespublic static final int kUnicodeTranslatorExportType
Translate a given XML document using the specified Unicode Translation Map.
setExportFilterType(int)
,
Constant Field Valuespublic static final int kXHTMLTransitionalExportType
Export to XHTML, optionally including detailed visual markup (works in tandem with kCSSExportType
)
setExportFilterType(int)
,
Constant Field Valuespublic static final int kRawTreeDumperExportType
Export to text, showing tree to expect when working on custom export filters.
Important: The output is not valid XML!
setExportFilterType(int)
,
Constant Field ValuesConstructor Detail |
---|
public UpcastEngine(java.lang.String instanceIDUser) throws ILException
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).
instanceIDUser
- you may pass an arbitrary string here which helps to identify the server instance in log file and debug message output.
ILException
public UpcastEngine(boolean debug, java.lang.String instanceIDUser) throws ILException
debug
- pass true if you want debug messages output to the logging system, false otherwise.instanceIDUser
- you may pass an arbitrary string here which helps to identify the server instance in log file and debug message output.
ILException
Method Detail |
---|
public void convertDocumentWithConfiguration(java.lang.String srcFile, java.lang.String destDir, java.lang.String configFile) throws ILException
This method sets up the current UpcastEngine
object according to the definitions found in the UpcastConfiguration file.
Important: You may only use the kRTFImportType
as import filter, the 'None' or 'Batch' variants are not allowed and will
be automatically reset to kRTFImportType
on reading the configuration. Also note that you cannot override any parameters since you do not
have any handles to the filter instances. If you need more flexibility, you should use the more granular API methods provided.
srcFile
- full path to the RTF source file to be converteddestDir
- full path to the destination directory/base directory for the resultsconfigFile
- full path to the upCast Configuration file to be used for this conversion
ILException
public void importStream(java.io.InputStream inStream) throws ILException
This method actually imports a document and stores it in a proprietary format in memory. For this it uses the import filter as earlier set by
setImportFilterType
with parameters as set by setImportFilterParameter
.
Any previously read document is replaced by the newly imported one.
The inStream can be any of the many predefined sub-classes/implementations of InputStream.
Note: To have WordLink function also when passing a .doc binary file in the stream, the InputStream implementation must support the mark() operation.
The imported document is held in memory until one of the following happens:
setImportFilterType
is issued
UpcastEngine
object (either explicitly or by exiting the application)
importStream
or importFile
inStream
- the stream that contains the input data.
ILException
- Throws an appropriate exception if anything goes wrong.public void importFile(java.lang.String srcFile) throws ILException
This method actually imports a document and stores it in a proprietary format in memory. For this it uses the import filter as earlier set by
setImportFilterType
with parameters as set by setImportFilterParameter
.
Any previously read document is replaced by the newly imported one.
The srcFile
should be an
The imported document is held in memory until one of the following happens:
setImportFilterType
is issued
UpcastEngine
object (either explicitly or by exiting the application)
importStream
or importFile
srcFile
- the (absolute) name (incl. path) of the file to be imported.
ILException
- Throws an appropriate exception if anything goes wrong.public void exportStream(java.io.OutputStream outStream) throws ILException
Export a document from the internal representation to a stream, using the export filter and settings as previously determined by calls to
setExportFilterType
and setExportFilterParameter
.
Any errors during export will be reported as Exceptions of the respective type.
After an export operation, the document exported will still be available unchanged in its internal representation, ready to be exported using e.g. a different filter or different parameters.
outStream
- the stream where the output gets written to.
ILException
- Throws an appropriate exception if anything goes wrong.public void exportFile(java.lang.String outFile) throws ILException
Export a document from the internal representation to a file, using the export filter and settings as previously determined by calls to
setExportFilterType
and setExportFilterParameter
. The file will be created if it does not
already exist (incl. all intermediate subdirectories, if necessary).
Any errors during export will be reported as Exceptions of the respective type.
After an export operation, the document exported will still be available unchanged in its internal representation, ready to be exported using e.g. a different filter or different parameters.
outFile
- the filename (absolute, incl. path) of the file where the output should get written.
ILException
- Throws an appropriate exception if anything goes wrong.OutputStream
public java.lang.String setImportFilterType(int filterType) throws ILException
importStream
or importFile
.
filterType
- the type of the filter. Use one of the following:
Only one filter can be installed at any time.
A previously installed filter will be replaced by the newly set one.
setImportFilterParameter
.
ILException
- thrown if an invalid import filter type is specifiedpublic java.lang.String setExportFilterType(int filterType) throws ILException
filterType
- the type of the filter. Use one of the following:
kCommandlineExportType
kCSSExportType
kDocBookExportType
kRawTreeDumperExportType
kXHTMLExportType
kXHTMLTransitionalExportType
kXMLExportType
kXMLRawExportType
kXMLValidatorExportType
kXSLTProcessorExportType
kUnicodeTranslatorExportType
A previously installed filter will be replaced by the newly set one.
setExportFilterParameter
.
ILException
- thrown if an invalid export filter type is specifiedsetExportFilterParameter(java.lang.String, java.lang.String, java.lang.Object)
public void setExportFilterParameter(java.lang.String filterInstance, java.lang.String filterParameter, java.lang.Object parameterValue) throws ILException
filterInstance
- the filter instance for which this parameter is to be set. The filter instance is retrieved from setExportFilterType
.filterParameter
- the name of the parameter to be set. For available parameter names of each filter, 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.
ILException
- Throws an appropriate exception if anything goes wrong.public void setImportFilterParameter(java.lang.String filterInstance, java.lang.String filterParameter, java.lang.Object parameterValue) throws ILException
filterInstance
- the filter instance for which this parameter is to be set. The filter instance is retrieved from setImportFilterType
.filterParameter
- the name of the parameter to be set. For available parameter names of each filter, 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.
ILException
- Throws an appropriate exception if anything goes wrong.public void setGlobalParameter(java.lang.String parameter, java.lang.Object value) throws ILException
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.
ILException
- 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 messagepublic void setDebuggingMode(boolean on)
on
- if true, debugging output to the log file is turned on, if false, it is turned off.public void dispose()
Prepares this UpcastEngine object for disposing. Clears all references to itself it has created so that when the variable that holds the reference to this object is set to null, the object becomes available to the garbage collector.
This is when you need to create a new instance of this object. Procedure:theServer.dispose(); theServer = null; System.gc():
public java.lang.String getInstanceNameUser()
public com.sun.resolver.tools.CatalogResolver getCatalogResolver()
public static 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 static 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 ILException
Encodings are global and shared by all concurrent UpcastEngine instances.
customEncodingStream
- the custom encoding
ILException
public void addCustomEncoding(java.lang.String customEncodingName) throws ILException
addCustomEncoding
for details.
customEncodingName
- file name of a custom encoding file
ILException
public void setCustomFontConfiguration(java.io.InputStream customFontConfigStream) throws ILException
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.
customFontConfigStream
- the custom stdfonts.config
file resp. stream
ILException
public void setCustomFontConfiguration(java.lang.String customFontConfigName) throws ILException
setCustomFontConfiguration
for details.
customFontConfigName
- the custom stdfonts.config file name
ILException
public static void addCatalog(java.lang.String catalogFile)
catalogFile
- the absolute path to the catalog filepublic static void discardCatalogs()
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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |