1 /*
   2  * Copyright (c) 2007, 2017 Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package org.jemmy.lookup;
  25 
  26 import java.io.PrintStream;
  27 import org.jemmy.interfaces.*;
  28 import org.jemmy.control.Wrap;
  29 import org.jemmy.env.Environment;
  30 import org.jemmy.env.Timeout;
  31 
  32 
  33 /**
  34  * A searcheable container of a set on UI controls.
  35  * @param <CONTROL>
  36  * @author shura
  37  */
  38 public interface Lookup<CONTROL> extends Parent<CONTROL> {
  39     /**
  40      * Default wait control timeout.
  41      * @see Timeout
  42      * @see Environment
  43      */
  44     public static final Timeout WAIT_CONTROL_TIMEOUT = new Timeout("wait.control", 10000);
  45     /**
  46      * Reruns the search until the number of found components is equal or greater
  47      * than required.
  48      * @param count
  49      * @return this or another Lookup instance.
  50      */
  51     public Lookup<? extends CONTROL> wait(int count);
  52     /**
  53      * Creates an instance of the Wrap class for one of the found UI controls.
  54      * @see Wrap
  55      * @param index
  56      * @return
  57      */
  58     public Wrap<? extends CONTROL> wrap(int index);
  59     /**
  60      * Same as <code>wrap(0)</code>
  61      * @see #wrap(int)
  62      * @return
  63      */
  64     public Wrap<? extends CONTROL> wrap();
  65 
  66     /**
  67      * Returns one of the found UI controls itself.
  68      * @param index
  69      * @return
  70      */
  71     public CONTROL get(int index);
  72     /**
  73      * Same as <code>get(0)</code>
  74      * @see #get(int)
  75      * @return
  76      */
  77     public CONTROL get();
  78 
  79     /**
  80      * Same as <code>wrap(index).as(interfaceClass)</code>
  81      * @param <INTERFACE>
  82      * @param index
  83      * @param interfaceClass
  84      * @return
  85      * @see #wrap(int)
  86      * @see Wrap#as(java.lang.Class)
  87      */
  88     public <INTERFACE extends ControlInterface> INTERFACE as(int index, Class<INTERFACE> interfaceClass);
  89     /**
  90      * Same as <code>wrap().as(interfaceClass)</code>
  91      * @param <INTERFACE>
  92      * @param interfaceClass
  93      * @return
  94      * @see #wrap()
  95      * @see Wrap#as(java.lang.Class)
  96      */
  97     public <INTERFACE extends ControlInterface> INTERFACE as(Class<INTERFACE> interfaceClass);
  98     /**
  99      * Same as <code>wrap(index).as(interfaceClass, type)</code>
 100      * @param <TYPE>
 101      * @param <INTERFACE>
 102      * @param index
 103      * @param interfaceClass
 104      * @param type
 105      * @return
 106      * @see #wrap(int)
 107      * @see Wrap#as(java.lang.Class, java.lang.Class)
 108      */
 109     public <TYPE, INTERFACE extends TypeControlInterface<TYPE>> INTERFACE as(int index, Class<INTERFACE> interfaceClass, Class<TYPE> type);
 110     /**
 111      * Same as <code>wrap().as(interfaceClass, type)</code>
 112      * @param <TYPE>
 113      * @param <INTERFACE>
 114      * @param interfaceClass
 115      * @param type
 116      * @return
 117      * @see #wrap(int)
 118      * @see Wrap#as(java.lang.Class, java.lang.Class)
 119      */
 120     public <TYPE, INTERFACE extends TypeControlInterface<TYPE>> INTERFACE as(Class<INTERFACE> interfaceClass, Class<TYPE> type);
 121 
 122     /**
 123      *
 124      * @return
 125      */
 126     public int size();
 127 
 128     /**
 129      *
 130      * @param out
 131      */
 132     public void dump(PrintStream out);
 133 }