junit.extensions.jfcunit.eventdata
Class AbstractKeyEventData

java.lang.Object
  extended byjunit.extensions.jfcunit.eventdata.AbstractEventData
      extended byjunit.extensions.jfcunit.eventdata.AbstractKeyEventData
All Implemented Interfaces:
EventDataConstants
Direct Known Subclasses:
KeyEventData, StringEventData

public abstract class AbstractKeyEventData
extends AbstractEventData

Abstract data container class that holds most of the data necessary for jfcUnit to fire key events.

Author:
Vijay Aravamudhan : ThoughtWorks Inc.

Field Summary
private  java.util.Vector m_keyStrokes
          Key Strokes to be simulated.
 
Fields inherited from class junit.extensions.jfcunit.eventdata.AbstractEventData
 
Fields inherited from interface junit.extensions.jfcunit.eventdata.EventDataConstants
CENTER, CUSTOM, DEFAULT_HOLDTIME, DEFAULT_ISPOPUPTRIGGER, DEFAULT_KEY_MODIFIERS, DEFAULT_MOUSE_MODIFIERS, DEFAULT_NUMBEROFCLICKS, DEFAULT_POPUP_MODIFIERS, DEFAULT_POSITION, DEFAULT_SCROLL_AMOUNT, DEFAULT_SLEEPTIME, DEFAULT_WHEEL_ROTATION, DOWN_ARROW_SUBCOMPONENT, EAST, EDITOR_SUBCOMPONENT, INVALID_SUBCOMPONENT, INVALID_TEXT_OFFSET, NORTH, NORTH_EAST, NORTH_WEST, OFFSET, PERCENT, POSITIONSTRINGS, SOUTH, SOUTH_EAST, SOUTH_WEST, UP_ARROW_SUBCOMPONENT, WEST
 
Constructor Summary
AbstractKeyEventData()
           
 
Method Summary
protected  void addKeyStrokes(JFCKeyStroke[] strokes)
          Add key strokes to this event.
protected  void applyModifier(int modifiers)
          Apply the modifiers specified to all of the key strokes.
 boolean canConsume(java.awt.AWTEvent ae)
          Check if this event can consume the AWTEvent.
protected  void clearKeyStrokes()
          Clear key Strokes.
 boolean consume(java.awt.AWTEvent ae)
          Get the attribute value.
 boolean equals(java.lang.Object o)
          Compare to event datas and deterime if they are equal.
 int getDefaultModifiers()
          Get the default modifiers.
static KeyMapping getKeyMapping()
          Get the attribute value.
 JFCKeyStroke[] getKeyStrokes()
          Get the key strokes for this event.
 java.lang.String getModifierText()
          Get the current modifier text.
 int hashCode()
          Return the hashCode of the object.
 boolean prepareComponent()
          Prepare the text component.
static void setKeyMapping(KeyMapping km)
          Set the attribute value.
 void setModifiers(int modifiers)
          Set the modifiers on the event.
protected abstract  void setupKeyStrokes()
          Each implementing class needs to provide a method to translate the string into the keystorkes required to produce the string.
 
Methods inherited from class junit.extensions.jfcunit.eventdata.AbstractEventData
calculatePoint, getComponent, getDefaultPosition, getDefaultSleepTime, getLocationOnScreen, getModifiers, getPosition, getReferencePoint, getRoot, getRoot, getSleepTime, getTestCase, isMetaChar, isValid, isValidForProcessing, populate, setLocationOnScreen, setPosition, setReferencePoint, setSleepTime, setTestCase, setValid, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

m_keyStrokes

private final java.util.Vector m_keyStrokes
Key Strokes to be simulated.

Constructor Detail

AbstractKeyEventData

public AbstractKeyEventData()
Method Detail

getKeyStrokes

public final JFCKeyStroke[] getKeyStrokes()
Get the key strokes for this event.

Returns:
JFCKeyStroke[] to be simulated by this event.

setModifiers

public final void setModifiers(int modifiers)
Set the modifiers on the event.

Overrides:
setModifiers in class AbstractEventData
Parameters:
modifiers - modifiers to be set.

getDefaultModifiers

public int getDefaultModifiers()
Get the default modifiers.

Specified by:
getDefaultModifiers in class AbstractEventData
Returns:
Default key modiers.

setKeyMapping

public static void setKeyMapping(KeyMapping km)
Set the attribute value.

Parameters:
km - The new KeyMapping

getKeyMapping

public static KeyMapping getKeyMapping()
Get the attribute value.

Returns:
KeyMapping The KeyMapping that is being currently used.

getModifierText

public final java.lang.String getModifierText()
Get the current modifier text.

Specified by:
getModifierText in class AbstractEventData
Returns:
String containing the text form of the modifiers.

canConsume

public boolean canConsume(java.awt.AWTEvent ae)
Check if this event can consume the AWTEvent.

Overrides:
canConsume in class AbstractEventData
Parameters:
ae - AWTEvent to be consumed.
Returns:
boolean true if the event can be consumed.

consume

public boolean consume(java.awt.AWTEvent ae)
Get the attribute value.

Specified by:
consume in class AbstractEventData
Parameters:
ae - AWTEvent to be processed.
Returns:
boolean The value of the attribute

equals

public boolean equals(java.lang.Object o)
Compare to event datas and deterime if they are equal.

Overrides:
equals in class AbstractEventData
Parameters:
o - Object to be compared.
Returns:
true if the events are the same.

hashCode

public int hashCode()
Return the hashCode of the object.

Overrides:
hashCode in class AbstractEventData
Returns:
hashCode of the super class.

prepareComponent

public boolean prepareComponent()
Prepare the text component.

Overrides:
prepareComponent in class AbstractEventData
Returns:
boolean true if the component is ready.

setupKeyStrokes

protected abstract void setupKeyStrokes()
Each implementing class needs to provide a method to translate the string into the keystorkes required to produce the string.


addKeyStrokes

protected final void addKeyStrokes(JFCKeyStroke[] strokes)
Add key strokes to this event.

Parameters:
strokes - Key strokes to be added.

applyModifier

protected final void applyModifier(int modifiers)
Apply the modifiers specified to all of the key strokes.

Parameters:
modifiers - Modifiers to be applied.

clearKeyStrokes

protected final void clearKeyStrokes()
Clear key Strokes.



Licensed under: GNU Lesser General Public License, Ver 2.1, February 1999