Package com.tom_roush.pdfbox.io
Class MemoryUsageSetting
- java.lang.Object
-
- com.tom_roush.pdfbox.io.MemoryUsageSetting
-
public final class MemoryUsageSetting extends Object
Controls how memory/temporary files are used for buffering streams etc.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetMaxMainMemoryBytes()Returns maximum size of main-memory in bytes to be used.longgetMaxStorageBytes()Returns maximum size of storage bytes to be used (main-memory in temporary files all together).FilegetTempDir()Returns directory to be used for temporary files ornullif it was not set.booleanisMainMemoryRestricted()Returnstrueif maximum main memory is restricted to a specific number of bytes.booleanisStorageRestricted()Returnstrueif maximum amount of storage is restricted to a specific number of bytes.MemoryUsageSettingsetTempDir(File tempDir)Sets directory to be used for temporary files.static MemoryUsageSettingsetupMainMemoryOnly()Setups buffering memory usage to only use main-memory (no temporary file) which is not restricted in size.static MemoryUsageSettingsetupMainMemoryOnly(long maxMainMemoryBytes)Setups buffering memory usage to only use main-memory with the defined maximum.static MemoryUsageSettingsetupMixed(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 MemoryUsageSettingsetupMixed(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 MemoryUsageSettingsetupTempFileOnly()Setups buffering memory usage to only use temporary file(s) (no main-memory) with not restricted size.static MemoryUsageSettingsetupTempFileOnly(long maxStorageBytes)Setups buffering memory usage to only use temporary file(s) (no main-memory) with the specified maximum size.StringtoString()booleanuseMainMemory()Returnstrueif main-memory is to be used.booleanuseTempFile()Returnstrueif temporary file is to be used.
-
-
-
Method Detail
-
setupMainMemoryOnly
public static MemoryUsageSetting setupMainMemoryOnly()
Setups buffering memory usage to only use main-memory (no temporary file) which is not restricted in size.
-
setupMainMemoryOnly
public static MemoryUsageSetting setupMainMemoryOnly(long maxMainMemoryBytes)
Setups buffering memory usage to only use main-memory with the defined maximum.- Parameters:
maxMainMemoryBytes- maximum number of main-memory to be used;-1for no restriction;0will also be interpreted here as no restriction
-
setupTempFileOnly
public static MemoryUsageSetting setupTempFileOnly()
Setups buffering memory usage to only use temporary file(s) (no main-memory) with not restricted size.
-
setupTempFileOnly
public static MemoryUsageSetting setupTempFileOnly(long maxStorageBytes)
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;-1for no restriction;0will also be interpreted here as no restriction
-
setupMixed
public 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.- Parameters:
maxMainMemoryBytes- maximum number of main-memory to be used; if-1this is the same assetupMainMemoryOnly(); if0this is the same assetupTempFileOnly()
-
setupMixed
public 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.- Parameters:
maxMainMemoryBytes- maximum number of main-memory to be used; if-1this is the same assetupMainMemoryOnly(); if0this is the same assetupTempFileOnly()maxStorageBytes- maximum size the main-memory and temporary file(s) may have all together;0or less will be ignored; if it is less than maxMainMemoryBytes we use maxMainMemoryBytes value instead
-
setTempDir
public MemoryUsageSetting setTempDir(File tempDir)
Sets directory to be used for temporary files.- Parameters:
tempDir- directory for temporary files- Returns:
- this instance
-
useMainMemory
public boolean useMainMemory()
Returnstrueif main-memory is to be used.If this returns
falseit is ensureduseTempFile()returnstrue.
-
useTempFile
public boolean useTempFile()
Returnstrueif temporary file is to be used.If this returns
falseit is ensureduseMainMemoryreturnstrue.
-
isMainMemoryRestricted
public boolean isMainMemoryRestricted()
Returnstrueif maximum main memory is restricted to a specific number of bytes.
-
isStorageRestricted
public boolean isStorageRestricted()
Returnstrueif 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
public File getTempDir()
Returns directory to be used for temporary files ornullif it was not set.
-
-