Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.pdfbox.cos
Class COSDictionary

    java.lang.Object
      org.pdfbox.cos.COSBase
          org.pdfbox.cos.COSDictionary

All Implemented Interfaces:
  COSObjectable

Direct Known Subclasses:
  COSStream

public class COSDictionary
extends COSBase

This class represents a dictionary where name/value pairs reside.

Version:
  $Revision: 1.27 $
Author:
  Ben Litchfield (ben@csh.rit.edu)

Constructor Summary
`COSDictionary()` Constructor.
`COSDictionary(COSDictionary dict)` Copy Constructor.

Method Summary
`Object` | `accept(ICOSVisitor visitor)` visitor pattern double dispatch method.
`void` | `addAll(COSDictionary dic)` This will add all of the dictionarys keys/values to this dictionary.
`void` | `clear()` This will clear all items in the map.
`boolean` | `getBoolean(COSName key, boolean defaultValue)` This is a convenience method that will get the dictionary object that is expected to be a COSBoolean and convert it to a primitive boolean.
`boolean` | `getBoolean(String key, boolean defaultValue)` This is a convenience method that will get the dictionary object that is expected to be a cos boolean and convert it to a primitive boolean.
`COSBase` | `getDictionaryObject(COSName key)` This will get an object from this dictionary.
`COSBase` | `getDictionaryObject(String key)` This will get an object from this dictionary.
`COSBase` | `getDictionaryObject(String[] keyList)` This is a special case of getDictionaryObject that takes multiple keys, it will handle the situation where multiple keys could get the same value, ie if either CS or ColorSpace is used to get the colorspace.
`float` | `getFloat(COSName key)` This is a convenience method that will get the dictionary object that is expected to be an float
`float` | `getFloat(COSName key, float defaultValue)` This is a convenience method that will get the dictionary object that is expected to be an float.
`float` | `getFloat(String key)` This is a convenience method that will get the dictionary object that is expected to be an int
`float` | `getFloat(String key, float defaultValue)` This is a convenience method that will get the dictionary object that is expected to be a float.
`int` | `getInt(COSName key)` This is a convenience method that will get the dictionary object that is expected to be an int
`int` | `getInt(COSName key, int defaultValue)` This is a convenience method that will get the dictionary object that is expected to be an integer.
`int` | `getInt(String key)` This is a convenience method that will get the dictionary object that is expected to be an int
`int` | `getInt(String[] keyList, int defaultValue)` This is a convenience method that will get the dictionary object that is expected to be an integer.
`int` | `getInt(String key, int defaultValue)` This is a convenience method that will get the dictionary object that is expected to be an integer.
`COSBase` | `getItem(COSName key)` This will do a lookup into the dictionary.
`String` | `getNameAsString(COSName key)` This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string.
`String` | `getNameAsString(COSName key, String defaultValue)` This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string.
`String` | `getNameAsString(String key)` This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string.
`String` | `getNameAsString(String key, String defaultValue)` This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string.
`COSBase` | `getObjectFromPath(String objPath)` Nice method, gives you every object you want Arrays works properly too.
`String` | `getString(COSName key)` This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string.
`String` | `getString(COSName key, String defaultValue)` This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string.
`String` | `getString(String key)` This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string.
`String` | `getString(String key, String defaultValue)` This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string.
`Collection` | `getValues()` This will get all of the values for the dictionary.
`List` | `keyList()` This will get the keys for all objects in the dictionary in the sequence that they were added.
`void` | `mergeInto(COSDictionary dic)` This will add all of the dictionarys keys/values to this dictionary, but only if they don't already exist.
`void` | `removeItem(COSName key)` This will remove an item for the dictionary.
`void` | `setFloat(COSName key, float value)` This is a convenience method that will convert the value to a COSFloat object.
`void` | `setFloat(String key, float value)` This is a convenience method that will convert the value to a COSFloat object.
`void` | `setInt(COSName key, int value)` This is a convenience method that will convert the value to a COSInteger object.
`void` | `setInt(String key, int value)` This is a convenience method that will convert the value to a COSInteger object.
`void` | `setItem(COSName key, boolean value)` This will set an item in the dictionary.
`void` | `setItem(COSName key, COSBase value)` This will set an item in the dictionary.
`void` | `setItem(COSName key, COSObjectable value)` This will set an item in the dictionary.
`void` | `setItem(String key, boolean value)` This will set an item in the dictionary.
`void` | `setItem(String key, COSBase value)` This will set an item in the dictionary.
`void` | `setItem(String key, COSObjectable value)` This will set an item in the dictionary.
`void` | `setName(COSName key, String value)` This is a convenience method that will convert the value to a COSName object.
`void` | `setName(String key, String value)` This is a convenience method that will convert the value to a COSName object.
`void` | `setString(COSName key, String value)` This is a convenience method that will convert the value to a COSString object.
`void` | `setString(String key, String value)` This is a convenience method that will convert the value to a COSString object.
`int` | `size()` This will return the number of elements in this dictionary.

Methods inherited from class org.pdfbox.cos.COSBase
`getCOSObject, getFilterManager`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### COSDictionary

    public COSDictionary()

  Constructor.

### COSDictionary

    public COSDictionary(COSDictionary dict)

  Copy Constructor. This will make a shallow copy of this dictionary.

Parameters:
  `dict` - The dictionary to copy.

Method Detail

### size

    public int size()

  This will return the number of elements in this dictionary.

  Returns:
    The number of elements in the dictionary.

### clear

    public void clear()

  This will clear all items in the map.

### getDictionaryObject

    public COSBase getDictionaryObject(String key)

  This will get an object from this dictionary. If the object is a reference then it will dereference it and get it from the document. If the object is COSNull then null will be returned.

  Parameters:
    `key` - The key to the object that we are getting.
  Returns:
    The object that matches the key.

### getDictionaryObject

    public COSBase getDictionaryObject(String[] keyList)

  This is a special case of getDictionaryObject that takes multiple keys, it will handle the situation where multiple keys could get the same value, ie if either CS or ColorSpace is used to get the colorspace. This will get an object from this dictionary. If the object is a reference then it will dereference it and get it from the document. If the object is COSNull then null will be returned.

  Parameters:
    `keyList` - The list of keys to find a value.
  Returns:
    The object that matches the key.

### getDictionaryObject

    public COSBase getDictionaryObject(COSName key)

  This will get an object from this dictionary. If the object is a reference then it will dereference it and get it from the document. If the object is COSNull then null will be returned.

  Parameters:
    `key` - The key to the object that we are getting.
  Returns:
    The object that matches the key.

### setItem

    public void setItem(COSName key,
                        COSBase value)

  This will set an item in the dictionary. If value is null then the result will be the same as removeItem( key ).

  Parameters:
    `key` - The key to the dictionary object.
    `value` - The value to the dictionary object.

### setItem

    public void setItem(COSName key,
                        COSObjectable value)

  This will set an item in the dictionary. If value is null then the result will be the same as removeItem( key ).

  Parameters:
    `key` - The key to the dictionary object.
    `value` - The value to the dictionary object.

### setItem

    public void setItem(String key,
                        COSObjectable value)

  This will set an item in the dictionary. If value is null then the result will be the same as removeItem( key ).

  Parameters:
    `key` - The key to the dictionary object.
    `value` - The value to the dictionary object.

### setItem

    public void setItem(String key,
                        boolean value)

  This will set an item in the dictionary.

  Parameters:
    `key` - The key to the dictionary object.
    `value` - The value to the dictionary object.

### setItem

    public void setItem(COSName key,
                        boolean value)

  This will set an item in the dictionary.

  Parameters:
    `key` - The key to the dictionary object.
    `value` - The value to the dictionary object.

### setItem

    public void setItem(String key,
                        COSBase value)

  This will set an item in the dictionary. If value is null then the result will be the same as removeItem( key ).

  Parameters:
    `key` - The key to the dictionary object.
    `value` - The value to the dictionary object.

### setName

    public void setName(String key,
                        String value)

  This is a convenience method that will convert the value to a COSName object. If it is null then the object will be removed.

  Parameters:
    `key` - The key to the object,
    `value` - The string value for the name.

### setName

    public void setName(COSName key,
                        String value)

  This is a convenience method that will convert the value to a COSName object. If it is null then the object will be removed.

  Parameters:
    `key` - The key to the object,
    `value` - The string value for the name.

### setString

    public void setString(String key,
                          String value)

  This is a convenience method that will convert the value to a COSString object. If it is null then the object will be removed.

  Parameters:
    `key` - The key to the object,
    `value` - The string value for the name.

### setString

    public void setString(COSName key,
                          String value)

  This is a convenience method that will convert the value to a COSString object. If it is null then the object will be removed.

  Parameters:
    `key` - The key to the object,
    `value` - The string value for the name.

### setInt

    public void setInt(String key,
                       int value)

  This is a convenience method that will convert the value to a COSInteger object.

  Parameters:
    `key` - The key to the object,
    `value` - The int value for the name.

### setInt

    public void setInt(COSName key,
                       int value)

  This is a convenience method that will convert the value to a COSInteger object.

  Parameters:
    `key` - The key to the object,
    `value` - The int value for the name.

### setFloat

    public void setFloat(String key,
                         float value)

  This is a convenience method that will convert the value to a COSFloat object.

  Parameters:
    `key` - The key to the object,
    `value` - The int value for the name.

### setFloat

    public void setFloat(COSName key,
                         float value)

  This is a convenience method that will convert the value to a COSFloat object.

  Parameters:
    `key` - The key to the object,
    `value` - The int value for the name.

### getNameAsString

    public String getNameAsString(String key)

  This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string. Null is returned if the entry does not exist in the dictionary.

  Parameters:
    `key` - The key to the item in the dictionary.
  Returns:
    The name converted to a string.

### getNameAsString

    public String getNameAsString(COSName key)

  This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string. Null is returned if the entry does not exist in the dictionary.

  Parameters:
    `key` - The key to the item in the dictionary.
  Returns:
    The name converted to a string.

### getNameAsString

    public String getNameAsString(String key,
                                  String defaultValue)

  This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string. Null is returned if the entry does not exist in the dictionary.

  Parameters:
    `key` - The key to the item in the dictionary.
    `defaultValue` - The value to return if the dictionary item is null.
  Returns:
    The name converted to a string.

### getNameAsString

    public String getNameAsString(COSName key,
                                  String defaultValue)

  This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string. Null is returned if the entry does not exist in the dictionary.

  Parameters:
    `key` - The key to the item in the dictionary.
    `defaultValue` - The value to return if the dictionary item is null.
  Returns:
    The name converted to a string.

### getString

    public String getString(String key)

  This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string. Null is returned if the entry does not exist in the dictionary.

  Parameters:
    `key` - The key to the item in the dictionary.
  Returns:
    The name converted to a string.

### getString

    public String getString(COSName key)

  This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string. Null is returned if the entry does not exist in the dictionary.

  Parameters:
    `key` - The key to the item in the dictionary.
  Returns:
    The name converted to a string.

### getString

    public String getString(String key,
                            String defaultValue)

  This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string. Null is returned if the entry does not exist in the dictionary.

  Parameters:
    `key` - The key to the item in the dictionary.
    `defaultValue` - The default value to return.
  Returns:
    The name converted to a string.

### getString

    public String getString(COSName key,
                            String defaultValue)

  This is a convenience method that will get the dictionary object that is expected to be a name and convert it to a string. Null is returned if the entry does not exist in the dictionary.

  Parameters:
    `key` - The key to the item in the dictionary.
    `defaultValue` - The default value to return.
  Returns:
    The name converted to a string.

### getBoolean

    public boolean getBoolean(String key,
                              boolean defaultValue)

  This is a convenience method that will get the dictionary object that is expected to be a cos boolean and convert it to a primitive boolean.

  Parameters:
    `key` - The key to the item in the dictionary.
    `defaultValue` - The value returned if the entry is null.
  Returns:
    The value converted to a boolean.

### getBoolean

    public boolean getBoolean(COSName key,
                              boolean defaultValue)

  This is a convenience method that will get the dictionary object that is expected to be a COSBoolean and convert it to a primitive boolean.

  Parameters:
    `key` - The key to the item in the dictionary.
    `defaultValue` - The value returned if the entry is null.
  Returns:
    The entry converted to a boolean.

### getInt

    public int getInt(String key)

  This is a convenience method that will get the dictionary object that is expected to be an int. -1 is returned if there is no value.

  Parameters:
    `key` - The key to the item in the dictionary.
  Returns:
    The integer value.

### getInt

    public int getInt(COSName key)

  This is a convenience method that will get the dictionary object that is expected to be an int. -1 is returned if there is no value.

  Parameters:
    `key` - The key to the item in the dictionary.
  Returns:
    The integer value..

### getInt

    public int getInt(String[] keyList,
                      int defaultValue)

  This is a convenience method that will get the dictionary object that is expected to be an integer. If the dictionary value is null then the default Value will be returned.

  Parameters:
    `keyList` - The key to the item in the dictionary.
    `defaultValue` - The value to return if the dictionary item is null.
  Returns:
    The integer value.

### getInt

    public int getInt(String key,
                      int defaultValue)

  This is a convenience method that will get the dictionary object that is expected to be an integer. If the dictionary value is null then the default Value will be returned.

  Parameters:
    `key` - The key to the item in the dictionary.
    `defaultValue` - The value to return if the dictionary item is null.
  Returns:
    The integer value.

### getInt

    public int getInt(COSName key,
                      int defaultValue)

  This is a convenience method that will get the dictionary object that is expected to be an integer. If the dictionary value is null then the default Value will be returned.

  Parameters:
    `key` - The key to the item in the dictionary.
    `defaultValue` - The value to return if the dictionary item is null.
  Returns:
    The integer value.

### getFloat

    public float getFloat(String key)

  This is a convenience method that will get the dictionary object that is expected to be an int. -1 is returned if there is no value.

  Parameters:
    `key` - The key to the item in the dictionary.
  Returns:
    The float value.

### getFloat

    public float getFloat(COSName key)

  This is a convenience method that will get the dictionary object that is expected to be an float. -1 is returned if there is no value.

  Parameters:
    `key` - The key to the item in the dictionary.
  Returns:
    The float value.

### getFloat

    public float getFloat(String key,
                          float defaultValue)

  This is a convenience method that will get the dictionary object that is expected to be a float. If the dictionary value is null then the default Value will be returned.

  Parameters:
    `key` - The key to the item in the dictionary.
    `defaultValue` - The value to return if the dictionary item is null.
  Returns:
    The float value.

### getFloat

    public float getFloat(COSName key,
                          float defaultValue)

  This is a convenience method that will get the dictionary object that is expected to be an float. If the dictionary value is null then the default Value will be returned.

  Parameters:
    `key` - The key to the item in the dictionary.
    `defaultValue` - The value to return if the dictionary item is null.
  Returns:
    The float value.

### removeItem

    public void removeItem(COSName key)

  This will remove an item for the dictionary. This will do nothing of the object does not exist.

  Parameters:
    `key` - The key to the item to remove from the dictionary.

### getItem

    public COSBase getItem(COSName key)

  This will do a lookup into the dictionary.

  Parameters:
    `key` - The key to the object.
  Returns:
    The item that matches the key.

### keyList

    public List keyList()

  This will get the keys for all objects in the dictionary in the sequence that they were added.

  Returns:
    a list of the keys in the sequence of insertion

### getValues

    public Collection getValues()

  This will get all of the values for the dictionary.

  Returns:
    All the values for the dictionary.

### accept

    public Object accept(ICOSVisitor visitor)
                  throws COSVisitorException

  visitor pattern double dispatch method.

  Specified by:
    `accept` in class `COSBase`
  Parameters:
    `visitor` - The object to notify when visiting this object.
  Returns:
    The object that the visitor returns.
  Throws:
    `COSVisitorException` - If there is an error visiting this object.

### addAll

    public void addAll(COSDictionary dic)

  This will add all of the dictionarys keys/values to this dictionary.

  Parameters:
    `dic` - The dic to get the keys from.

### mergeInto

    public void mergeInto(COSDictionary dic)

  This will add all of the dictionarys keys/values to this dictionary, but only if they don't already exist. If a key already exists in this dictionary then nothing is changed.

  Parameters:
    `dic` - The dic to get the keys from.

### getObjectFromPath

    public COSBase getObjectFromPath(String objPath)

  Nice method, gives you every object you want Arrays works properly too. Try "P/Annots/[k]/Rect" where k means the index of the Annotsarray.

  Parameters:
    `objPath` - the relative path to the object.
  Returns:
    the object

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD