public class CustomProperties extends HashMap
Maintains the instances of CustomProperty
that belong to a
DocumentSummaryInformation
. The class maintains the names of the
custom properties in a dictionary. It implements the Map
interface
and by this provides a simplified view on custom properties: A property's
name is the key that maps to a typed value. This implementation hides
property IDs from the developer and regards the property names as keys to
typed values.
While this class provides a simple API to custom properties, it ignores the fact that not names, but IDs are the real keys to properties. Under the hood this class maintains a 1:1 relationship between IDs and names. Therefore you should not use this class to process property sets with several IDs mapping to the same name or with properties without a name: the result will contain only a subset of the original properties. If you really need to deal such property sets, use HPSF's low-level access methods.
An application can call the isPure
method to check whether a
property set parsed by CustomProperties
is still pure (i.e.
unmodified) or whether one or more properties have been dropped.
This class is not thread-safe; concurrent access to instances of this class must be syncronized.
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Modifier and Type | Field and Description |
---|---|
private Map |
dictionaryIDToName
Maps property IDs to property names.
|
private Map |
dictionaryNameToID
Maps property names to property IDs.
|
private boolean |
isPure
Tells whether this object is pure or not.
|
Constructor and Description |
---|
CustomProperties() |
Modifier and Type | Method and Description |
---|---|
Object |
get(String name)
Gets a named value from the custom properties.
|
int |
getCodepage()
Gets the codepage.
|
(package private) Map |
getDictionary()
Gets the dictionary which contains IDs and names of the named custom
properties.
|
boolean |
isPure()
Tells whether this
CustomProperties instance is pure or one or
more properties of the underlying low-level property set has been
dropped. |
private Object |
put(CustomProperty customProperty)
Puts a
CustomProperty that has not yet a valid ID into this
map. |
Object |
put(Object name,
Object customProperty)
Puts a
CustomProperty into this map. |
Object |
put(String name,
Boolean value)
Adds a named boolean property.
|
Object |
put(String name,
Date value)
Adds a named date property.
|
Object |
put(String name,
Double value)
Adds a named double property.
|
Object |
put(String name,
Integer value)
Adds a named integer property.
|
Object |
put(String name,
Long value)
Adds a named long property.
|
Object |
put(String name,
String value)
Adds a named string property.
|
Object |
remove(String name)
Removes a custom property.
|
void |
setCodepage(int codepage)
Sets the codepage.
|
void |
setPure(boolean isPure)
Sets the purity of the custom property set.
|
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, putAll, remove, size, values
equals, hashCode, toString
private Map dictionaryIDToName
Maps property IDs to property names.
private Map dictionaryNameToID
Maps property names to property IDs.
private boolean isPure
Tells whether this object is pure or not.
public Object put(Object name, Object customProperty) throws ClassCastException
Puts a CustomProperty
into this map. It is assumed that the
CustomProperty
already has a valid ID. Otherwise use
put(CustomProperty)
.
put
in interface Map
put
in class HashMap
ClassCastException
private Object put(CustomProperty customProperty) throws ClassCastException
Puts a CustomProperty
that has not yet a valid ID into this
map. The method will allocate a suitable ID for the custom property:
If there is already a property with the same name, take the ID of that property.
Otherwise find the highest ID and use its value plus one.
customProperty
- ClassCastException
public Object remove(String name)
Removes a custom property.
name
- The name of the custom property to removenull
if the specified property was not found.HashSet.remove(java.lang.Object)
public Object put(String name, String value)
Adds a named string property.
name
- The property's name.value
- The property's value.null
if there was no such property before.public Object put(String name, Long value)
Adds a named long property.
name
- The property's name.value
- The property's value.null
if there was no such property before.public Object put(String name, Double value)
Adds a named double property.
name
- The property's name.value
- The property's value.null
if there was no such property before.public Object put(String name, Integer value)
Adds a named integer property.
name
- The property's name.value
- The property's value.null
if there was no such property before.public Object put(String name, Boolean value)
Adds a named boolean property.
name
- The property's name.value
- The property's value.null
if there was no such property before.public Object get(String name)
Gets a named value from the custom properties.
name
- the name of the value to getnull
if a value with the specified
name is not found in the custom properties.public Object put(String name, Date value)
Adds a named date property.
name
- The property's name.value
- The property's value.null
if there was no such property before.public void setCodepage(int codepage)
Sets the codepage.
codepage
- the codepageMap getDictionary()
Gets the dictionary which contains IDs and names of the named custom properties.
public int getCodepage()
Gets the codepage.
public boolean isPure()
Tells whether this CustomProperties
instance is pure or one or
more properties of the underlying low-level property set has been
dropped.
true
if the CustomProperties
is pure, else
false
.public void setPure(boolean isPure)
Sets the purity of the custom property set.
isPure
- the purityCopyright © 2016 Open Microscopy Environment