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, reset
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
hasChanged, registerChange, reset
public AbstractSaver()
public void addFileExtension(java.lang.String ext)
Savable
addFileExtension
in interface Savable
ext
- the extension to add starting with a "."public java.lang.String getDefaultExtension()
Savable
getDefaultExtension
in interface Savable
public java.lang.String[] getFileExtensions()
getFileExtensions
in interface Savable
public void removeFileExtention(java.lang.String ext)
removeFileExtention
in interface Savable
public void setDefaultExtension(java.lang.String ext)
setDefaultExtension
in interface Savable
public boolean endsWithDefaultExt(java.lang.String path)
Savable
endsWithDefaultExt
in interface Savable
path
- the path or file name to testpublic boolean endsWithValidExt(java.lang.String path)
Savable
endsWithValidExt
in interface Savable
path
- the path or file name to testprotected abstract void saveDataToFile(java.io.File file)
public abstract boolean askToSave()
Savable
true
.public java.lang.String getDefaultName()
Savable
getDefaultName
in interface Savable
public java.io.File getFile()
Savable
public boolean hasFile()
Savable
public java.lang.String getDefaultNameOrPath()
Savable
getDefaultNameOrPath
in interface Savable
public boolean save()
Savable
public abstract boolean saveAs()
Savable
public void setDefaultName(java.lang.String path)
Savable
setDefaultName
in interface Savable