junit.extensions.awt.script
Class ComponentReference

java.lang.Object
  |
  +--junit.extensions.awt.script.ComponentReference
All Implemented Interfaces:
Tags, XMLifiable

public class ComponentReference
extends java.lang.Object
implements Tags, XMLifiable

Encapsulate as much information as is available to identify a GUI component.


Fields inherited from interface junit.extensions.awt.script.Tags
TAG_ACTION, TAG_ARGS, TAG_ASSERT, TAG_AWTTESTSCRIPT, TAG_CLASS, TAG_COMPONENT, TAG_COUNT, TAG_DESC, TAG_EVENT, TAG_FILENAME, TAG_ID, TAG_INVERT, TAG_INVOKER, TAG_KEYCHAR, TAG_KEYCODE, TAG_KIND, TAG_LAUNCH, TAG_METHOD, TAG_MODIFIERS, TAG_NAME, TAG_PARENT, TAG_POLL_INTERVAL, TAG_SCRIPT, TAG_SEQUENCE, TAG_STOP_ON_ERROR, TAG_STOP_ON_FAILURE, TAG_TAG, TAG_TERMINATE, TAG_THREADED, TAG_TIMEOUT, TAG_TITLE, TAG_TRIGGER, TAG_TYPE, TAG_VALUE, TAG_WAIT, TAG_WINDOW, TAG_X, TAG_Y
 
Constructor Summary
ComponentReference(Resolver resolver, ComponentFinder finder, java.awt.Component comp)
          Create a reference based on the given component.
ComponentReference(Resolver resolver, ComponentFinder finder, org.w3c.dom.Element el)
           
 
Method Summary
 boolean equals(java.lang.Object obj)
          Any two component references are equivalent if they have the same XML.
 void fromXML(java.lang.String xml)
           
 java.lang.String getID()
          Unique identifier for this component.
 java.awt.Point getInvocationLocation()
           
 java.lang.String getInvoker()
          Invoker of a JPopupMenu.
 java.lang.String getName()
          This component's name, null if no name was set.
 java.lang.String getParentID()
          Reference ID of this component's parent (optional).
 ComponentReference getParentReference()
          Return a reference to this reference's parent, if available.
 java.lang.Class getRefClass()
          This component's class.
 java.lang.String getTag()
          Returns a component class-specific tag used to match this reference to a real component.
 java.lang.String getTitle()
          Title string of this component's parent frame (optional).
 java.lang.String getWindowID()
          Reference ID of this component's parent window (optional).
 ComponentReference getWindowReference()
          Return a reference to this reference's window, if available.
 int hashCode()
          Hash off of the XML representation rather than the objects themselves.
 boolean matches(java.awt.Component comp)
           
 java.awt.Component resolve()
           
 java.lang.String toString()
           
 java.lang.String toXML()
          Provide an XML representation of the object.
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComponentReference

public ComponentReference(Resolver resolver,
                          ComponentFinder finder,
                          org.w3c.dom.Element el)
                   throws java.lang.IllegalArgumentException

ComponentReference

public ComponentReference(Resolver resolver,
                          ComponentFinder finder,
                          java.awt.Component comp)
Create a reference based on the given component. May recursively add other components required to identify this one.
Method Detail

getID

public java.lang.String getID()
Unique identifier for this component.

getName

public java.lang.String getName()
This component's name, null if no name was set.

getRefClass

public java.lang.Class getRefClass()
This component's class.

getParentID

public java.lang.String getParentID()
Reference ID of this component's parent (optional).

getWindowID

public java.lang.String getWindowID()
Reference ID of this component's parent window (optional).

getTitle

public java.lang.String getTitle()
Title string of this component's parent frame (optional).

getInvoker

public java.lang.String getInvoker()
Invoker of a JPopupMenu.

getInvocationLocation

public java.awt.Point getInvocationLocation()

getTag

public java.lang.String getTag()
Returns a component class-specific tag used to match this reference to a real component.

fromXML

public void fromXML(java.lang.String xml)

getWindowReference

public ComponentReference getWindowReference()
Return a reference to this reference's window, if available.

getParentReference

public ComponentReference getParentReference()
Return a reference to this reference's parent, if available.

resolve

public java.awt.Component resolve()
                           throws ComponentNotFoundException

toXML

public java.lang.String toXML()
Description copied from interface: XMLifiable
Provide an XML representation of the object.
Specified by:
toXML in interface XMLifiable

hashCode

public int hashCode()
Hash off of the XML representation rather than the objects themselves.
Overrides:
hashCode in class java.lang.Object

matches

public boolean matches(java.awt.Component comp)

equals

public boolean equals(java.lang.Object obj)
Any two component references are equivalent if they have the same XML.
Overrides:
equals in class java.lang.Object

toString

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