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.
`COSObject(COSBase object, COSObjectKey objectKey)` Constructor.
`COSObject(COSBase object, ICOSParser parser)` Constructor.
`COSObject(COSObjectKey key, ICOSParser parser)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods
`void` `accept(ICOSVisitor visitor)` visitor pattern double dispatch method.
`int` `getGenerationNumber()` Deprecated. will be removed in 4.0.0
`COSBase` `getObject()` This will get the object that this object encapsulates.
`long` `getObjectNumber()` Deprecated. will be removed in 4.0.0
`COSUpdateState` `getUpdateState()` Returns the current `COSUpdateState` of this `COSObject`.
`boolean` `isDereferenced()` Returns `true`, if the hereby referenced `COSBase` has already been parsed and loaded.
`boolean` `isObjectNull()` Indicates if the referenced object is present or not.
`void` `setToNull()` Sets the referenced object to COSNull and removes the initially assigned parser.
`String` `toString()`

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

`getCOSObject, getKey, isDirect, setDirect, setKey`

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

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

### Methods inherited from interface org.apache.pdfbox.cos.COSUpdateInfo

`isNeedToBeUpdated, setNeedToBeUpdated, toIncrement`

### Methods inherited from interface org.apache.pdfbox.pdmodel.common.COSObjectable

`getCOSObject`

### Constructor Detail

#### COSObject

    public COSObject(COSBase object)

Constructor.

Parameters:
  `object` - The object that this encapsulates.

#### COSObject

    public COSObject(COSBase object,
                     COSObjectKey objectKey)

Constructor.

Parameters:
  `object` - The object that this encapsulates.
  `objectKey` - The COSObjectKey of the encapsulated object

#### COSObject

    public COSObject(COSBase object,
                     ICOSParser parser)

Constructor.

Parameters:
  `object` - The object that this encapsulates.
  `parser` - The parser to be used to load the object on demand

#### COSObject

    public COSObject(COSObjectKey key,
                     ICOSParser parser)

Constructor.

Parameters:
  `key` - The object number of the encapsulated object.
  `parser` - The parser to be used to load the object on demand

### Method Detail

#### isObjectNull

    public boolean isObjectNull()

Indicates if the referenced object is present or not.

Returns:
  true if the indirect object is dereferenced

#### getObject

    public COSBase getObject()

This will get the object that this object encapsulates.

Returns:
  The encapsulated object.

#### setToNull

    public final void setToNull()

Sets the referenced object to COSNull and removes the initially assigned parser.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### getObjectNumber

    @Deprecated
    public long getObjectNumber()

Deprecated. will be removed in 4.0.0
Getter for property objectNumber.

Returns:
  Value of property objectNumber.

#### getGenerationNumber

    @Deprecated
    public int getGenerationNumber()

Deprecated. will be removed in 4.0.0
Getter for property generationNumber.

Returns:
  Value of property generationNumber.

#### accept

    public void 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.
Throws:
  `IOException` - If an error occurs while visiting this object.

#### isDereferenced

    public boolean isDereferenced()

Returns `true`, if the hereby referenced `COSBase` has already been parsed and loaded.

Returns:
  `true`, if the hereby referenced `COSBase` has already been parsed and loaded.

#### getUpdateState

    public COSUpdateState getUpdateState()

Returns the current `COSUpdateState` of this `COSObject`.

Specified by:
  `getUpdateState` in interface `COSUpdateInfo`
Returns:
  The current `COSUpdateState` of this `COSObject`.
See Also:
  `COSUpdateState`