Class ByteArrayAsset

  • All Implemented Interfaces:
    Asset

    public class ByteArrayAsset
    extends java.lang.Object
    implements Asset
    Implementation of an Asset backed by a byte array
    Version:
    $Revision: $
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private byte[] content
      Underlying content
      private static java.util.logging.Logger log
      Logger
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteArrayAsset​(byte[] content)
      Creates a new Asset instance backed by the specified byte array
      ByteArrayAsset​(java.io.InputStream stream)
      Creates a new Asset instance backed by the bytes contained in the the specified InputStream
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] getSource()
      Returns the underlying content.
      java.io.InputStream openStream()
      Get a input stream for the resource content.
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • log

        private static final java.util.logging.Logger log
        Logger
      • content

        private final byte[] content
        Underlying content
    • Constructor Detail

      • ByteArrayAsset

        public ByteArrayAsset​(byte[] content)
                       throws java.lang.IllegalArgumentException
        Creates a new Asset instance backed by the specified byte array
        Parameters:
        content -
        Throws:
        java.lang.IllegalArgumentException - If the contents were not specified
      • ByteArrayAsset

        public ByteArrayAsset​(java.io.InputStream stream)
        Creates a new Asset instance backed by the bytes contained in the the specified InputStream
        Parameters:
        stream -
        Throws:
        java.lang.IllegalArgumentException - If the stream is not specified
    • Method Detail

      • openStream

        public java.io.InputStream openStream()
        Description copied from interface: Asset
        Get a input stream for the resource content. The caller is responsible for closing the stream.
        Specified by:
        openStream in interface Asset
        Returns:
        A new open InputStream for each call
        See Also:
        Asset.openStream()
      • getSource

        public byte[] getSource()
        Returns the underlying content.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()