public abstract class AbstractSaver extends ChangeMonitor implements ChangeMonitorable, Savable
| Constructor and Description |
|---|
AbstractSaver() |
| Modifier and Type | Method and Description |
|---|---|
void |
addFileExtension(java.lang.String ext)
Adds an file extension to the list of the allowed file extensions which can be entered
by the user in the save as dialog.
|
abstract boolean |
askToSave()
Promts the user wheather to save changed data and calls save() if necessary.
|
boolean |
endsWithDefaultExt(java.lang.String path)
Tests if the given string ends with the default file extension.
|
boolean |
endsWithValidExt(java.lang.String path)
Tests if the given string ends with one of the valid file extensions stored.
|
java.lang.String |
getDefaultExtension()
The file extension which should be add to file name chosen in the save as dialog,
if not one of the allowed ones is already present.
|
java.lang.String |
getDefaultName()
The path that should be proposed by the saveAs()-method if no path has been assigned.
|
java.lang.String |
getDefaultNameOrPath()
The path of the assigned file or the default name if no file has been specified.
|
java.io.File |
getFile()
Returns the assigned file.
|
java.lang.String[] |
getFileExtensions() |
boolean |
hasFile()
Checks weather a file has been assigned
|
void |
removeFileExtention(java.lang.String ext) |
boolean |
save()
This method should save the data to a file defined by the path and should call
saveAs() if no path was assigned.
|
abstract boolean |
saveAs()
Promts the user der select a path to save the data.
|
protected abstract void |
saveDataToFile(java.io.File file) |
void |
setDefaultExtension(java.lang.String ext) |
void |
setDefaultName(java.lang.String path)
Sets the path that should be proposed by the saveAs()-method if no path has been
assigned.
|
void |
setFile(java.io.File file)
Manually assignes a path.
|
hasChanged, registerChange, resetclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithasChanged, registerChange, resetpublic AbstractSaver()
public void addFileExtension(java.lang.String ext)
SavableaddFileExtension in interface Savableext - the extension to add starting with a "."public java.lang.String getDefaultExtension()
SavablegetDefaultExtension in interface Savablepublic java.lang.String[] getFileExtensions()
getFileExtensions in interface Savablepublic void removeFileExtention(java.lang.String ext)
removeFileExtention in interface Savablepublic void setDefaultExtension(java.lang.String ext)
setDefaultExtension in interface Savablepublic boolean endsWithDefaultExt(java.lang.String path)
SavableendsWithDefaultExt in interface Savablepath - the path or file name to testpublic boolean endsWithValidExt(java.lang.String path)
SavableendsWithValidExt in interface Savablepath - the path or file name to testprotected abstract void saveDataToFile(java.io.File file)
public abstract boolean askToSave()
Savabletrue.public java.lang.String getDefaultName()
SavablegetDefaultName in interface Savablepublic java.io.File getFile()
Savablepublic boolean hasFile()
Savablepublic java.lang.String getDefaultNameOrPath()
SavablegetDefaultNameOrPath in interface Savablepublic boolean save()
Savablepublic abstract boolean saveAs()
Savablepublic void setDefaultName(java.lang.String path)
SavablesetDefaultName in interface Savable