Class CustomProperties
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.
-
Nested Class Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleancontainsKey(Object key) Checks against both String Name and Long IDbooleancontainsValue(Object value) Checks against both the property, and its values.entrySet()booleanGets a named value from the custom properties - only works for keys of type StringintGets the codepage.inthashCode()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.keySet()Returns a set of all the names of our custom properties.nameSet()Returns a set of all the names of our custom propertiesAdds a named property.put(String name, CustomProperty cp) Puts aCustomPropertyinto this map.voidRemoves 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()values()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
CustomProperties
public CustomProperties()
-
-
Method Details
-
put
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
Adds a named property. -
get
Gets a named value from the custom properties - only works for keys of type String -
remove
Removes a custom property - only works for keys of type String -
size
public int size() -
isEmpty
public boolean isEmpty() -
clear
public void clear() -
hashCode
public int hashCode() -
equals
-
putAll
-
properties
- Returns:
- the list of properties
-
values
- Specified by:
valuesin interfaceMap<String,Object> - Returns:
- the list of property values - use
properties()for the wrapped values
-
entrySet
-
keySet
Returns a set of all the names of our custom properties. Equivalent tonameSet() -
nameSet
Returns a set of all the names of our custom properties- Returns:
- a set of all the names of our custom properties
-
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
Checks against both String Name and Long ID- Specified by:
containsKeyin interfaceMap<String,Object>
-
containsValue
Checks against both the property, and its values.- Specified by:
containsValuein interfaceMap<String,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
-