Class CustomProperties
- java.lang.Object
-
- org.apache.poi.hpsf.CustomProperties
-
- All Implemented Interfaces:
java.util.Map<java.lang.String,java.lang.Object>
public class CustomProperties extends java.lang.Object implements java.util.Map<java.lang.String,java.lang.Object>Maintains the instances ofCustomPropertythat belong to aDocumentSummaryInformation. The class maintains the names of the custom properties in a dictionary. It implements theMapinterface 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
isPuremethod to check whether a property set parsed byCustomPropertiesis 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<Long,CustomProperty>, that's the internal representation. To external calls, it should appear as HashMap<String,Object> mapping between Names and Custom Property Values.
-
-
Constructor Summary
Constructors Constructor Description CustomProperties()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()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.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>>entrySet()booleanequals(java.lang.Object obj)java.lang.Objectget(java.lang.Object key)Gets a named value from the custom properties - only works for keys of type StringintgetCodepage()Gets the codepage.inthashCode()java.util.Set<java.lang.Long>idSet()Returns a set of all the IDs of our custom propertiesbooleanisEmpty()booleanisPure()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.util.List<CustomProperty>properties()java.lang.Objectput(java.lang.String key, java.lang.Object value)Adds a named property.CustomPropertyput(java.lang.String name, CustomProperty cp)Puts aCustomPropertyinto this map.voidputAll(java.util.Map<? extends java.lang.String,?> m)CustomPropertyremove(java.lang.Object key)Removes a custom property - only works for keys of type StringvoidsetCodepage(int codepage)Sets the codepage.voidsetPure(boolean isPure)Sets the purity of the custom property set.intsize()java.util.Collection<java.lang.Object>values()
-
-
-
Method Detail
-
put
public CustomProperty put(java.lang.String name, CustomProperty cp)
Puts aCustomPropertyinto this map. It is assumed that theCustomPropertyalready has a valid ID. Otherwise useput(CustomProperty).- Parameters:
name- the property namecp- the property- Returns:
- the previous property stored under this name
-
put
public java.lang.Object put(java.lang.String key, java.lang.Object value)Adds a named property.- Specified by:
putin interfacejava.util.Map<java.lang.String,java.lang.Object>- Parameters:
key- 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.Object key)
Gets a named value from the custom properties - only works for keys of type String- Specified by:
getin interfacejava.util.Map<java.lang.String,java.lang.Object>- Parameters:
key- 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.
-
remove
public CustomProperty remove(java.lang.Object key)
Removes a custom property - only works for keys of type String- Specified by:
removein interfacejava.util.Map<java.lang.String,java.lang.Object>- Parameters:
key- The name of the custom property to remove- Returns:
- The removed property or
nullif the specified property was not found.
-
size
public int size()
- Specified by:
sizein interfacejava.util.Map<java.lang.String,java.lang.Object>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Map<java.lang.String,java.lang.Object>
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Map<java.lang.String,java.lang.Object>
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.util.Map<java.lang.String,java.lang.Object>- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin interfacejava.util.Map<java.lang.String,java.lang.Object>- Overrides:
equalsin classjava.lang.Object
-
putAll
public void putAll(java.util.Map<? extends java.lang.String,?> m)
- Specified by:
putAllin interfacejava.util.Map<java.lang.String,java.lang.Object>
-
properties
public java.util.List<CustomProperty> properties()
- Returns:
- the list of properties
-
values
public java.util.Collection<java.lang.Object> values()
- Specified by:
valuesin interfacejava.util.Map<java.lang.String,java.lang.Object>- Returns:
- the list of property values - use
properties()for the wrapped values
-
entrySet
public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()
- Specified by:
entrySetin interfacejava.util.Map<java.lang.String,java.lang.Object>
-
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.String,java.lang.Object>- Returns:
- a set of all the names of our custom properties
-
nameSet
public java.util.Set<java.lang.String> nameSet()
Returns a set of all the names of our custom properties- Returns:
- a set of all the names of our custom properties
-
idSet
public java.util.Set<java.lang.Long> idSet()
Returns a set of all the IDs of our custom properties- Returns:
- a set of all the IDs of our custom properties
-
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.
-
containsKey
public boolean containsKey(java.lang.Object key)
Checks against both String Name and Long ID- Specified by:
containsKeyin interfacejava.util.Map<java.lang.String,java.lang.Object>
-
containsValue
public boolean containsValue(java.lang.Object value)
Checks against both the property, and its values.- Specified by:
containsValuein interfacejava.util.Map<java.lang.String,java.lang.Object>
-
isPure
public boolean isPure()
Tells whether thisCustomPropertiesinstance 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
-
-