Package org.netbeans.jemmy
Class Timeouts
- java.lang.Object
-
- org.netbeans.jemmy.Timeouts
-
public class Timeouts extends Object
Class to store and process a set of timeout values.- Author:
- Alexandre Iline (alexandre.iline@sun.com)
- See Also:
setDefault(String, long)
,getDefault(String)
,setTimeout(String, long)
,getTimeout(String)
-
-
Constructor Summary
Constructors Constructor Description Timeouts()
Creates empty Timeouts object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Timeouts
cloneThis()
Creates a copy of the current timeouts set.boolean
contains(String name)
Checks if timeout has already been defined in this timeout instance.static boolean
containsDefault(String name)
Check that default timeout value was defined.Timeout
create(String name)
Creates Timeout new object by name and getTimeout(name) value.Timeout
createDelta()
Create timeout for "Timeouts.DeltaTimeout" name.void
eSleep(String name)
Sleeps for the "name" timeout value.static long
getDefault(String name)
Gets default timeout value.long
getDeltaTimeout()
Gets "Timeouts.DeltaTimeout" timeout value.long
getTimeout(String name)
Gets timeout value.static double
getTimeoutsScale()
Get timeouts scale.static void
initDefault(String name, long newValue)
Sets default timeout value if it was not set before.long
initTimeout(String name, long newValue)
Sets timeout value if it was not set before.void
load()
Loads timeouts values.void
load(InputStream stream)
Loads timeouts values.void
load(String fileName)
Loads timeouts values from file.void
loadDebugTimeouts()
Loads debug timeouts values.void
loadDefaults()
Loads default timeouts values.void
loadDefaults(InputStream stream)
Loads default timeouts values.void
loadDefaults(String fileName)
Loads default timeouts values from file.void
print(PrintStream ps)
Prins all defined timeouts.void
print(PrintWriter pw)
Prins all defined timeouts.static void
setDefault(String name, long newValue)
Stores default timeout value.long
setTimeout(String name, long newValue)
Sets new timeout value.void
sleep(String name)
Sleeps for the "name" timeout value.
-
-
-
Method Detail
-
setDefault
public static void setDefault(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(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(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(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(InputStream stream) throws IOException
Loads default timeouts values.- Parameters:
stream
- Stream to load timeouts from.- Throws:
IOException
- See Also:
loadDefaults(String)
,loadDefaults()
-
loadDefaults
public void loadDefaults(String fileName) throws FileNotFoundException, IOException
Loads default timeouts values from file.- Parameters:
fileName
- File to load timeouts from.- Throws:
IOException
FileNotFoundException
- See Also:
loadDefaults(InputStream)
,loadDefaults(String)
-
loadDefaults
public void loadDefaults() throws FileNotFoundException, IOException
Loads default timeouts values. Uses jemmy.timeouts system property to get timeouts file.- Throws:
IOException
FileNotFoundException
- See Also:
loadDefaults(InputStream)
,loadDefaults(String)
-
create
public Timeout create(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(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(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(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(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(String name) throws InterruptedException
Sleeps for the "name" timeout value. Can throw InterruptedException if current thread was interrupted.- Parameters:
name
- Timeout name.- Throws:
InterruptedException
-
sleep
public void sleep(String name)
Sleeps for the "name" timeout value. Does not throw InterruptedException anyway.- Parameters:
name
- Timeout name.
-
print
public void print(PrintWriter pw)
Prins all defined timeouts.- Parameters:
pw
- PrintWriter to print into.
-
print
public void print(PrintStream ps)
Prins all defined timeouts.- Parameters:
ps
- PrintStream to print into.
-
load
public void load(InputStream stream) throws IOException
Loads timeouts values.- Parameters:
stream
- Stream to load timeouts from.- Throws:
IOException
- See Also:
load(String)
,load()
-
load
public void load(String fileName) throws FileNotFoundException, IOException
Loads timeouts values from file.- Parameters:
fileName
- File to load timeouts from.- Throws:
IOException
FileNotFoundException
- See Also:
load(InputStream)
,load(String)
-
load
public void load() throws FileNotFoundException, IOException
Loads timeouts values. Uses jemmy.timeouts system property to get timeouts file.- Throws:
IOException
FileNotFoundException
- See Also:
load(InputStream)
,load(String)
-
loadDebugTimeouts
public void loadDebugTimeouts() throws IOException
Loads debug timeouts values.- Throws:
IOException
-
getTimeoutsScale
public static double getTimeoutsScale()
Get timeouts scale. Uses jemmy.timeouts.scale system property to get the value.- Returns:
- timeouts scale or 1 if the property is not set.
-
-