|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xml.sax.helpers.DefaultHandler file2xliff4j.XliffImporter
public class XliffImporter
The XliffImporter is used to normalize "outside" XLIFF to a smaller subset of XLIFF. This importer assumes that the "owner" of the XLIFF file used as input is responsible for its associated skeleton and other files. This converter creates skeleton and format files, but only for the purpose of exporting the reduced XLIFF file to the original format. (Upon export, the XLIFF file will have additional translation unit targets, and existing targets might be modified.)
This importer replaces bpt, ept, sub, it and ph elements (which "mask off codes left inline") with x, bx and ex elements (which "remove codes"). The codes removed from the bpt, ept, sub, it and ph elements are placed in a format file. At export time, the information from the format file is used to restore the original bpt, ept, sub, it and ph elements.
This importer also replaces opening g tags with bx elements and closing g tags with ex elements.
Field Summary | |
---|---|
java.util.ArrayList<file2xliff4j.TuListItem> |
subTuList
|
java.util.ArrayList<file2xliff4j.TuListItem> |
tuList
|
Fields inherited from interface file2xliff4j.Converter |
---|
BLKSIZE, formatSuffix, skeletonSuffix, startXliff, stylesTSkeletonSuffix, tSkeletonSuffix, xliffSuffix, xmlDeclaration |
Constructor Summary | |
---|---|
XliffImporter()
Constructor for the XLIFF importer. |
Method Summary | |
---|---|
void |
characters(char[] ch,
int start,
int length)
Called whenever characters are encountered |
void |
comment(char[] text,
int start,
int length)
Method defined by the LexicalHandler interface that we don't care about. |
ConversionStatus |
convert(ConversionMode mode,
java.util.Locale language,
java.lang.String phaseName,
int maxPhase,
java.nio.charset.Charset nativeEncoding,
FileType nativeFileType,
java.lang.String inputXliffFileName,
java.lang.String baseDir,
Notifier notifier)
Deprecated. |
ConversionStatus |
convert(ConversionMode mode,
java.util.Locale language,
java.lang.String phaseName,
int maxPhase,
java.nio.charset.Charset nativeEncoding,
FileType nativeFileType,
java.lang.String inputXliffFileName,
java.lang.String baseDir,
Notifier notifier,
SegmentBoundary boundary,
java.io.StringWriter generatedFileName)
Convert an XLIFF file to a reduced subset of XLIFF for storage within a repository. |
ConversionStatus |
convert(ConversionMode mode,
java.util.Locale language,
java.lang.String phaseName,
int maxPhase,
java.nio.charset.Charset nativeEncoding,
FileType nativeFileType,
java.lang.String inputXliffFileName,
java.lang.String baseDir,
Notifier notifier,
SegmentBoundary boundary,
java.io.StringWriter generatedFileName,
java.util.Set<f2xutils.XMLTuXPath> skipList)
Convert an XLIFF file to a reduced subset of XLIFF for storage within a repository. |
void |
endCDATA()
Method defined by the LexicalHandler interface that we don't care about. |
void |
endDocument()
When the end-of-document is encountered, write what follows the final translation unit. |
void |
endDTD()
Method defined by the LexicalHandler interface that we don't care about. |
void |
endElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qualifiedName)
Method called whenever an end element is encountered |
void |
endEntity(java.lang.String name)
Method that the SAX parser calls whenever it reaches the end of an entity (e.g. |
java.lang.Object |
getConversionProperty(java.lang.String property)
Return an object representing a format-specific (and converter-specific) property. |
FileType |
getFileType()
Return the file type that this converter handles. |
void |
setConversionProperty(java.lang.String property,
java.lang.Object value)
Set a format-specific property that might affect the way that the conversion occurs. |
void |
startCDATA()
Method defined by the LexicalHandler interface that we don't care about. |
void |
startDocument()
Method called by the SAX parser at the beginning of document parsing. |
void |
startDTD(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
Method defined by the LexicalHandler interface that we don't care about. |
void |
startElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qualifiedName,
org.xml.sax.Attributes atts)
Method called whenever a start element is encountered |
void |
startEntity(java.lang.String name)
Method that the SAX parser calls whenever it encounters an entity (e.g. |
Methods inherited from class org.xml.sax.helpers.DefaultHandler |
---|
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public java.util.ArrayList<file2xliff4j.TuListItem> tuList
public java.util.ArrayList<file2xliff4j.TuListItem> subTuList
Constructor Detail |
---|
public XliffImporter()
Method Detail |
---|
public ConversionStatus convert(ConversionMode mode, java.util.Locale language, java.lang.String phaseName, int maxPhase, java.nio.charset.Charset nativeEncoding, FileType nativeFileType, java.lang.String inputXliffFileName, java.lang.String baseDir, Notifier notifier, SegmentBoundary boundary, java.io.StringWriter generatedFileName) throws ConversionException
convert
in interface Converter
mode
- The mode of conversion (to or from XLIFF). The value must be
TO_XLIFF.language
- The primary source language of the XLIFF file to be
imported. (This is the language of the <source> elements in
the input XLIFF file.)phaseName
- The name of the phase to convert. (This parameter is
currently ignored by this importer.)maxPhase
- The maximum phase number. This value is currently ignored.nativeEncoding
- The encoding of the input XLIFF file--probably
UTF-8, but the XLIFF specification allows UTF-16 as well). If null,
the encoding specified in the input XLIFF file's XML header is used.nativeFileType
- The type of the input file. Must be XLIFF.inputXliffFileName
- The name of the input XLIFF file.baseDir
- The directory that contains the input XLIFF file--from which
we will read the input file. This is also the directory in which the output
xliff, skeleton and format files will be written. The output files will
be named as follows:
notifier
- Instance of a class that implements the Notifier
interface (to send notifications in case of conversion error).boundary
- The boundary on which to segment translation units (e.g.,
on paragraph or sentence boundaries)generatedFileName
- If non-null, the converter will write the name
of the file (without parent directories) to which the generated
XLIFF file was written.
ConversionException
- If a conversion exception is encountered.public ConversionStatus convert(ConversionMode mode, java.util.Locale language, java.lang.String phaseName, int maxPhase, java.nio.charset.Charset nativeEncoding, FileType nativeFileType, java.lang.String inputXliffFileName, java.lang.String baseDir, Notifier notifier, SegmentBoundary boundary, java.io.StringWriter generatedFileName, java.util.Set<f2xutils.XMLTuXPath> skipList) throws ConversionException
convert
in interface Converter
mode
- The mode of conversion (to or from XLIFF). The value must be
TO_XLIFF.language
- The primary source language of the XLIFF file to be
imported. (This is the language of the <source> elements in
the input XLIFF file.)phaseName
- The name of the phase to convert. (This parameter is
currently ignored by this importer.)maxPhase
- The maximum phase number. This value is currently ignored.nativeEncoding
- The encoding of the input XLIFF file--probably
UTF-8, but the XLIFF specification allows UTF-16 as well). If null,
the encoding specified in the input XLIFF file's XML header is used.nativeFileType
- The type of the input file. Must be XLIFF.inputXliffFileName
- The name of the input XLIFF file.baseDir
- The directory that contains the input XLIFF file--from which
we will read the input file. This is also the directory in which the output
xliff, skeleton and format files will be written. The output files will
be named as follows:
notifier
- Instance of a class that implements the Notifier
interface (to send notifications in case of conversion error).boundary
- The boundary on which to segment translation units (e.g.,
on paragraph or sentence boundaries)generatedFileName
- If non-null, the converter will write the name
of the file (without parent directories) to which the generated
XLIFF file was written.skipList
- (Not used by this converter.)
ConversionException
- If a conversion exception is encountered.@Deprecated public ConversionStatus convert(ConversionMode mode, java.util.Locale language, java.lang.String phaseName, int maxPhase, java.nio.charset.Charset nativeEncoding, FileType nativeFileType, java.lang.String inputXliffFileName, java.lang.String baseDir, Notifier notifier) throws ConversionException
convert
in interface Converter
mode
- The mode of conversion (to or from XLIFF). The value must be
TO_XLIFF.language
- The primary source language of the XLIFF file to be
imported. (This is the language of the <source> elements in
the input XLIFF file.)phaseName
- The name of the phase to convert. (This parameter is
currently ignored by this importer.)maxPhase
- The maximum phase number. This value is currently ignored.nativeEncoding
- The encoding of the input XLIFF file--probably
UTF-8, but the XLIFF specification allows UTF-16 as well). If null,
the encoding specified in the input XLIFF file's XML header is used.nativeFileType
- The type of the input file. Must be XLIFF.inputXliffFileName
- The name of the input XLIFF file.baseDir
- The directory that contains the input XLIFF file--from which
we will read the input file. This is also the directory in which the output
xliff, skeleton and format files will be written. The output files will
be named as follows:
notifier
- Instance of a class that implements the Notifier
interface (to send notifications in case of conversion error).
ConversionException
- If a conversion exception is encountered.public void startDocument() throws org.xml.sax.SAXException
startDocument
in interface org.xml.sax.ContentHandler
startDocument
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
- I if any problems are found.public void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qualifiedName, org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
startElement
in interface org.xml.sax.ContentHandler
startElement
in class org.xml.sax.helpers.DefaultHandler
namespaceURI
- The URI of the namespacelocalName
- The local name (without prefix), or the empty string if
Namespace processing is not being performed.qualifiedName
- The qualified name (with prefix), or the empty string
if qualified names are not availableatts
- The specified or defaulted attributes.
org.xml.sax.SAXException
public void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qualifiedName) throws org.xml.sax.SAXException
endElement
in interface org.xml.sax.ContentHandler
endElement
in class org.xml.sax.helpers.DefaultHandler
namespaceURI
- The URI of the namespacelocalName
- The local name (without prefix), or the empty string if Namespace processing is not being performed.qualifiedName
- The qualified name (with prefix), or the empty string if qualified names are not available
org.xml.sax.SAXException
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
characters
in interface org.xml.sax.ContentHandler
characters
in class org.xml.sax.helpers.DefaultHandler
ch
- Array containing characters encounteredstart
- Position in array of first applicable characterlength
- How many characters are of interest?
org.xml.sax.SAXException
public void endDocument() throws org.xml.sax.SAXException
endDocument
in interface org.xml.sax.ContentHandler
endDocument
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void startEntity(java.lang.String name) throws org.xml.sax.SAXException
The inEntity instance variable is checked by the characters method of the ContentHandler (DefaultHandler) extension (above). The SAX parser calls the characters method whenever it expands an entity, passing it *only* the expansion of the entity it just encountered. Since we want to write out the unexpanded version of the entity, this (startEntity) method writes out the entity, and characters() just returns without outputting the expansion of the entity (if inEntity is true).
Note: the endEntity method (below) sets the inEntity variable to false.
startEntity
in interface org.xml.sax.ext.LexicalHandler
name
- The name of the entity (e.g. "lt", "gt", etc.--without a
leading ampersand or trailing semicolon.)
org.xml.sax.SAXException
public void endEntity(java.lang.String name) throws org.xml.sax.SAXException
endEntity
in interface org.xml.sax.ext.LexicalHandler
name
- The name of the entity (e.g. "lt", "gt", etc.--without a
leading ampersand or trailing semicolon.)
org.xml.sax.SAXException
public void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
startDTD
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void endDTD() throws org.xml.sax.SAXException
endDTD
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void startCDATA() throws org.xml.sax.SAXException
startCDATA
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void endCDATA() throws org.xml.sax.SAXException
endCDATA
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public void comment(char[] text, int start, int length) throws org.xml.sax.SAXException
comment
in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException
public java.lang.Object getConversionProperty(java.lang.String property)
getConversionProperty
in interface Converter
property
- The name of the property to return.
public FileType getFileType()
getFileType
in interface Converter
public void setConversionProperty(java.lang.String property, java.lang.Object value) throws ConversionException
Note: This converter needs no format-specific properties. If any are passed, they will be silently ignored.
setConversionProperty
in interface Converter
property
- The name of the propertyvalue
- The value of the property
ConversionException
- If the property isn't recognized (and if it matters).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |