Class BasePackageWriter
- java.lang.Object
-
- net.sf.okapi.steps.rainbowkit.common.BasePackageWriter
-
- All Implemented Interfaces:
AutoCloseable
,IFilterWriter
,IPackageWriter
- Direct Known Subclasses:
OntramPackageWriter
,POPackageWriter
,TablePackageWriter
,TransifexPackageWriter
,XLIFF2PackageWriter
,XLIFFPackageWriter
public abstract class BasePackageWriter extends Object implements IPackageWriter
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
copiedTargetsLikeApproved
protected int
docId
protected String
extractionType
protected String
inputRootDir
protected Manifest
manifest
protected Parameters
params
protected String
rootDir
protected ISkeletonWriter
skelWriter
protected boolean
supporstOneOutputPerInput
protected String
tempTmxPathAlternates
protected String
tempTmxPathApproved
protected String
tempTmxPathLeverage
protected String
tempTmxPathUnApproved
protected boolean
tmxInfoAlreadySet
protected String
tmxPathAlternates
protected String
tmxPathApproved
protected String
tmxPathLeverage
protected String
tmxPathUnApproved
protected TMXWriter
tmxWriterAlternates
protected TMXWriter
tmxWriterApproved
protected TMXWriter
tmxWriterLeverage
protected TMXWriter
tmxWriterUnApproved
protected boolean
useLetterCodes
protected boolean
zeroBasedLetterCodes
-
Constructor Summary
Constructors Constructor Description BasePackageWriter(String extractionType)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
cancel()
Cancels the current process.protected void
copySupportMaterial()
protected Event
creatRawDocumentEventSet(String inputPath, String defaultEncoding, LocaleId srcLoc, LocaleId trgLoc)
EncoderManager
getEncoderManager()
Gets the current encoder manager for this writer.String
getMainOutputPath()
Parameters
getParameters()
Gets the current parameters for this writer.ISkeletonWriter
getSkeletonWriter()
Gets the skeleton writer associated with this writer.Event
handleEvent(Event event)
Handles the filter events.protected void
initializeTMXWriters()
protected void
processDocumentPart(Event event)
protected void
processEndBatch()
protected void
processEndBatchItem()
protected abstract Event
processEndDocument(Event event)
protected void
processEndGroup(Event event)
protected void
processEndSubDocument(Event event)
protected void
processRawDocument(Event event)
protected void
processStartBatch()
protected void
processStartBatchItem()
protected void
processStartDocument(Event event)
protected void
processStartGroup(Event event)
protected void
processStartSubDocument(Event event)
protected abstract void
processTextUnit(Event event)
void
setBatchInformation(String packageRoot, LocaleId srcLoc, LocaleId trgLoc, String inputRootDir, String rootDir, String packageId, String projectId, String creatorParams, String tempPackageRoot)
void
setDocumentInformation(String relativeInputPath, String filterConfigId, String filterParameters, String inputEncoding, String relativeTargetPath, String targetEncoding, ISkeletonWriter skelWriter)
void
setOptions(LocaleId locale, String defaultEncoding)
Sets the options for this writer.void
setOutput(OutputStream output)
Sets the output through its output stream.void
setOutput(String path)
Sets the output through the path of the output file.void
setParameters(IParameters params)
Sets new parameters for this writer.void
setSupporstOneOutputPerInput(boolean supporstOneOutputPerInput)
protected void
setTMXInfo(boolean generate, String pathApproved, boolean useLetterCodes, boolean zerobasedletterCodes, boolean overwrite)
protected void
writeTMXEntries(ITextUnit tu)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.okapi.common.filterwriter.IFilterWriter
close, getName
-
-
-
-
Field Detail
-
params
protected Parameters params
-
manifest
protected Manifest manifest
-
docId
protected int docId
-
extractionType
protected String extractionType
-
skelWriter
protected ISkeletonWriter skelWriter
-
supporstOneOutputPerInput
protected boolean supporstOneOutputPerInput
-
inputRootDir
protected String inputRootDir
-
rootDir
protected String rootDir
-
tmxWriterApproved
protected TMXWriter tmxWriterApproved
-
tmxPathApproved
protected String tmxPathApproved
-
tempTmxPathApproved
protected String tempTmxPathApproved
-
tmxWriterUnApproved
protected TMXWriter tmxWriterUnApproved
-
tmxPathUnApproved
protected String tmxPathUnApproved
-
tempTmxPathUnApproved
protected String tempTmxPathUnApproved
-
tmxWriterAlternates
protected TMXWriter tmxWriterAlternates
-
tmxPathAlternates
protected String tmxPathAlternates
-
tempTmxPathAlternates
protected String tempTmxPathAlternates
-
tmxWriterLeverage
protected TMXWriter tmxWriterLeverage
-
tmxPathLeverage
protected String tmxPathLeverage
-
tempTmxPathLeverage
protected String tempTmxPathLeverage
-
copiedTargetsLikeApproved
protected boolean copiedTargetsLikeApproved
-
useLetterCodes
protected boolean useLetterCodes
-
zeroBasedLetterCodes
protected boolean zeroBasedLetterCodes
-
tmxInfoAlreadySet
protected boolean tmxInfoAlreadySet
-
-
Constructor Detail
-
BasePackageWriter
public BasePackageWriter(String extractionType)
-
-
Method Detail
-
getParameters
public Parameters getParameters()
Description copied from interface:IFilterWriter
Gets the current parameters for this writer.- Specified by:
getParameters
in interfaceIFilterWriter
- Specified by:
getParameters
in interfaceIPackageWriter
- Returns:
- The current parameters for this writer.
-
setParameters
public void setParameters(IParameters params)
Description copied from interface:IFilterWriter
Sets new parameters for this writer.- Specified by:
setParameters
in interfaceIFilterWriter
- Specified by:
setParameters
in interfaceIPackageWriter
- Parameters:
params
- The new parameters to use.
-
setBatchInformation
public void setBatchInformation(String packageRoot, LocaleId srcLoc, LocaleId trgLoc, String inputRootDir, String rootDir, String packageId, String projectId, String creatorParams, String tempPackageRoot)
- Specified by:
setBatchInformation
in interfaceIPackageWriter
-
getMainOutputPath
public String getMainOutputPath()
-
cancel
public void cancel()
Description copied from interface:IFilterWriter
Cancels the current process.- Specified by:
cancel
in interfaceIFilterWriter
-
getEncoderManager
public EncoderManager getEncoderManager()
Description copied from interface:IFilterWriter
Gets the current encoder manager for this writer. Some special implementation of IFilterWriter may not use an encoder manager (for example writers that do not use skeleton).- Specified by:
getEncoderManager
in interfaceIFilterWriter
- Returns:
- the current encoder manager for this writer, or null if none exists for this writer.
-
getSkeletonWriter
public ISkeletonWriter getSkeletonWriter()
Description copied from interface:IFilterWriter
Gets the skeleton writer associated with this writer. Some implementation of IFilterWriter may not use a skeleton writer.- Specified by:
getSkeletonWriter
in interfaceIFilterWriter
- Returns:
- the skeleton writer associated with this writer or null if none is associated.
-
handleEvent
public Event handleEvent(Event event)
Description copied from interface:IFilterWriter
Handles the filter events.- Specified by:
handleEvent
in interfaceIFilterWriter
- Parameters:
event
- The event to process.- Returns:
- The event that was processed.
-
setOptions
public void setOptions(LocaleId locale, String defaultEncoding)
Description copied from interface:IFilterWriter
Sets the options for this writer.- Specified by:
setOptions
in interfaceIFilterWriter
- Parameters:
locale
- the output locale.defaultEncoding
- Name of the character set encoding for the output.
-
setOutput
public void setOutput(String path)
Description copied from interface:IFilterWriter
Sets the output through the path of the output file.- Specified by:
setOutput
in interfaceIFilterWriter
- Parameters:
path
- Full path of the output file.
-
setOutput
public void setOutput(OutputStream output)
Description copied from interface:IFilterWriter
Sets the output through its output stream.- Specified by:
setOutput
in interfaceIFilterWriter
- Parameters:
output
- Output stream to use for the output.
-
processStartBatch
protected void processStartBatch()
-
setTMXInfo
protected void setTMXInfo(boolean generate, String pathApproved, boolean useLetterCodes, boolean zerobasedletterCodes, boolean overwrite)
-
initializeTMXWriters
protected void initializeTMXWriters()
-
processEndBatch
protected void processEndBatch()
-
processStartBatchItem
protected void processStartBatchItem()
-
processEndBatchItem
protected void processEndBatchItem()
-
processRawDocument
protected void processRawDocument(Event event)
-
setDocumentInformation
public void setDocumentInformation(String relativeInputPath, String filterConfigId, String filterParameters, String inputEncoding, String relativeTargetPath, String targetEncoding, ISkeletonWriter skelWriter)
- Specified by:
setDocumentInformation
in interfaceIPackageWriter
-
processStartDocument
protected void processStartDocument(Event event)
-
processStartSubDocument
protected void processStartSubDocument(Event event)
-
processEndSubDocument
protected void processEndSubDocument(Event event)
-
processStartGroup
protected void processStartGroup(Event event)
-
processEndGroup
protected void processEndGroup(Event event)
-
processDocumentPart
protected void processDocumentPart(Event event)
-
processTextUnit
protected abstract void processTextUnit(Event event)
-
writeTMXEntries
protected void writeTMXEntries(ITextUnit tu)
-
setSupporstOneOutputPerInput
public void setSupporstOneOutputPerInput(boolean supporstOneOutputPerInput)
- Specified by:
setSupporstOneOutputPerInput
in interfaceIPackageWriter
-
creatRawDocumentEventSet
protected Event creatRawDocumentEventSet(String inputPath, String defaultEncoding, LocaleId srcLoc, LocaleId trgLoc)
-
copySupportMaterial
protected void copySupportMaterial()
-
-