Build 1.0_r1(from source)

java.util
Class Properties

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<Object,Object>
          extended by java.util.Properties
All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>
Direct Known Subclasses:
Provider, SystemProperties

public class Properties
extends Hashtable<Object,Object>

Properties is a Hashtable where the keys and values must be Strings. Each Properties can have a default Properties which specifies the default values which are used if the key is not in this Properties.

See Also:
Hashtable, System.getProperties(), Serialized Form

Field Summary
protected  Properties defaults
          The default values for this Properties.
 
Fields inherited from class java.util.Hashtable
elementCount, elementData, firstSlot, lastSlot, modCount
 
Constructor Summary
Properties()
          Constructs a new Properties object.
Properties(Properties properties)
          Constructs a new Properties object using the specified default properties.
 
Method Summary
 String getProperty(String name)
          Searches for the property with the specified name.
 String getProperty(String name, String defaultValue)
          Searches for the property with the specified name.
 void list(PrintStream out)
          Lists the mappings in this Properties to the specified PrintStream in a human readable form.
 void list(PrintWriter writer)
          Lists the mappings in this Properties to the specified PrintWriter in a human readable form.
 void load(InputStream in)
          Loads properties from the specified InputStream.
 void loadFromXML(InputStream in)
           
 Enumeration<?> propertyNames()
          Returns all of the property names that this Properties contains.
 void save(OutputStream out, String comment)
          Deprecated. Does not throw an IOException, use store(java.io.OutputStream, java.lang.String)
 Object setProperty(String name, String value)
          Maps the specified key to the specified value.
 void store(OutputStream out, String comment)
          Stores the mappings in this Properties to the specified OutputStream, putting the specified comment at the beginning.
 void storeToXML(OutputStream os, String comment)
           
 void storeToXML(OutputStream os, String comment, String encoding)
           
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, getEntry, 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

defaults

protected Properties defaults
The default values for this Properties.

Constructor Detail

Properties

public Properties()
Constructs a new Properties object.


Properties

public Properties(Properties properties)
Constructs a new Properties object using the specified default properties.

Parameters:
properties - the default properties
Method Detail

getProperty

public String getProperty(String name)
Searches for the property with the specified name. If the property is not found, look in the default properties. If the property is not found in the default properties, answer null.

Parameters:
name - the name of the property to find
Returns:
the named property value

getProperty

public String getProperty(String name,
                          String defaultValue)
Searches for the property with the specified name. If the property is not found, look in the default properties. If the property is not found in the default properties, answer the specified default.

Parameters:
name - the name of the property to find
defaultValue - the default value
Returns:
the named property value

list

public void list(PrintStream out)
Lists the mappings in this Properties to the specified PrintStream in a human readable form.

Parameters:
out - the PrintStream

list

public void list(PrintWriter writer)
Lists the mappings in this Properties to the specified PrintWriter in a human readable form.

Parameters:
writer - the PrintWriter

load

public void load(InputStream in)
          throws IOException
Loads properties from the specified InputStream. The properties are of the form key=value, one property per line.

Parameters:
in - the input stream
Throws:
IOException

propertyNames

public Enumeration<?> propertyNames()
Returns all of the property names that this Properties contains.

Returns:
an Enumeration containing the names of all properties

save

@Deprecated
public void save(OutputStream out,
                            String comment)
Deprecated. Does not throw an IOException, use store(java.io.OutputStream, java.lang.String)

Saves the mappings in this Properties to the specified OutputStream, putting the specified comment at the beginning. The output from this method is suitable for being read by the load() method.

Parameters:
out - the OutputStream
comment - the comment
Throws:
ClassCastException - when the key or value of a mapping is not a String

setProperty

public Object setProperty(String name,
                          String value)
Maps the specified key to the specified value. If the key already exists, the old value is replaced. The key and value cannot be null.

Parameters:
name - the key
value - the value
Returns:
the old value mapped to the key, or null

store

public void store(OutputStream out,
                  String comment)
           throws IOException
Stores the mappings in this Properties to the specified OutputStream, putting the specified comment at the beginning. The output from this method is suitable for being read by the load() method.

Parameters:
out - the OutputStream
comment - the comment
Throws:
IOException
ClassCastException - when the key or value of a mapping is not a String

loadFromXML

public void loadFromXML(InputStream in)
                 throws IOException,
                        InvalidPropertiesFormatException
Throws:
IOException
InvalidPropertiesFormatException

storeToXML

public void storeToXML(OutputStream os,
                       String comment)
                throws IOException
Throws:
IOException

storeToXML

public void storeToXML(OutputStream os,
                       String comment,
                       String encoding)
                throws IOException
Throws:
IOException

Build 1.0_r1(from source)

Please submit a feedback, bug or feature