Class CosDictionary
- java.lang.Object
-
- com.adobe.internal.pdftoolkit.core.cos.CosObject
-
- com.adobe.internal.pdftoolkit.core.cos.CosContainer
-
- com.adobe.internal.pdftoolkit.core.cos.CosDictionary
-
- Direct Known Subclasses:
CosStream
public class CosDictionary extends CosContainer
Represents a COS dictionary as defined in section 3.2.6 of the PDF Reference Manual version 1.4.
-
-
Field Summary
-
Fields inherited from class com.adobe.internal.pdftoolkit.core.cos.CosObject
DIRECT, INDIRECT, t_Array, t_Boolean, t_Dictionary, t_KeyAbsent, t_Name, t_Null, t_Numeric, t_ObjectRef, t_Stream, t_String
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Removes all entries from the CosDictionary.boolean
containsKey(java.lang.Object key)
Returns whether this dictionary contains an entry for the given keyCosDictionary
copy()
Returns a "direct" dictionary object with all the direct objects cloned but keys and indirect objects are not cloned.boolean
equals(CosObject value)
This method checks the inside key-value pairs of CosDictionary and returns true if they have same number of key-value pairs and also equal data for each key.CosObject
get(ASName key)
Obtains the object corresponding to the specified key.java.lang.Boolean
getBoolean(ASName key)
Accesor function to get the scalar value from the object associated with a given key.CosArray
getCosArray(ASName key)
Accesor function to get the array value from the object associated with a given key.CosDictionary
getCosDictionary(ASName key)
Accesor function to get the dictionary value from the object associated with a given key.CosStream
getCosStream(ASName key)
Accesor function to get the stream value from the object associated with a given key.CosString
getCosString(ASName key)
Accesor function to get the scalar value from the object associated with a given key.java.lang.Double
getDouble(ASName key)
Accesor function to get the scalar value from the object associated with a given key.CosObject
getInheritable(ASName name, ASName parentKey)
Obtains the object corresponding to the specified key.java.lang.Integer
getInt(ASName key)
Accesor function to get the scalar value from the object associated with a given key.ASName
getKeyForValue(CosObject value)
Returns key corresponding to the value passed here.java.util.List<ASName>
getKeys()
Returns the list of keys of this dictionary.java.lang.Long
getLong(ASName key)
Accesor function to get the scalar value from the object associated with a given key.ASName
getName(ASName key)
Accesor functions to get the scalar value from the object associated with a given key.InputByteStream
getStream(ASName key)
Accesor function to get the decoded stream value from the object associated with a given key.ASString
getString(ASName key)
Accesor function to get the scalar value from the object associated with a given key.int
getType()
return the type of this CosObjectint
getType(ASName key)
Returns the type of the value associated with the given keyjava.lang.Object
getValue()
CosContainerValuesIterator
getValuesIterator()
boolean
isEmpty()
Indicates whether the dictionary has any entries.boolean
isInvalidDict()
Only for Internal Engineering Use.java.util.Iterator<ASName>
keyIterator()
Returns an iterator over keys of this dictionary.java.util.Set<ASName>
keySet()
Returns the key set of this dictionary.CosObject
put(ASName key, boolean value)
Places the key/value pair into the dictionary.CosObject
put(ASName key, boolean[] value)
Put an array of boolean into a Dictionary under the given ASName key.CosObject
put(ASName key, double value)
Places the key/value pair into the dictionary.CosObject
put(ASName key, double[] value)
Put an array of double into a Dictionary under the given ASName key.CosObject
put(ASName key, int value)
Places the key/value pair into the dictionary.CosObject
put(ASName key, int[] value)
Put an array of int into a Dictionary under the given ASName key.CosObject
put(ASName key, long value)
Places the key/value pair into the dictionary.CosObject
put(ASName key, long[] value)
Put an array of long into a Dictionary under the given ASName key.CosObject
put(ASName key, CosObject cosObject)
Places the key/value pair into the dictionary.CosObject
put(ASName key, ASName value)
Places the key/value pair into the dictionary.CosObject
put(ASName key, ASName[] value)
CosObject
put(ASName key, ASString value)
Places the key/value pair into the dictionary.CosObject
put(ASName key, java.lang.String value)
Places the key/value pair into the dictionary.CosObject
put(ASName key, java.lang.String[] value)
Put an array of string into a Dictionary under the given ASName key.CosObject
remove(ASName key)
Removes the key mapping from the dictionary.void
setEncryptionState(boolean state)
Set the specified encryption state for all strings and streams in a dictionary recursivelyvoid
setRepairedValue(ASName key, CosObject cosObject)
Set the repaired value for this cos dictionary.int
size()
Returns the number of key/value pairs in the dictionary.java.util.List<CosObject>
values()
Returns a list of values in this dictionary.-
Methods inherited from class com.adobe.internal.pdftoolkit.core.cos.CosContainer
findObjPos, markNotDirty
-
Methods inherited from class com.adobe.internal.pdftoolkit.core.cos.CosObject
booleanValue, doubleValue, equals, getDocument, getObjEOF, getObjGen, getObjNum, getObjPos, getObjRevision, getStreamManager, hexStringValue, intValue, isCompressed, isDirty, isIndirect, longValue, nameValue, numberValue, stringValue, textValue, toString
-
-
-
-
Method Detail
-
isInvalidDict
public boolean isInvalidDict()
Only for Internal Engineering Use. ' This api may change without Notice Used for PDFA validation of dictionary.- Returns:
- true if the dictionary has unequal key and values; false otherwise.
-
copy
public CosDictionary copy() throws PDFCosParseException, PDFIOException, PDFSecurityException
Returns a "direct" dictionary object with all the direct objects cloned but keys and indirect objects are not cloned.
-
getKeys
public java.util.List<ASName> getKeys()
Returns the list of keys of this dictionary.
-
getType
public int getType()
return the type of this CosObject
-
isEmpty
public boolean isEmpty()
Indicates whether the dictionary has any entries.- Returns:
- true if the dictionary does not contain any entries; false otherwise.
-
size
public int size()
Returns the number of key/value pairs in the dictionary.- Returns:
- Number of key/value pairs in the dictionary.
-
containsKey
public boolean containsKey(java.lang.Object key)
Returns whether this dictionary contains an entry for the given key- Parameters:
key
-
-
setEncryptionState
public void setEncryptionState(boolean state) throws PDFCosParseException, PDFIOException, PDFSecurityException
Set the specified encryption state for all strings and streams in a dictionary recursively
-
get
public CosObject get(ASName key) throws PDFCosParseException, PDFIOException, PDFSecurityException
Obtains the object corresponding to the specified key. An indirect object reference is resolved to the referenced object before being returned.- Parameters:
key
- A key in the dictionary- Returns:
- Object corresponding to the specified key.
- Throws:
PDFCosParseException
PDFIOException
PDFSecurityException
-
getType
public int getType(ASName key)
Returns the type of the value associated with the given key- Parameters:
key
-
-
getName
public ASName getName(ASName key) throws PDFCosParseException, PDFIOException, PDFSecurityException
Accesor functions to get the scalar value from the object associated with a given key. These should only be called if the key is known to be present and the type is known to be compatible with scalar result
-
getBoolean
public java.lang.Boolean getBoolean(ASName key) throws PDFCosParseException, PDFIOException, PDFSecurityException
Accesor function to get the scalar value from the object associated with a given key. These should only be called if the key is known to be present and the type is known to be compatible with scalar result.
-
getDouble
public java.lang.Double getDouble(ASName key) throws PDFCosParseException, PDFIOException, PDFSecurityException
Accesor function to get the scalar value from the object associated with a given key. These should only be called if the key is known to be present and the type is known to be compatible with scalar result.
-
getInt
public java.lang.Integer getInt(ASName key) throws PDFCosParseException, PDFIOException, PDFSecurityException
Accesor function to get the scalar value from the object associated with a given key. These should only be called if the key is known to be present and the type is known to be compatible with scalar result.
-
getLong
public java.lang.Long getLong(ASName key) throws PDFCosParseException, PDFIOException, PDFSecurityException
Accesor function to get the scalar value from the object associated with a given key. These should only be called if the key is known to be present and the type is known to be compatible with scalar result.
-
getString
public ASString getString(ASName key) throws PDFCosParseException, PDFIOException, PDFSecurityException
Accesor function to get the scalar value from the object associated with a given key. These should only be called if the key is known to be present and the type is known to be compatible with scalar result.
-
getCosString
public CosString getCosString(ASName key) throws PDFCosParseException, PDFIOException, PDFSecurityException
Accesor function to get the scalar value from the object associated with a given key. These should only be called if the key is known to be present and the type is known to be compatible with scalar result.
-
getCosArray
public CosArray getCosArray(ASName key) throws PDFCosParseException, PDFIOException, PDFSecurityException
Accesor function to get the array value from the object associated with a given key. These should only be called if the key is known to be present and the type is known to be compatible with result.
-
getCosDictionary
public CosDictionary getCosDictionary(ASName key) throws PDFCosParseException, PDFIOException, PDFSecurityException
Accesor function to get the dictionary value from the object associated with a given key. These should only be called if the key is known to be present and the type is known to be compatible with result.
-
getCosStream
public CosStream getCosStream(ASName key) throws PDFCosParseException, PDFIOException, PDFSecurityException
Accesor function to get the stream value from the object associated with a given key. These should only be called if the key is known to be present and the type is known to be compatible with result.
-
getStream
public InputByteStream getStream(ASName key) throws PDFCosParseException, PDFIOException, PDFSecurityException
Accesor function to get the decoded stream value from the object associated with a given key. These should only be called if the key is known to be present and the type is known to be compatible with result.
-
setRepairedValue
public void setRepairedValue(ASName key, CosObject cosObject)
Set the repaired value for this cos dictionary.- Parameters:
key
-cosObject
-
-
put
public CosObject put(ASName key, CosObject cosObject) throws PDFCosParseException, PDFIOException, PDFSecurityException
Places the key/value pair into the dictionary. If the value is an indirect object, the object's reference is used as the value. This will overwrite the value associated with the key if there already is an entry for the key in the dictionary. The removed value will have its reference count decremented if it's on the dirty list. The added value will have its reference count incremented if it's on the dirty list.- Parameters:
key
- Key for the entrycosObject
- CosObject value for the entry- Returns:
- CosObject value added to the dictionary.
- Throws:
PDFIOException
PDFCosParseException
PDFSecurityException
-
put
public CosObject put(ASName key, ASName value) throws PDFCosParseException, PDFIOException, PDFSecurityException
Places the key/value pair into the dictionary. This will overwrite the value associated with the key if there already is an entry for the key in the dictionary. The removed value will have its reference count decremented if it's on the dirty list. The added value will have its reference count incremented if it's on the dirty list.
-
put
public CosObject put(ASName key, boolean value) throws PDFCosParseException, PDFIOException, PDFSecurityException
Places the key/value pair into the dictionary. This will overwrite the value associated with the key if there already is an entry for the key in the dictionary. The removed value will have its reference count decremented if it's on the dirty list. The added value will have its reference count incremented if it's on the dirty list.
-
put
public CosObject put(ASName key, double value) throws PDFCosParseException, PDFIOException, PDFSecurityException
Places the key/value pair into the dictionary. This will overwrite the value associated with the key if there already is an entry for the key in the dictionary. The removed value will have its reference count decremented if it's on the dirty list. The added value will have its reference count incremented if it's on the dirty list.
-
put
public CosObject put(ASName key, long value) throws PDFCosParseException, PDFIOException, PDFSecurityException
Places the key/value pair into the dictionary. This will overwrite the value associated with the key if there already is an entry for the key in the dictionary. The removed value will have its reference count decremented if it's on the dirty list. The added value will have its reference count incremented if it's on the dirty list.
-
put
public CosObject put(ASName key, int value) throws PDFCosParseException, PDFIOException, PDFSecurityException
Places the key/value pair into the dictionary. This will overwrite the value associated with the key if there already is an entry for the key in the dictionary. The removed value will have its reference count decremented if it's on the dirty list. The added value will have its reference count incremented if it's on the dirty list.
-
put
public CosObject put(ASName key, ASString value) throws PDFCosParseException, PDFIOException, PDFSecurityException
Places the key/value pair into the dictionary. This will overwrite the value associated with the key if there already is an entry for the key in the dictionary. The removed value will have its reference count decremented if it's on the dirty list. The added value will have its reference count incremented if it's on the dirty list.
-
put
public CosObject put(ASName key, java.lang.String value) throws PDFCosParseException, PDFIOException, PDFSecurityException
Places the key/value pair into the dictionary. This will overwrite the value associated with the key if there already is an entry for the key in the dictionary. The removed value will have its reference count decremented if it's on the dirty list. The added value will have its reference count incremented if it's on the dirty list.
-
put
public CosObject put(ASName key, double[] value) throws PDFCosParseException, PDFIOException, PDFSecurityException
Put an array of double into a Dictionary under the given ASName key.- Parameters:
key
-value
- an array of values- Throws:
PDFIOException
PDFCosParseException
PDFSecurityException
-
put
public CosObject put(ASName key, long[] value) throws PDFCosParseException, PDFIOException, PDFSecurityException
Put an array of long into a Dictionary under the given ASName key.
-
put
public CosObject put(ASName key, ASName[] value) throws PDFCosParseException, PDFIOException, PDFSecurityException
-
put
public CosObject put(ASName key, int[] value) throws PDFCosParseException, PDFIOException, PDFSecurityException
Put an array of int into a Dictionary under the given ASName key.
-
put
public CosObject put(ASName key, java.lang.String[] value) throws PDFCosParseException, PDFIOException, PDFSecurityException
Put an array of string into a Dictionary under the given ASName key.
-
put
public CosObject put(ASName key, boolean[] value) throws PDFCosParseException, PDFIOException, PDFSecurityException
Put an array of boolean into a Dictionary under the given ASName key.
-
clear
public void clear() throws PDFCosParseException, PDFIOException, PDFSecurityException
Removes all entries from the CosDictionary.
-
remove
public CosObject remove(ASName key) throws PDFCosParseException, PDFIOException, PDFSecurityException
Removes the key mapping from the dictionary.- Parameters:
key
- Key mapping to remove- Returns:
- If an object was already present in the dictionary using the specified key, that object is returned. Otherwise, null is returned.
- Throws:
PDFCosParseException
PDFIOException
PDFSecurityException
-
keySet
public java.util.Set<ASName> keySet()
Returns the key set of this dictionary.
-
keyIterator
public java.util.Iterator<ASName> keyIterator()
Returns an iterator over keys of this dictionary.
-
getValuesIterator
public CosContainerValuesIterator getValuesIterator()
- Specified by:
getValuesIterator
in classCosContainer
-
values
public java.util.List<CosObject> values()
Returns a list of values in this dictionary.
-
getValue
public java.lang.Object getValue() throws PDFCosParseException, PDFIOException, PDFSecurityException
- Specified by:
getValue
in classCosObject
- Returns:
- Object value of CosObject
- Throws:
PDFCosParseException
PDFIOException
PDFSecurityException
-
getKeyForValue
public ASName getKeyForValue(CosObject value) throws PDFCosParseException, PDFIOException, PDFSecurityException
Returns key corresponding to the value passed here.
-
equals
public boolean equals(CosObject value)
This method checks the inside key-value pairs of CosDictionary and returns true if they have same number of key-value pairs and also equal data for each key. Returns false if passed CosObject is not an instance of CosDictionary. This maintains a continuously growing list of indirect CosObject pairs, which have already been compared, to get rid of infinite recursion. This method can take some time if called on large Cos Objects.
-
getInheritable
public CosObject getInheritable(ASName name, ASName parentKey) throws PDFCosParseException, PDFIOException, PDFSecurityException
Obtains the object corresponding to the specified key. If the object does not exist, the inheritance chain of this dictionary is walked using the parentKey to find the parent dictionary. Each parent dictionary is subsequently searched until either the key is found, or we run out of parents. An indirect object reference is resolved to the referenced object before being returned.- Parameters:
name
- A key in the dictionaryparentKey
- The key that specifies the "parent" dictionary- Returns:
- Object corresponding to the specified key.
- Throws:
PDFCosParseException
PDFIOException
PDFSecurityException
-
-