Module org.htmlunit

Class Blob.InMemoryBackend

java.lang.Object
org.htmlunit.javascript.host.file.Blob.InMemoryBackend
All Implemented Interfaces:
Serializable, Blob.Backend
Enclosing class:
Blob

protected static class Blob.InMemoryBackend extends Object implements Blob.Backend
Implementation of the Blob.Backend that stores the bytes in memory.
See Also:
  • Constructor Details

    • InMemoryBackend

      protected InMemoryBackend(byte[] bytes, String fileName, String type, long lastModified)
      Ctor.
      Parameters:
      bytes - the bytes
      fileName - the name
      type - the type
      lastModified - last modified
  • Method Details

    • create

      protected static Blob.InMemoryBackend create(org.htmlunit.corejs.javascript.NativeArray fileBits, String fileName, String type, long lastModified)
      Factory method to create an Blob.InMemoryBackend from an NativeArray.
      Parameters:
      fileBits - the bytes as NativeArray
      fileName - the name
      type - the type
      lastModified - last modified
      Returns:
      the new Blob.InMemoryBackend
    • getName

      public String getName()
      Returns the name.
      Specified by:
      getName in interface Blob.Backend
      Returns:
      the name
    • getLastModified

      public long getLastModified()
      Returns the last modified timestamp as long.
      Specified by:
      getLastModified in interface Blob.Backend
      Returns:
      the last modified timestamp as long
    • getSize

      public long getSize()
      Returns the size.
      Specified by:
      getSize in interface Blob.Backend
      Returns:
      the size
    • getType

      public String getType(BrowserVersion browserVersion)
      Returns the type.
      Specified by:
      getType in interface Blob.Backend
      Parameters:
      browserVersion - the BrowserVersion
      Returns:
      the type
    • getText

      public String getText() throws IOException
      Returns the text.
      Specified by:
      getText in interface Blob.Backend
      Returns:
      the text
      Throws:
      IOException - in case of error
    • getBytes

      public byte[] getBytes(int start, int end)
      Returns the bytes.
      Specified by:
      getBytes in interface Blob.Backend
      Parameters:
      start - the start position
      end - the end position
      Returns:
      the bytes
    • getKeyDataPair

      public KeyDataPair getKeyDataPair(String name, String fileName, String contentType)
      Returns the KeyDataPair for this Blob/File.
      Specified by:
      getKeyDataPair in interface Blob.Backend
      Parameters:
      name - the name
      fileName - the file name
      contentType - the content type
      Returns:
      the KeyDataPair to hold the data