java.lang.Object
org.sejda.sambox.input.LazyIndirectObjectsProvider
- All Implemented Interfaces:
Closeable,AutoCloseable,IndirectObjectsProvider
A lazy implementation of the
IndirectObjectsProvider that retrieves COSBase objects parsing the
underlying source on demand (ie. when the IndirectObjectsProvider.get(COSObjectKey) method is called). Parsed
objects are stored in a cache to be reused. If for given a COSObjectKey no entry is found in the xref, a
fallback mechanism is activated performing a full scan of the document to retrieve all the objects defined in it.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Set<COSObjectKey>private static final org.slf4j.Loggerprivate COSParserprivate ObjectsFullScannerprivate SecurityHandlerprivate final Map<COSObjectKey,COSBase> private final Xref -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds the given xref entry to theXrefaddEntryIfAbsent(XrefEntry entry) Adds the given xref entry to theXrefif absentvoidclose()private voidprivate voidget(COSObjectKey key) id()initializeWith(COSParser parser) Initialize the component with theCOSParserto use to retrieve and parse requested objectinitializeWith(SecurityHandler handler) Initialize the component with theSecurityHandlerto decrypt streams and strings.private booleanisIndirectContainedIn(COSBase item, XrefEntry containingStreamEntry) private voidparseCompressedEntry(XrefEntry xrefEntry) private voidparseInUseEntry(XrefEntry xrefEntry) private voidparseObject(COSObjectKey key) private voidparseObjectStream(XrefEntry containingStreamEntry, COSStream stream) voidrelease(COSObjectKey key) Signals that the object corresponding to the given key is no longer needed and can be released
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
xref
-
scanner
-
store
-
currentlyParsing
-
securityHandler
-
parser
-
-
Constructor Details
-
LazyIndirectObjectsProvider
LazyIndirectObjectsProvider()
-
-
Method Details
-
get
- Specified by:
getin interfaceIndirectObjectsProvider- Returns:
- the
COSBasecorresponding to the given key.
-
release
Description copied from interface:IndirectObjectsProviderSignals that the object corresponding to the given key is no longer needed and can be released- Specified by:
releasein interfaceIndirectObjectsProvider
-
addEntryIfAbsent
Description copied from interface:IndirectObjectsProviderAdds the given xref entry to theXrefif absent- Specified by:
addEntryIfAbsentin interfaceIndirectObjectsProvider- Returns:
- null if the entry was added. The current entry with the given object number and generation if the entry was already present.
- See Also:
-
addEntry
Description copied from interface:IndirectObjectsProviderAdds the given xref entry to theXref- Specified by:
addEntryin interfaceIndirectObjectsProvider- Returns:
- the previous value or null if no entry was previously associated to the given object number and generation.
- See Also:
-
highestKey
- Specified by:
highestKeyin interfaceIndirectObjectsProvider- Returns:
- the highest key (object number + generation number) for this provider.
-
initializeWith
Description copied from interface:IndirectObjectsProviderInitialize the component with theCOSParserto use to retrieve and parse requested object- Specified by:
initializeWithin interfaceIndirectObjectsProvider- Returns:
- this provider
-
initializeWith
Description copied from interface:IndirectObjectsProviderInitialize the component with theSecurityHandlerto decrypt streams and strings.- Specified by:
initializeWithin interfaceIndirectObjectsProvider- Returns:
- this provider
-
parseObject
-
doParseFallbackObject
-
doParse
- Throws:
IOException
-
parseInUseEntry
- Throws:
IOException
-
parseCompressedEntry
- Throws:
IOException
-
parseObjectStream
private void parseObjectStream(XrefEntry containingStreamEntry, COSStream stream) throws IOException - Throws:
IOException
-
isIndirectContainedIn
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
id
- Specified by:
idin interfaceIndirectObjectsProvider- Returns:
- the unique id for the provider.
-