com.denova.util
Class PropertyList

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--java.util.Properties
                    |
                    +--com.denova.util.PropertyList
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.lang.Runnable, java.io.Serializable

public class PropertyList
extends java.util.Properties
implements java.lang.Runnable

Extends Properties and implements Runnable.

Author:
DeNova Copyright (c) 1997-2008 DeNova All rights reserved worldwide.
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
PropertyList()
          Extends Properties and implements Runnable.
PropertyList(java.util.Properties defaults)
          Extends Properties and implements Runnable.
 
Method Summary
 void addProperties(java.util.Properties p)
          Adds the Properties to the current Properties.
 void addPropertyList(com.denova.util.PropertyList p)
          Adds the PropertyList to the current PropertyList.
 void clear()
          Deletes all the properties.
 void clearLastError()
          Clears the last known error.
 boolean fromString(java.lang.String s)
          Adds the values from a String produced by toString() to this PropertyList.
 boolean getBooleanProperty(java.lang.String name)
          Gets a boolean property.
 boolean getBooleanProperty(java.lang.String name, boolean dflt)
          Gets a boolean property.
 int getIntProperty(java.lang.String name)
          Gets an integer property.
 java.lang.Exception getLastError()
          Gets the last known error.
 long getLongProperty(java.lang.String name)
          Gets an integer property.
 java.util.Properties getProperties()
          Gets the current Properties.
 java.util.Properties getPropertyList()
          Gets the current PropertyList.
 com.denova.util.PropertyList getPropertyListProperty(java.lang.String name)
          Gets a PropertyList property.
 com.denova.util.PropertyList getPropertyListProperty(java.lang.String name, com.denova.util.PropertyList dflt)
          Gets a PropertyList property.
 boolean load(java.io.File f)
          Loads the Properties from the File.
 void load(java.io.InputStream in)
          Loads the Properties from the InputStream.
 boolean load(java.lang.String filename)
          Loads the Properties from the filename.
static void main(java.lang.String[] args)
          The main program for the PropertyList class
 java.util.Vector propertyNamesList()
           
 java.lang.Object removeProperty(java.lang.String attribute)
          Deletes a property.
 void run()
          Thread safe way to set a container
 boolean save(java.io.File f)
          Saves the Properties to the File.
 void save(java.io.OutputStream outStream, java.lang.String title)
          Saves the Properties to the stream with the given title.
 boolean save(java.lang.String filename)
          Saves the Properties to the filename.
 void setBooleanProperty(java.lang.String name, boolean value)
          Sets the boolean AV pair.
 boolean setContainer(com.denova.lang.FieldAccess fieldAccess)
          Sets the container.
 boolean setProperties(java.awt.Container container, com.denova.lang.FieldAccess fieldAccess)
          Sets the current Properties.
 void setProperties(java.util.Properties p)
          Sets the current Properties.
 java.lang.Object setProperty(java.lang.String name, java.awt.Component c)
          Sets an AV pair.
 java.lang.Object setProperty(java.lang.String name, int i)
          Sets an AV pair.
 java.lang.Object setProperty(java.lang.String name, long l)
          Sets an AV pair.
 java.lang.Object setProperty(java.lang.String attribute, java.util.Properties value)
          Sets an AV pair.
 java.lang.Object setProperty(java.lang.String attribute, java.lang.String value)
          Sets an AV pair.
 void setPropertyList(com.denova.util.PropertyList p)
          Sets the current PropertyList.
 void setPropertyListProperty(java.lang.String name, com.denova.util.PropertyList value)
          Sets a PropertyList property.
 void setTitle(java.lang.String newTitle)
          Sets the title in the properties file.
 java.lang.String toString()
          Changes the entire PropertyList into a single String.
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, propertyNames, store
 
Methods inherited from class java.util.Hashtable
clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PropertyList

public PropertyList(java.util.Properties defaults)
Extends Properties and implements Runnable.

defaults sets the default Properties

Parameters:
defaults -

PropertyList

public PropertyList()
Extends Properties and implements Runnable.

Method Detail

main

public static void main(java.lang.String[] args)
The main program for the PropertyList class

Parameters:
args - The command line arguments

load

public boolean load(java.lang.String filename)
Loads the Properties from the filename.

Parameters:
filename -
Returns:
true if successful

load

public boolean load(java.io.File f)
Loads the Properties from the File.

Parameters:
f - the properties file
Returns:
true if successful

load

public void load(java.io.InputStream in)
          throws java.io.IOException
Loads the Properties from the InputStream. This is unlike the other variants of load() here because its signature must match the superclass.

Overrides:
load in class java.util.Properties
Parameters:
in -
Throws:
java.io.IOException - any I/O exceptions

save

public boolean save(java.lang.String filename)
Saves the Properties to the filename.

Parameters:
filename - full path name of properties file.
Returns:
true if succesful.

save

public boolean save(java.io.File f)
Saves the Properties to the File.

Parameters:
f - properties file.
Returns:
true if succesful.

save

public void save(java.io.OutputStream outStream,
                 java.lang.String title)
Saves the Properties to the stream with the given title.

Overrides:
save in class java.util.Properties
Parameters:
outStream -
title -

setTitle

public void setTitle(java.lang.String newTitle)
Sets the title in the properties file.

newTitle: new string to use at the top of the properties file in a comment line.

Parameters:
newTitle - new title

setProperty

public java.lang.Object setProperty(java.lang.String attribute,
                                    java.lang.String value)
Sets an AV pair.

Overrides:
setProperty in class java.util.Properties
Parameters:
attribute - property's key
value - property's setting
Returns:
he previous value of the specified key in this hashtable, or null if it did not have one.

setProperty

public java.lang.Object setProperty(java.lang.String attribute,
                                    java.util.Properties value)
Sets an AV pair.

Parameters:
attribute - property's key
value - property's setting
Returns:
he previous value of the specified key in this hashtable, or null if it did not have one.

setProperty

public java.lang.Object setProperty(java.lang.String name,
                                    java.awt.Component c)
Sets an AV pair.

Parameters:
name - name of the property
c - property's setting
Returns:
he previous value of the specified key in this hashtable, or null if it did not have one.

setProperty

public java.lang.Object setProperty(java.lang.String name,
                                    int i)
Sets an AV pair.

Parameters:
name - property's key
i - property's setting
Returns:
he previous value of the specified key in this hashtable, or null if it did not have one.

setProperty

public java.lang.Object setProperty(java.lang.String name,
                                    long l)
Sets an AV pair.

Parameters:
name - property's key
l - property's setting
Returns:
he previous value of the specified key in this hashtable, or null if it did not have one.

setBooleanProperty

public void setBooleanProperty(java.lang.String name,
                               boolean value)
Sets the boolean AV pair.

name is the name of the property
value is the property's boolean setting

Parameters:
name - new boolean property
value - new boolean property

getIntProperty

public int getIntProperty(java.lang.String name)
Gets an integer property.

name is the property's attribute (i.e., the left hand side of the AV pair)

Parameters:
name -
Returns:
int property

getLongProperty

public long getLongProperty(java.lang.String name)
Gets an integer property.

name is the property's attribute (i.e., the left hand side of the AV pair)

Parameters:
name -
Returns:
long property

getBooleanProperty

public boolean getBooleanProperty(java.lang.String name)
Gets a boolean property.

name is the property's key or attribute (i.e., the left hand side of the AV pair)

Parameters:
name -
Returns:
boolean property

getBooleanProperty

public boolean getBooleanProperty(java.lang.String name,
                                  boolean dflt)
Gets a boolean property.

name is the property's key or attribute (i.e., the left hand side of the AV pair)
dflt is the default property if the property doesn't have a value

Parameters:
name -
dflt -
Returns:
boolean property

getPropertyListProperty

public com.denova.util.PropertyList getPropertyListProperty(java.lang.String name)
Gets a PropertyList property.

name is the property's key or attribute (i.e., the left hand side of the AV pair)

Parameters:
name -
Returns:
property list property

getPropertyListProperty

public com.denova.util.PropertyList getPropertyListProperty(java.lang.String name,
                                                            com.denova.util.PropertyList dflt)
Gets a PropertyList property.

name is the property's key or attribute (i.e., the left hand side of the AV pair)
dflt is the default property if the property doesn't have a value

Parameters:
name -
dflt -
Returns:
property list property

setPropertyListProperty

public void setPropertyListProperty(java.lang.String name,
                                    com.denova.util.PropertyList value)
Sets a PropertyList property.

name is the property's key or attribute (i.e., the left hand side of the AV pair)
value is the property's new setting

Parameters:
name - new property list property
value - new property list property

removeProperty

public java.lang.Object removeProperty(java.lang.String attribute)
Deletes a property.

Parameters:
attribute - property's key
Returns:
the value to which the key had been mapped in this hashtable, or null if the key did not have a mapping.

clear

public void clear()
Deletes all the properties.

Specified by:
clear in interface java.util.Map
Overrides:
clear in class java.util.Hashtable

setPropertyList

public void setPropertyList(com.denova.util.PropertyList p)
Sets the current PropertyList.

Removes all the old properties before adding the new ones.

Parameters:
p - new property list

setProperties

public void setProperties(java.util.Properties p)
Sets the current Properties.

Removes all the old properties before adding the new ones.

Parameters:
p - new properties

setProperties

public boolean setProperties(java.awt.Container container,
                             com.denova.lang.FieldAccess fieldAccess)
Sets the current Properties.

Removes all the old properties before adding the new ones.

Parameters:
container - container with properties
fieldAccess - new properties
Returns:
true if successful

setContainer

public boolean setContainer(com.denova.lang.FieldAccess fieldAccess)
Sets the container.

Manages threading.

Parameters:
fieldAccess - new container
Returns:
true if successful setting container.

addPropertyList

public void addPropertyList(com.denova.util.PropertyList p)
Adds the PropertyList to the current PropertyList.

Parameters:
p - The property list added.

addProperties

public void addProperties(java.util.Properties p)
Adds the Properties to the current Properties.

Parameters:
p - The properties added.

getPropertyList

public java.util.Properties getPropertyList()
Gets the current PropertyList.

Returns:
property list

getProperties

public java.util.Properties getProperties()
Gets the current Properties.

Returns:
properties

run

public void run()
Thread safe way to set a container

Specified by:
run in interface java.lang.Runnable

toString

public java.lang.String toString()
Changes the entire PropertyList into a single String.

This String can be used as the value for an attribute in another PropertyList.

Overrides:
toString in class java.util.Hashtable
Returns:
string with all the properties from the list.

fromString

public boolean fromString(java.lang.String s)
Adds the values from a String produced by toString() to this PropertyList.

Parameters:
s -
Returns:
true if succesful.

getLastError

public java.lang.Exception getLastError()
Gets the last known error.

If an error is detected, the high level must call clearLastError() to reset the lastError.

Returns:
last error

clearLastError

public void clearLastError()
Clears the last known error.

If an error is detected, the high level must call clearLastError() to reset the lastError.


propertyNamesList

public java.util.Vector propertyNamesList()