|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsears.file.FileConversion
public abstract class FileConversion
This class must be implemented each time a java.io.File object will have to be converted to
a sears.file.SubtitleFile object
It wrap a BufferedReader and gives method to access to it with respect of the Sears constraints
Field Summary | |
---|---|
protected java.io.File |
file
|
protected int |
lineCount
|
Constructor Summary | |
---|---|
FileConversion(java.io.File file,
java.lang.String charset)
Constructs a new instance |
Method Summary | |
---|---|
protected void |
closeReader()
Closes the reader and reset line count |
protected void |
ensureStringIsValid(java.lang.String str)
Tests the validity of str return true if str is not null and if it is not an empty String, false if not |
protected abstract Subtitle |
getSubtitle(java.lang.String line)
Constructs and returns the Subtitle object which represents subtitles information begin at line given in parameters This method is used by the non abstract parse(ArrayList) method |
protected java.lang.String |
getTheNextNonEmptyLine()
Place the 'read head' on the next non empty line and returns it |
void |
parse(java.util.ArrayList<Subtitle> subtitleList)
Principal method: parses file and fill the array list given in parameters with founded subtitles informations If there's no subtitles found, the array list stays as it was before |
protected java.lang.String |
readLine()
Reads and returns the next line in the buffer and increment the line count |
protected static java.lang.String |
subString(java.lang.String str)
If str length is more than 100 characters, str is cut and returned |
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 int lineCount
Constructor Detail |
---|
public FileConversion(java.io.File file, java.lang.String charset) throws FileConversionException
file
- the file to parsecharset
- the charset used to read the file
java.lang.NullPointerException
- if file or/and charset are null
FileConversionException
Method Detail |
---|
public void parse(java.util.ArrayList<Subtitle> subtitleList) throws FileConversionException
subtitleList
- the array of subtitles to fill
FileConversionException
- if an error occurs during the conversionprotected abstract Subtitle getSubtitle(java.lang.String line) throws FileConversionException
parse(ArrayList)
method
line
- the first line...
FileConversionException
- if an error occurs during the conversionprotected java.lang.String readLine() throws FileConversionException
FileConversionException
- if a basic IOException occurs when
attempts to read in the bufferprotected java.lang.String getTheNextNonEmptyLine() throws FileConversionException
FileConversionException
protected void closeReader() throws FileConversionException
FileConversionException
- if a basic IOException occurs when
attempts to close the the buffer readerprotected void ensureStringIsValid(java.lang.String str) throws FileConversionException
java.io.IOException
FileConversionException
protected static java.lang.String subString(java.lang.String str)
str
- the string to cut
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |