< prev index next >

core/JemmyCore/src/org/jemmy/lookup/ParentImpl.java

Print this page




  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package org.jemmy.lookup;
  27 
  28 import org.jemmy.control.Wrap;
  29 import org.jemmy.control.Wrapper;
  30 import org.jemmy.env.Environment;
  31 import org.jemmy.interfaces.Parent;
  32 
  33 /**
  34  *
  35  * @param <T>
  36  * @author shura
  37  */
  38 public class ParentImpl<T> extends AbstractParent<T> {
  39 
  40     private Class<T> type;
  41     private ControlHierarchy ch;
  42     private ControlList cl;
  43     private Environment env;
  44     private Wrapper wrapper;
  45 
  46     /**
  47      *
  48      * @param env
  49      * @param type
  50      * @param ch
  51      */
  52     public ParentImpl(Environment env, Class<T> type, ControlHierarchy ch) {
  53         this(env, type, ch, Wrap.getWrapper());
  54     }
  55     /**
  56      *
  57      * @param env
  58      * @param type
  59      * @param ch
  60      * @param wrapper
  61      */
  62     public ParentImpl(Environment env, Class<T> type, ControlHierarchy ch, Wrapper wrapper) {
  63         this.type = type;
  64         this.ch = ch;
  65         this.env = env;
  66         this.wrapper = wrapper;
  67     }
  68 
  69     /**
  70      *
  71      * @param env
  72      * @param type
  73      * @param cl
  74      */
  75     public ParentImpl(Environment env, Class<T> type, ControlList cl) {
  76         this(env, type, cl, Wrap.getWrapper());
  77     }
  78     /**
  79      *
  80      * @param env
  81      * @param type
  82      * @param cl
  83      * @param wrapper
  84      */
  85     public ParentImpl(Environment env, Class<T> type, ControlList cl, Wrapper wrapper) {
  86         this.type = type;
  87         this.cl = cl;
  88         this.env = env;
  89         this.wrapper = wrapper;
  90     }
  91 
  92     public <ST extends T> Lookup<ST> lookup(Class<ST> controlClass, LookupCriteria<ST> criteria) {
  93         if(ch != null) {
  94             return new HierarchyLookup<ST>(env, ch, wrapper, controlClass, criteria);
  95         } else if(cl != null) {
  96             return new PlainLookup<ST>(env, cl, wrapper, controlClass, criteria);
  97         }
  98         throw new IllegalStateException();
  99     }
 100 
 101     public Lookup<T> lookup(LookupCriteria<T> criteria) {
 102         return lookup(type, criteria);
 103     }
 104 


  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package org.jemmy.lookup;
  27 
  28 import org.jemmy.control.Wrap;
  29 import org.jemmy.control.Wrapper;
  30 import org.jemmy.env.Environment;
  31 import org.jemmy.interfaces.Parent;
  32 
  33 /**


  34  * @author shura
  35  */
  36 public class ParentImpl<T> extends AbstractParent<T> {
  37 
  38     private Class<T> type;
  39     private ControlHierarchy ch;
  40     private ControlList cl;
  41     private Environment env;
  42     private Wrapper wrapper;
  43 






  44     public ParentImpl(Environment env, Class<T> type, ControlHierarchy ch) {
  45         this(env, type, ch, Wrap.getWrapper());
  46     }
  47 






  48     public ParentImpl(Environment env, Class<T> type, ControlHierarchy ch, Wrapper wrapper) {
  49         this.type = type;
  50         this.ch = ch;
  51         this.env = env;
  52         this.wrapper = wrapper;
  53     }
  54 






  55     public ParentImpl(Environment env, Class<T> type, ControlList cl) {
  56         this(env, type, cl, Wrap.getWrapper());
  57     }
  58 






  59     public ParentImpl(Environment env, Class<T> type, ControlList cl, Wrapper wrapper) {
  60         this.type = type;
  61         this.cl = cl;
  62         this.env = env;
  63         this.wrapper = wrapper;
  64     }
  65 
  66     public <ST extends T> Lookup<ST> lookup(Class<ST> controlClass, LookupCriteria<ST> criteria) {
  67         if(ch != null) {
  68             return new HierarchyLookup<ST>(env, ch, wrapper, controlClass, criteria);
  69         } else if(cl != null) {
  70             return new PlainLookup<ST>(env, cl, wrapper, controlClass, criteria);
  71         }
  72         throw new IllegalStateException();
  73     }
  74 
  75     public Lookup<T> lookup(LookupCriteria<T> criteria) {
  76         return lookup(type, criteria);
  77     }
  78 
< prev index next >