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, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetInitialName, getInitialNutType, getParentFile, getProxyUri, getVersionNumber, setProxyUripublic 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 ConvertibleNuttrue if transformed, false otherwisepublic InputStream openStream() throws IOException
Opens and returns an InputStream pointing to the nut.
openStream in interface NutIOException - 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 ConvertibleNutnull if this nut is actually originalpublic String getName()
Returns the name potentially altered by other components like transformers.
getName in interface ConvertibleNutpublic void setNutName(String nutName)
Sets the nut name.
setNutName in interface ConvertibleNutnutName - 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 NutisDynamic in class AbstractNuttrue if content is dynamic, false otherwisepublic NutType getNutType()
Returns the nut type potentially modified by other components like transformers.
getNutType in interface ConvertibleNutpublic void setNutType(NutType nutType)
Sets the nut type.
setNutType in interface ConvertibleNutnutType - 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 ConvertibleNutonReady - 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 ConvertibleNutonReady - the callback to addpublic List<Pipe.OnReady> getReadyCallbacks()
Gets the callbacks notified when transformation has been done.
getReadyCallbacks in interface ConvertibleNutpublic void addTransformer(Pipe.Transformer<ConvertibleNut> transformer)
Adds a Pipe.Transformer.
addTransformer in interface ConvertibleNuttransformer - the transformerpublic Set<Pipe.Transformer<ConvertibleNut>> getTransformers()
Gets the registered transformers. The set must be ordered.
getTransformers in interface ConvertibleNutpublic void addReferencedNut(ConvertibleNut referenced)
Adds a new nut referenced by this nut.
addReferencedNut in interface ConvertibleNutreferenced - the referenced nutpublic List<ConvertibleNut> getReferencedNuts()
Gets the nuts referenced by this nut.
getReferencedNuts in interface ConvertibleNutnull if no nut is referencedpublic void setIsCompressed(Boolean c)
Indicates if the nut is compressed.
setIsCompressed in interface ConvertibleNutc - true if the nut is compressed, false otherwisepublic Boolean isCompressed()
Indicates if the nut is compressed.
isCompressed in interface ConvertibleNuttrue 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 ConvertibleNuttrue 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 ConvertibleNutsubResource - true if the nut is a sub resource, false otherwiseCopyright © 2012-2015. All Rights Reserved.