Package net.sf.okapi.filters.subtitles
Class SubtitleFilter
- java.lang.Object
-
- net.sf.okapi.common.filters.AbstractFilter
-
- net.sf.okapi.filters.subtitles.SubtitleFilter
-
- All Implemented Interfaces:
AutoCloseable,Iterator<Event>,IFilter
- Direct Known Subclasses:
TTMLFilter,VTTFilter
public abstract class SubtitleFilter extends AbstractFilter
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringDEFAULT_TIME_FORMATprotected SubtitleEventBuildereventBuilderprotected DateTimeFormatterformatterprotected booleanhasUtf8Bomprotected booleanhasUtf8Encodingprotected org.slf4j.LoggerLOGGERprotected intmaxCharprotected intmaxLineprotected SubtitleParametersparamsprotected PatternterminalPattern-
Fields inherited from interface net.sf.okapi.common.filters.IFilter
SUB_FILTER
-
-
Constructor Summary
Constructors Constructor Description SubtitleFilter()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddCaptionAnnotation(String startTime, String endTime)protected voidaddString(String string)protected voidaddToDocumentPart(String part)protected voidaddToTextUnit(String text)protected voidendFilter()protected booleanendsWithPunctuation(String str)static DateTimeFormattergetDateTimeFormatter(String timeFormat)intgetMaxChar()intgetMaxLine()SubtitleParametersgetParameters()Gets the current parameters for this filter.protected abstract StringgetTerminalRegex()booleanhasNext()Indicates if there is an event to process.static booleanisCJK(LocaleId localeId)protected booleanisInsideTextRun()protected booleanisUtf8Bom()Does the input have a UTF-8 Byte Order Mark?protected booleanisUtf8Encoding()Is the input encoded as UTF-8?CaptionAnnotationmakeCaptionAnnotation()protected static booleanneedToAppendWhitespace(String str)protected static booleanneedToPrependWhitespace(String str)voidopen(RawDocument input)Opens the input document described in a give RawDocument object.voidopen(RawDocument input, boolean generateSkeleton)Opens the input document described in a give RawDocument object, and optionally creates skeleton information.voidsetParameters(IParameters params)Sets new parameters for this filter.-
Methods inherited from class net.sf.okapi.common.filters.AbstractFilter
addConfiguration, addConfiguration, addConfiguration, addConfigurations, cancel, close, createEndFilterEvent, createFilterWriter, createSkeletonWriter, createStartFilterEvent, findConfiguration, getConfiguration, getConfigurations, getDisplayName, getDocumentId, getDocumentName, getEncoderManager, getEncoding, getFilterConfigurationMapper, getMimeType, getName, getNewlineType, getParameters, getParametersClassName, getParentId, getSrcLoc, getTrgLoc, isCanceled, isGenerateSkeleton, isMultilingual, removeConfiguration, setDisplayName, setDocumentName, setEncoding, setFilterConfigurationMapper, setGenerateSkeleton, setMimeType, setMultilingual, setName, setNewlineType, setOptions, setParentId, setSrcLoc, setTrgLoc
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
-
-
-
Field Detail
-
DEFAULT_TIME_FORMAT
protected static final String DEFAULT_TIME_FORMAT
- See Also:
- Constant Field Values
-
LOGGER
protected final org.slf4j.Logger LOGGER
-
eventBuilder
protected SubtitleEventBuilder eventBuilder
-
params
protected SubtitleParameters params
-
hasUtf8Bom
protected boolean hasUtf8Bom
-
hasUtf8Encoding
protected boolean hasUtf8Encoding
-
maxChar
protected int maxChar
-
maxLine
protected int maxLine
-
formatter
protected DateTimeFormatter formatter
-
terminalPattern
protected Pattern terminalPattern
-
-
Method Detail
-
setParameters
public void setParameters(IParameters params)
Description copied from interface:IFilterSets new parameters for this filter.- Specified by:
setParametersin interfaceIFilter- Overrides:
setParametersin classAbstractFilter- Parameters:
params- The new parameters to use.
-
getParameters
public SubtitleParameters getParameters()
Description copied from interface:IFilterGets the current parameters for this filter.- Specified by:
getParametersin interfaceIFilter- Overrides:
getParametersin classAbstractFilter- Returns:
- The current parameters for this filter, or
DefaultParametersif this filter has no parameters.
-
open
public void open(RawDocument input)
Description copied from interface:IFilterOpens the input document described in a give RawDocument object. Skeleton information is always created when you use this method.- Parameters:
input- The RawDocument object to use to open the document.
-
open
public void open(RawDocument input, boolean generateSkeleton)
Description copied from interface:IFilterOpens the input document described in a give RawDocument object, and optionally creates skeleton information.- Specified by:
openin interfaceIFilter- Overrides:
openin classAbstractFilter- Parameters:
input- The RawDocument object to use to open the document.generateSkeleton- true to generate the skeleton data, false otherwise.
-
getDateTimeFormatter
public static DateTimeFormatter getDateTimeFormatter(String timeFormat)
-
isUtf8Encoding
protected boolean isUtf8Encoding()
Is the input encoded as UTF-8?- Overrides:
isUtf8Encodingin classAbstractFilter- Returns:
- true if the document is in utf8 encoding.
-
isUtf8Bom
protected boolean isUtf8Bom()
Does the input have a UTF-8 Byte Order Mark?- Overrides:
isUtf8Bomin classAbstractFilter- Returns:
- true if the document has a utf-8 byte order mark.
-
isCJK
public static boolean isCJK(LocaleId localeId)
-
getMaxChar
public int getMaxChar()
-
getMaxLine
public int getMaxLine()
-
hasNext
public boolean hasNext()
Description copied from interface:IFilterIndicates if there is an event to process.Implementer Note: The caller must be able to call this method several times without changing state.
- Returns:
- True if there is at least one event to process, false if not.
-
endFilter
protected void endFilter()
-
addString
protected void addString(String string)
-
isInsideTextRun
protected boolean isInsideTextRun()
-
addToDocumentPart
protected void addToDocumentPart(String part)
-
addToTextUnit
protected void addToTextUnit(String text)
-
needToAppendWhitespace
protected static boolean needToAppendWhitespace(String str)
-
needToPrependWhitespace
protected static boolean needToPrependWhitespace(String str)
-
makeCaptionAnnotation
public CaptionAnnotation makeCaptionAnnotation()
-
getTerminalRegex
protected abstract String getTerminalRegex()
-
endsWithPunctuation
protected boolean endsWithPunctuation(String str)
-
-