sears.file
Class FileSystemAccess

java.lang.Object
  extended by sears.file.FileSystemAccess

public class FileSystemAccess
extends java.lang.Object

Provides access method to file like open and save
An instance of this class captures error coming from the conversion of file to subtitle file


Field Summary
static int MAX_SUBTITLE_FILE_SIZE
          (int) maximum authorized size for a subtitle file, 2 Mo
 
Constructor Summary
protected FileSystemAccess(MainWindow mainWindow)
          Default constructor
 
Method Summary
static FileSystemAccess getInstance()
          Gives the same instance of this class
Only used by MainWindow class
 SubtitleFile openFile(java.io.File file, java.util.ArrayList<Subtitle> subtitleList, java.lang.String charset)
          Provides a way to get SubtitleFile instance from a file
If an error occurs an error dialog is called
 SubtitleFile openFile(java.io.File file, java.lang.String charset)
          Provides a way to get a SubtitleFile instance from a file
 boolean saveFile(java.io.File file, SubtitleFile subtitleFile, java.lang.String charset)
          Writes the subtitle to a file and invokes an error dialog if an error occurs during the action
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_SUBTITLE_FILE_SIZE

public static final int MAX_SUBTITLE_FILE_SIZE
(int) maximum authorized size for a subtitle file, 2 Mo

See Also:
Constant Field Values
Constructor Detail

FileSystemAccess

protected FileSystemAccess(MainWindow mainWindow)
Default constructor

Parameters:
mainWindow - the extended controller
Method Detail

getInstance

public static FileSystemAccess getInstance()
Gives the same instance of this class
Only used by MainWindow class

Returns:
an object instance of FileSystemAccess class.

openFile

public SubtitleFile openFile(java.io.File file,
                             java.lang.String charset)
Provides a way to get a SubtitleFile instance from a file

Parameters:
file - the file to convert
charset - the charset used for the conversion
Returns:
the SubtitleFile object created or null if an error occurs

openFile

public SubtitleFile openFile(java.io.File file,
                             java.util.ArrayList<Subtitle> subtitleList,
                             java.lang.String charset)
Provides a way to get SubtitleFile instance from a file
If an error occurs an error dialog is called

Parameters:
file - the file to convert
subtitleList - the subtitle list to fill
charset - the charset used for the conversion
Returns:
the SubtitleFile object created or null if an error occurs

saveFile

public boolean saveFile(java.io.File file,
                        SubtitleFile subtitleFile,
                        java.lang.String charset)
Writes the subtitle to a file and invokes an error dialog if an error occurs during the action

Parameters:
file - the file in which the subtitle must be write
subtitleFile - the subtitle to write
charset - the charset used to write the file, if null the subtitle's charset will be used
Returns:
true if action succeed, false if not