|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.reverseXSL.transform.TransformerFactory
public final class TransformerFactory
A TransformerFactory is instantiated with a source of transformation meta-data, namely mapping selection meta-data as well as parsing DEFinitions and XSL transformation templates.
The distinction between a TransformerFactory and subsequent Transformer objects follows the classical java pattern.
A factory is instantiated, used to set various parameters, and then used to instantiate Transformer objects. All Transformer objects from the same factory inherit and share meta-data from the factory. The factory can be used to tune parameters that control the behaviour of Transformer objects.
Transformer objects are in turn used to execute message parsings and transformations, with the help of resources and parameters inherited from the factory.
Note that the link between the factory and Transformer objects is never broken in the present design: changes to factory parameters may affect the behaviour of Transformer objects already generated! Yet, proper practice recommends to set all factory features before instantiating the first Transformer, and using it.
Transformer
Method Summary | |
---|---|
static TransformerFactory |
newInstance()
Instantiates a Transformer Factory that will load meta-data from the software distribution jar file itself. |
Transformer |
newTransformer()
Instantiate a new Transformer from the factory. |
Transformer |
newTransformer(java.util.jar.JarFile jarFile)
Instantiates a Transformer with meta-data from an explicitly specified jar file. |
Transformer |
newTransformer(java.io.Reader myDefinition,
java.io.Reader myXSLT)
Instantiates a new Transformer instance from the factory, which will bypass the Mapping Selection process. |
void |
setExternalMappingSelectionTable(java.io.Reader r)
Imposes the specified Mapping Selection Table meta-data (full replacement). |
void |
setExternalMappingSelectionTable(java.io.Reader r,
java.lang.String path)
Imposes the specified Mapping Selection Table meta-data (full replacement). |
void |
setInputCharSet(java.nio.charset.Charset charset)
Sets the Charset used for decoding input message bytes into characters, using a java Charset object. |
void |
setInputCharSet(java.lang.String charset)
Sets the Charset used for decoding input message bytes into characters, using a java Charset name. |
void |
setInputDataConversions(int specs)
Sets the conversions to perform on input data at byte or character level before applying transformations in proper. |
void |
setOutputCharSet(java.nio.charset.Charset charset)
Sets the Charset used for encoding output message characters into bytes, using a java Charset object. |
void |
setOutputCharSet(java.lang.String charset)
Sets the Charset used for encoding output message characters into bytes, using a java Charset object. |
void |
setParserExceptionThresholds(int maxFatal,
int maxTotal)
Sets specific Parser tolerance to input message syntax errors. |
void |
setParserRemoveNonRepeatableNilOptionalElements(boolean bool)
Would cause (if set TRUE) to remove from the output XML document all data elements with a NIL value that are optional or conditional elements, and whose matching definition indicates that the element is non repeatable (i.e. |
void |
setPrintableXmlIndent(java.lang.String ptrn)
Sets the pattern of chars that will be repeated at each depth level to indent the printable-XML output. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static final TransformerFactory newInstance()
This variant uses the classloader. It is then able to find all meta-data resources that are placed on the CLASSPATH.
public Transformer newTransformer() throws java.io.IOException, TransformerException
java.io.IOException
TransformerException
public Transformer newTransformer(java.util.jar.JarFile jarFile) throws java.io.IOException, TransformerException
The jar file does not need to be on the CLASSPATH and may contain alternative transformation meta-data sets. The jar must contain a Mapping Selection Table and all other dependent meta-data pieces (Parsing DEFs and XSL templates). The specified jar does not take precedence but replaces entirely the default resources, including the mapping selection table.
The method setExternalMappingSelectionTable(Reader)
still allows
to overrride the mapping selection table (over that which can be on the
CALSSPATH, else within the explicitly specified jar).
jarFile
- a JarFile object containing all meta-data resources
java.io.IOException
TransformerException
public Transformer newTransformer(java.io.Reader myDefinition, java.io.Reader myXSLT) throws java.io.IOException
myDefinition
- a Reader on a DEF file or nullmyXSLT
- a Reader on an XSL file or null
java.io.IOException
- in case of read errors from one of the Reader argumentspublic void setExternalMappingSelectionTable(java.io.Reader r) throws java.io.IOException, TransformerException
The CLASSPATH or a JAR will still be used as source for transformation resources (Parsing DEFs and XSL templates), depending upon the method of creating the Transformer.
r
- A Reader from which the table will be loaded
java.io.IOException
TransformerException
public void setExternalMappingSelectionTable(java.io.Reader r, java.lang.String path) throws java.io.IOException, TransformerException
One can provide an optional path argument that will formally be added to the CLASSPATH for loading resources (Parsing DEFs and XSL templates).
r
- A Reader from which the table will be loadedpath
- if not null or empty, a directory path to be used as root
location for loading associated mapping resources
java.io.IOException
TransformerException
public void setInputCharSet(java.nio.charset.Charset charset)
charset
- a java Charset
or null to reset to default UTF-8setInputCharSet(String)
public void setInputCharSet(java.lang.String charset)
Useful character set names to consider are the legacy 7bit "US-ASCII", 8-bit collections like "ISO-8859-1" (ISO Latin Alphabet No. 1 or 2,3,4..), "EBCDIC-INT", and "EBCDIC-CP-US", multibyte sets like "Shift_JIS", and the now standard Unicode Transformation Formats "UTF-8", or "UTF-16". The full listing is available at the IANA Charset Registry (http://www.iana.org/assignments/character-sets).
charset
- a java Charset
name as String or null to reset to
default UTF-8public void setInputDataConversions(int specs)
specs
- add flag values as defined by Data
constants.Data
public void setOutputCharSet(java.nio.charset.Charset charset)
charset
- a java Charset
or null to reset to default UTF-8setOutputCharSet(String)
public void setOutputCharSet(java.lang.String charset)
Useful character set names to consider are the legacy 7bit "US-ASCII", 8-bit collections like "ISO-8859-1" (ISO Latin Alphabet No. 1 or 2,3,4..), "EBCDIC-INT", and "EBCDIC-CP-US", multibyte sets like "Shift_JIS", and the now standard Unicode Transformation Formats "UTF-8", or "UTF-16". The full listing is available at the IANA Charset Registry (http://www.iana.org/assignments/character-sets).
charset
- a java Charset
name as String or null to reset to
default UTF-8public void setParserExceptionThresholds(int maxFatal, int maxTotal)
maxFatal
- new acceptable count of syntax violations conunted as FatalmaxTotal
- new total acceptable count of syntax violations (all as
warnings, or acceptable fatal + acceptable warnings)public void setParserRemoveNonRepeatableNilOptionalElements(boolean bool)
This function is actually quite useful on messages based on the principle of positional data elements within 'segments' (e.g. EDIFACT, TRADACOMS, X12, etc.). Indeed, most positions (think 'slots') in such segments are occupied by optional/conditional data elements, all unique and distinguished by their relative position in the 'segment'. Every unoccupied position will yield a corresponding NIL data element in XML, that can be suppressed from the XML output if this method is set to TRUE.
NIL data elements are supressed only if they have a min/max size
specification (of the kind [1..15]
) with a minimum of at
least 1. Obviously, if 0 is an acceptable size for the element, there's
no reason to suppress the element.
Moreover, the element must be non-repeatable otherwise there is a risk to eat-up intermediate elements within series, causing undesirable rank shifts.
The default value is TRUE.
bool
- whether or not to Remove non-repeatable NIL optionalspublic void setPrintableXmlIndent(java.lang.String ptrn)
Transformer.printableTransform(InputStream, StringBuffer)
ptrn
- a pattern like " ", or "| " for increased readability
(really cool!).
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |