Class PdfMemoryUsageSetting

java.lang.Object
eu.europa.esig.dss.pdf.PdfMemoryUsageSetting

public class PdfMemoryUsageSetting extends Object
Represents the PDF document loading setting on signature creation or validation.
  • Constructor Details

    • PdfMemoryUsageSetting

      protected PdfMemoryUsageSetting(PdfMemoryUsageSetting.Mode mode)
      Default constructor
      Parameters:
      mode - PdfMemoryUsageSetting.Mode the memory handling mode
    • PdfMemoryUsageSetting

      protected PdfMemoryUsageSetting(PdfMemoryUsageSetting.Mode mode, long maxMemoryBytes, long maxStorageBytes)
      Constructor with memory allocation parameters
      Parameters:
      mode - PdfMemoryUsageSetting.Mode the memory handling mode
      maxMemoryBytes - the maximum number of bytes to be allocated in memory
      maxStorageBytes - the maximum number of bytes to be allocated both in memory and in a temporary file
  • Method Details

    • getMode

      public PdfMemoryUsageSetting.Mode getMode()
      Gets the PDF memory usage mode
      Returns:
      MemoryUsageSetting's load option PdfMemoryUsageSetting.Mode
    • getMaxMemoryBytes

      public long getMaxMemoryBytes()
      Gets the maximum number of bytes to be allocated in memory. NOTE: applicable only when mode is Mode.MEMORY or Mode.MIXED (implementation dependent)
      Returns:
      max bytes to be loaded into memory
    • getMaxStorageBytes

      public long getMaxStorageBytes()
      Gets the maximum number of bytes to be allocated in both memory and temporary file. NOTE: applicable only when mode is Mode.FILE or Mode.MIXED (implementation dependent)
      Returns:
      max bytes to be loaded into file
    • memoryFull

      public static PdfMemoryUsageSetting memoryFull()
      It represents a memory-forced type of handling. When chosen, the File is read and loaded to a byte array before processing.
      Returns:
      the PDF document load setting PdfMemoryUsageSetting
    • memoryBuffered

      public static PdfMemoryUsageSetting memoryBuffered()
      It represents memory unrestricted allocation size load mode. When this method is chosen, the file is loaded to the memory, as needed.
      Returns:
      the PDF document load setting PdfMemoryUsageSetting
    • memoryBuffered

      public static PdfMemoryUsageSetting memoryBuffered(long maxBytes)
      It represents memory unrestricted allocation size load mode. When this method is chosen, the file is loaded to the memory, as needed.
      Parameters:
      maxBytes - max allocation size
      Returns:
      the PDF document load setting PdfMemoryUsageSetting
    • fileOnly

      public static PdfMemoryUsageSetting fileOnly()
      It represents file only unrestricted allocation size load mode. When this method is chosen, the content of a file is stored in a temporary file in filesystem.
      Returns:
      the PDF document load setting PdfMemoryUsageSetting
    • fileOnly

      public static PdfMemoryUsageSetting fileOnly(long maxStorageBytes)
      It represents file only unrestricted allocation size load mode. When this method is chosen, the content of a file is stored in a temporary file in filesystem.
      Parameters:
      maxStorageBytes - max allocation size
      Returns:
      the PDF document load setting PdfMemoryUsageSetting
    • mixed

      public static PdfMemoryUsageSetting mixed(long maxMemoryBytes)
      It represents mixed memory-first unrestricted file allocation size load mode. When this mode is chosen, the content of file is stored in memory before exceeding of maxMemoryBytes, and the rest is stored in a temporary file in a filesystem.
      Parameters:
      maxMemoryBytes - max memory allocation size
      Returns:
      the PDF document load setting PdfMemoryUsageSetting
    • mixed

      public static PdfMemoryUsageSetting mixed(long maxMemoryBytes, long maxStorageBytes)
      It represents mixed memory-first restricted file allocation size load mode. When this mode is chosen, the content of file is stored in memory before exceeding of maxMemoryBytes, and the rest is stored in a temporary file in a filesystem.
      Parameters:
      maxMemoryBytes - max memory allocation size
      maxStorageBytes - max size the memory and temporary file may have together
      Returns:
      the PDF document load setting PdfMemoryUsageSetting
    • toString

      public String toString()
      Overrides:
      toString in class Object