< prev index next >

core/JemmyCore/src/org/jemmy/env/Environment.java

Print this page

        

*** 41,70 **** import org.jemmy.input.CharBindingMap; import org.jemmy.interfaces.ControlInterfaceFactory; import org.jemmy.timing.Waiter; /** - * * @author shura, mrkam, erikgreijus */ public class Environment { - - /** - * - */ public static final String JEMMY_PROPERTIES_FILE_PROPERTY = "jemmy.properties"; public static final String TIMEOUTS_FILE_PROPERTY = "timeouts"; /** * Information output for Environment class */ public static final String OUTPUT = Environment.class.getName() + ".OUTPUT"; private final static Environment env = new Environment(null); - /** - * - * @return - */ public static Environment getEnvironment() { return env; } static { --- 41,61 ----
*** 72,112 **** env.setExecutor(new DefaultExecutor()); } private HashMap<PropertyKey, Object> environment = new HashMap<PropertyKey, Object>(); private Environment parent; - /** - * - * @param parent - */ public Environment(Environment parent) { this.parent = parent; environment = new HashMap<PropertyKey, Object>(); if (parent == null) { loadProperties(System.getProperty(JEMMY_PROPERTIES_FILE_PROPERTY)); } } - /** - * - */ public Environment() { this(getEnvironment()); } - /** - * - * @return - */ public Environment getParentEnvironment() { return parent; } - /** - * - * @param parent - */ public void setParentEnvironment(Environment parent) { this.parent = parent; } public void loadProperties(String propFileName) { --- 63,88 ----
*** 149,163 **** } catch (IOException ex) { throw new JemmyException("Unable to load timeouts", ex, timeoutsFile.getAbsolutePath()); } } - /** - * - * @param cls - * @return - */ public List<?> get(Class cls) { Set<PropertyKey> all = environment.keySet(); ArrayList<Object> result = new ArrayList<Object>(); for (PropertyKey key : all) { if (key.getCls().equals(cls)) { --- 125,134 ----
*** 165,187 **** } } return result; } - /** - * - * @param defaultExecutor - * @return - */ public ActionExecutor setExecutor(ActionExecutor defaultExecutor) { return (ActionExecutor) setProperty(ActionExecutor.class, defaultExecutor); } - /** - * - * @return - */ public ActionExecutor getExecutor() { ActionExecutor res = (ActionExecutor) getProperty(ActionExecutor.class); if (res == null) { String executorClassName = (String) getProperty(ActionExecutor.ACTION_EXECUTOR_PROPERTY); try { --- 136,149 ----
*** 223,298 **** return defaultValue; } } /** ! * ! * @param <T> ! * @param cls * @param obj if null then property is removed ! * @return */ public <T> T setProperty(Class<T> cls, T obj) { return setProperty(cls, null, obj); } /** ! * ! * @param <T> ! * @param cls * @param obj if null then property is removed ! * @return */ public <T> T setPropertyIfNotSet(Class<T> cls, T obj) { return setPropertyIfNotSet(cls, null, obj); } - /** - * - * @param <T> - * @param cls - * @return - */ public <T> T getProperty(Class<T> cls) { return getProperty(cls, null); } /** ! * ! * @param name * @param obj if null then property is removed ! * @return */ public Object setProperty(String name, Object obj) { return setProperty(Object.class, name, obj); } - /** - * - * @param name - * @param obj - * @return - */ public Object setPropertyIfNotSet(String name, Object obj) { return setPropertyIfNotSet(Object.class, name, obj); } - /** - * - * @param name - * @return - */ public Object getProperty(String name) { return getProperty(Object.class, name); } - /** - * - * @param name - * @param defaultValue - * @return - */ public Object getProperty(String name, Object defaultValue) { return getProperty(Environment.class, name, defaultValue); } private <T> T setProperty(PropertyKey<T> key, Object value) { --- 185,234 ---- return defaultValue; } } /** ! * @param <T> todo document ! * @param cls todo document * @param obj if null then property is removed ! * @return todo document */ public <T> T setProperty(Class<T> cls, T obj) { return setProperty(cls, null, obj); } /** ! * @param <T> todo document ! * @param cls todo document * @param obj if null then property is removed ! * @return todo document */ public <T> T setPropertyIfNotSet(Class<T> cls, T obj) { return setPropertyIfNotSet(cls, null, obj); } public <T> T getProperty(Class<T> cls) { return getProperty(cls, null); } /** ! * @param name todo document * @param obj if null then property is removed ! * @return todo document */ public Object setProperty(String name, Object obj) { return setProperty(Object.class, name, obj); } public Object setPropertyIfNotSet(String name, Object obj) { return setPropertyIfNotSet(Object.class, name, obj); } public Object getProperty(String name) { return getProperty(Object.class, name); } public Object getProperty(String name, Object defaultValue) { return getProperty(Environment.class, name, defaultValue); } private <T> T setProperty(PropertyKey<T> key, Object value) {
*** 320,365 **** private Object getProperty(PropertyKey key) { return environment.get(key); } - /** - * - * @param out - * @return - */ public TestOut setOutput(TestOut out) { return (TestOut) setProperty(TestOut.class, out); } - /** - * - * @return - */ public TestOut getOutput() { return (TestOut) getProperty(TestOut.class); } /** * Set some specific output. All classes which provide output should use * some specific outputs. Please consult javadoc for a class in question. * Use <code>null</code> to unset the property. * ! * @param outputName ! * @param out ! * @return */ public TestOut setOutput(String outputName, TestOut out) { return (TestOut) setProperty(TestOut.class, outputName, out); } /** * Initializes some specific output only if it is not yet set. * ! * @param outputName ! * @param out ! * @return */ public TestOut initOutput(String outputName, TestOut out) { TestOut res = (TestOut) getProperty(TestOut.class, outputName); if (res == null) { return setOutput(outputName, out); --- 256,292 ---- private Object getProperty(PropertyKey key) { return environment.get(key); } public TestOut setOutput(TestOut out) { return (TestOut) setProperty(TestOut.class, out); } public TestOut getOutput() { return (TestOut) getProperty(TestOut.class); } /** * Set some specific output. All classes which provide output should use * some specific outputs. Please consult javadoc for a class in question. * Use <code>null</code> to unset the property. * ! * @param outputName todo document ! * @param out todo document ! * @return todo document */ public TestOut setOutput(String outputName, TestOut out) { return (TestOut) setProperty(TestOut.class, outputName, out); } /** * Initializes some specific output only if it is not yet set. * ! * @param outputName todo document ! * @param out todo document ! * @return todo document */ public TestOut initOutput(String outputName, TestOut out) { TestOut res = (TestOut) getProperty(TestOut.class, outputName); if (res == null) { return setOutput(outputName, out);
*** 370,419 **** /** * Get's a specific output. If nothing assigned, returns * <code>getOutput()</code> * ! * @param outputName ! * @return */ public TestOut getOutput(String outputName) { TestOut res = (TestOut) getProperty(TestOut.class, outputName); return (res != null) ? res : getOutput(); } - /** - * - * @param timeout - * @return - */ public Waiter getWaiter(Timeout timeout) { return getWaiter(timeout.getName()); } - /** - * - * @param timeoutName - * @return - */ public Waiter getWaiter(String timeoutName) { return new Waiter(getTimeout(timeoutName)); } - /** - * - * @param timeout - * @return - */ public Timeout getTimeout(Timeout timeout) { return getTimeout(timeout.getName()); } - /** - * - * @param name - * @return - */ public Timeout getTimeout(String name) { return (Timeout) getProperty(Timeout.class, name); } /** --- 297,326 ---- /** * Get's a specific output. If nothing assigned, returns * <code>getOutput()</code> * ! * @param outputName todo document ! * @return todo document */ public TestOut getOutput(String outputName) { TestOut res = (TestOut) getProperty(TestOut.class, outputName); return (res != null) ? res : getOutput(); } public Waiter getWaiter(Timeout timeout) { return getWaiter(timeout.getName()); } public Waiter getWaiter(String timeoutName) { return new Waiter(getTimeout(timeoutName)); } public Timeout getTimeout(Timeout timeout) { return getTimeout(timeout.getName()); } public Timeout getTimeout(String name) { return (Timeout) getProperty(Timeout.class, name); } /**
*** 460,490 **** */ public Timeout setTimeout(String name, long value) { return setTimeout(new Timeout(name, value)); } - /** - * - * @return - */ public CharBindingMap getBindingMap() { return (CharBindingMap) getProperty(CharBindingMap.class); } - /** - * - * @param map - * @return - */ public CharBindingMap setBindingMap(CharBindingMap map) { return (CharBindingMap) setProperty(CharBindingMap.class, map); } - /** - * - * @return - */ public ImageLoader getImageLoader() { ImageLoader res = (ImageLoader) getProperty(ImageLoader.class); if (res == null) { String loaderClass = (String) getProperty(Wrap.IMAGE_LOADER_PROPERTY); if (loaderClass == null) { --- 367,384 ----
*** 502,515 **** } } return res; } - /** - * - * @return - */ public ImageCapturer getImageCapturer() { ImageCapturer res = (ImageCapturer) getProperty(ImageCapturer.class); if (res == null) { String capturerClass = (String) getProperty(Wrap.IMAGE_CAPTURER_PROPERTY); if (capturerClass == null) { --- 396,405 ----
*** 527,559 **** } } return res; } - /** - * - * @param imageLoader - * @return - */ public ImageLoader setImageLoader(ImageLoader imageLoader) { return (ImageLoader) setProperty(ImageLoader.class, imageLoader); } - /** - * - * @param imageCapturer - * @return - */ public ImageCapturer setImageCapturer(ImageCapturer imageCapturer) { getOutput(OUTPUT).println("ImageCapturer set to " + imageCapturer); return (ImageCapturer) setProperty(ImageCapturer.class, imageCapturer); } - /** - * - * @return - */ public ControlInterfaceFactory getInputFactory() { ControlInterfaceFactory res = (ControlInterfaceFactory) getProperty(ControlInterfaceFactory.class); if (res == null) { String factoryClass = (String) getProperty(Wrap.INPUT_FACTORY_PROPERTY); if (factoryClass != null) { --- 417,435 ----
*** 570,584 **** } } return res; } - /** - * - * @param factory - * @return - */ public ControlInterfaceFactory setInputFactory(ControlInterfaceFactory factory) { getOutput(OUTPUT).println("Input factory set to " + factory); return (ControlInterfaceFactory) setProperty(ControlInterfaceFactory.class, factory); } --- 446,455 ----
< prev index next >