|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsears.file.SubtitleFile
public abstract class SubtitleFile
Class SubtitleFile.
Summary:
This class represents a subtitle file.
It provides facilities on subtitles, as delay, resynchro.
It must be specialized to the subtitle file type you want to open.
You would have to use the getInstance(File, ArrayList, String)
static method for this
Field Summary | |
---|---|
static java.lang.String[] |
BASIC_CHARSETS
Represents an array of charsets that Sears can use to parse a file if an error occurs with the default one |
static java.lang.String |
DEFAULT_CHARSET
The default charset that Sears use to parse a subtitle file: "ISO-8859-1" |
protected java.io.File |
file
The system File that contains the file |
protected boolean |
fileChanged
A boolean to know if file has changed |
protected java.util.ArrayList<Subtitle> |
subtitleList
The ArrayList of subtitles found |
protected java.io.File |
temporaryFile
The temporary file |
Constructor Summary | |
---|---|
SubtitleFile()
Constructor SubtitleFile. |
|
SubtitleFile(java.io.File _file,
java.util.ArrayList<Subtitle> _subtitlesList)
Constructor SubtitleFile. |
|
SubtitleFile(java.io.File _file,
java.util.ArrayList<Subtitle> _subtitlesList,
java.lang.String charset)
Constructor SubtitleFile. |
|
SubtitleFile(java.lang.String fileToOpen,
java.util.ArrayList<Subtitle> _subtitlesList)
Constructor SubtitleFile. |
Method Summary | |
---|---|
void |
accentRepair(int[] selectedIndex)
Method accentRepair. |
void |
addFakeSub()
Method addFakeSub. |
void |
addSubtitle(Subtitle subtitle)
Method addSubtitle. |
void |
addSubtitle(Subtitle subtitle,
boolean updateNumber)
Method addSubtitle. |
void |
append(SubtitleFile subtitleFileToAppend,
int delay)
Method append. |
void |
delay(int delay)
Method delay. |
void |
delay(int[] indexToDelay,
int delay)
Method delay. |
void |
delay(int beginIndex,
int endIndex,
int delay)
Method delay. |
abstract java.lang.String |
extension()
Returns the extension file |
void |
fileChanged()
Method fileChanged Summary: Set the fileChanged status flag to true. |
protected static java.lang.String |
getANonNullCharset(java.lang.String charset)
Returns charset if it is non null, else DEFAULT_CHARSET is returned |
java.lang.String |
getCharset()
Returns the charset used for write and read operations |
java.io.File |
getContentDirectory()
Method getContentDirectory. |
java.io.File |
getFile()
Method getFile. |
static SubtitleFile |
getInstance(java.io.File file,
java.util.ArrayList<Subtitle> subtitleList)
Same that getInstance(File, ArrayList, String) . |
static SubtitleFile |
getInstance(java.io.File file,
java.util.ArrayList<Subtitle> subtitleList,
java.lang.String charset)
Returns an instance of a SubtitleFile implementation class
which represents the subtitle type of the given java.io.File object. |
static SubtitleFile |
getInstance(java.io.File file,
java.util.ArrayList<Subtitle> subtitleList,
java.lang.String charset,
boolean useEmptyConstructor)
Returns an instance of a SubtitleFile implementation class
which represents the subtitle type of the given java.io.File object. |
static java.lang.String |
getLineSeparator()
Returns the line separator (end of line) to use (depends to the user choice). |
protected abstract SubtitleFile |
getNewInstance()
Method getNewInstance. |
Subtitle |
getSubtitleAtDate(int date)
Method getSubtitleIndex. |
java.util.ArrayList<Subtitle> |
getSubtitleList()
Method getSubtitleList. |
java.util.ArrayList<Subtitle> |
getSubtitleListClone()
Method getSubtitleListClone. |
protected java.util.ArrayList<Subtitle> |
getSubtitles()
Method getSubtitles. |
java.io.File |
getTemporaryFile()
Method getTemporaryFile. |
void |
htmlRepair(int[] selectedIndex)
Method htmlRepair. |
boolean |
isFileChanged()
|
void |
magicResynchro()
Method magicResynchro. |
boolean |
mixWithAnotherSubtitleFile(SubtitleFile theOtherSubtitleFile,
boolean keepSubtitles)
Mix subtitle files keeps times and copy subtiles from another subtitle file. |
void |
normalizeDuration(int[] indexToNormalize,
int minDuration,
int maxDuration)
Method normalizeDuration. |
void |
normalizeDuration(int minDuration,
int maxDuration)
Method normalizeDuration. |
void |
orderRepair()
Method orderRepair. |
protected abstract void |
parse()
Method parse. |
void |
resynchro(int[] result)
Method resynchro. |
void |
setCharset(java.lang.String charset)
Changes the charset, if a non null value is given, DEFAULT_CHARSET is set as the used charset |
void |
setFile(java.io.File file)
Method setFile. |
void |
setSubtitleList(java.util.ArrayList<Subtitle> subtitleList)
Method setSubtitleList. |
protected void |
shiftToZero()
Method shiftToZero. |
SubtitleFile[] |
split(java.io.File[] destinationFiles,
int subtitleIndex,
int secondPartDelay)
Method split. |
static int |
stringToTime(java.lang.String time)
Method stringToTime. |
void |
timeRepair()
Method timeRepair. |
static java.lang.String |
timeToString(int milliseconds)
Method timeToString. |
abstract void |
writeToFile(java.io.File fileToWrite)
Method writeToFile. |
abstract void |
writeToTemporaryFile()
Method writeToTemporaryFile. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.io.File file
protected java.util.ArrayList<Subtitle> subtitleList
protected boolean fileChanged
protected java.io.File temporaryFile
public static final java.lang.String DEFAULT_CHARSET
public static final java.lang.String[] BASIC_CHARSETS
Constructor Detail |
---|
public SubtitleFile()
public SubtitleFile(java.lang.String fileToOpen, java.util.ArrayList<Subtitle> _subtitlesList) throws FileConversionException
fileToOpen
- The (String) path to file to open._subtitlesList
- The (ArrayList) List of subtitles.
FileConversionException
- if a limitation when reading the file appearspublic SubtitleFile(java.io.File _file, java.util.ArrayList<Subtitle> _subtitlesList) throws FileConversionException
_file
- The (File) file to open._subtitlesList
- The (ArrayList) List of subtitles.
FileConversionException
- if a limitation when reading the file appearspublic SubtitleFile(java.io.File _file, java.util.ArrayList<Subtitle> _subtitlesList, java.lang.String charset) throws FileConversionException
_file
- The (File) file to open._subtitlesList
- The (ArrayList) List of subtitles.charset
- The charset to use during operations on the file ...
FileConversionException
- if a limitation when reading the file appearsMethod Detail |
---|
protected static java.lang.String getANonNullCharset(java.lang.String charset)
charset
- the charset to test
public java.lang.String getCharset()
public void setCharset(java.lang.String charset)
charset
- the new charset to usepublic static java.lang.String getLineSeparator()
public abstract java.lang.String extension()
protected abstract void parse() throws FileConversionException
FileConversionException
- if a limitation when reading the file appearspublic java.io.File getContentDirectory()
public java.io.File getFile()
public java.io.File getTemporaryFile()
public static java.lang.String timeToString(int milliseconds)
milliseconds
- The number of milliseconds to transform
public static int stringToTime(java.lang.String time) throws java.lang.NumberFormatException
time
- The string srt time representation.
java.lang.NumberFormatException
- if there's a time errorpublic abstract void writeToFile(java.io.File fileToWrite) throws FileConversionException
fileToWrite
- The File to write the file.
FileConversionException
public abstract void writeToTemporaryFile()
public void addFakeSub()
public void delay(int beginIndex, int endIndex, int delay)
beginIndex
- The first index to begin delay.endIndex
- The last index to put a delaydelay
- The delay to Apply.public void delay(int[] indexToDelay, int delay)
indexToDelay
- The array of subtitle's index to be delayed.delay
- The delay to apply.public void delay(int delay)
delay
- The delay to apply.public void normalizeDuration(int minDuration, int maxDuration)
minDuration
- The min duration to ensure.maxDuration
- The max duration to ensure.public void normalizeDuration(int[] indexToNormalize, int minDuration, int maxDuration)
indexToNormalize
- The array of subtitle index to be normalized.minDuration
- The min duration to ensure.maxDuration
- The max duration to ensure.public void resynchro(int[] result)
result
- The resynchro parameter, an int array organized like this:
[0]:The source 1
[1]:The destination 1
[2]:The source 2
[3]:The destination 2public void setFile(java.io.File file)
file
- The file to set.public void addSubtitle(Subtitle subtitle)
subtitle
- The Subtitle to add to the file.public void addSubtitle(Subtitle subtitle, boolean updateNumber)
subtitle
- The Subtitle to add to the file.updateNumber
- A boolean, true if want to update the number with its index. False not to update it.public SubtitleFile[] split(java.io.File[] destinationFiles, int subtitleIndex, int secondPartDelay)
destinationFiles
- The File[] where to save the two parts of the file.subtitleIndex
- The int subtitle index, from wich create the second part of the subtitle.secondPartDelay
- The int initial delay to apply to the second part.
protected void shiftToZero()
protected abstract SubtitleFile getNewInstance()
public void append(SubtitleFile subtitleFileToAppend, int delay)
subtitleFileToAppend
- The SubtitleFile subtitle file to append.delay
- The int delay to use.protected java.util.ArrayList<Subtitle> getSubtitles()
public boolean isFileChanged()
public void fileChanged()
public void accentRepair(int[] selectedIndex)
selectedIndex
- The index to remove the accents.public void htmlRepair(int[] selectedIndex)
selectedIndex
- The index to remove the accents.public void timeRepair()
public void orderRepair()
public Subtitle getSubtitleAtDate(int date)
date
- The date (in milliseconds).
public void magicResynchro()
public boolean mixWithAnotherSubtitleFile(SubtitleFile theOtherSubtitleFile, boolean keepSubtitles)
theOtherSubtitleFile
- a SubtitleFile
objectkeepSubtitles
- true, the subtitles are kept, false the times are kept
this
are changed, false if notpublic static SubtitleFile getInstance(java.io.File file, java.util.ArrayList<Subtitle> subtitleList, java.lang.String charset, boolean useEmptyConstructor) throws FileConversionException, java.lang.Exception
SubtitleFile
implementation class
which represents the subtitle type of the given java.io.File
object.
SrtFile
)
file
- the subtitle filesubtitleList
- the subtitles listuseEmptyConstructor
- True if you want to call the empty constructor of the instance. false If you want the full constructor of subtitleFile to be called (will parse the file)
SubtitleFile
implementation class,
null if an error occurs
FileConversionException
- if a limitation when reading the file appears
java.lang.Exception
- // --temporary-- //public static SubtitleFile getInstance(java.io.File file, java.util.ArrayList<Subtitle> subtitleList, java.lang.String charset) throws FileConversionException, java.lang.Exception
SubtitleFile
implementation class
which represents the subtitle type of the given java.io.File
object.
SrtFile
)
file
- the subtitle filesubtitleList
- the subtitles list
SubtitleFile
implementation class,
null if an error occurs
FileConversionException
- if a limitation when reading the file appears
java.lang.Exception
- // --temporary-- //public static SubtitleFile getInstance(java.io.File file, java.util.ArrayList<Subtitle> subtitleList) throws FileConversionException, java.lang.Exception
getInstance(File, ArrayList, String)
.
file
- the subtitle filesubtitleList
- the subtitle list to fill
FileConversionException
- if an error occurs
java.lang.Exception
- if an untraitable error occurs [to solved]public java.util.ArrayList<Subtitle> getSubtitleList()
public void setSubtitleList(java.util.ArrayList<Subtitle> subtitleList)
subtitleList
- the subtitleList to setpublic java.util.ArrayList<Subtitle> getSubtitleListClone()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |