|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.Dictionary<K,V> java.util.Hashtable<java.lang.Object,java.lang.Object> java.util.Properties org.w3c.util.XMLProperties
public class XMLProperties
The Properties
class represents a persistent set of
properties. The Properties
can be saved to a stream or
loaded from a stream. Each key and its corresponding value in the
property list is a string.
A property list can contain another property list as its "defaults"; this second property list is searched if the property key is not found in the original property list. Because Properties inherits from Hashtable, the put and putAll methods can be applied to a Properties object. Their use is strongly discouraged as they allow the caller to insert entries whose keys or values are not Strings. The setProperty method should be used instead. If the store or save method is called on a "compromised" Properties object that contains a non-String key or value, the call will fail.
This is a special implementation for XML :
<properties> <key name="My_key1">My_Value1</key> <key name="My_key2">My_Value2</key> </properties>
Field Summary | |
---|---|
boolean |
debug
|
static java.lang.String |
PARSER_P
|
Fields inherited from class java.util.Properties |
---|
defaults |
Constructor Summary | |
---|---|
XMLProperties()
Creates an empty property list with no default values. |
|
XMLProperties(java.util.Properties defaults)
Creates an empty property list with the specified defaults. |
|
XMLProperties(java.lang.String parser,
java.util.Properties defaults)
Creates an empty property list with the specified defaults. |
Method Summary | |
---|---|
protected java.lang.StringBuffer |
encode(java.lang.String string)
|
void |
load(java.io.File file)
Reads a property list from an input stream. |
void |
load(java.io.InputStream in)
Reads a property list from an input stream. |
void |
save(java.io.OutputStream out,
java.lang.String header)
Deprecated. This method does not throw an IOException if an I/O error occurs while saving the property list. As of JDK 1.2, the preferred way to save a properties list is via the store(OutputStream out,
String header) method. |
void |
setDebug(boolean debug)
|
void |
store(java.io.OutputStream out,
java.lang.String header)
Writes this property list (key and element pairs) in this Properties table to the output stream in a format suitable
for loading into a Properties table using the
load method. |
Methods inherited from class java.util.Properties |
---|
getProperty, getProperty, list, list, loadFromXML, propertyNames, setProperty, storeToXML, storeToXML |
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 |
---|
public static final java.lang.String PARSER_P
public boolean debug
Constructor Detail |
---|
public XMLProperties()
public XMLProperties(java.util.Properties defaults)
defaults
- the defaults.public XMLProperties(java.lang.String parser, java.util.Properties defaults)
parser
- the XML Parser classname (default is PARSER_P)defaults
- the defaults.Method Detail |
---|
public void load(java.io.InputStream in) throws java.io.IOException
load
in class java.util.Properties
in
- the input stream.
java.io.IOException
- if an error occurred when reading from the
input stream.public void load(java.io.File file) throws java.io.IOException
file
- the properties file.
java.io.IOException
- if an error occurred when reading from the
input stream.public void save(java.io.OutputStream out, java.lang.String header)
store(OutputStream out,
String header)
method.
store(OutputStream out, String header)
method
and suppresses IOExceptions that were thrown.
save
in class java.util.Properties
out
- an output stream.header
- a description of the property list.
java.lang.ClassCastException
- if this Properties
object
contains any keys or values that are not Strings
.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.
After the entries have been written, the output stream is flushed. The output stream remains open after this method returns.
store
in class java.util.Properties
out
- an output stream.header
- a description of the property list.
java.lang.ClassCastException
- if this Properties
object
contains any keys or values that are not Strings
.
java.io.IOException
protected java.lang.StringBuffer encode(java.lang.String string)
public void setDebug(boolean debug)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |