jclass
Class SimpleProperties

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--java.util.Properties
                    |
                    +--jclass.SimpleProperties

public class SimpleProperties
extends java.util.Properties

This extension of Properties allows reading Long, String, Boolean and Float value fields instead of simple strings.

Written: Radu Sion
Version: 0.14
Source: SimpleProperties.java

Visit Smart Software 

See Also:
Serialized Form

Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
SimpleProperties()
           
 
Method Summary
static SimpleProperties fromFile(java.lang.String filename)
          Reads a resource file and returnes the resources into a SimpleProperties for later use from inside the calling program.
 int getBoolean(java.lang.String resname)
          Returns a property value interpreted as a boolean.
 java.lang.Double getDouble(java.lang.String resname)
          Returns the first occurence of a resource value interpreted as a double.
 double getDoubleValue(java.lang.String resname)
          Returns a double representing the value of the above .getDouble() returned Double object.
 java.lang.Long getLong(java.lang.String resname)
          Returns a resource value interpreted as a Long.
 long getLongValue(java.lang.String resname)
          Returns a long representing the value of the above .getLong() returned Long object.
 java.lang.String getString(java.lang.String resname)
           
 
hods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, propertyNames, save, setProperty, store
 
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
 

Constructor Detail

SimpleProperties

public SimpleProperties()
Method Detail

getString

public java.lang.String getString(java.lang.String resname)
See Also:
Properties.getProperty(java.lang.String)

getBoolean

public int getBoolean(java.lang.String resname)
Returns a property value interpreted as a boolean. A boolean may have the following string values meaning true or false:
 true: ok, enabled, true, on
 false: disabled, false, off
 
Parameters:
resname - Resource to consider
Returns:
1 if resource interpreted as true, 0 if false, -1 if error

getLong

public java.lang.Long getLong(java.lang.String resname)
Returns a resource value interpreted as a Long.
Parameters:
resname - Resource name to consider
Returns:
The value interpreted, null if error

getLongValue

public long getLongValue(java.lang.String resname)
Returns a long representing the value of the above .getLong() returned Long object.
NOTE: If .getLong() returns null then this method returns 0 !!!
Error tracking is difficult.
Parameters:
resname - Resource name to consider
Returns:
A long or 0 if error (may be zero also if no error !!!)

getDouble

public java.lang.Double getDouble(java.lang.String resname)
Returns the first occurence of a resource value interpreted as a double.
Parameters:
resname - Resource name to consider (case senzitive)
Returns:
The value interpreted, null if error

getDoubleValue

public double getDoubleValue(java.lang.String resname)
Returns a double representing the value of the above .getDouble() returned Double object.
NOTE: If .getDouble() returns null then this method returns 0 !!! Error tracking is difficult !!!
Parameters:
resname - Resource name to consider
Returns:
A double or 0 if error (may be zero also if no error !!!)

fromFile

public static SimpleProperties fromFile(java.lang.String filename)
                                 throws java.io.FileNotFoundException,
                                        java.io.IOException
Reads a resource file and returnes the resources into a SimpleProperties for later use from inside the calling program. For details on resource file format refer to JDK docs.

No parameter checkings are performed.
Parameters:
filename - Resource file name
Returns:
null in case of error
Throws:
java.io.FileNotFoundException - In case the filename is not found