|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmro.util.properties.Properties
public class Properties
This class works a bit like java.util.Properties.
The main difference is that each value is stored as a
Property
-object,
which may have a description attached to it. The Property-objects
also may have PropertyValueDescription
:s. These store
a description of the meaning of a certain value of the Property.
Further the Property:s may be grouped together in
PropertyGroup
:s.
Each Properties is tied to a owner object. That object is remembered
with a UniqueIdentifier
. The Properties may also have several
related identifiers, also UniqueIdentifiers.
When using Properties as a instance field, let the class implement
the HasProperties-interface. Set the properties owner to the instance
using the setOwnerIdentifier(mro.util.UniqueIdentifier)
method.
A Properties-object is conveniently saved/loaded to/from a XML-file. Using the identifiers a datastructure of different objects may be rebuilt.
Property
,
PropertyValueDescription
,
PropertyGroup
,
UniqueIdentifier
Field Summary | |
---|---|
private java.lang.String |
description
Info about the Properties (and its owning class). |
private java.util.HashMap<java.lang.String,PropertyGroup> |
namePropertyGroupMap
PropertyGroup:s. |
private java.util.HashMap<java.lang.String,Property> |
namePropertyMap
All Property:s. |
private UniqueIdentifier |
ownerIdentifier
This identifier identifies the owning object. |
private java.lang.String |
propertiesName
The name of the Properties. |
private java.util.Vector<Property> |
propertyVector
The vector in the order the user wants it. |
private java.util.Vector<UniqueIdentifier> |
relatedIdentifiers
The related identifiers. |
Constructor Summary | |
---|---|
|
Properties(Properties ps)
Copy constructor. |
protected |
Properties(java.lang.String name)
A constructor. |
|
Properties(java.lang.String name,
java.lang.Object o)
A constructor that creates a UniqueIdentifier from the object that is passed along and lets it be the owner identifier. |
|
Properties(java.lang.String name,
java.lang.String ownerClassName)
A constructor that creates a UniqueIdentifier with the specified owner class name. |
|
Properties(java.lang.String name,
UniqueIdentifier ownerIdentifier)
A constructor. |
Method Summary | |
---|---|
void |
addProperty(Property p)
Adds a Property (or a PropertyGroup ) to the Properties. |
void |
addRelatedIdentifier(UniqueIdentifier relatedIdentifier)
Add a UniqueIdentifier as a related identifier. |
boolean |
equals(Properties properties2)
Returns true if: 1) the Properties:s have the same name, 2) all Property:s (including PropertyGroup:s) have the same name and are in the same order, and the Property:s have the same values. |
private java.lang.String |
fixFileName(java.lang.String name)
IO |
java.lang.String |
getAppropriateValueDescription(java.lang.String name)
|
java.lang.String |
getOwnerClassName()
|
UniqueIdentifier |
getOwnerIdentifier()
Returns the owner identifier (a UniqueIdentifier ). |
java.lang.String |
getPropertiesName()
|
Property |
getProperty(java.lang.String name)
Returns a Property with the specified name. |
PropertyGroup |
getPropertyGroup(java.lang.String propertyGroupName)
Returns a PropertyGroup with the specified name. |
java.lang.Object |
getPropertyValue(java.lang.String name)
|
java.util.Vector<Property> |
getPropertyVector()
|
java.util.Vector<UniqueIdentifier> |
getRelatedIdentifiers()
Returns all related identifiers, a Vector
of UniqueIdentifier :s. |
static Properties |
load(java.io.File file)
Loads a Properties-object from the specified file. |
static Properties |
load(java.lang.String fileName)
Loads a Properties-object from a file with the specified file name. |
static Properties |
loadXML(org.xml.sax.InputSource source)
Loads a Properties-object from an java.io.InputSource . |
static void |
printDTD(java.io.PrintWriter pw)
Prints the complete DTD of a Properties-XML-file to a PrintWriter . |
static void |
printPartDTD(java.io.PrintWriter pw)
Prints the DTD of a Properties-XML-file to a PrintWriter . |
void |
printPartXML(java.io.PrintWriter pw)
|
static void |
printPropertiesXSLReference(java.io.PrintWriter pw)
Prints a reference to the Properties-XSL-file to a PrintWriter . |
void |
printXML(java.io.PrintWriter pw)
Prints the Properties to a PrintWriter . |
void |
printXSL(java.io.PrintWriter pw)
Prints a basic XSL-file for Properties XML-files to a PrintWriter . |
private void |
recursivelyAddPropertiesInPropertyVector(java.util.Vector properties)
Used by the addProperty(mro.util.properties.Property) -method. |
void |
removeProperty(java.lang.String propertyName)
Removes the Property with the specified name. |
private void |
removePropertyRecursively(java.lang.String propertyName,
java.util.Vector<Property> propertyVector)
|
boolean |
sameOwnerIdentifier(Properties ps)
Returns true if this and ps has the same owner-object as decided by their owner identifier, an UniqueIdentifier . |
boolean |
sameProperties(Properties properties)
Returns true if all Property:s (including PropertyGroup:s) have the same name and are in the same order, false otherwise. |
boolean |
sameRelatedIdentifiers(Properties ps)
Returns true if this and ps has the same related identifiers ( UniqueIdentifier -objects). |
void |
save(java.io.File file)
Saves a Properties-object to the specified file. |
void |
save(java.lang.String fileName)
Saves a Properties-object to a file with the specified file name. |
void |
saveToDirectory(java.lang.String directoryName)
Saves a Properties-object to the directory with specified file name. |
void |
setOwnerIdentifier(UniqueIdentifier ownerIdentifier)
Set the owner identifier to the specified UniqueIdentifier . |
void |
setPropertiesInPropertyVector(java.util.Vector<Property> propertyVector)
Uses #setProperty(). |
void |
setProperty(java.lang.String name,
java.lang.Object value)
Sets a Property with the given name to the given value. |
int |
size()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private UniqueIdentifier ownerIdentifier
private java.util.Vector<UniqueIdentifier> relatedIdentifiers
private java.lang.String propertiesName
private java.util.HashMap<java.lang.String,Property> namePropertyMap
private java.util.HashMap<java.lang.String,PropertyGroup> namePropertyGroupMap
private java.util.Vector<Property> propertyVector
private java.lang.String description
Constructor Detail |
---|
protected Properties(java.lang.String name)
public Properties(java.lang.String name, java.lang.String ownerClassName)
public Properties(java.lang.String name, java.lang.Object o)
public Properties(java.lang.String name, UniqueIdentifier ownerIdentifier)
public Properties(Properties ps) throws PropertyNameConflictException
PropertyNameConflictException
Method Detail |
---|
public void addProperty(Property p) throws PropertyNameConflictException
Property
(or a PropertyGroup
) to the Properties.
PropertyNameConflictException
private void recursivelyAddPropertiesInPropertyVector(java.util.Vector properties) throws PropertyNameConflictException
addProperty(mro.util.properties.Property)
-method.
PropertyNameConflictException
public PropertyGroup getPropertyGroup(java.lang.String propertyGroupName)
PropertyGroup
with the specified name.
null if it doesn't exist.
public Property getProperty(java.lang.String name)
Property
with the specified name.
null if it doesn't exist.
public java.lang.Object getPropertyValue(java.lang.String name)
public java.lang.String getAppropriateValueDescription(java.lang.String name)
public java.util.Vector<Property> getPropertyVector()
public boolean sameProperties(Properties properties)
public boolean equals(Properties properties2)
public void setProperty(java.lang.String name, java.lang.Object value) throws PropertyNotFoundException
PropertyNotFoundException
is thrown.
PropertyNotFoundException
public void setPropertiesInPropertyVector(java.util.Vector<Property> propertyVector) throws PropertyNotFoundException
PropertyNotFoundException
public void removeProperty(java.lang.String propertyName)
private void removePropertyRecursively(java.lang.String propertyName, java.util.Vector<Property> propertyVector)
public UniqueIdentifier getOwnerIdentifier()
UniqueIdentifier
).
public void setOwnerIdentifier(UniqueIdentifier ownerIdentifier)
UniqueIdentifier
.
public void addRelatedIdentifier(UniqueIdentifier relatedIdentifier)
UniqueIdentifier
as a related identifier.
public java.util.Vector<UniqueIdentifier> getRelatedIdentifiers()
Vector
of UniqueIdentifier
:s.
public java.lang.String getOwnerClassName()
public java.lang.String getPropertiesName()
public int size()
public boolean sameOwnerIdentifier(Properties ps)
UniqueIdentifier
. False otherwise.
public boolean sameRelatedIdentifiers(Properties ps)
UniqueIdentifier
-objects). False otherwise.
If both Properties has no related identifiers true is returned.
private java.lang.String fixFileName(java.lang.String name)
public void saveToDirectory(java.lang.String directoryName) throws java.io.IOException
java.io.IOException
public void save(java.lang.String fileName) throws java.io.IOException
java.io.IOException
public void save(java.io.File file) throws java.io.IOException
java.io.IOException
public static void printDTD(java.io.PrintWriter pw) throws java.io.IOException
PrintWriter
.
java.io.IOException
public static void printPartDTD(java.io.PrintWriter pw) throws java.io.IOException
PrintWriter
. Only the elements.
This method may be used when the Properties-XML should
be part of a larger XML.
java.io.IOException
public static void printPropertiesXSLReference(java.io.PrintWriter pw) throws java.io.IOException
PrintWriter
.
java.io.IOException
public void printXML(java.io.PrintWriter pw) throws java.io.IOException
PrintWriter
.
java.io.IOException
public void printPartXML(java.io.PrintWriter pw) throws java.io.IOException
java.io.IOException
public void printXSL(java.io.PrintWriter pw) throws java.io.IOException
PrintWriter
.
java.io.IOException
public static Properties load(java.lang.String fileName) throws java.io.IOException, org.xml.sax.SAXException
java.io.IOException
org.xml.sax.SAXException
public static Properties load(java.io.File file) throws java.io.IOException, org.xml.sax.SAXException
java.io.IOException
org.xml.sax.SAXException
public static Properties loadXML(org.xml.sax.InputSource source) throws java.io.IOException, org.xml.sax.SAXException
java.io.InputSource
.
java.io.IOException
org.xml.sax.SAXException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |