Class CustomProperties
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap
-
- loci.poi.hpsf.CustomProperties
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Map
public class CustomProperties extends HashMap
Maintains the instances of
CustomProperty
that belong to aDocumentSummaryInformation
. The class maintains the names of the custom properties in a dictionary. It implements theMap
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 byCustomProperties
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.
- Since:
- 2006-02-09
- Version:
- $Id$
- Author:
- Rainer Klute <klute@rainer-klute.de>
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Constructor Description CustomProperties()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
get(String name)
Gets a named value from the custom properties.int
getCodepage()
Gets the codepage.boolean
isPure()
Tells whether thisCustomProperties
instance is pure or one or more properties of the underlying low-level property set has been dropped.Object
put(Object name, Object customProperty)
Puts aCustomProperty
into this map.Object
put(String name, Boolean value)
Adds a named boolean 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
put(String name, Date value)
Adds a named date 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.-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
-
-
-
Method Detail
-
put
public Object put(Object name, Object customProperty) throws ClassCastException
Puts a
CustomProperty
into this map. It is assumed that theCustomProperty
already has a valid ID. Otherwise useput(CustomProperty)
.- Specified by:
put
in interfaceMap
- Overrides:
put
in classHashMap
- Throws:
ClassCastException
-
remove
public Object remove(String name)
Removes a custom property.
- Parameters:
name
- The name of the custom property to remove- Returns:
- The removed property or
null
if the specified property was not found. - See Also:
HashSet.remove(java.lang.Object)
-
put
public Object put(String name, String value)
Adds a named string property.
- Parameters:
name
- The property's name.value
- The property's value.- Returns:
- the property that was stored under the specified name before, or
null
if there was no such property before.
-
put
public Object put(String name, Long value)
Adds a named long property.
- Parameters:
name
- The property's name.value
- The property's value.- Returns:
- the property that was stored under the specified name before, or
null
if there was no such property before.
-
put
public Object put(String name, Double value)
Adds a named double property.
- Parameters:
name
- The property's name.value
- The property's value.- Returns:
- the property that was stored under the specified name before, or
null
if there was no such property before.
-
put
public Object put(String name, Integer value)
Adds a named integer property.
- Parameters:
name
- The property's name.value
- The property's value.- Returns:
- the property that was stored under the specified name before, or
null
if there was no such property before.
-
put
public Object put(String name, Boolean value)
Adds a named boolean property.
- Parameters:
name
- The property's name.value
- The property's value.- Returns:
- the property that was stored under the specified name before, or
null
if there was no such property before.
-
get
public Object get(String name)
Gets a named value from the custom properties.
- Parameters:
name
- the name of the value to get- Returns:
- the value or
null
if a value with the specified name is not found in the custom properties.
-
put
public Object put(String name, Date value)
Adds a named date property.
- Parameters:
name
- The property's name.value
- The property's value.- Returns:
- the property that was stored under the specified name before, or
null
if there was no such property before.
-
setCodepage
public void setCodepage(int codepage)
Sets the codepage.
- Parameters:
codepage
- the codepage
-
getCodepage
public int getCodepage()
Gets the codepage.
- Returns:
- the codepage or -1 if the codepage is undefined.
-
isPure
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.- Returns:
true
if theCustomProperties
is pure, elsefalse
.
-
setPure
public void setPure(boolean isPure)
Sets the purity of the custom property set.
- Parameters:
isPure
- the purity
-
-