org.netbeans.modules.xml.xam/1 1.18.0 1

org.netbeans.modules.xml.xam.dom
Class AbstractNamedComponentReference<T extends NamedReferenceable>

java.lang.Object
  extended by org.netbeans.modules.xml.xam.AbstractReference<T>
      extended by org.netbeans.modules.xml.xam.dom.AbstractNamedComponentReference<T>
All Implemented Interfaces:
NamedComponentReference<T>, Reference<T>

public abstract class AbstractNamedComponentReference<T extends NamedReferenceable>
extends AbstractReference<T>
implements NamedComponentReference<T>

Abstract implementation of reference by name 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.


Field Summary
protected  String localName
           
protected  String prefix
           
protected  QName qname
           
 
Fields inherited from class org.netbeans.modules.xml.xam.AbstractReference
refString
 
Constructor Summary
AbstractNamedComponentReference(Class<T> referencedType, AbstractDocumentComponent parent, String ref)
          Constructor for reading.
AbstractNamedComponentReference(T referenced, Class<T> referencedType, AbstractDocumentComponent parent)
          Constructor for writing.
 
Method Summary
protected  QName calculateQNameLocally()
          Calculate the QName based on the local information without loading the referenced object.
protected  void checkParentNotRemovedFromModel()
           
protected  void checkParentPartOfModel()
           
 boolean equals(Object obj)
           
protected  String getLocalName()
           
protected  AbstractDocumentComponent getParent()
          Returns parent referencing component.
protected  String getPrefix()
           
 QName getQName()
          Note this method will first attempt to build the QName base on local lookup before trying to resolve the referenced.
protected  T getReferenced()
          Access method for referenced.
 String getRefString()
           
 int hashCode()
           
 boolean references(T target)
          Return true if this reference refers to target.
 void refresh()
           
 
Methods inherited from class org.netbeans.modules.xml.xam.AbstractReference
getType, isBroken, setReferenced, 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.dom.NamedComponentReference
getEffectiveNamespace
 
Methods inherited from interface org.netbeans.modules.xml.xam.Reference
get, getType, isBroken
 

Field Detail

prefix

protected String prefix

localName

protected String localName

qname

protected QName qname
Constructor Detail

AbstractNamedComponentReference

public AbstractNamedComponentReference(T referenced,
                                       Class<T> referencedType,
                                       AbstractDocumentComponent 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.

AbstractNamedComponentReference

public AbstractNamedComponentReference(Class<T> referencedType,
                                       AbstractDocumentComponent parent,
                                       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

references

public boolean references(T target)
Return true if this reference refers to target. This method is more efficient than invoking get

Specified by:
references in interface Reference<T extends NamedReferenceable>
Overrides:
references in class AbstractReference<T extends NamedReferenceable>

getRefString

public String getRefString()
Specified by:
getRefString in interface Reference<T extends NamedReferenceable>
Overrides:
getRefString in class AbstractReference<T extends NamedReferenceable>
Returns:
string to use in persiting the reference as attribute value of the containing component

getPrefix

protected String getPrefix()

getLocalName

protected String getLocalName()

getReferenced

protected T getReferenced()
Description copied from class: AbstractReference
Access method for referenced.

Overrides:
getReferenced in class AbstractReference<T extends NamedReferenceable>

getQName

public QName getQName()
Note this method will first attempt to build the QName base on local lookup before trying to resolve the referenced. Subclasses need to override if local calculation is not desirable.

Specified by:
getQName in interface NamedComponentReference<T extends NamedReferenceable>
Returns:
QName of the referenced component.
Throws:
IllegalStateException - if referencing component is discarded from the model.

getParent

protected AbstractDocumentComponent getParent()
Returns parent referencing component.

Overrides:
getParent in class AbstractReference<T extends NamedReferenceable>

checkParentPartOfModel

protected void checkParentPartOfModel()
Throws:
IllegalStateException - if parent is not part of a model.

checkParentNotRemovedFromModel

protected void checkParentNotRemovedFromModel()
Throws:
IllegalStateException - if parent is already removed from a model.

calculateQNameLocally

protected QName calculateQNameLocally()
Calculate the QName based on the local information without loading the referenced object.


equals

public boolean equals(Object obj)
Overrides:
equals in class AbstractReference<T extends NamedReferenceable>

hashCode

public int hashCode()
Overrides:
hashCode in class AbstractReference<T extends NamedReferenceable>

refresh

public void refresh()

org.netbeans.modules.xml.xam/1 1.18.0 1

Built on May 25 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.