|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Dictionary<K,V>
java.util.Hashtable<java.lang.Object,java.lang.Object>
java.util.Properties
simtools.ui.UserProperties
public class UserProperties
This class returns a user preferences as saved at previous use of the tool
Nested Class Summary | |
---|---|
protected static class |
UserProperties.Info
The information class |
Field Summary | |
---|---|
protected java.io.File |
_file
The file to read and write properties to |
protected java.util.LinkedList |
_infoList
List of informations to write sorted properties in file. |
protected java.lang.String |
_productName
The product name to apply properties to |
protected boolean |
_propertiesLoadedFromFile
|
protected static char[] |
hexDigit
A table of hex digits |
protected static java.lang.String |
keyValueSeparators
|
protected static java.lang.String |
specialSaveChars
|
protected static java.lang.String |
strictKeyValueSeparators
|
protected static java.lang.String |
whiteSpaceChars
|
Fields inherited from class java.util.Properties |
---|
defaults |
Constructor Summary | |
---|---|
UserProperties(java.io.File propertyFile)
Contructor UserProperties Summary: The constructor of the class UserProperties. |
|
UserProperties(java.lang.String productName)
Creates user properties without reading values from the file. |
|
UserProperties(java.lang.String productName,
boolean useSystemDefaultValues)
Creates user properties without reading values from the file. |
Method Summary | |
---|---|
void |
addComment(java.lang.String comment)
Add a comment at the end of the properties sequence. |
void |
addNewLine()
Add a new empty line at the end of the properties sequence. |
protected boolean |
continueLine(java.lang.String line)
|
boolean |
getBoolean(java.lang.String name,
boolean value)
Gets a boolean |
byte |
getByte(java.lang.String name,
byte value)
Gets a byte |
double |
getDouble(java.lang.String name,
double value)
Gets a double |
java.io.File |
getFile()
|
float |
getFloat(java.lang.String name,
float value)
Gets a float |
int |
getInt(java.lang.String name,
int value)
Gets an int |
long |
getLong(java.lang.String name,
long value)
Gets a long |
java.lang.String |
getProperty(java.lang.String key)
Method getProperty Summary: Use this method to get a property. |
short |
getShort(java.lang.String name,
short value)
Gets a short |
java.lang.String |
getString(java.lang.String name,
java.lang.String value)
Gets a string |
void |
load(java.io.InputStream inStream)
Reads a property sequence from the input stream. |
protected java.lang.String |
loadConvert(java.lang.String theString)
|
void |
read()
Reads properties from the file defined in the constructor. |
void |
read2()
Reads properties from the file defined in the constructor. |
protected java.lang.String |
saveConvert(java.lang.String theString,
boolean escapeSpace)
|
void |
setBoolean(java.lang.String name,
boolean value)
Sets a boolean |
void |
setByte(java.lang.String name,
byte value)
Sets a byte |
void |
setDouble(java.lang.String name,
double value)
Sets a double |
void |
setFloat(java.lang.String name,
float value)
Sets a float |
void |
setInt(java.lang.String name,
int value)
Sets an int |
void |
setLong(java.lang.String name,
long value)
Sets a long |
java.lang.Object |
setProperty(java.lang.String key,
java.lang.String value)
Calls the Hashtable method put . |
void |
setShort(java.lang.String name,
short value)
Sets a short |
void |
setString(java.lang.String name,
java.lang.String value)
Sets a string |
void |
store(java.io.OutputStream out,
java.lang.String header)
Writes a property sequence in this Properties table to the
output stream in a format suitable for loading into a
Properties table using the load method. |
protected static char |
toHex(int nibble)
Convert a nibble to a hex character |
void |
write()
Writes properties to the file defined in the constructor. |
void |
write2()
Writes properties to the file defined in the constructor. |
Methods inherited from class java.util.Properties |
---|
getProperty, list, list, load, loadFromXML, propertyNames, save, store, storeToXML, storeToXML, stringPropertyNames |
Methods inherited from class java.util.Hashtable |
---|
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.io.File _file
protected java.lang.String _productName
protected java.util.LinkedList _infoList
protected boolean _propertiesLoadedFromFile
protected static final java.lang.String keyValueSeparators
protected static final java.lang.String strictKeyValueSeparators
protected static final java.lang.String specialSaveChars
protected static final java.lang.String whiteSpaceChars
protected static final char[] hexDigit
Constructor Detail |
---|
public UserProperties(java.lang.String productName)
productName + ".home"
is set then look
for properties file into this directory, else merely use the user home
directory.
Unlike the Properties
class, there is no property list for
default values.
productName
- the product namepublic UserProperties(java.lang.String productName, boolean useSystemDefaultValues)
productName + ".home"
is set then look
for properties file into this directory, else merely use the user home
directory.
Unlike the Properties
class, there is no property list for
default values.
productName
- the product nameuseSystemDefaultValues
- true to use system properties defined
with -Dproperty=value at launch time. These default values are used only
when a property is not defined in user property file.public UserProperties(java.io.File propertyFile)
productName + ".home"
is set then look
for properties file into this directory, else merely use the user home
directory.
Unlike the Properties
class, there is no property list for
default values.
propertyFile
- The file that contains the properties to be loaded.Method Detail |
---|
public java.io.File getFile()
public void read()
public void write()
public void read2() throws java.io.FileNotFoundException, java.io.IOException
java.io.FileNotFoundException
java.io.IOException
public java.lang.String getProperty(java.lang.String key)
getProperty
in class java.util.Properties
key
- The key of the property to find, or null if not found.public void write2() throws java.io.FileNotFoundException, java.io.IOException
java.io.FileNotFoundException
java.io.IOException
public java.lang.String getString(java.lang.String name, java.lang.String value)
name
- property namevalue
- the default value
public void setString(java.lang.String name, java.lang.String value)
name
- property namevalue
- its new valuepublic boolean getBoolean(java.lang.String name, boolean value)
name
- property namevalue
- the default value
public void setBoolean(java.lang.String name, boolean value)
name
- property namevalue
- the default valuepublic double getDouble(java.lang.String name, double value)
name
- property namevalue
- the default value
public float getFloat(java.lang.String name, float value)
name
- property namevalue
- the default value
public void setDouble(java.lang.String name, double value)
name
- property namevalue
- its new valuepublic void setFloat(java.lang.String name, float value)
name
- property namevalue
- its new valuepublic long getLong(java.lang.String name, long value)
name
- property namevalue
- the default value
public int getInt(java.lang.String name, int value)
name
- property namevalue
- the default value
public short getShort(java.lang.String name, short value)
name
- property namevalue
- the default value
public byte getByte(java.lang.String name, byte value)
name
- property namevalue
- the default value
public void setLong(java.lang.String name, long value)
name
- property namevalue
- its new valuepublic void setInt(java.lang.String name, int value)
name
- property namevalue
- its new valuepublic void setShort(java.lang.String name, short value)
name
- property namevalue
- its new valuepublic void setByte(java.lang.String name, byte value)
name
- property namevalue
- its new valuepublic java.lang.Object setProperty(java.lang.String key, java.lang.String value)
put
. Provided for
parallelism with the getProperty method. Enforces use of
strings for property keys and values. The value returned is the
result of the Hashtable call to put
.
setProperty
in class java.util.Properties
key
- the key to be placed into this property list.value
- the value corresponding to key.
null
if it did not have one.public void addComment(java.lang.String comment)
comment
- the comment linepublic void addNewLine()
public void load(java.io.InputStream inStream) throws java.io.IOException
load
in class java.util.Properties
inStream
- the input stream.
java.io.IOException
- if an error occurred when reading from the
input stream.protected boolean continueLine(java.lang.String line)
protected java.lang.String loadConvert(java.lang.String theString)
protected java.lang.String saveConvert(java.lang.String theString, boolean escapeSpace)
public void store(java.io.OutputStream out, java.lang.String header) throws java.io.IOException
Properties
table to the
output stream in a format suitable for loading into a
Properties
table using the load
method. The
stream is written using the ISO 8859-1 character encoding.
Comments, property definitions with value, and empty line are written,
keeping them in creating order.
store
in class java.util.Properties
out
- an output stream.header
- Not used in this method
java.io.IOException
- if writing this property list to the
specified output stream throws an IOException.
java.lang.ClassCastException
- if this Properties
object contains any keys or values
that are not Strings
.
java.lang.NullPointerException
- if out
is null.protected static char toHex(int nibble)
nibble
- the nibble to convert.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |