Package org.apache.pdfbox.io
Class MemoryUsageSetting
java.lang.Object
org.apache.pdfbox.io.MemoryUsageSetting
Controls how memory/temporary files are used for
buffering streams etc.
-
Method Summary
Modifier and TypeMethodDescriptionlong
Returns maximum size of main-memory in bytes to be used.long
Returns maximum size of storage bytes to be used (main-memory in temporary files all together).getPartitionedCopy
(int parallelUseCount) Returns a copy of this instance with the maximum memory/storage restriction divided by the provided number of parallel uses.Returns directory to be used for temporary files ornull
if it was not set.boolean
Returnstrue
if maximum main memory is restricted to a specific number of bytes.boolean
Returnstrue
if maximum amount of storage is restricted to a specific number of bytes.setTempDir
(File tempDir) Sets directory to be used for temporary files.static MemoryUsageSetting
Setups buffering memory usage to only use main-memory (no temporary file) which is not restricted in size.static MemoryUsageSetting
setupMainMemoryOnly
(long maxMainMemoryBytes) Setups buffering memory usage to only use main-memory with the defined maximum.static MemoryUsageSetting
setupMixed
(long maxMainMemoryBytes) Setups buffering memory usage to use a portion of main-memory and additionally temporary file(s) in case the specified portion is exceeded.static MemoryUsageSetting
setupMixed
(long maxMainMemoryBytes, long maxStorageBytes) Setups buffering memory usage to use a portion of main-memory and additionally temporary file(s) in case the specified portion is exceeded.static MemoryUsageSetting
Setups buffering memory usage to only use temporary file(s) (no main-memory) with not restricted size.static MemoryUsageSetting
setupTempFileOnly
(long maxStorageBytes) Setups buffering memory usage to only use temporary file(s) (no main-memory) with the specified maximum size.toString()
boolean
Returnstrue
if main-memory is to be used.boolean
Returnstrue
if temporary file is to be used.
-
Method Details
-
setupMainMemoryOnly
Setups buffering memory usage to only use main-memory (no temporary file) which is not restricted in size. -
setupMainMemoryOnly
Setups buffering memory usage to only use main-memory with the defined maximum.- Parameters:
maxMainMemoryBytes
- maximum number of main-memory to be used;-1
for no restriction;0
will also be interpreted here as no restriction
-
setupTempFileOnly
Setups buffering memory usage to only use temporary file(s) (no main-memory) with not restricted size. -
setupTempFileOnly
Setups buffering memory usage to only use temporary file(s) (no main-memory) with the specified maximum size.- Parameters:
maxStorageBytes
- maximum size the temporary file(s) may have all together;-1
for no restriction;0
will also be interpreted here as no restriction
-
setupMixed
Setups buffering memory usage to use a portion of main-memory and additionally temporary file(s) in case the specified portion is exceeded.- Parameters:
maxMainMemoryBytes
- maximum number of main-memory to be used; if-1
this is the same assetupMainMemoryOnly()
; if0
this is the same assetupTempFileOnly()
-
setupMixed
Setups buffering memory usage to use a portion of main-memory and additionally temporary file(s) in case the specified portion is exceeded.- Parameters:
maxMainMemoryBytes
- maximum number of main-memory to be used; if-1
this is the same assetupMainMemoryOnly()
; if0
this is the same assetupTempFileOnly()
maxStorageBytes
- maximum size the main-memory and temporary file(s) may have all together;0
or less will be ignored; if it is less than maxMainMemoryBytes we use maxMainMemoryBytes value instead
-
getPartitionedCopy
Returns a copy of this instance with the maximum memory/storage restriction divided by the provided number of parallel uses.- Parameters:
parallelUseCount
- specifies the number of parallel usages for the setting to be returned- Returns:
- a copy from this instance with the maximum memory/storage restrictions adjusted to the multiple usage
-
setTempDir
Sets directory to be used for temporary files.- Parameters:
tempDir
- directory for temporary files- Returns:
- this instance
-
useMainMemory
public boolean useMainMemory()Returnstrue
if main-memory is to be used.If this returns
false
it is ensureduseTempFile()
returnstrue
. -
useTempFile
public boolean useTempFile()Returnstrue
if temporary file is to be used.If this returns
false
it is ensureduseMainMemory
returnstrue
. -
isMainMemoryRestricted
public boolean isMainMemoryRestricted()Returnstrue
if maximum main memory is restricted to a specific number of bytes. -
isStorageRestricted
public boolean isStorageRestricted()Returnstrue
if maximum amount of storage is restricted to a specific number of bytes. -
getMaxMainMemoryBytes
public long getMaxMainMemoryBytes()Returns maximum size of main-memory in bytes to be used. -
getMaxStorageBytes
public long getMaxStorageBytes()Returns maximum size of storage bytes to be used (main-memory in temporary files all together). -
getTempDir
Returns directory to be used for temporary files ornull
if it was not set. -
toString
-