org.apache.pdfbox.pdfparser

## Class PDFObjectStreamParser

- java.lang.Object
- - org.apache.pdfbox.pdfparser.BaseParser
  - - org.apache.pdfbox.pdfparser.PDFObjectStreamParser

    public class PDFObjectStreamParser
    extends BaseParser

This will parse a PDF 1.5 object stream and extract the object with given object number from the stream.

Author:
  Ben Litchfield

### Field Summary

### Fields inherited from class org.apache.pdfbox.pdfparser.BaseParser

`A, ASCII_CR, ASCII_LF, B, D, DEF, document, E, ENDOBJ_STRING, ENDSTREAM_STRING, J, M, N, O, R, S, source, STREAM_STRING, T`

### Constructor Summary

Constructors
Constructor and Description
`PDFObjectStreamParser(COSStream stream, COSDocument document)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`Map<COSObjectKey,COSBase>` `parseAllObjects()` Parse all compressed objects.
`COSBase` `parseObject(long objectNumber)` Search for/parse the object with the given object number.
`Map<Long,Integer>` `readObjectNumbers()` Read all object numbers from the compressed object stream.

### Methods inherited from class org.apache.pdfbox.pdfparser.BaseParser

`getObjectKey, isClosing, isClosing, isDigit, isDigit, isEndOfName, isEOF, isEOL, isEOL, isSpace, isSpace, isWhitespace, isWhitespace, parseCOSArray, parseCOSDictionary, parseCOSName, parseCOSString, parseDirObject, readExpectedChar, readExpectedString, readGenerationNumber, readInt, readLine, readLong, readObjectNumber, readString, readString, readStringNumber, skipLinebreak, skipSpaces, skipWhiteSpaces`

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

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

### Constructor Detail

#### PDFObjectStreamParser

    public PDFObjectStreamParser(COSStream stream,
                                 COSDocument document)
                          throws IOException

Constructor.

Parameters:
  `stream` - The stream to parse.
  `document` - The document for the current parsing.
Throws:
  `IOException` - If there is an error initializing the stream.

### Method Detail

#### parseObject

    public COSBase parseObject(long objectNumber)
                        throws IOException

Search for/parse the object with the given object number. The stream is closed after parsing the object with the given number.

Parameters:
  `objectNumber` - the number of the object to b e parsed
Returns:
  the parsed object or null if the object with the given number can't be found
Throws:
  `IOException` - if there is an error while parsing the stream

#### parseAllObjects

    public Map<COSObjectKey,COSBase> parseAllObjects()
                                              throws IOException

Parse all compressed objects. The stream is closed after parsing.

Returns:
  a map containing all parsed objects using the object number as key
Throws:
  `IOException` - if there is an error while parsing the stream

#### readObjectNumbers

    public Map<Long,Integer> readObjectNumbers()
                                        throws IOException

Read all object numbers from the compressed object stream. The stream is closed after reading the object numbers.

Returns:
  a map off all object numbers and the corresponding offset within the object stream.
Throws:
  `IOException` - if there is an error while parsing the stream