Class CustomProperties
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.util.Map<java.lang.Object,CustomProperty>
public class CustomProperties extends java.util.HashMap<java.lang.Object,CustomProperty>
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 synchronized.
While this class is roughly HashMap
- Author:
- Rainer Klute <klute@rainer-klute.de>
- See Also:
- Serialized Form
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor Description CustomProperties() -
Method Summary
Modifier and Type Method Description booleancontainsKey(java.lang.Object key)Checks against both String Name and Long IDbooleancontainsValue(java.lang.Object value)Checks against both the property, and its values.java.lang.Objectget(java.lang.String name)Gets a named value from the custom properties.intgetCodepage()Gets the codepage.java.util.Set<java.lang.String>idSet()Returns a set of all the IDs of our custom propertiesbooleanisPure()Tells whether thisCustomPropertiesinstance is pure or one or more properties of the underlying low-level property set has been dropped.java.util.SetkeySet()Returns a set of all the names of our custom properties.java.util.Set<java.lang.String>nameSet()Returns a set of all the names of our custom propertiesjava.lang.Objectput(java.lang.String name, java.lang.Boolean value)Adds a named boolean property.java.lang.Objectput(java.lang.String name, java.lang.Double value)Adds a named double property.java.lang.Objectput(java.lang.String name, java.lang.Integer value)Adds a named integer property.java.lang.Objectput(java.lang.String name, java.lang.Long value)Adds a named long property.java.lang.Objectput(java.lang.String name, java.lang.String value)Adds a named string property.java.lang.Objectput(java.lang.String name, java.util.Date value)Adds a named date property.CustomPropertyput(java.lang.String name, CustomProperty cp)Puts aCustomPropertyinto this map.java.lang.Objectremove(java.lang.String name)Removes a custom property.voidsetCodepage(int codepage)Sets the codepage.voidsetPure(boolean isPure)Sets the purity of the custom property set.Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, entrySet, forEach, get, getOrDefault, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Constructor Details
-
CustomProperties
public CustomProperties()
-
-
Method Details
-
put
Puts a
CustomPropertyinto this map. It is assumed that theCustomPropertyalready has a valid ID. Otherwise useput(CustomProperty). -
remove
public java.lang.Object remove(java.lang.String name)Removes a custom property.
- Parameters:
name- The name of the custom property to remove- Returns:
- The removed property or
nullif the specified property was not found. - See Also:
HashSet.remove(java.lang.Object)
-
put
public java.lang.Object put(java.lang.String name, java.lang.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
nullif there was no such property before.
-
put
public java.lang.Object put(java.lang.String name, java.lang.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
nullif there was no such property before.
-
put
public java.lang.Object put(java.lang.String name, java.lang.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
nullif there was no such property before.
-
put
public java.lang.Object put(java.lang.String name, java.lang.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
nullif there was no such property before.
-
put
public java.lang.Object put(java.lang.String name, java.lang.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
nullif there was no such property before.
-
get
public java.lang.Object get(java.lang.String name)Gets a named value from the custom properties.
- Parameters:
name- the name of the value to get- Returns:
- the value or
nullif a value with the specified name is not found in the custom properties.
-
put
public java.lang.Object put(java.lang.String name, java.util.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
nullif there was no such property before.
-
keySet
public java.util.Set keySet()Returns a set of all the names of our custom properties. Equivalent tonameSet()- Specified by:
keySetin interfacejava.util.Map<java.lang.Object,CustomProperty>- Overrides:
keySetin classjava.util.HashMap<java.lang.Object,CustomProperty>
-
nameSet
public java.util.Set<java.lang.String> nameSet()Returns a set of all the names of our custom properties -
idSet
public java.util.Set<java.lang.String> idSet()Returns a set of all the IDs of our custom properties -
setCodepage
public void setCodepage(int codepage)Sets the codepage.
- Parameters:
codepage- the codepage
-
containsKey
public boolean containsKey(java.lang.Object key)Checks against both String Name and Long ID- Specified by:
containsKeyin interfacejava.util.Map<java.lang.Object,CustomProperty>- Overrides:
containsKeyin classjava.util.HashMap<java.lang.Object,CustomProperty>
-
containsValue
public boolean containsValue(java.lang.Object value)Checks against both the property, and its values.- Specified by:
containsValuein interfacejava.util.Map<java.lang.Object,CustomProperty>- Overrides:
containsValuein classjava.util.HashMap<java.lang.Object,CustomProperty>
-
getCodepage
public int getCodepage()Gets the codepage.
- Returns:
- the codepage or -1 if the codepage is undefined.
-
isPure
public boolean isPure()Tells whether this
CustomPropertiesinstance is pure or one or more properties of the underlying low-level property set has been dropped.- Returns:
trueif theCustomPropertiesis pure, elsefalse.
-
setPure
public void setPure(boolean isPure)Sets the purity of the custom property set.
- Parameters:
isPure- the purity
-