public class NutWrapper extends AbstractNut implements ConvertibleNut
This class wraps a Nut
and implements Nut
interface by delegating method calls.
Useful when you need to change only some method behavior.
Constructor and Description |
---|
NutWrapper()
Default constructor for serialization purpose.
|
NutWrapper(ConvertibleNut w)
Builds a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addReferencedNut(ConvertibleNut referenced)
Adds a new nut referenced by this nut.
|
void |
addTransformer(Pipe.Transformer<ConvertibleNut> transformer)
Adds a
Pipe.Transformer . |
String |
getName()
Returns the name potentially altered by other components like transformers.
|
NutType |
getNutType()
Returns the nut type potentially modified by other components like transformers.
|
List<ConvertibleNut> |
getOriginalNuts()
When this nut is the result of the transformation of another one, then it is actually a processed nut.
|
List<Pipe.OnReady> |
getReadyCallbacks()
Gets the callbacks notified when transformation has been done.
|
List<ConvertibleNut> |
getReferencedNuts()
Gets the nuts referenced by this nut.
|
Set<Pipe.Transformer<ConvertibleNut>> |
getTransformers()
Gets the registered transformers.
|
Boolean |
isCompressed()
Indicates if the nut is compressed.
|
boolean |
isDynamic()
Indicates if this nut has a dynamic content, meaning that it could be changed each time
Nut.openStream() is
invoked. |
boolean |
isSubResource()
Indicates if this nut is a sub resource of the nut referencing it.
|
boolean |
isTransformed()
Indicates if this nut is transformed or not.
|
void |
onReady(Pipe.OnReady onReady)
Adds the given callback to be invoked once transformation occurs.
|
InputStream |
openStream()
Opens and returns an
InputStream pointing to the nut. |
void |
setIsCompressed(Boolean c)
Indicates if the nut is compressed.
|
void |
setIsSubResource(boolean subResource)
Mark this nut as a sub resource or not.
|
void |
setNutName(String nutName)
Sets the nut name.
|
void |
setNutType(NutType nutType)
Sets the nut type.
|
void |
transform(Pipe.OnReady... onReady)
Transforms the source stream with all registered transformers and calls the given callback in addition
to callbacks previously registered.
|
equals, getInitialName, getInitialNutType, getParentFile, getProxyUri, getVersionNumber, hashCode, setProxyUri, setVersionNumber, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getInitialName, getInitialNutType, getParentFile, getProxyUri, getVersionNumber, setProxyUri
public NutWrapper()
Default constructor for serialization purpose.
public NutWrapper(ConvertibleNut w)
Builds a new instance.
w
- teh wrapped nutpublic boolean isTransformed()
Indicates if this nut is transformed or not.
isTransformed
in interface ConvertibleNut
true
if transformed, false
otherwisepublic InputStream openStream() throws IOException
Opens and returns an InputStream
pointing to the nut.
openStream
in interface Nut
IOException
- if an I/O error occurspublic List<ConvertibleNut> getOriginalNuts()
When this nut is the result of the transformation of another one, then it is actually a processed nut. This returns
a list of original nuts that have been transformed to obtain this nut. When this nut is actually an non-transformed
one, say an original nut, then the returned value should be null
.
getOriginalNuts
in interface ConvertibleNut
null
if this nut is actually originalpublic String getName()
Returns the name potentially altered by other components like transformers.
getName
in interface ConvertibleNut
public void setNutName(String nutName)
Sets the nut name.
setNutName
in interface ConvertibleNut
nutName
- the namepublic 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 AbstractNut
true
if content is dynamic, false
otherwisepublic NutType getNutType()
Returns the nut type potentially modified by other components like transformers.
getNutType
in interface ConvertibleNut
public void setNutType(NutType nutType)
Sets the nut type.
setNutType
in interface ConvertibleNut
nutType
- the new nut typepublic void transform(Pipe.OnReady... onReady) throws IOException
Transforms the source stream with all registered transformers and calls the given callback in addition to callbacks previously registered. The method also writes the result to the given output stream.
transform
in interface ConvertibleNut
onReady
- the callbackIOException
- if an I/O error occurspublic void onReady(Pipe.OnReady onReady)
Adds the given callback to be invoked once transformation occurs.
onReady
in interface ConvertibleNut
onReady
- the callback to addpublic List<Pipe.OnReady> getReadyCallbacks()
Gets the callbacks notified when transformation has been done.
getReadyCallbacks
in interface ConvertibleNut
public void addTransformer(Pipe.Transformer<ConvertibleNut> transformer)
Adds a Pipe.Transformer
.
addTransformer
in interface ConvertibleNut
transformer
- the transformerpublic Set<Pipe.Transformer<ConvertibleNut>> getTransformers()
Gets the registered transformers. The set must be ordered.
getTransformers
in interface ConvertibleNut
public void addReferencedNut(ConvertibleNut referenced)
Adds a new nut referenced by this nut.
addReferencedNut
in interface ConvertibleNut
referenced
- the referenced nutpublic List<ConvertibleNut> getReferencedNuts()
Gets the nuts referenced by this nut.
getReferencedNuts
in interface ConvertibleNut
null
if no nut is referencedpublic void setIsCompressed(Boolean c)
Indicates if the nut is compressed.
setIsCompressed
in interface ConvertibleNut
c
- true
if the nut is compressed, false
otherwisepublic Boolean isCompressed()
Indicates if the nut is compressed.
isCompressed
in interface ConvertibleNut
true
if the nut is compressed, false
otherwisepublic boolean isSubResource()
Indicates if this nut is a sub resource of the nut referencing it. If this is true
, then this means that
the referencer must loads this nut in order to work.
isSubResource
in interface ConvertibleNut
true
if the nut is a sub resource, false
otherwisepublic void setIsSubResource(boolean subResource)
Mark this nut as a sub resource or not.
setIsSubResource
in interface ConvertibleNut
subResource
- true
if the nut is a sub resource, false
otherwiseCopyright © 2012-2015. All Rights Reserved.