org.apache.pdfbox.cos

## Class COSObject

- java.lang.Object
- - org.apache.pdfbox.cos.COSBase
  - - org.apache.pdfbox.cos.COSObject

All Implemented Interfaces:
  COSUpdateInfo, COSObjectable

    public class COSObject
    extends COSBase
    implements COSUpdateInfo

This class represents a PDF object.

Author:
  Ben Litchfield

### Constructor Summary

Constructors
Constructor and Description
`COSObject(COSBase object)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods
`Object` `accept(ICOSVisitor visitor)` visitor pattern double dispatch method.
`boolean` `derefencingInProgress()` Indicates that the dereferencing of the represented indirect object is in progress.
`void` `dereferencingFinished()` Dereferencing of the represented indirect object is finished.
`void` `dereferencingStarted()` Start dereferencing the represented indirect object.
`COSBase` `getDictionaryObject(COSName key)` Deprecated. This will be removed in 3.0. Call `getObject()` to find out if it has the correct type and then call `getDictionaryObject(org.apache.pdfbox.cos.COSName)`.
`int` `getGenerationNumber()` Getter for property generationNumber.
`COSBase` `getItem(COSName key)` Deprecated. This will be removed in 3.0. Call `getObject()` to find out if it has the correct type and then call `getDictionaryObject(org.apache.pdfbox.cos.COSName)`.
`COSBase` `getObject()` This will get the object that this object encapsulates.
`long` `getObjectNumber()` Getter for property objectNumber.
`boolean` `isNeedToBeUpdated()` Get the update state for the COSWriter.
`void` `setGenerationNumber(int generationNumberValue)` Setter for property generationNumber.
`void` `setNeedToBeUpdated(boolean flag)` Set the update state of the dictionary for the COSWriter.
`void` `setObject(COSBase object)` This will set the object that this object encapsulates.
`void` `setObjectNumber(long objectNum)` Setter for property objectNumber.
`String` `toString()`

### Methods inherited from class org.apache.pdfbox.cos.COSBase

`getCOSObject, isDirect, setDirect`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### COSObject

    public COSObject(COSBase object)
              throws IOException

Constructor.

Parameters:
  `object` - The object that this encapsulates.
Throws:
  `IOException` - If there is an error with the object passed in.

### Method Detail

#### getDictionaryObject

    @Deprecated
    public COSBase getDictionaryObject(COSName key)

Deprecated. This will be removed in 3.0. Call `getObject()` to find out if it has the correct type and then call `getDictionaryObject(org.apache.pdfbox.cos.COSName)`.
This will get the dictionary object in this object that has the name key and if it is a pdfobjref then it will dereference that and return it.

Parameters:
  `key` - The key to the value that we are searching for.
Returns:
  The pdf object that matches the key.

#### getItem

    @Deprecated
    public COSBase getItem(COSName key)

Deprecated. This will be removed in 3.0. Call `getObject()` to find out if it has the correct type and then call `getDictionaryObject(org.apache.pdfbox.cos.COSName)`.
This will get the dictionary object in this object that has the name key.

Parameters:
  `key` - The key to the value that we are searching for.
Returns:
  The pdf object that matches the key.

#### getObject

    public COSBase getObject()

This will get the object that this object encapsulates.

Returns:
  The encapsulated object.

#### setObject

    public final void setObject(COSBase object)
                         throws IOException

This will set the object that this object encapsulates.

Parameters:
  `object` - The new object to encapsulate.
Throws:
  `IOException` - If there is an error setting the updated object.

#### derefencingInProgress

    public boolean derefencingInProgress()

Indicates that the dereferencing of the represented indirect object is in progress. It is used to detect a possible recursion which most likely ends up in a stack overflow.

Returns:
  true if dereferencing is in progress.

#### dereferencingStarted

    public void dereferencingStarted()

Start dereferencing the represented indirect object.

#### dereferencingFinished

    public void dereferencingFinished()

Dereferencing of the represented indirect object is finished.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### getObjectNumber

    public long getObjectNumber()

Getter for property objectNumber.

Returns:
  Value of property objectNumber.

#### setObjectNumber

    public void setObjectNumber(long objectNum)

Setter for property objectNumber.

Parameters:
  `objectNum` - New value of property objectNumber.

#### getGenerationNumber

    public int getGenerationNumber()

Getter for property generationNumber.

Returns:
  Value of property generationNumber.

#### setGenerationNumber

    public void setGenerationNumber(int generationNumberValue)

Setter for property generationNumber.

Parameters:
  `generationNumberValue` - New value of property generationNumber.

#### accept

    public Object accept(ICOSVisitor visitor)
                  throws IOException

visitor pattern double dispatch method.

Specified by:
  `accept` in class `COSBase`
Parameters:
  `visitor` - The object to notify when visiting this object.
Returns:
  any object, depending on the visitor implementation, or null
Throws:
  `IOException` - If an error occurs while visiting this object.

#### isNeedToBeUpdated

    public boolean isNeedToBeUpdated()

Get the update state for the COSWriter.

Specified by:
  `isNeedToBeUpdated` in interface `COSUpdateInfo`
Returns:
  the update state.

#### setNeedToBeUpdated

    public void setNeedToBeUpdated(boolean flag)

Set the update state of the dictionary for the COSWriter.

Specified by:
  `setNeedToBeUpdated` in interface `COSUpdateInfo`
Parameters:
  `flag` - the update state.