com.jme.system
Class PropertiesIO

java.lang.Object
  extended by com.jme.system.PropertiesIO

public class PropertiesIO
extends java.lang.Object

PropertiesIO handles loading and saving a properties file that defines the display settings. A property file is identified during creation of the object. The properties file should have the following format:

FREQ=60
RENDERER=LWJGL
WIDTH=1280
HEIGHT=1024
DEPTH=32
FULLSCREEN=false

Version:
$Id: PropertiesIO.java 4131 2009-03-19 20:15:28Z blaine.dev $
Author:
Mark Powell

Field Summary
static int DEFAULT_DEPTH
          The default depth, used if there is a problem with the properties file.
static int DEFAULT_FREQ
          The default frequency, used if there is a problem with the properties file.
static boolean DEFAULT_FULLSCREEN
          The default fullscreen flag, used if there is a problem with the properties file.
static int DEFAULT_HEIGHT
          The default height, used if there is a problem with the properties file.
static java.lang.String DEFAULT_RENDERER
          The default renderer flag, used if there is a problem with the properties file.
static int DEFAULT_WIDTH
          The default width, used if there is a problem with the properties file.
 
Constructor Summary
PropertiesIO(java.lang.String filename)
          Constructor creates the PropertiesIO object for use.
 
Method Summary
 java.lang.String get(java.lang.String key)
          get takes an arbitrary string as a key and returns any value associated with it, null if none.
 int getDepth()
          getDepth returns the depth as read from the properties file.
 int getFreq()
          getFreq returns the frequency of the monitor as read from the properties file.
 boolean getFullscreen()
          getFullscreen returns the fullscreen flag as read from the properties file.
 int getHeight()
          getHeight returns the height as read from the properties file.
 java.lang.String getRenderer()
          getRenderer returns the requested rendering API, or the default.
 int getWidth()
          getWidth returns the width as read from the properties file.
 boolean load()
          load attempts to load the properties file defined during instantiation and put all properties in the table.
 boolean save(int width, int height, int depth, int freq, boolean fullscreen, java.lang.String renderer)
          save overwrites the properties file with the given parameters.
 void set(java.lang.String key, java.lang.String value)
          set adds a key/value pair to the properties list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_WIDTH

public static final int DEFAULT_WIDTH
The default width, used if there is a problem with the properties file.

See Also:
Constant Field Values

DEFAULT_HEIGHT

public static final int DEFAULT_HEIGHT
The default height, used if there is a problem with the properties file.

See Also:
Constant Field Values

DEFAULT_DEPTH

public static final int DEFAULT_DEPTH
The default depth, used if there is a problem with the properties file.

See Also:
Constant Field Values

DEFAULT_FREQ

public static final int DEFAULT_FREQ
The default frequency, used if there is a problem with the properties file.

See Also:
Constant Field Values

DEFAULT_FULLSCREEN

public static final boolean DEFAULT_FULLSCREEN
The default fullscreen flag, used if there is a problem with the properties file.

See Also:
Constant Field Values

DEFAULT_RENDERER

public static final java.lang.String DEFAULT_RENDERER
The default renderer flag, used if there is a problem with the properties file.

See Also:
Constant Field Values
Constructor Detail

PropertiesIO

public PropertiesIO(java.lang.String filename)
Constructor creates the PropertiesIO object for use.

Parameters:
filename - the properties file to use.
Throws:
JmeException - if the filename is null.
Method Detail

load

public boolean load()
load attempts to load the properties file defined during instantiation and put all properties in the table. If there is a problem loading or reading the file, false is returned. If all goes well, true is returned.

Returns:
the success of the load, true indicated success and false indicates failure.

save

public boolean save(int width,
                    int height,
                    int depth,
                    int freq,
                    boolean fullscreen,
                    java.lang.String renderer)
save overwrites the properties file with the given parameters.

Parameters:
width - the width of the resolution.
height - the height of the resolution.
depth - the bits per pixel.
freq - the frequency of the monitor.
fullscreen - use fullscreen or not.
Returns:
true if save was successful, false otherwise.

getWidth

public int getWidth()
getWidth returns the width as read from the properties file. If the properties file does not contain width or was not read properly, the default width is returned.

Returns:
the width determined by the properties file, or the default.

getHeight

public int getHeight()
getHeight returns the height as read from the properties file. If the properties file does not contain height or was not read properly, the default height is returned.

Returns:
the height determined by the properties file, or the default.

getDepth

public int getDepth()
getDepth returns the depth as read from the properties file. If the properties file does not contain depth or was not read properly, the default depth is returned.

Returns:
the depth determined by the properties file, or the default.

getFreq

public int getFreq()
getFreq returns the frequency of the monitor as read from the properties file. If the properties file does not contain frequency or was not read properly the default frequency is returned.

Returns:
the frequency determined by the properties file, or the default.

getFullscreen

public boolean getFullscreen()
getFullscreen returns the fullscreen flag as read from the properties file. If the properties file does not contain the fullscreen flag or was not read properly, the default fullscreen flag is returned.

Returns:
the fullscreen flag determined by the properties file, or the default.

getRenderer

public java.lang.String getRenderer()
getRenderer returns the requested rendering API, or the default.

Returns:
the rendering API or the default.

get

public java.lang.String get(java.lang.String key)
get takes an arbitrary string as a key and returns any value associated with it, null if none.

Parameters:
key - the key to use for data retrieval.
Returns:
the string associated with the key, null if none.

set

public void set(java.lang.String key,
                java.lang.String value)
set adds a key/value pair to the properties list.

Parameters:
key - the key of the pair.
value - the value of the pair.