public abstract class AbstractConvertibleNut extends AbstractNut implements ConvertibleNut
Base class for ConvertibleNut
implementation with state management (attributes like transformers or referenced
nuts). Transformation is delegated to subclass.
Modifier | Constructor and Description |
---|---|
protected |
AbstractConvertibleNut(Nut o)
Builds a new instance.
|
protected |
AbstractConvertibleNut(String name,
NutType ft,
Future<Long> v,
Boolean c)
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 . |
boolean |
equals(Object other) |
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.
|
String |
getParentFile()
If the file is stored in a directory on the file system, then this method returns the directory.
|
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.
|
int |
hashCode() |
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.
|
void |
onReady(Pipe.OnReady callback)
Adds the given callback to be invoked once transformation occurs.
|
InputStream |
openStream()
Opens and returns an
InputStream pointing to the nut. |
void |
setIsCompressed(Boolean compressed)
Indicates if the nut is compressed.
|
void |
setIsSubResource(boolean sr)
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.
|
protected void |
setOriginalNuts(List<ConvertibleNut> o)
Sets the original nuts.
|
getInitialName, getInitialNutType, getProxyUri, getVersionNumber, setProxyUri, setVersionNumber, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isTransformed, transform
getInitialName, getInitialNutType, getProxyUri, getVersionNumber, setProxyUri
protected AbstractConvertibleNut(Nut o)
Builds a new instance.
o
- the converted nutprotected final void setOriginalNuts(List<ConvertibleNut> o)
Sets the original nuts.
o
- the original nutspublic Set<Pipe.Transformer<ConvertibleNut>> getTransformers()
Gets the registered transformers. The set must be ordered.
getTransformers
in interface ConvertibleNut
public List<Pipe.OnReady> getReadyCallbacks()
Gets the callbacks notified when transformation has been done.
getReadyCallbacks
in interface ConvertibleNut
public final Boolean isCompressed()
Indicates if the nut is compressed.
isCompressed
in interface ConvertibleNut
true
if the nut is compressed, false
otherwisepublic final void setIsCompressed(Boolean compressed)
Indicates if the nut is compressed.
setIsCompressed
in interface ConvertibleNut
compressed
- true
if the nut is compressed, false
otherwisepublic final void setNutName(String nutName)
Sets the nut name.
setNutName
in interface ConvertibleNut
nutName
- the namepublic final void setNutType(NutType nutType)
Sets the nut type.
setNutType
in interface ConvertibleNut
nutType
- the new nut typepublic final void setIsSubResource(boolean sr)
Mark this nut as a sub resource or not.
setIsSubResource
in interface ConvertibleNut
sr
- true
if the nut is a sub resource, false
otherwisepublic final boolean isSubResource()
ConvertibleNut
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 addTransformer(Pipe.Transformer<ConvertibleNut> transformer)
Adds a Pipe.Transformer
.
addTransformer
in interface ConvertibleNut
transformer
- the transformerpublic void onReady(Pipe.OnReady callback)
Adds the given callback to be invoked once transformation occurs.
onReady
in interface ConvertibleNut
callback
- the callback to addpublic String getName()
Returns the name potentially altered by other components like transformers.
getName
in interface ConvertibleNut
public NutType getNutType()
Returns the nut type potentially modified by other components like transformers.
getNutType
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 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 InputStream openStream() throws IOException
Opens and returns an InputStream
pointing to the nut.
openStream
in interface Nut
IOException
- if an I/O error occurspublic 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 String getParentFile()
If the file is stored in a directory on the file system, then this method returns the directory.
getParentFile
in interface Nut
getParentFile
in class AbstractNut
null
if the nut is not directly accessible on the file systempublic boolean equals(Object other)
equals
in class AbstractNut
public int hashCode()
hashCode
in class AbstractNut
Copyright © 2012-2015. All Rights Reserved.