com.vinculumtech.carrierwave.image
Class Image

java.lang.Object
  extended bycom.vinculumtech.carrierwave.image.Image
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public abstract class Image
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Image is the base abstract class for all client side Imageable representations. That is, all server side classes that implement the Imageable interface have a semantically equivalent client side type that subclasses the Image class.

During runtime, if an Image subclass is instantiated on the client, it can be sent to the server so that an Imageable equivalent can be created, sourced by the values the Image instance was given on the client.

Version:
$Id: //depot/carrierwave/src/shared/com/vinculumtech/carrierwave/image/Image.java#21 $
See Also:
Serialized Form

Nested Class Summary
static class Image.Identity
          This class represents the identity of a non-reflected Image instance.
 
Constructor Summary
  Image()
           
protected Image(Icon icon)
           
 
Method Summary
 Icon associateIcon(int index, Icon icon)
          Used by the ImageArray class to add Icon only referenced elements.
 Icon associateIcon(java.lang.Object key, Icon icon)
          Used by the ImageMap class to add Icon only referenced elements.
protected  Icon associateImage(Icon icon, java.lang.String edge)
           
protected  Icon associateImage(Image image, java.lang.String edge)
           
 Icon associateImage(int index, Image image, java.lang.String edge)
          Used by the ImageArray class to add elements.
 Icon associateImage(java.lang.Object key, Image image, java.lang.String edge)
          Used by the ImageMap class to add elements.
 void clearEdges()
          Sets all edge fields to null.
abstract  java.lang.Object clone()
          Returns a clone of this Image instance.
protected  java.lang.Object clone(Image image)
           
protected  int decrementReferenceCount()
           
 void disassociateImage(Icon icon)
          Disassociates the an Image instance associated with the given Icon instance from the ImageGraph this instance belongs, if applicable.
 void disassociateImage(Image image)
          Disassociates the given Image instance from the ImageGraph this instance belongs, if applicable.
protected  void disassociateImage(java.util.Map images)
           
 boolean equals(java.lang.Object object)
          Returns true if the object is a subclass of Image and the Icon instance equals this Image instances Icon.
 Icon getIcon()
           
 Image getImage(Icon icon)
           
abstract  java.lang.String getImageableType()
          The Imageable type this Image instance represents.
 ImageGraph getImageGraph()
          Returns the ImageGraph instance this Image instance is associated with, if none exists, an ImageGraph instance is created on demand (lazy init).
abstract  java.lang.String getImageInterfaceType()
          The image interface type this Image instance implements.
 Image getImageStrict(Icon icon)
           
 Image getParentImage()
          If this Image instance is dependent, returns the parent Imgae instance of this Image instance, otherwise null.
 int getReferenceCount()
          Returns the number of Image instances that reference this Image instance.
 int hashCode()
          Simply uses the hashcode of the Icon held by this Image instance.
 boolean hasImageGraph()
           
static Icon iconOf(java.lang.Object object)
          A simple convenience method that returns the Icon for the given object.
static Image imageOf(java.lang.Object object)
          A simple convenience method that returns the given object cast as an Image.
protected  int incrementReferenceCount()
           
protected  int incrementReferenceCount(int advance)
           
 boolean isDependent()
          Dependent Images are those who represent Imageable, but not ImageableIdentifiable, server side types.
That is, they do not have a persistent identity that is not relative to another object.
 boolean isDirty()
          Returns true if this image has been changed since it was marked clean.
Images returned from the server are clean by default.
 boolean isIgnoreChange()
           
 boolean isOrigin()
           
 boolean isReflection()
           
 boolean isTransient()
          Transient Images are those who are Imageable but are never persisted via PersistenceRoot.
Typically ImageableFinder or ImageableAction concrete types should also be ImageableTransient.
protected  void localProjectInto(java.lang.Object imageable)
          Overriden by Image subclasses.
protected  void localReflectFrom(java.lang.Object imageable)
          Overriden by Image subclasses.
protected  Icon makeDependentIcon(Icon icon, java.lang.String imageType, java.lang.String edge)
           
 void markClean()
          Marks this instance as clean.
 void markDirty()
          Marks this Image instance as dirty.
 void projectInto(java.lang.Object imageable)
          Projection only stores literal values into the given source, not into related Imageable objects.
 void reflectFrom(java.lang.Object imageable)
          Reflection only retrieves literal values from the given source, not related Imageable objects.
 void resetReferenceCount()
          Sets the referenceCount to zero.
abstract  boolean[] retrieveDependentEdges()
          Returns an array specifying which edge fields on this Image instance are 'dependent'.
The values are ordered relative to the fields in the method retrieveEdges.
abstract  java.lang.String[] retrieveEdgeImageTypes()
          Returns an array specifying the image types of the edge fields.
The values are ordered relative to the fields in the method retrieveEdges.
abstract  java.lang.String[] retrieveEdges()
          Returns an array of all the fields on this Image instance that represent non literal values.
abstract  java.lang.String[] retrieveEdgeTypes()
          Returns an array specifying the private types of the edge fields.
The values are ordered relative to the fields in the method retrieveEdges.
abstract  java.lang.String[] retrieveLiterals()
          Returns an array of all the field names on this Image instance that represent literal values.
abstract  java.lang.String[] retrieveLiteralTypes()
          Returns an array of all the field types on this Image instance that represent literal values.
abstract  boolean[] retrieveReadOnlyEdges()
          Returns an array specifying which edge fields on this Image instance are 'read-only'.
The values are ordered relative to the fields in the method retrieveEdges.
abstract  boolean[] retrieveReadOnlyLiterals()
          Returns an array specifying which literal fields on this Image instance are 'read-only'.
The values are ordered relative to the fields in the method retrieveLiterals.
abstract  boolean[] retrieveReferenceOnlyEdges()
          Returns an array specifying which edge fields on this Image instance are 'reference only'.
The values are ordered relative to the fields in the method retrieveEdges.
protected  void setIcon(Icon icon)
           
 void setIgnoreChange(boolean ignoreChange)
          Set to true if this image should not be marked dirty during any setter or adder.
protected  void setImageGraph(ImageGraph imageGraph)
           
protected  void setIsDirty(boolean isDirty)
           
protected  void setIsOrigin(boolean isOrigin)
           
protected  void setIsReflection(boolean isReflection)
           
 void setReferenceCount(int referenceCount)
          Sets the referenceCount of this Image instance.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Image

public Image()

Image

protected Image(Icon icon)
Method Detail

iconOf

public static final Icon iconOf(java.lang.Object object)
A simple convenience method that returns the Icon for the given object.

Parameters:
object -
Returns:

imageOf

public static final Image imageOf(java.lang.Object object)
A simple convenience method that returns the given object cast as an Image.

Parameters:
object -
Returns:

isIgnoreChange

public boolean isIgnoreChange()
Returns:
true if this instance will not become dirty during a setter call

setIgnoreChange

public void setIgnoreChange(boolean ignoreChange)
Set to true if this image should not be marked dirty during any setter or adder.

Parameters:
ignoreChange -

setIsOrigin

protected void setIsOrigin(boolean isOrigin)

isOrigin

public boolean isOrigin()
Returns:
true if this instance is considered an origin by its owning ImageGraph instance

associateImage

public Icon associateImage(int index,
                           Image image,
                           java.lang.String edge)
Used by the ImageArray class to add elements.

Parameters:
index -
image -
edge -
Returns:

associateImage

public Icon associateImage(java.lang.Object key,
                           Image image,
                           java.lang.String edge)
Used by the ImageMap class to add elements.

Parameters:
key -
image -
edge -
Returns:

associateIcon

public Icon associateIcon(int index,
                          Icon icon)
Used by the ImageArray class to add Icon only referenced elements.

Parameters:
index -
icon -
Returns:

associateIcon

public Icon associateIcon(java.lang.Object key,
                          Icon icon)
Used by the ImageMap class to add Icon only referenced elements.

Parameters:
key -
icon -
Returns:

associateImage

protected Icon associateImage(Icon icon,
                              java.lang.String edge)

associateImage

protected Icon associateImage(Image image,
                              java.lang.String edge)

disassociateImage

protected void disassociateImage(java.util.Map images)

disassociateImage

public void disassociateImage(Image image)
Disassociates the given Image instance from the ImageGraph this instance belongs, if applicable.

Parameters:
image -

disassociateImage

public void disassociateImage(Icon icon)
Disassociates the an Image instance associated with the given Icon instance from the ImageGraph this instance belongs, if applicable.

Parameters:
icon -

getImage

public Image getImage(Icon icon)
Parameters:
icon -
Returns:
an Image instance associated with the given Icon instance, null otherwise

getImageStrict

public Image getImageStrict(Icon icon)
Parameters:
icon -
Returns:
an Image instance associated with the given Icon instance, exception otherwise
Throws:
IconOnlyFoundException - if no Image instance can be found for the given Icon instance

setImageGraph

protected void setImageGraph(ImageGraph imageGraph)

hasImageGraph

public boolean hasImageGraph()
Returns:
true if this Image instance is associated with an ImageGraph instance.

getImageGraph

public ImageGraph getImageGraph()
Returns the ImageGraph instance this Image instance is associated with, if none exists, an ImageGraph instance is created on demand (lazy init).

Returns:
the ImageGraph instance this Image instance is associated with.

setIsDirty

protected void setIsDirty(boolean isDirty)

markDirty

public void markDirty()
Marks this Image instance as dirty. If this instance is dependent, the parent will be marked dirtly also.


isDirty

public boolean isDirty()
Returns true if this image has been changed since it was marked clean.
Images returned from the server are clean by default. Images instantiated in the client are dirty by default.

Returns:
true if this Image instance is dirty

markClean

public void markClean()
Marks this instance as clean. Does not affect parent or child Image instance.


isDependent

public boolean isDependent()
Dependent Images are those who represent Imageable, but not ImageableIdentifiable, server side types.
That is, they do not have a persistent identity that is not relative to another object.

Returns:
true is this Image instance is dependent

isTransient

public boolean isTransient()
Transient Images are those who are Imageable but are never persisted via PersistenceRoot.
Typically ImageableFinder or ImageableAction concrete types should also be ImageableTransient.

Returns:

isReflection

public boolean isReflection()
Returns:
true if this Image instance was sourced by server side Imageable instance, false if instantiated on the client

setIsReflection

protected void setIsReflection(boolean isReflection)

incrementReferenceCount

protected int incrementReferenceCount(int advance)

incrementReferenceCount

protected int incrementReferenceCount()

decrementReferenceCount

protected int decrementReferenceCount()

getReferenceCount

public int getReferenceCount()
Returns the number of Image instances that reference this Image instance. This values may not always be correct. See ImageGraphHelper for tools to synchronize an ImageGraph.

Returns:
the number of Image instances that reference this Image instance
See Also:
ImageGraphHelper

setReferenceCount

public void setReferenceCount(int referenceCount)
Sets the referenceCount of this Image instance.

Parameters:
referenceCount -

resetReferenceCount

public void resetReferenceCount()
Sets the referenceCount to zero.


setIcon

protected void setIcon(Icon icon)

makeDependentIcon

protected Icon makeDependentIcon(Icon icon,
                                 java.lang.String imageType,
                                 java.lang.String edge)

getIcon

public final Icon getIcon()
Returns:
the Icon instance that represents this Image instances identity

getParentImage

public Image getParentImage()
If this Image instance is dependent, returns the parent Imgae instance of this Image instance, otherwise null.

Returns:
this Image instances parent Image instance

clearEdges

public void clearEdges()
Sets all edge fields to null. All literal values are untouched.
Note that this method will not decrement reference counts of the associated images.


toString

public java.lang.String toString()

clone

public abstract java.lang.Object clone()
                                throws java.lang.CloneNotSupportedException
Returns a clone of this Image instance. The clone is not deep, but containers held by this instance are cloned (but not the values in them).
Also the origin, reflection, and dirty status is copies, as is the Icon.

Returns:
Throws:
java.lang.CloneNotSupportedException

clone

protected java.lang.Object clone(Image image)

hashCode

public int hashCode()
Simply uses the hashcode of the Icon held by this Image instance.

Returns:

equals

public boolean equals(java.lang.Object object)
Returns true if the object is a subclass of Image and the Icon instance equals this Image instances Icon.

Parameters:
object -
Returns:
true if the given object equals this Image instance

retrieveLiterals

public abstract java.lang.String[] retrieveLiterals()
Returns an array of all the field names on this Image instance that represent literal values.

Returns:

retrieveLiteralTypes

public abstract java.lang.String[] retrieveLiteralTypes()
Returns an array of all the field types on this Image instance that represent literal values.

Returns:

retrieveReadOnlyLiterals

public abstract boolean[] retrieveReadOnlyLiterals()
Returns an array specifying which literal fields on this Image instance are 'read-only'.
The values are ordered relative to the fields in the method retrieveLiterals.

Returns:

retrieveEdges

public abstract java.lang.String[] retrieveEdges()
Returns an array of all the fields on this Image instance that represent non literal values.

Returns:

retrieveEdgeTypes

public abstract java.lang.String[] retrieveEdgeTypes()
Returns an array specifying the private types of the edge fields.
The values are ordered relative to the fields in the method retrieveEdges.

Returns:

retrieveEdgeImageTypes

public abstract java.lang.String[] retrieveEdgeImageTypes()
Returns an array specifying the image types of the edge fields.
The values are ordered relative to the fields in the method retrieveEdges.

Returns:

retrieveDependentEdges

public abstract boolean[] retrieveDependentEdges()
Returns an array specifying which edge fields on this Image instance are 'dependent'.
The values are ordered relative to the fields in the method retrieveEdges.

Returns:

retrieveReferenceOnlyEdges

public abstract boolean[] retrieveReferenceOnlyEdges()
Returns an array specifying which edge fields on this Image instance are 'reference only'.
The values are ordered relative to the fields in the method retrieveEdges.

Returns:

retrieveReadOnlyEdges

public abstract boolean[] retrieveReadOnlyEdges()
Returns an array specifying which edge fields on this Image instance are 'read-only'.
The values are ordered relative to the fields in the method retrieveEdges.

Returns:

getImageableType

public abstract java.lang.String getImageableType()
The Imageable type this Image instance represents.

Returns:

getImageInterfaceType

public abstract java.lang.String getImageInterfaceType()
The image interface type this Image instance implements.

Returns:

reflectFrom

public final void reflectFrom(java.lang.Object imageable)
                       throws ReflectionException
Reflection only retrieves literal values from the given source, not related Imageable objects.

Parameters:
imageable -
Throws:
ReflectionException

localReflectFrom

protected void localReflectFrom(java.lang.Object imageable)
                         throws java.lang.Exception
Overriden by Image subclasses.

Parameters:
imageable -
Throws:
java.lang.Exception

projectInto

public final void projectInto(java.lang.Object imageable)
                       throws ProjectionException
Projection only stores literal values into the given source, not into related Imageable objects.

Parameters:
imageable -
Throws:
ProjectionException

localProjectInto

protected void localProjectInto(java.lang.Object imageable)
                         throws java.lang.Exception
Overriden by Image subclasses.

Parameters:
imageable -
Throws:
java.lang.Exception


Copyright (C) 2002 Vinculum Technologies, Inc. All Rights Reserved.