org.netbeans.jemmy
Class Timeouts

java.lang.Object
  extended by org.netbeans.jemmy.Timeouts

public class Timeouts
extends java.lang.Object

Class to store and process a set of timeout values.

Author:
Alexandre Iline ([email protected])
See Also:
setDefault(String, long), getDefault(String), setTimeout(String, long), getTimeout(String)

Constructor Summary
Timeouts()
          Creates empty Timeouts object.
 
Method Summary
 Timeouts cloneThis()
          Creates a copy of the current timeouts set.
 boolean contains(java.lang.String name)
          Checks if timeout has already been defined in this timeout instance.
static boolean containsDefault(java.lang.String name)
          Check that default timeout value was defined.
 Timeout create(java.lang.String name)
          Creates Timeout new object by name and getTimeout(name) value.
 Timeout createDelta()
          Create timeout for "Timeouts.DeltaTimeout" name.
 void eSleep(java.lang.String name)
          Sleeps for the "name" timeout value.
static long getDefault(java.lang.String name)
          Gets default timeout value.
 long getDeltaTimeout()
          Gets "Timeouts.DeltaTimeout" timeout value.
 long getTimeout(java.lang.String name)
          Gets timeout value.
static void initDefault(java.lang.String name, long newValue)
          Sets default timeout value if it was not set before.
 long initTimeout(java.lang.String name, long newValue)
          Sets timeout value if it was not set before.
 void load()
          Loads timeouts values.
 void load(java.io.InputStream stream)
          Loads timeouts values.
 void load(java.lang.String fileName)
          Loads timeouts values from file.
 void loadDebugTimeouts()
          Loads debug timeouts values.
 void loadDefaults()
          Loads default timeouts values.
 void loadDefaults(java.io.InputStream stream)
          Loads default timeouts values.
 void loadDefaults(java.lang.String fileName)
          Loads default timeouts values from file.
 void print(java.io.PrintStream ps)
          Prins all defined timeouts.
 void print(java.io.PrintWriter pw)
          Prins all defined timeouts.
static void setDefault(java.lang.String name, long newValue)
          Stores default timeout value.
 long setTimeout(java.lang.String name, long newValue)
          Sets new timeout value.
 void sleep(java.lang.String name)
          Sleeps for the "name" timeout value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Timeouts

public Timeouts()
Creates empty Timeouts object.

Method Detail

setDefault

public static void setDefault(java.lang.String name,
                              long newValue)
Stores default timeout value.

Parameters:
name - Timeout name.
newValue - Timeout value.
See Also:
getDefault(String), initDefault(String, long), containsDefault(String)

initDefault

public static void initDefault(java.lang.String name,
                               long newValue)
Sets default timeout value if it was not set before.

Parameters:
name - Timeout name.
newValue - Timeout value.
See Also:
setDefault(String, long), getDefault(String), containsDefault(String)

getDefault

public static long getDefault(java.lang.String name)
Gets default timeout value.

Parameters:
name - Timeout name.
Returns:
Timeout value or -1 if timeout is not defined.
See Also:
setDefault(String, long), initDefault(String, long), containsDefault(String)

containsDefault

public static boolean containsDefault(java.lang.String name)
Check that default timeout value was defined.

Parameters:
name - Timeout name.
Returns:
True if timeout has been defined, false otherwise.
See Also:
setDefault(String, long), getDefault(String), initDefault(String, long)

loadDefaults

public void loadDefaults(java.io.InputStream stream)
                  throws java.io.IOException
Loads default timeouts values.

Parameters:
stream - Stream to load timeouts from.
Throws:
java.io.IOException
See Also:
loadDefaults(String), loadDefaults()

loadDefaults

public void loadDefaults(java.lang.String fileName)
                  throws java.io.FileNotFoundException,
                         java.io.IOException
Loads default timeouts values from file.

Parameters:
fileName - File to load timeouts from.
Throws:
java.io.IOException
java.io.FileNotFoundException
See Also:
loadDefaults(InputStream), loadDefaults(String)

loadDefaults

public void loadDefaults()
                  throws java.io.FileNotFoundException,
                         java.io.IOException
Loads default timeouts values. Uses jemmy.timeouts system property to get timeouts file.

Throws:
java.io.IOException
java.io.FileNotFoundException
See Also:
loadDefaults(InputStream), loadDefaults(String)

create

public Timeout create(java.lang.String name)
Creates Timeout new object by name and getTimeout(name) value.

Parameters:
name - Timeout name.
Returns:
a Timeout instance.

createDelta

public Timeout createDelta()
Create timeout for "Timeouts.DeltaTimeout" name.

Returns:
a Timeout instance.

contains

public boolean contains(java.lang.String name)
Checks if timeout has already been defined in this timeout instance.

Parameters:
name - Timeout name.
Returns:
True if timeout has been defined, false otherwise.
See Also:
containsDefault(String)

setTimeout

public long setTimeout(java.lang.String name,
                       long newValue)
Sets new timeout value.

Parameters:
name - Timeout name.
newValue - Timeout value.
Returns:
old timeout value
See Also:
getTimeout(java.lang.String)

getTimeout

public long getTimeout(java.lang.String name)
Gets timeout value. It timeout was not defined in this instance, returns default timeout value.

Parameters:
name - Timeout name.
Returns:
Timeout value.
See Also:
getDefault(String), setTimeout(java.lang.String, long)

getDeltaTimeout

public long getDeltaTimeout()
Gets "Timeouts.DeltaTimeout" timeout value.

Returns:
Timeout value.
See Also:
getDefault(String)

initTimeout

public long initTimeout(java.lang.String name,
                        long newValue)
Sets timeout value if it was not set before.

Parameters:
name - Timeout name.
newValue - Timeout value.
Returns:
old timeout value

cloneThis

public Timeouts cloneThis()
Creates a copy of the current timeouts set.

Returns:
A copy.

eSleep

public void eSleep(java.lang.String name)
            throws java.lang.InterruptedException
Sleeps for the "name" timeout value. Can throw InterruptedException if current thread was interrupted.

Parameters:
name - Timeout name.
Throws:
java.lang.InterruptedException

sleep

public void sleep(java.lang.String name)
Sleeps for the "name" timeout value. Does not throw InterruptedException anyway.

Parameters:
name - Timeout name.

print

public void print(java.io.PrintWriter pw)
Prins all defined timeouts.

Parameters:
pw - PrintWriter to print into.

print

public void print(java.io.PrintStream ps)
Prins all defined timeouts.

Parameters:
ps - PrintStream to print into.

load

public void load(java.io.InputStream stream)
          throws java.io.IOException
Loads timeouts values.

Parameters:
stream - Stream to load timeouts from.
Throws:
java.io.IOException
See Also:
load(String), load()

load

public void load(java.lang.String fileName)
          throws java.io.FileNotFoundException,
                 java.io.IOException
Loads timeouts values from file.

Parameters:
fileName - File to load timeouts from.
Throws:
java.io.IOException
java.io.FileNotFoundException
See Also:
load(InputStream), load(String)

load

public void load()
          throws java.io.FileNotFoundException,
                 java.io.IOException
Loads timeouts values. Uses jemmy.timeouts system property to get timeouts file.

Throws:
java.io.IOException
java.io.FileNotFoundException
See Also:
load(InputStream), load(String)

loadDebugTimeouts

public void loadDebugTimeouts()
                       throws java.io.IOException
Loads debug timeouts values.

Throws:
java.io.IOException