RegisterSign In

API Documentation: Class PropertySet

Package: com.mckoi.data
implements com.mckoi.util.PropertyRead, com.mckoi.util.PropertyWrite

A set of string key to value properties mapped over a DataFile object. This class provides a convenient way to query and map text and basic numeric properties in a DataFile. This object stores all key and value data as 16 bit unicode character strings.

The format used to store the property map is very simple; Each key/value pair is a variable length string wherein the key and value is deliminated with an '=' character. All properties are stored in an OrderedSetString object in lexicographical order by the property key. A key lookup is therefore a binary search over the set of all strings.

Note that this object inherits the performance characteristics of OrderedSetString. All operations are efficient regardless of the size of the property set with the exception of the 'size()' query (the number of key/value pairs stored in the map).

Limitations: This object can not store 'null' values or keys, or can it store keys that contain an '=' character. Also, key and value strings may not contain the character code '0x0FFFF' (an illegal unicode character).

Constructors Summary

PropertySet(DataFile data)

Methods Summary

void setProperty(String key, String value)
String getProperty(String key)
String getProperty(String key, String default_value)
void setIntegerProperty(String key, int val)
int getIntegerProperty(String key, int default_value)
void setLongProperty(String key, long val)
long getLongProperty(String key, long default_value)
void setBooleanProperty(String key, boolean val)
boolean getBooleanProperty(String key, boolean default_value)
SortedSet<String> keySet()
String toString()

Constructor Details

PropertySet(DataFile data)

Constructs the property set mapped over the given DataFile object.

Method Details

void setProperty(String key, String value)

Sets a property value in the set. If the property already exists, it is overwritten. If 'value' is null, the property is removed.

String getProperty(String key)

Returns a property value from the set given the key. Returns null if the property doesn't exist.

String getProperty(String key, String default_value)

Gets a property, or returns the default value if the property isn't set.

void setIntegerProperty(String key, int val)

Sets a property to an integer value.

int getIntegerProperty(String key, int default_value)

Gets an integer value, or returns the default value if the property isn't set.

void setLongProperty(String key, long val)

Sets a property to a long value.

long getLongProperty(String key, long default_value)

Gets a long value, or returns the default value if the property isn't set.

void setBooleanProperty(String key, boolean val)

Sets a property to a boolean value.

boolean getBooleanProperty(String key, boolean default_value)

Gets a boolean value, or returns the default value if the property isn't set.

SortedSet<String> keySet()

Returns a sorted set of all keys in this property set. The returned object supports removing values from the property set but not adding new keys. The 'subSet' query provided by the returned SortedSet is backed by the OrderedSetString object. Note that the 'size' query requires a full scan of the data file to compute so care should be taken when using this query.

String toString()

Returns a representation of all key/value properties stored in the DataFile. This operation will iterate over every key/value pair stored in this object, therefore care should be taken when using this on a property set storing a very large number of items.

The text on this page is licensed under the Creative Commons Attribution 3.0 License. Java is a registered trademark of Oracle and/or its affiliates.
Mckoi is Copyright © 2000 - 2018 Diehl and Associates, Inc. All rights reserved.