de.caff.maze
Class ApplicationSystemAccess

java.lang.Object
  extended by de.caff.maze.ApplicationSystemAccess
All Implemented Interfaces:
DataStorage, SystemAccess

 class ApplicationSystemAccess
extends java.lang.Object
implements SystemAccess

System access if running as an application.

 

Nested Class Summary
 
Nested classes/interfaces inherited from interface de.caff.maze.SystemAccess
SystemAccess.FileType
 
Field Summary
static java.lang.String RESOURCE_MAZE_FILTER_DESCRIPTION
          Shortcut for mazeFilterDescription i18n resource key.
 
Fields inherited from interface de.caff.maze.SystemAccess
IMAGE_FILE_TYPE, MAZE_FILE_TYPE
 
Constructor Summary
ApplicationSystemAccess()
          Constructor.
 
Method Summary
 boolean getBoolean(java.lang.String key, boolean defaultValue)
          Get a persistent boolean value.
 java.awt.Color getColor(java.lang.String key, java.awt.Color defaultValue)
          Get a persistent color value.
 double getDouble(java.lang.String key, double defaultValue)
          Get a persistent double value.
 int getInt(java.lang.String key, int defaultValue)
          Get a persistent integer value.
 long getLong(java.lang.String key, long defaultValue)
          Get a persistent long integer value.
 java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
          Get a persistent string value.
 byte[] getUserFileContent(SystemAccess.FileType filetype)
          Get the contents of a user selected file.
 boolean hasKey(java.lang.String key)
          Is his key defined?
 boolean print(java.awt.print.Printable printable)
          Print the given printable.
 boolean saveUserFileContent(byte[] content, SystemAccess.FileType filetype)
          Save a byte array into a user selected file.
 void setBoolean(java.lang.String key, boolean value)
          Set a persistent boolean.
 void setColor(java.lang.String key, java.awt.Color value)
          Set a persistent color.
 void setDouble(java.lang.String key, double value)
          Set a persistent double value.
 void setInt(java.lang.String key, int value)
          Set a persistent integer value.
 void setLong(java.lang.String key, long value)
          Set a persistent long integer value.
 void setMainFrame(javax.swing.JFrame frame)
          Sets the main frame of the application.
 void setString(java.lang.String key, java.lang.String value)
          Set a persistent string.
 void storePersistentData()
          Store all persistent data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE_MAZE_FILTER_DESCRIPTION

public static final java.lang.String RESOURCE_MAZE_FILTER_DESCRIPTION
Shortcut for mazeFilterDescription i18n resource key.

See Also:
Constant Field Values
Constructor Detail

ApplicationSystemAccess

public ApplicationSystemAccess()
Constructor.

Method Detail

print

public boolean print(java.awt.print.Printable printable)
Print the given printable.

Specified by:
print in interface SystemAccess
Parameters:
printable - printable to be printed
Returns:
true: printing was successful, false: printing failed or was canceled

getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.String defaultValue)
Get a persistent string value. A persistent string is a string which should survive the end of the program.

Specified by:
getString in interface DataStorage
Parameters:
key - key for the string
defaultValue - default value which is returned if the string is not defined
Returns:
the string value defined by the key or the default value

setString

public void setString(java.lang.String key,
                      java.lang.String value)
Set a persistent string. The string should be stored so it may be read again in this or a later session.

Specified by:
setString in interface DataStorage
Parameters:
key - key for the string
value - the string value to store

getBoolean

public boolean getBoolean(java.lang.String key,
                          boolean defaultValue)
Get a persistent boolean value.

Specified by:
getBoolean in interface DataStorage
Parameters:
key - the key of the value
defaultValue - the default value if the key is not defined
Returns:
the boolean value defined by the key of the default value

setBoolean

public void setBoolean(java.lang.String key,
                       boolean value)
Set a persistent boolean.

Specified by:
setBoolean in interface DataStorage
Parameters:
key - key for the boolean
value - value of the boolean

getColor

public java.awt.Color getColor(java.lang.String key,
                               java.awt.Color defaultValue)
Get a persistent color value.

Specified by:
getColor in interface DataStorage
Parameters:
key - the key of the value
defaultValue - the default value if the key is not defined
Returns:
the color value deg“fined by the key of the default value

setColor

public void setColor(java.lang.String key,
                     java.awt.Color value)
Set a persistent color.

Specified by:
setColor in interface DataStorage
Parameters:
key - key for the color
value - value of the color

getInt

public int getInt(java.lang.String key,
                  int defaultValue)
Get a persistent integer value.

Specified by:
getInt in interface DataStorage
Parameters:
key - the key of the value
defaultValue - the default value if the key is not defined
Returns:
the integer value defined by the key of the default value

setInt

public void setInt(java.lang.String key,
                   int value)
Set a persistent integer value.

Specified by:
setInt in interface DataStorage
Parameters:
key - key for the int
value - value of the int

getLong

public long getLong(java.lang.String key,
                    long defaultValue)
Get a persistent long integer value.

Specified by:
getLong in interface DataStorage
Parameters:
key - the key of the value
defaultValue - the default value if the key is not defined
Returns:
the long integer value defined by the key of the default value

setLong

public void setLong(java.lang.String key,
                    long value)
Set a persistent long integer value.

Specified by:
setLong in interface DataStorage
Parameters:
key - key for the long int
value - value of the long int

getDouble

public double getDouble(java.lang.String key,
                        double defaultValue)
Get a persistent double value.

Specified by:
getDouble in interface DataStorage
Parameters:
key - the key of the value
defaultValue - the default value if the key is not defined
Returns:
the double value defined by the key of the default value

setDouble

public void setDouble(java.lang.String key,
                      double value)
Set a persistent double value.

Specified by:
setDouble in interface DataStorage
Parameters:
key - key for the int
value - value of the int

hasKey

public boolean hasKey(java.lang.String key)
Is his key defined?

Specified by:
hasKey in interface DataStorage
Parameters:
key - key to look for
Returns:
true if the key is defined, false otherwise

storePersistentData

public void storePersistentData()
Store all persistent data. This is called when the process is about to shutdown.

Specified by:
storePersistentData in interface DataStorage

getUserFileContent

public byte[] getUserFileContent(SystemAccess.FileType filetype)
                          throws java.io.IOException
Get the contents of a user selected file.

Specified by:
getUserFileContent in interface SystemAccess
Throws:
java.io.IOException - on errors during file access
Parameters:
filetype - type of file to be used
Returns:
byte array or null if the user canceled the operation

saveUserFileContent

public boolean saveUserFileContent(byte[] content,
                                   SystemAccess.FileType filetype)
                            throws java.io.IOException
Save a byte array into a user selected file.

Specified by:
saveUserFileContent in interface SystemAccess
Throws:
java.io.IOException - on errors during file access
Parameters:
content - the content of the file
filetype - type of file to be used
Returns:
true if the user saved the file, false otherwise

setMainFrame

public void setMainFrame(javax.swing.JFrame frame)
Sets the main frame of the application. This is useful for centering dialogs.

Specified by:
setMainFrame in interface SystemAccess
Parameters:
frame - application's main frame