Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.util
Class XMLJiveProperties

java.lang.Object
  extended by com.jivesoftware.util.XMLJiveProperties
All Implemented Interfaces:
JiveProperties, java.util.Map

public class XMLJiveProperties
extends java.lang.Object
implements JiveProperties

Provides the the ability to use simple XML property files. Each property is in the form X.Y.Z, which would map to an XML snippet of:

 <X>
     <Y>
         <Z>someValue</Z>
     </Y>
 </X>
 
The XML file is passed in to the constructor and must be readable and writtable. Setting property values will automatically persist those value to disk. The file encoding used is UTF-8.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
XMLJiveProperties(java.io.InputStream in)
          Creates a properties object given an input stream of valid XML.
XMLJiveProperties(java.lang.String fileName)
          Creates a new XMLJiveProperties object from the given file of XML.
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object object)
           
 boolean containsValue(java.lang.Object object)
           
 java.util.Set entrySet()
           
 java.lang.Object get(java.lang.Object o)
          Returns the value of the specified property.
 java.lang.String getAttribute(java.lang.String name, java.lang.String attribute)
          Returns the value of the attribute of the given property name or null if it doesn't exist.
 java.util.Collection getChildrenNames(java.lang.String parent)
          Return all children property names of a parent property as a Collection of String objects.
 java.lang.String getProperty(java.lang.String name)
           
 java.util.Collection getPropertyNames()
          Returns all property names as a Collection of String values.
 boolean isEmpty()
           
 java.util.Set keySet()
           
 java.lang.Object put(java.lang.Object k, java.lang.Object v)
          Sets the value of the specified property.
 void putAll(java.util.Map propertyMap)
          Sets multiple properties at once.
 java.lang.Object remove(java.lang.Object n)
          Deletes the specified property.
 int size()
           
 java.util.Collection values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

XMLJiveProperties

public XMLJiveProperties(java.io.InputStream in)
                  throws java.lang.Exception
Creates a properties object given an input stream of valid XML.

Parameters:
in - an input stream of XML.
Throws:
java.lang.Exception - if an exception occurs while parsing.

XMLJiveProperties

public XMLJiveProperties(java.lang.String fileName)
                  throws java.io.IOException
Creates a new XMLJiveProperties object from the given file of XML.

Parameters:
fileName - the full path the file that properties should be read from and written to.
Throws:
java.io.IOException - if an exception occurs reading or parsing the file.
Method Detail

get

public java.lang.Object get(java.lang.Object o)
Returns the value of the specified property.

Specified by:
get in interface java.util.Map
Parameters:
o - the name of the property to get.
Returns:
the value of the specified property.

getChildrenNames

public java.util.Collection getChildrenNames(java.lang.String parent)
Description copied from interface: JiveProperties
Return all children property names of a parent property as a Collection of String objects. For example, given the properties X.Y.A, X.Y.B, and X.Y.C, then the child properties of X.Y are X.Y.A, X.Y.B, and X.Y.C. The method is not recursive; ie, it does not return children of children.

Specified by:
getChildrenNames in interface JiveProperties
Parameters:
parent - the name of the parent property.
Returns:
all child property names for the given parent.

getPropertyNames

public java.util.Collection getPropertyNames()
Description copied from interface: JiveProperties
Returns all property names as a Collection of String values.

Specified by:
getPropertyNames in interface JiveProperties
Returns:
all property names.

getAttribute

public java.lang.String getAttribute(java.lang.String name,
                                     java.lang.String attribute)
Returns the value of the attribute of the given property name or null if it doesn't exist. Note, this

Parameters:
name - the property name to lookup - ie, "foo.bar"
attribute - the name of the attribute, ie "id"
Returns:
the value of the attribute of the given property or null if it doesn't exist.

put

public java.lang.Object put(java.lang.Object k,
                            java.lang.Object v)
Sets the value of the specified property. If the property doesn't currently exist, it will be automatically created.

Specified by:
put in interface java.util.Map
Parameters:
k - the name of the property to set.
v - the new value for the property.

putAll

public void putAll(java.util.Map propertyMap)
Sets multiple properties at once. If any of the property doesn't currently exist they will be automatically created.

Specified by:
putAll in interface java.util.Map
Parameters:
propertyMap - a map of properties, keyed on property name.

remove

public java.lang.Object remove(java.lang.Object n)
Deletes the specified property.

Specified by:
remove in interface java.util.Map
Parameters:
n - the property to delete.

getProperty

public java.lang.String getProperty(java.lang.String name)

containsKey

public boolean containsKey(java.lang.Object object)
Specified by:
containsKey in interface java.util.Map

containsValue

public boolean containsValue(java.lang.Object object)
Specified by:
containsValue in interface java.util.Map

values

public java.util.Collection values()
Specified by:
values in interface java.util.Map

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map

size

public int size()
Specified by:
size in interface java.util.Map

entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map

clear

public void clear()
Specified by:
clear in interface java.util.Map

keySet

public java.util.Set keySet()
Specified by:
keySet in interface java.util.Map

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.