< prev index next >
core/JemmyCore/src/org/jemmy/control/Wrap.java
Print this page
@@ -51,69 +51,25 @@
*/
@ControlType(Object.class)
@ControlInterfaces({Mouse.class, Keyboard.class, Drag.class})
public abstract class Wrap<CONTROL extends Object> {
- /**
- *
- */
public static final String BOUNDS_PROP_NAME = "bounds";
- /**
- *
- */
public static final String CLICKPOINT_PROP_NAME = "clickPoint";
- /**
- *
- */
public static final String CONTROL_CLASS_PROP_NAME = "control.class";
- /**
- *
- */
public static final String CONTROL_PROP_NAME = "control";
- /**
- *
- */
public static final String INPUT_FACTORY_PROPERTY = "input.control.interface.factory";
- /**
- *
- */
public static final String IMAGE_LOADER_PROPERTY = "image.loader";
- /**
- *
- */
public static final String IMAGE_CAPTURER_PROPERTY = "image.capturer";
- /**
- *
- */
public static final String TEXT_PROP_NAME = "text";
- /**
- *
- */
public static final String POSITION_PROP_NAME = "position";
- /**
- *
- */
public static final String VALUE_PROP_NAME = "value";
- /**
- *
- */
public static final String WRAPPER_CLASS_PROP_NAME = "wrapper.class";
- /**
- *
- */
public static final String TOOLTIP_PROP_NAME = "tooltip";
- /**
- *
- */
public static final String NAME_PROP_NAME = "name";
- /**
- *
- */
public static final Timeout WAIT_STATE_TIMEOUT = new Timeout("wait.state", 1000);
- /**
- *
- */
+
public static final String OUTPUT = Wrap.class.getName() + ".OUTPUT";
private static DefaultWrapper theWrapper = new DefaultWrapper(Environment.getEnvironment());
static {
Environment.getEnvironment().initTimeout(WAIT_STATE_TIMEOUT);
@@ -123,14 +79,10 @@
Environment.getEnvironment().initTimeout(Drag.BEFORE_DROP_TIMEOUT);
Environment.getEnvironment().initTimeout(Drag.IN_DRAG_TIMEOUT);
Environment.getEnvironment().initTimeout(Keyboard.PUSH);
}
- /**
- *
- * @return
- */
public static DefaultWrapper getWrapper() {
return theWrapper;
}
CONTROL node;
Environment env;
@@ -182,11 +134,11 @@
/**
* Return default point to click, drag. This implementation returns the
* center must be overriden if something different is desired.
*
- * @return
+ * @return the default click point
*/
@Property(CLICKPOINT_PROP_NAME)
public Point getClickPoint() {
return new Point(getScreenBounds().width / 2, (getScreenBounds().height / 2));
}
@@ -205,12 +157,12 @@
/**
* Transforms point in local control coordinate system to screen
* coordinates.
*
- * @param local
- * @return
+ * @param local the local coordinate
+ * @return a absolute translated point
* @see #toLocal(org.jemmy.Point)
*/
public Point toAbsolute(Point local) {
Rectangle bounds = getScreenBounds();
return local.translate(bounds.x, bounds.y);
@@ -218,11 +170,11 @@
/**
* Transforms point in screen coordinates to local control coordinate
* system.
*
- * @param local
+ * @param local the local coordinate
* @return coordinates which should be used for mouse operations.
* @see #toAbsolute(org.jemmy.Point)
*/
public Point toLocal(Point local) {
Rectangle bounds = getScreenBounds();
@@ -256,11 +208,11 @@
/**
* Waits for a portion of image to be exact the same as the parameter.
*
* @see Wrap#as(java.lang.Class)
- * @param golden
+ * @param golden the image to match against
* @param rect A portion of control to compare.
* @param resID ID of a result image to save in case of failure. No image
* saved if null.
* @param diffID ID of a diff image to save in case of failure. No image
* saved if null.
@@ -294,11 +246,11 @@
/**
* Waits for image to be exact the same as the parameter.
*
* @see Wrap#as(java.lang.Class)
- * @param golden
+ * @param golden the image to match against
* @param resID ID of a result image to save in case of failure. No image
* saved if null.
* @param diffID ID of a diff image to save in case of failure. No image
* saved if null.
*/
@@ -308,25 +260,23 @@
}
/**
* TODO javadoc
*
- * @param <V>
- * @param state
- * @param value
+ * @param <V> the states type
+ * @param state the state
+ * @param value the state value
* @return last returned State value
* @throws TimeoutExpiredException in case the wait is unsuccessful.
*/
public <V> V waitState(State<V> state, V value) {
return getEnvironment().getWaiter(WAIT_STATE_TIMEOUT).ensureValue(value, state);
}
/**
- * TODO javadoc
- *
- * @param <V>
- * @param state
+ * @param <V> the states type
+ * @param state the state
* @return last returned State value
* @throws TimeoutExpiredException in case the wait is unsuccessful.
*/
public <V> V waitState(State<V> state) {
return getEnvironment().getWaiter(WAIT_STATE_TIMEOUT).ensureState(state);
@@ -368,13 +318,14 @@
* <code>KeyTarget</code>, which implementations are encapsulated. If some
* other functionality is desired, must be overriden together with
* <code>as(java.lang.Class)</code>
*
* @see Wrap#is(java.lang.Class)
- * @param <INTERFACE>
- * @param interfaceClass
- * @return
+ * @param <INTERFACE> the control interface
+ * @param interfaceClass the interface class
+ * @return <code>true</code> if the control is an ControlInterface,
+ * <code>false</code> otherwise
*/
public <INTERFACE extends ControlInterface> boolean is(Class<INTERFACE> interfaceClass) {
if (interfaceClass.isInstance(this)) {
return true;
}
@@ -391,15 +342,16 @@
* <code>KeyTarget</code>, which implementations are encapsulated. If some
* other functionality is desired, must be overriden together with
* <code>as(java.lang.Class)</code>
*
* @see Wrap#is(java.lang.Class)
- * @param <TYPE>
- * @param <INTERFACE>
- * @param interfaceClass
+ * @param <TYPE> the type interface
+ * @param <INTERFACE> the control interface
+ * @param interfaceClass the interface class
* @param type The parameter class.
- * @return
+ * @return <code>true</code> if the control is an ControlInterface,
+ * <code>false</code> otherwise
*/
public <TYPE, INTERFACE extends TypeControlInterface<TYPE>> boolean is(Class<INTERFACE> interfaceClass, Class<TYPE> type) {
if (interfaceClass.isInstance(this)) {
if (interfaceClass.cast(this).getType().isAssignableFrom(type)) {
return true;
@@ -433,13 +385,13 @@
/**
* Returns an implementation of interface associated with this object. First
* it checks
*
* @see Wrap#is(java.lang.Class)
- * @param <INTERFACE>
- * @param interfaceClass
- * @return
+ * @param <INTERFACE> the control interface
+ * @param interfaceClass the interface class
+ * @return the control interface instance
*/
public <INTERFACE extends ControlInterface> INTERFACE as(Class<INTERFACE> interfaceClass) {
if (interfaceClass.isInstance(this)) {
return interfaceClass.cast(this);
}
@@ -454,15 +406,15 @@
/**
* Returns an implementation of interface associated with the object.
*
* @see Wrap#is(java.lang.Class)
- * @param <TYPE>
- * @param <INTERFACE>
- * @param interfaceClass
+ * @param <TYPE> the type interface
+ * @param <INTERFACE> the control interface
+ * @param interfaceClass the interface class
* @param type The parameter class.
- * @return
+ * @return the type control instance
*/
public <TYPE, INTERFACE extends TypeControlInterface<TYPE>> INTERFACE as(Class<INTERFACE> interfaceClass, Class<TYPE> type) {
if (interfaceClass.isInstance(this)) {
if (interfaceClass.cast(this).getType().isAssignableFrom(type)) {
return interfaceClass.cast(this);
@@ -488,42 +440,39 @@
private Mouse mouse = null;
private Drag drag = null;
private Keyboard keyboard = null;
/**
- * A shortcut to
- * <code>as(MouseTarget.class).mouse()</code>
+ * A shortcut to <code>as(MouseTarget.class).mouse()</code>
*
- * @return
+ * @return the mouse target
*/
@As(Mouse.class)
public Mouse mouse() {
if (mouse == null) {
mouse = getEnvironment().getInputFactory().create(this, Mouse.class);
}
return mouse;
}
/**
- * A shortcut to
- * <code>as(MouseTarget.class).drag()</code>
+ * A shortcut to <code>as(MouseTarget.class).drag()</code>
*
- * @return
+ * @return the drag target
*/
@As(Drag.class)
public Drag drag() {
if (drag == null) {
drag = getEnvironment().getInputFactory().create(this, Drag.class);
}
return drag;
}
/**
- * A shortcut to
- * <code>as(KeyTarget.class).wrap()</code>
+ * A shortcut to <code>as(KeyTarget.class).wrap()</code>
*
- * @return
+ * @return the wrap target
*/
@As(Keyboard.class)
public Keyboard keyboard() {
if (keyboard == null) {
keyboard = getEnvironment().getInputFactory().create(this, Keyboard.class);
@@ -539,14 +488,10 @@
/**
* ***********************************************************************
*/
private HashMap<String, Object> properties = new HashMap<String, Object>();
- /**
- *
- * @return
- */
@Property(CONTROL_CLASS_PROP_NAME)
public Class<?> getControlClass() {
return getControl().getClass();
}
@@ -665,17 +610,16 @@
throw new JemmyException("Unable to obtain property \"" + ((prop != null) ? prop.value() : "null") + "\"", ex, this);
}
}
/**
- * Get property of the wrapped object. Uses first available from <nl>
- * <li>methods annotated by
- * <code>org.jemmy.control.Property</code></li> <li>wrapped object methods
- * listed in
- * <code>org.jemmy.control.MethodProperties</code></li> <li>wrapped object
- * fields listed in
- * <code>org.jemmy.control.FieldProperties</code></li> </nl>
+ * Get property of the wrapped object. Uses first available from
+ * <ol>
+ * <li>methods annotated by <code>org.jemmy.control.Property</code></li>
+ * <li>wrapped object methods listed in <code>org.jemmy.control.MethodProperties</code></li>
+ * <li>wrapped object fields listed in <code>org.jemmy.control.FieldProperties</code></li>
+ * </ol>
*
* @param name property name
* @throws JemmyException if no property found
* @see Property
* @see MethodProperties
@@ -709,29 +653,29 @@
/**
* Get property out of the control interface. Refer to the interface doc to
* find out what properties are provided.
*
- * @param <INTERFACE>
- * @param name
- * @param intrfc
- * @return
+ * @param <INTERFACE> the control interface
+ * @param name the property name
+ * @param intrfc the interface class
+ * @return the control property
*/
public <INTERFACE extends ControlInterface> Object getProperty(String name, Class<INTERFACE> intrfc) {
return getInterfaceProperty(intrfc, as(intrfc), name);
}
/**
* Get property out of the control interface. Refer to the interface doc to
* find out what properties are provided.
*
- * @param <TYPE>
- * @param <INTERFACE>
- * @param name
- * @param intrfc
- * @param type
- * @return
+ * @param <TYPE> the type interface
+ * @param <INTERFACE> the control interface
+ * @param name the property name
+ * @param intrfc the interface class
+ * @param type The parameter class.
+ * @return the control property
*/
public <TYPE, INTERFACE extends TypeControlInterface<TYPE>> Object getProperty(String name, Class<INTERFACE> intrfc, Class<TYPE> type) {
return getInterfaceProperty(intrfc, as(intrfc, type), name);
}
@@ -760,14 +704,14 @@
/**
* Wait for the property
* <code>property</code> of control interface to get the specified value.
* <code>WAIT_STATE_TIMOUT</code> timeout is used
*
- * @param <INTERFACE>
- * @param property
- * @param intrfc
- * @param value
+ * @param <INTERFACE> the control interface
+ * @param property the property name
+ * @param intrfc the interface class
+ * @param value the new parameter value
*/
public <INTERFACE extends ControlInterface> void waitProperty(final String property, final Class<INTERFACE> intrfc, final Object value) {
Object instance = as(intrfc);
getEnvironment().getWaiter(WAIT_STATE_TIMEOUT).ensureValue(value, new State<Object>() {
@@ -785,16 +729,16 @@
/**
* Wait for the property
* <code>property</code> of control interface to get the specified value.
* <code>WAIT_STATE_TIMOUT</code> timeout is used
*
- * @param <TYPE>
- * @param <INTERFACE>
- * @param property
- * @param intrfc
- * @param type
- * @param value
+ * @param <TYPE> the type interface
+ * @param <INTERFACE> the control interface
+ * @param property the property name
+ * @param intrfc the interface class
+ * @param type the parameter class.
+ * @param value the new parameter value
*/
public <TYPE, INTERFACE extends TypeControlInterface<TYPE>> void waitProperty(final String property, final Class<INTERFACE> intrfc, final Class<TYPE> type, final Object value) {
getEnvironment().getWaiter(WAIT_STATE_TIMEOUT).ensureValue(value, new State<Object>() {
public Object reached() {
@@ -806,15 +750,10 @@
return "Interface " + intrfc.getName() + " having property " + property + " expected value '" + value + "' (Property = '" + getProperty(property) + "')";
}
});
}
- /**
- *
- * @param name
- * @return
- */
public boolean hasFieldProperty(String name) {
Class<?> cls = getClass();
do {
if (cls.isAnnotationPresent(FieldProperties.class)) {
FieldProperties props = cls.getAnnotation(FieldProperties.class);
@@ -824,15 +763,10 @@
}
} while ((cls = cls.getSuperclass()) != null);
return false;
}
- /**
- *
- * @param name
- * @return
- */
public boolean hasMethodProperty(String name) {
Class<?> cls = getClass();
do {
if (cls.isAnnotationPresent(MethodProperties.class)) {
MethodProperties props = cls.getAnnotation(MethodProperties.class);
@@ -852,15 +786,10 @@
}
return false;
}
- /**
- *
- * @param name
- * @return
- */
public Object getFieldProperty(final String name) {
if (!hasFieldProperty(name)) {
throw new JemmyException("No \"" + name + "\" field property specified on " + getClass().getName());
}
GetAction action = new GetAction() {
@@ -875,15 +804,10 @@
throw new JemmyException("Unable to obtain property \"" + name + "\"", action.getThrowable(), this);
}
return result;
}
- /**
- *
- * @param name
- * @return
- */
public Object getMethodProperty(final String name) {
if (!hasMethodProperty(name)) {
throw new JemmyException("No \"" + name + "\" method property specified on " + getClass().getName());
}
GetAction action = new GetAction() {
@@ -903,17 +827,10 @@
throw new JemmyException("Unable to obtain property \"" + name + "\"", action.getThrowable(), this);
}
return result;
}
- /**
- *
- * @param <P>
- * @param valueClass
- * @param name
- * @return
- */
public <P> P getProperty(Class<P> valueClass, String name) {
return valueClass.cast(getProperty(name));
}
/**
@@ -922,11 +839,11 @@
* <code>@Property</code> and values of methods/field from
* <code>@MethodProperties</code>/
* <code>FieldProperties</code> correspondingly.
*
* @return a map of properties
- * @throws Runtime exception should there be an exception thrown while
+ * @throws RuntimeException should there be an exception thrown while
* getting a property
*/
public HashMap<String, Object> getProperties() {
fillTheProps(false);
return properties;
< prev index next >