java.lang.Object | +--TextFileHolder
Provides ability to connect in read-only mode to files, much like
the Acrobat Reader, but GUI is assumed to be implemented via
interface TextFileView.
LinkedList.
LinkedList,
TextFileView| Constructor Summary | |
TextFileHolder(String filename,
TextFileView view)
Opens a given file and shows it in a given TextFileView. |
|
| Method Summary | |
static File |
fetchFile(String filename)
Provides a file object from a given filename. |
String |
getContent()
Provides the contents of the file held by this object. |
String |
getTargetName()
Provides the name of the file held by this object. |
boolean |
isEmpty()
Tells whether this object does not hold any file. |
void |
processClose()
Usually notified this object to clean up itself and destroy its view. |
static void |
processExit()
Terminated this Runtime. |
static void |
processOpen(String filename,
TextFileView view)
Just create a new TextFileHolder showing file
filename in the given TextFileView |
static String |
readFile(File file)
Provides the contents of a given file. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public TextFileHolder(String filename,
TextFileView view)
throws IOException
TextFileView.
Opening the null-String file results only in a new
TextFileView, if currently no instance of
TextFileHolder exists. If the given file is already
held by another instance of TextFileHolder, its
view will come into front.
filename - name of the file to be held by this new object
and that should be shown in viewview - if a new TextFileHolder is accepted due
to the policy described in this constructor's comments,
the contents of its target will be shown in view
if - I/O errors occur, in particular if filename
does not exist, is not a regular file, or is not readable
IOException| Method Detail |
public final String getTargetName()
null if
no file is held by this instancepublic final String getContent()
null if
no file is held by this instance
public static final void processOpen(String filename,
TextFileView view)
throws IOException
TextFileHolder showing file
filename in the given TextFileView
filename - name of the file to be held by a new object
and that should be shown in viewview - if a new TextFileHolder is accepted due
to the policy described in the constructor's comments,
the contents of its target will be shown in view
if - I/O errors occur, in particular if filename
does not exist, is not a regular file, or is not readable
IOExceptionTextFileHolder(String, TextFileView)public final void processClose()
TextFileHolder, then we distinguish two cases.
Either this object still holds a file. Then the connection
to that file will be dropped. Or this object did not held
any file already before. Then this Runtime will be shut.
processExit()public static final void processExit()
System.exit(int)public final boolean isEmpty()
true iff this object does not hold any file
public static String readFile(File file)
throws IOException
file - the file to provide its contents
IOException - if opening, reading, or closing file
via a BufferedReader technically failsBufferedReader
public static File fetchFile(String filename)
throws IOException
filename - the name of the file to get an object to
IOException - if the given file does not exist,
is not a regular file, or is not readable