org.openpermis.editor.policy
Class ApplicationState

java.lang.Object
  extended by org.openpermis.editor.policy.ApplicationState

public final class ApplicationState
extends Object

Describes persistent application state.

Since:
0.1.0

Field Summary
private  PropertyChangeSupport propertyChangeSupport
          The property change support for bound properties.
private  String[] recentFiles
          List of recent files, never null.
private  String workingDirectory
          The working directory of the application.
 
Constructor Summary
ApplicationState()
          Creates a new application state.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a property change listener that gets notified on bound property changes.
 void addRecentFiles(String file)
          Convenience method to add a file entry to the recent files list.
private  void assertValidRecentFilesIndex(int index)
          Checks if the specified recent files index is valid.
 String[] getRecentFiles()
          Returns a clone of the recent files list of this application state.
 String getRecentFiles(int index)
          Returns a recent files entry at the specified index.
private  String getRecentFilesAsString()
          Returns a string representation for the recent files list.
 int getRecentFilesCount()
          Returns the number of recent files stored at this application state.
 String getWorkingDirectory()
          Returns the working directory bean property.
 File getWorkingDirectoryFile()
          Returns the application working directory as file.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes the specified property change listener.
 void removeRecentFiles(int index)
          Convenience method to remove the file entry at the specified index.
 void setRecentFiles(int index, String file)
          Sets the recent files entry at the specified index.
 void setRecentFiles(String[] files)
          Sets the recent files list of this application state.
 void setWorkingDirectory(String workingDirectory)
          Sets the working directory bean property.
 void setWorkingDirectoryFile(File file)
          Sets the application working directory from the given file.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

workingDirectory

private String workingDirectory
The working directory of the application.

Since:
0.1.0

recentFiles

private String[] recentFiles
List of recent files, never null.

Since:
0.1.0

propertyChangeSupport

private final PropertyChangeSupport propertyChangeSupport
The property change support for bound properties.

Since:
0.1.0
Constructor Detail

ApplicationState

public ApplicationState()
Creates a new application state.

Since:
0.1.0
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a property change listener that gets notified on bound property changes.

The same listener object may be added more than once, and will be called as many times as it is added. If listener is null, no exception is thrown and no action is taken.

Parameters:
listener - the listener to add.
Since:
0.1.0

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes the specified property change listener.

If listener was added more than once to the same event source, it will be notified one less time after being removed. If listener is null, or was never added, no exception is thrown and no action is taken.

Parameters:
listener - the listener to remove.
Since:
0.1.0

getWorkingDirectory

public String getWorkingDirectory()
Returns the working directory bean property.

Use the file version if you are interested in an actual File object.

Returns:
the working directory bean property.
See Also:
getWorkingDirectoryFile()
Since:
0.1.0

setWorkingDirectory

public void setWorkingDirectory(String workingDirectory)
Sets the working directory bean property.

Use the file version if your source is an actual File object.

Parameters:
workingDirectory - the working directory bean property.
See Also:
setWorkingDirectoryFile(File)
Since:
0.1.0

getWorkingDirectoryFile

public File getWorkingDirectoryFile()
Returns the application working directory as file.

Convenience method for the working directory bean property.

Returns:
the application working directory as file.
See Also:
getWorkingDirectory()
Since:
0.1.0

setWorkingDirectoryFile

public void setWorkingDirectoryFile(File file)
Sets the application working directory from the given file.

If the file denotes a directory it is used as is, in case of a plain file the parent directory is chosen.

Convenience method for the working directory bean property.

Parameters:
file - the working directory to set.
See Also:
setWorkingDirectory(String)
Since:
0.1.0

getRecentFiles

public String getRecentFiles(int index)
Returns a recent files entry at the specified index.

Parameters:
index - the index of the recent files entry to retrieve.
Returns:
the recent files entry requested or null if there is no such entry.
Since:
0.1.0

getRecentFilesCount

public int getRecentFilesCount()
Returns the number of recent files stored at this application state.

Returns:
the number of recent files stored at this application state.
Since:
0.1.0

getRecentFiles

public String[] getRecentFiles()
Returns a clone of the recent files list of this application state.

Returns:
the recent files list requested, guaranteed not to be null.
Since:
0.1.0

assertValidRecentFilesIndex

private void assertValidRecentFilesIndex(int index)
Checks if the specified recent files index is valid.

Parameters:
index - the index to check.
Throws:
IllegalArgumentException - if the index is not valid.
Since:
0.1.0

setRecentFiles

public void setRecentFiles(int index,
                           String file)
Sets the recent files entry at the specified index.

Parameters:
index - the index of the file entry to set, [0..getRecentFilesCount()[.
file - the file to entry to set, null to remove the entry.
See Also:
getRecentFilesCount()
Throws:
IllegalArgumentException - if the index is not a valid index.
Since:
0.1.0

removeRecentFiles

public void removeRecentFiles(int index)
Convenience method to remove the file entry at the specified index.

This method changes the whole recent files list.

Parameters:
index - the index of the file entry to set, [0..getRecentFilesCount()[.
Throws:
IllegalArgumentException - if the index is not a valid index.
Since:
0.1.0

addRecentFiles

public void addRecentFiles(String file)
Convenience method to add a file entry to the recent files list.

This method does nothing if the file entry is null or there is already a file entry equal to the one specified contained.

This method changes the whole recent files list.

Parameters:
file - the file entry to add, may be null.
Since:
0.1.0

setRecentFiles

public void setRecentFiles(String[] files)
Sets the recent files list of this application state.

Parameters:
files - the new files list to set, null to set an empty files list.
Since:
0.1.0

getRecentFilesAsString

private String getRecentFilesAsString()
Returns a string representation for the recent files list.

Returns:
the string representation for the recent files list.
Since:
0.1.0

toString

public String toString()
Overrides:
toString in class Object
Since:
0.1.0


PERMIS Role Based Access Control 0.4.0 (Build 15)
2009/05/20 08:15:22
Copyright (c) 2002-2007 Ergon Informatik AG