public class CustomProperties
extends java.lang.Object
implements java.util.Map<java.lang.String,java.lang.Object>
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<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 and Description |
---|
CustomProperties() |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(java.lang.Object key)
Checks against both String Name and Long ID
|
boolean |
containsValue(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() |
boolean |
equals(java.lang.Object obj) |
java.lang.Object |
get(java.lang.Object key)
Gets a named value from the custom properties - only works for keys of type String
|
int |
getCodepage()
Gets the codepage.
|
int |
hashCode() |
java.util.Set<java.lang.Long> |
idSet()
Returns a set of all the IDs of our custom properties
|
boolean |
isEmpty() |
boolean |
isPure()
Tells whether this
CustomProperties instance is pure or one or
more properties of the underlying low-level property set has been
dropped. |
java.util.Set |
keySet()
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 properties
|
java.util.List<CustomProperty> |
properties() |
CustomProperty |
put(java.lang.String name,
CustomProperty cp)
Puts a
CustomProperty into this map. |
java.lang.Object |
put(java.lang.String key,
java.lang.Object value)
Adds a named property.
|
void |
putAll(java.util.Map<? extends java.lang.String,?> m) |
CustomProperty |
remove(java.lang.Object key)
Removes a custom property - only works for keys of type String
|
void |
setCodepage(int codepage)
Sets the codepage.
|
void |
setPure(boolean isPure)
Sets the purity of the custom property set.
|
int |
size() |
java.util.Collection<java.lang.Object> |
values() |
public CustomProperty put(java.lang.String name, CustomProperty cp)
CustomProperty
into this map. It is assumed that the
CustomProperty
already has a valid ID. Otherwise use
put(CustomProperty)
.name
- the property namecp
- the propertypublic java.lang.Object put(java.lang.String key, java.lang.Object value)
put
in interface java.util.Map<java.lang.String,java.lang.Object>
key
- The property's name.value
- The property's value.null
if there was no such property before.public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map<java.lang.String,java.lang.Object>
key
- the name of the value to getnull
if a value with the specified
name is not found in the custom properties.public CustomProperty remove(java.lang.Object key)
remove
in interface java.util.Map<java.lang.String,java.lang.Object>
key
- The name of the custom property to removenull
if the specified property was not found.public int size()
size
in interface java.util.Map<java.lang.String,java.lang.Object>
public boolean isEmpty()
isEmpty
in interface java.util.Map<java.lang.String,java.lang.Object>
public void clear()
clear
in interface java.util.Map<java.lang.String,java.lang.Object>
public int hashCode()
hashCode
in interface java.util.Map<java.lang.String,java.lang.Object>
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in interface java.util.Map<java.lang.String,java.lang.Object>
equals
in class java.lang.Object
public void putAll(java.util.Map<? extends java.lang.String,?> m)
putAll
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.util.List<CustomProperty> properties()
public java.util.Collection<java.lang.Object> values()
values
in interface java.util.Map<java.lang.String,java.lang.Object>
properties()
for the wrapped valuespublic java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()
entrySet
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.util.Set keySet()
nameSet()
keySet
in interface java.util.Map<java.lang.String,java.lang.Object>
public java.util.Set<java.lang.String> nameSet()
public java.util.Set<java.lang.Long> idSet()
public void setCodepage(int codepage)
codepage
- the codepagepublic int getCodepage()
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<java.lang.String,java.lang.Object>
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map<java.lang.String,java.lang.Object>
public boolean isPure()
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)
isPure
- the purityCopyright 2021 The Apache Software Foundation or its licensors, as applicable.