|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--gecco.server.core.TypedProperties
Maintains a mapping between names and values. The names are always Strings, but the values can be any kind of object. This class keeps track of the type of the object, and provides convenient get/set methods for certain popular types, avoiding the inconvenience and hazard of explicit type casting.
| Inner classes inherited from class java.util.Map |
Map.Entry |
| Field Summary | |
private Map |
properties
The Map used to store the properties |
private Map |
propertyTypes
The Map used to store the property types |
static String |
TYPE_DOUBLE
Predefined property type corresponding to the primitive data type
double |
static String |
TYPE_INT
Predefined property type corresponding to the primitive data type
int |
static String |
TYPE_STRING
Predefined property type corresponding to the class String |
static String |
TYPE_UNDEFINED
Property type assigned when none was specified |
| Constructor Summary | |
TypedProperties()
Constructor for the TypedProperties object. |
|
TypedProperties(TypedProperties other)
Constructor for the TypedProperties object. |
|
| Method Summary | |
void |
clear()
Removes all properties |
boolean |
containsKey(Object key)
Checks whether an Object is a key in a mapping, that is, if
there is a property of that name. |
boolean |
containsValue(Object value)
Checks whether an Object is a value in a mapping, that is,
if there is a property with that value. |
Set |
entrySet()
Returns the set of mappings. |
boolean |
equals(Object o)
Tests the given Object for equality with this one. |
Object |
get(Object key)
Retrieves the value associated with a name, without regard of its type. |
double |
getDoubleProperty(String name)
Retrieves the double value associated with a name |
int |
getIntProperty(String name)
Retrieves the int value associated with a name |
Object |
getProperty(String name)
Retrieves the value associated with a name, without regard of its type. |
private Object |
getPropertyOfType(String name,
String type)
Retrieves the value associated with a name. |
String |
getPropertyType(String name)
Retrieves the type of a property |
String |
getStringProperty(String name)
Retrieves the String value associated with a name |
int |
hashCode()
Computes a hash code for this object. |
boolean |
isEmpty()
Checks if any properties are defined or not. |
Set |
keySet()
Returns the set of all names of properties that have been defined |
void |
loadProperties(TypedProperties other)
Copies all properties (and their types) from the given
TypedProperties to this one. |
Object |
put(Object key,
Object value)
Creates or replaces a property. |
void |
putAll(Map t)
Copies all the key/value pairs from a map as properties in this mapping. |
Object |
remove(Object key)
Removes a property This method exists only because the Map
interface requires it. |
Object |
removeProperty(String name)
Removes a property |
void |
setProperty(String name,
double value)
Creates or replaces a property. |
void |
setProperty(String name,
int value)
Creates or replaces a property. |
void |
setProperty(String name,
Object value,
String type)
Creates or replaces a property. |
void |
setProperty(String name,
String value)
Creates or replaces a property. |
int |
size()
Calculates the number of properties stored in this mapping |
Collection |
values()
Returns a Collection view of all values stored in this
mapping |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
private Map properties
Map used to store the propertiesprivate Map propertyTypes
Map used to store the property typespublic static final String TYPE_DOUBLE
doublepublic static final String TYPE_INT
intpublic static final String TYPE_STRING
Stringpublic static final String TYPE_UNDEFINED
| Constructor Detail |
public TypedProperties()
TypedProperties object. Creates an
empty mapping.public TypedProperties(TypedProperties other)
TypedProperties object. Creates an
exact duplicate of the given TypedProperties .other - The TypedProperties object to be duplicated| Method Detail |
public void setProperty(String name,
double value)
double .name - The name of the propertyvalue - The value
public void setProperty(String name,
int value)
int .name - The name of the propertyvalue - The value
public void setProperty(String name,
String value)
String .name - The name of the propertyvalue - The value
public void setProperty(String name,
Object value,
String type)
null values are not
permitted.name - The name of the propertyvalue - The valuetype - The typepublic Object getProperty(String name)
name - The namepublic String getPropertyType(String name)
name - The name of the propertypublic double getDoubleProperty(String name)
double value associated with a namename - The namepublic int getIntProperty(String name)
int value associated with a namename - The namepublic String getStringProperty(String name)
String value associated with a namename - The namepublic Object get(Object key)
Map interface requires
it. It is recommended that you use getProperty() instead.get in interface Mapkey - The object whose toString() method will provide
the namepublic boolean isEmpty()
isEmpty in interface Maptrue if no mappings are definedpublic void loadProperties(TypedProperties other)
TypedProperties to this one. Existing properties with the same
name are overwritten, as usual.other - The TypedProperties containing the properties
to be copiedpublic Object removeProperty(String name)
name - The name of the property to be removed
null if the name was not boundpublic void clear()
clear in interface Mappublic boolean containsKey(Object key)
Object is a key in a mapping, that is, if
there is a property of that name.containsKey in interface Mapkey - The object whose toString() method will provide
the nametrue if the name is mapped to a valuepublic boolean containsValue(Object value)
Object is a value in a mapping, that is,
if there is a property with that value.containsValue in interface Mapvalue - The valuetrue if any name is mapped to that valuepublic Set entrySet()
entrySet in interface Mappublic boolean equals(Object o)
Object for equality with this one.equals in interface Mapequals in class Objecto - The other objecttrue if and only if the other object is a
TypedProperties containing the exact same properties as this
one.public int hashCode()
hashCode in interface MaphashCode in class Objectpublic Set keySet()
keySet in interface Map
public Object put(Object key,
Object value)
Map interface requires it.
It is recommended that you use one of the setProperty()
methods instead.put in interface Mapkey - The object whose toString() method will
provide the namevalue - The value
null if the name was unboundpublic void putAll(Map t)
toString() methods. The
types are marked as undefined.putAll in interface Mapt - The map with the properties to insertpublic Object remove(Object key)
Map
interface requires it. It is recommended that you use
removeProperty() instead.remove in interface Mapkey - The object whose toString() method will provide
the namenull
if the name was not boundpublic int size()
size in interface Mappublic Collection values()
Collection view of all values stored in this
mappingvalues in interface Map
private Object getPropertyOfType(String name,
String type)
NoSuchElementException
is thrown.name - The nametype - The type
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||