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. Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  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 java.io.PrintStream;
  29 import org.jemmy.interfaces.*;
  30 import org.jemmy.control.Wrap;
  31 import org.jemmy.env.Environment;
  32 import org.jemmy.env.Timeout;
  33 
  34 
  35 /**
  36  * A searcheable container of a set on UI controls.
  37  * @param <CONTROL>
  38  * @author shura
  39  */
  40 public interface Lookup<CONTROL> extends Parent<CONTROL> {
  41     /**
  42      * Default wait control timeout.
  43      * @see Timeout
  44      * @see Environment
  45      */
  46     public static final Timeout WAIT_CONTROL_TIMEOUT = new Timeout("wait.control", 10000);
  47     /**
  48      * Reruns the search until the number of found components is equal or greater
  49      * than required.
  50      * @param count
  51      * @return this or another Lookup instance.
  52      */
  53     public Lookup<? extends CONTROL> wait(int count);
  54     /**
  55      * Creates an instance of the Wrap class for one of the found UI controls.
  56      * @see Wrap
  57      * @param index
  58      * @return
  59      */
  60     public Wrap<? extends CONTROL> wrap(int index);
  61     /**
  62      * Same as <code>wrap(0)</code>
  63      * @see #wrap(int)
  64      * @return
  65      */
  66     public Wrap<? extends CONTROL> wrap();
  67 
  68     /**
  69      * Returns one of the found UI controls itself.
  70      * @param index
  71      * @return
  72      */
  73     public CONTROL get(int index);
  74     /**
  75      * Same as <code>get(0)</code>
  76      * @see #get(int)
  77      * @return
  78      */
  79     public CONTROL get();
  80 
  81     /**
  82      * Same as <code>wrap(index).as(interfaceClass)</code>
  83      * @param <INTERFACE>
  84      * @param index
  85      * @param interfaceClass
  86      * @return
  87      * @see #wrap(int)
  88      * @see Wrap#as(java.lang.Class)
  89      */
  90     public <INTERFACE extends ControlInterface> INTERFACE as(int index, Class<INTERFACE> interfaceClass);
  91     /**
  92      * Same as <code>wrap().as(interfaceClass)</code>
  93      * @param <INTERFACE>
  94      * @param interfaceClass
  95      * @return
  96      * @see #wrap()
  97      * @see Wrap#as(java.lang.Class)
  98      */
  99     public <INTERFACE extends ControlInterface> INTERFACE as(Class<INTERFACE> interfaceClass);
 100     /**
 101      * Same as <code>wrap(index).as(interfaceClass, type)</code>
 102      * @param <TYPE>
 103      * @param <INTERFACE>
 104      * @param index
 105      * @param interfaceClass
 106      * @param type
 107      * @return
 108      * @see #wrap(int)
 109      * @see Wrap#as(java.lang.Class, java.lang.Class)
 110      */
 111     public <TYPE, INTERFACE extends TypeControlInterface<TYPE>> INTERFACE as(int index, Class<INTERFACE> interfaceClass, Class<TYPE> type);
 112     /**
 113      * Same as <code>wrap().as(interfaceClass, type)</code>
 114      * @param <TYPE>
 115      * @param <INTERFACE>
 116      * @param interfaceClass
 117      * @param type
 118      * @return
 119      * @see #wrap(int)
 120      * @see Wrap#as(java.lang.Class, java.lang.Class)
 121      */
 122     public <TYPE, INTERFACE extends TypeControlInterface<TYPE>> INTERFACE as(Class<INTERFACE> interfaceClass, Class<TYPE> type);
 123 
 124     /**
 125      *
 126      * @return
 127      */
 128     public int size();
 129 
 130     /**
 131      *
 132      * @param out
 133      */
 134     public void dump(PrintStream out);
 135 }