public final class ByteArrayNut extends PipedConvertibleNut implements Serializable
Represents an in-memory nut which can be created on the fly in any context.
This class also aims to provide a fully Serializable
Nut
.
Since the Future
implementation which provides the version number could is not
always a Serializable
, then the version number must be directly provided.
Constructor and Description |
---|
ByteArrayNut(byte[] bytes,
String name,
NutType nt,
ConvertibleNut originalNut)
Builds a new
Nut transformed nut based on a given byte array and only one original nut. |
ByteArrayNut(byte[] bytes,
String name,
NutType nt,
List<ConvertibleNut> originalNuts,
Long version)
Builds a new
Nut transformed nut based on a specified byte array. |
ByteArrayNut(byte[] bytes,
String name,
NutType nt,
Long version,
boolean dynamicContent)
Builds a new
Nut original nut based on a given byte array. |
Modifier and Type | Method and Description |
---|---|
boolean |
isDynamic()
Indicates if this nut has a dynamic content, meaning that it could be changed each time
Nut.openStream() is
invoked. |
InputStream |
openStream()
Opens and returns an
InputStream pointing to the nut. |
void |
setByteArray(byte[] bytes)
Sets the content.
|
static ConvertibleNut |
toByteArrayNut(ConvertibleNut nut)
Converts the given nut and its referenced nuts into nuts wrapping an in memory byte array.
|
static List<ConvertibleNut> |
toByteArrayNut(List<ConvertibleNut> nuts)
Converts the given nuts list and its referenced nuts into nuts wrapping an in memory byte array.
|
isTransformed, setTransformed, transform, transform
addReferencedNut, addTransformer, equals, getName, getNutType, getOriginalNuts, getParentFile, getReadyCallbacks, getReferencedNuts, getTransformers, hashCode, isCompressed, isSubResource, onReady, setIsCompressed, setIsSubResource, setNutName, setNutType, setOriginalNuts
getInitialName, getInitialNutType, getProxyUri, getVersionNumber, setProxyUri, setVersionNumber, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getInitialName, getInitialNutType, getProxyUri, getVersionNumber, setProxyUri
public ByteArrayNut(byte[] bytes, String name, NutType nt, ConvertibleNut originalNut)
Builds a new Nut
transformed nut based on a given byte array and only one original nut.
bytes
- the byte arrayname
- the nut nament
- the NutType
originalNut
- the original nutpublic ByteArrayNut(byte[] bytes, String name, NutType nt, List<ConvertibleNut> originalNuts, Long version)
Builds a new Nut
transformed nut based on a specified byte array. Content will be static and call to
setByteArray(byte[])
will be avoided.
bytes
- the byte arrayname
- the nut nament
- the NutType
originalNuts
- the original nutsversion
- the version numberpublic ByteArrayNut(byte[] bytes, String name, NutType nt, Long version, boolean dynamicContent)
Builds a new Nut
original nut based on a given byte array.
bytes
- the byte arrayname
- the nut nament
- the NutType
version
- the version numberdynamicContent
- true
if you will call setByteArray(byte[])
in the futurepublic static List<ConvertibleNut> toByteArrayNut(List<ConvertibleNut> nuts) throws IOException
Converts the given nuts list and its referenced nuts into nuts wrapping an in memory byte array.
IOException
- if any I/O error occurspublic static ConvertibleNut toByteArrayNut(ConvertibleNut nut) throws IOException
Converts the given nut and its referenced nuts into nuts wrapping an in memory byte array.
nut
- the nut to convertIOException
- if any I/O error occurspublic void setByteArray(byte[] bytes)
Sets the content.
bytes
- the new contentpublic InputStream openStream()
Opens and returns an InputStream
pointing to the nut.
openStream
in interface Nut
openStream
in class AbstractConvertibleNut
public boolean isDynamic()
Indicates if this nut has a dynamic content, meaning that it could be changed each time Nut.openStream()
is
invoked. In this case the nut should not be added to any cache and transformation chain should be applied.
isDynamic
in interface Nut
isDynamic
in class AbstractConvertibleNut
true
if content is dynamic, false
otherwiseCopyright © 2012-2015. All Rights Reserved.