org.netbeans.modules.xml.xam
Class AbstractReference<T extends Referenceable>

java.lang.Object
  extended by org.netbeans.modules.xml.xam.AbstractReference<T>
All Implemented Interfaces:
Reference<T>
Direct Known Subclasses:
AbstractNamedComponentReference, AbstractReference, BindingFaultImpl.FaultReference, BindingInputImpl.InputReference, BindingOutputImpl.OutputReference, OperationReference

public abstract class AbstractReference<T extends Referenceable>
extends java.lang.Object
implements Reference<T>

Represents reference to a component. On writing, this indirection help serialize the referenced component as an attribute string value. On reading, the referenced can be resolved on demand.

Note: Client code should always check for brokeness before access the referenced.

Author:
rico, Nam Nguyen, Chris Webster

Field Summary
protected  java.lang.String refString
           
 
Constructor Summary
AbstractReference(java.lang.Class<T> referencedType, AbstractComponent parent, java.lang.String ref)
          Constructor for reading.
AbstractReference(T referenced, java.lang.Class<T> referencedType, AbstractComponent parent)
          Constructor for writing.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
protected  AbstractComponent getParent()
           
protected  T getReferenced()
          Access method for referenced.
 java.lang.String getRefString()
           
 java.lang.Class<T> getType()
          Returns type of the referenced component
 int hashCode()
           
 boolean isBroken()
          Returns true if the reference cannot be resolved in the current document
 boolean references(T target)
          Returns true if this reference refers to the target component.
protected  void setReferenced(T referenced)
          Accessor method for referenced.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.netbeans.modules.xml.xam.Reference
get
 

Field Detail

refString

protected java.lang.String refString
Constructor Detail

AbstractReference

public AbstractReference(T referenced,
                         java.lang.Class<T> referencedType,
                         AbstractComponent parent)
Constructor for writing.

Parameters:
referenced - the component being referenced
referencedType - type of the referenced component
parent - referencing component on which the referenced is serialized as an attribute string value.

AbstractReference

public AbstractReference(java.lang.Class<T> referencedType,
                         AbstractComponent parent,
                         java.lang.String ref)
Constructor for reading.

Parameters:
referencedType - type of the referenced component
parent - referencing component on which the referenced is serialized as an attribute string value.
ref - the string value used in resolving.
Method Detail

getReferenced

protected T getReferenced()
Access method for referenced.


setReferenced

protected void setReferenced(T referenced)
Accessor method for referenced.


getType

public java.lang.Class<T> getType()
Returns type of the referenced component

Specified by:
getType in interface Reference<T extends Referenceable>

isBroken

public boolean isBroken()
Returns true if the reference cannot be resolved in the current document

Specified by:
isBroken in interface Reference<T extends Referenceable>

references

public boolean references(T target)
Returns true if this reference refers to the target component.

Specified by:
references in interface Reference<T extends Referenceable>

getRefString

public java.lang.String getRefString()
Specified by:
getRefString in interface Reference<T extends Referenceable>
Returns:
string to use in persiting the reference as attribute value of the containing component

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getParent

protected AbstractComponent getParent()

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object