com.vinculumtech.carrierwave
Class Icon

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

public final class Icon
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Icon is a paritally immutable token representnig an Image and/or Imageable instance.

It is only partially immutable since the becomeSoft() method changes the state of the Icon instance.

Version:
$Id: //depot/carrierwave/src/shared/com/vinculumtech/carrierwave/Icon.java#28 $
See Also:
Serialized Form

Field Summary
static java.lang.String ICON_PREFIX
           
static int NO_INDEX
          No index value.
static java.lang.Object NO_KEY
          No key value.
 
Constructor Summary
protected Icon(Icon parent, java.lang.String imageType, java.lang.String edge)
           
protected Icon(Icon parent, java.lang.String imageType, java.lang.String edge, int index)
           
protected Icon(Icon parent, java.lang.String imageType, java.lang.String edge, java.lang.Object key)
           
  Icon(java.lang.String externalForm)
          Takes the externalized form of an Icon and initializes this instance.
protected Icon(java.lang.String imageType, java.lang.String referenceableName)
           
protected Icon(java.lang.String host, java.lang.String imageType, java.lang.Object objectId)
           
protected Icon(java.lang.String host, java.lang.String imageType, java.lang.Object objectId, java.lang.String referenceableName)
           
protected Icon(java.lang.String host, java.lang.String imageType, java.lang.String referenceableName)
           
 
Method Summary
 void becomeSoft()
          Forces this Icon instance to loose its objectId if it has a referenceableName.
This is useful for long term storage of an Icon instance where the referenceableName is more durable than the objectId (ie, during developement or schema migration).
 java.lang.Object clone()
           
 boolean equals(java.lang.Object object)
           
 Icon getChild()
           
 java.lang.String getEdge()
          If this instance references a dependent object, returns the edge off the parent object used to reach the dependent object.
protected  java.lang.String getFullEdge()
           
 java.lang.String getHost()
           
 java.lang.String getImageType()
           
 int getIndex()
          If this Icon instance references an object in a List, this method will return the index that identifies it in that List
 java.lang.Object getKey()
          If this Icon instance references an object in a Map, this method will return the key that identifies it in that Map
 java.lang.Object getObjectId()
          Returns the object id of the object this instance references.
 Icon getParent()
           
 java.lang.String getReferenceableName()
           
 Icon getRoot()
          Returns the top level parent Icon instance or this if this instance is the root.
This method always returns a value.
 int hashCode()
           
 boolean hasIndex()
           
 boolean hasKey()
           
 boolean hasObjectId()
           
 boolean hasReferenceableName()
           
 boolean isContained()
           
 boolean isImageableIcon()
           
 boolean isImageIcon()
           
protected  void setIndex(int index)
           
protected  void setKey(java.lang.Object key)
           
 java.lang.String toExternalForm()
          This method returns a "stringized" version of this Icon instance.
Currently it is of the format:
 java.lang.StringBuffer toExternalForm(java.lang.StringBuffer stringBuffer)
           
 java.lang.String toString()
          Simply calls toExternalForm
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ICON_PREFIX

public static final java.lang.String ICON_PREFIX
See Also:
Constant Field Values

NO_INDEX

public static final int NO_INDEX
No index value.

See Also:
Constant Field Values

NO_KEY

public static final java.lang.Object NO_KEY
No key value.

Constructor Detail

Icon

public Icon(java.lang.String externalForm)
Takes the externalized form of an Icon and initializes this instance.

Parameters:
externalForm -

Icon

protected Icon(Icon parent,
               java.lang.String imageType,
               java.lang.String edge)

Icon

protected Icon(Icon parent,
               java.lang.String imageType,
               java.lang.String edge,
               int index)

Icon

protected Icon(Icon parent,
               java.lang.String imageType,
               java.lang.String edge,
               java.lang.Object key)

Icon

protected Icon(java.lang.String imageType,
               java.lang.String referenceableName)

Icon

protected Icon(java.lang.String host,
               java.lang.String imageType,
               java.lang.String referenceableName)

Icon

protected Icon(java.lang.String host,
               java.lang.String imageType,
               java.lang.Object objectId)

Icon

protected Icon(java.lang.String host,
               java.lang.String imageType,
               java.lang.Object objectId,
               java.lang.String referenceableName)
Method Detail

becomeSoft

public final void becomeSoft()
Forces this Icon instance to loose its objectId if it has a referenceableName.
This is useful for long term storage of an Icon instance where the referenceableName is more durable than the objectId (ie, during developement or schema migration).


isImageIcon

public final boolean isImageIcon()
Returns:
true if the objectId references a local Image instance only

isImageableIcon

public final boolean isImageableIcon()
Returns:
true if the objectId references a remote Imageable instance

getHost

public final java.lang.String getHost()
Returns:
the hostname:port of the server the object this Icon references lives

getObjectId

public final java.lang.Object getObjectId()
Returns the object id of the object this instance references. If the return value equals NO_ID, there is no valid id. If the value is zero or positive, this Icon references a valid object. If the value is negative, this Icon does not reference a valid object, only a local (temporary) Image instance.

Returns:
the object id of the object this instance references

hasObjectId

public final boolean hasObjectId()
Returns:
true if there is an object id

getReferenceableName

public final java.lang.String getReferenceableName()
Returns:
the referenceableName of the object this instance references

hasReferenceableName

public final boolean hasReferenceableName()
Returns:
true if this instance knows the referenced objects referenceableName

getImageType

public final java.lang.String getImageType()
Returns:
the Image type of the object this Icon instance references

getParent

public final Icon getParent()
Returns:
the parent Icon if this instance represents a dependent object

getChild

public final Icon getChild()
Returns:
the child Icon instance, if this Icon instance is a parent, otherwise null

getRoot

public final Icon getRoot()
Returns the top level parent Icon instance or this if this instance is the root.
This method always returns a value.

Returns:
the first parent Icon if this instance represents a dependent object, otherwise this

getEdge

public final java.lang.String getEdge()
If this instance references a dependent object, returns the edge off the parent object used to reach the dependent object.

Returns:
the edge that references the dependent object from the parent object

getFullEdge

protected final java.lang.String getFullEdge()

setIndex

protected final void setIndex(int index)

getIndex

public final int getIndex()
If this Icon instance references an object in a List, this method will return the index that identifies it in that List

Returns:
the element index in an List this Icon instance references

hasIndex

public final boolean hasIndex()
Returns:
true if this Icon instance knows the index

setKey

protected final void setKey(java.lang.Object key)

getKey

public final java.lang.Object getKey()
If this Icon instance references an object in a Map, this method will return the key that identifies it in that Map

Returns:
the element key in an Map this Icon instance references

hasKey

public final boolean hasKey()
Returns:
true if this Icon instance knows the key

isContained

public final boolean isContained()
Returns:
true if this Icon instance references an object in either a Map or List

toExternalForm

public final java.lang.String toExternalForm()
This method returns a "stringized" version of this Icon instance.
Currently it is of the format:
 ICON:imageType{HOST:hostname}{ID:id}{RNAME:name}
 ICON:imageType{HOST:hostname}{ID:id}{RNAME:name}.imageType{EDGE:edge}
 ICON:imageType{HOST:hostname}{ID:id}{RNAME:name}.imageType{EDGE:edge[index]}
 ICON:imageType{HOST:hostname}{ID:id}{RNAME:name}.imageType{EDGE:edge}
 

Returns:
a stringized version of this instance

toExternalForm

public final java.lang.StringBuffer toExternalForm(java.lang.StringBuffer stringBuffer)

toString

public final java.lang.String toString()
Simply calls toExternalForm

Returns:
a stringized version of this instance

hashCode

public final int hashCode()

equals

public final boolean equals(java.lang.Object object)

clone

public final java.lang.Object clone()
                             throws java.lang.CloneNotSupportedException
Throws:
java.lang.CloneNotSupportedException


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