Groovy Documentation

org.codehaus.groovy.runtime
[Java] Class DefaultGroovyStaticMethods

java.lang.Object
  org.codehaus.groovy.runtime.DefaultGroovyStaticMethods

public class DefaultGroovyStaticMethods
extends java.lang.Object

This class defines all the new static groovy methods which appear on normal JDK classes inside the Groovy environment. Static methods are used with the first parameter as the destination class.

Authors:
Guillaume Laforge
Dierk Koenig
Joachim Baumann
Paul King
Version:
\$Revision\$


Method Summary
static java.util.ResourceBundle getBundle(java.util.ResourceBundle self, java.lang.String bundleName)

Works exactly like ResourceBundle.getBundle(String).

static java.util.ResourceBundle getBundle(java.util.ResourceBundle self, java.lang.String bundleName, java.util.Locale locale)

Works exactly like ResourceBundle.getBundle(String, Locale).

static java.util.regex.Matcher getLastMatcher(java.util.regex.Matcher self)

Get the last hidden matcher that the system used to do a match.

static java.util.Date parse(java.util.Date self, java.lang.String format, java.lang.String input)

Parse a String into a Date instance using the given pattern.

static java.util.Date parseToStringDate(java.util.Date self, java.lang.String dateToString)

Parse a String matching the pattern EEE MMM dd HH:mm:ss zzz yyyy containing US-locale-constants only (e.g.

static void sleep(java.lang.Object self, long milliseconds)

Sleep for so many milliseconds, even if interrupted.

static void sleep(java.lang.Object self, long milliseconds, Closure onInterrupt)

Sleep for so many milliseconds, using a given closure for interrupt processing.

static java.lang.Thread start(java.lang.Thread self, Closure closure)

Start a Thread with the given closure as a Runnable instance.

static java.lang.Thread start(java.lang.Thread self, java.lang.String name, Closure closure)

Start a Thread with a given name and the given closure as a Runnable instance.

static java.lang.Thread startDaemon(java.lang.Thread self, Closure closure)

Start a daemon Thread with the given closure as a Runnable instance.

static java.lang.Thread startDaemon(java.lang.Thread self, java.lang.String name, Closure closure)

Start a daemon Thread with a given name and the given closure as a Runnable instance.

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Method Detail

getBundle

public static java.util.ResourceBundle getBundle(java.util.ResourceBundle self, java.lang.String bundleName)
Works exactly like ResourceBundle.getBundle(String). This is needed because the java method depends on a particular stack configuration that is not guaranteed in Groovy when calling the Java method.
Parameters:
self - placeholder variable used by Groovy categories; ignored for default static methods
bundleName - the name of the bundle.
Returns:
the resource bundle
See Also:
java.util.ResourceBundle#getBundle(java.lang.String)
Since:
1.6.0


getBundle

public static java.util.ResourceBundle getBundle(java.util.ResourceBundle self, java.lang.String bundleName, java.util.Locale locale)
Works exactly like ResourceBundle.getBundle(String, Locale). This is needed because the java method depends on a particular stack configuration that is not guaranteed in Groovy when calling the Java method.
Parameters:
self - placeholder variable used by Groovy categories; ignored for default static methods
bundleName - the name of the bundle.
locale - the specific locale
Returns:
the resource bundle
See Also:
java.util.ResourceBundle#getBundle(java.lang.String, java.util.Locale)
Since:
1.6.0


getLastMatcher

public static java.util.regex.Matcher getLastMatcher(java.util.regex.Matcher self)
Get the last hidden matcher that the system used to do a match.
Parameters:
self - placeholder variable used by Groovy categories; ignored for default static methods
Returns:
the last regex matcher
Since:
1.0


parse

public static java.util.Date parse(java.util.Date self, java.lang.String format, java.lang.String input)
Parse a String into a Date instance using the given pattern. This convenience method acts as a wrapper for java.text.SimpleDateFormat.

Note that a new SimpleDateFormat instance is created for every invocation of this method (for thread safety).

throws:
ParseException if there is a parse error
Parameters:
self - placeholder variable used by Groovy categories; ignored for default static methods
format - pattern used to parse the input string.
input - String to be parsed to create the date instance
Returns:
a new Date instance representing the parsed input string
See Also:
java.text.SimpleDateFormat#parse(java.lang.String)
Since:
1.5.7


parseToStringDate

public static java.util.Date parseToStringDate(java.util.Date self, java.lang.String dateToString)
Parse a String matching the pattern EEE MMM dd HH:mm:ss zzz yyyy containing US-locale-constants only (e.g. Sat for Saturdays). Such a string is generated by the toString method of java.util.Date

Note that a new SimpleDateFormat instance is created for every invocation of this method (for thread safety).

throws:
ParseException if there is a parse error
Parameters:
self - placeholder variable used by Groovy categories; ignored for default static methods
dateToString - String to be parsed to create the date instance. Must match the pattern EEE MMM dd HH:mm:ss zzz yyyy with US-locale symbols
Returns:
a new Date instance representing the parsed input string


sleep

public static void sleep(java.lang.Object self, long milliseconds)
Sleep for so many milliseconds, even if interrupted.
Parameters:
self - placeholder variable used by Groovy categories; ignored for default static methods
milliseconds - the number of milliseconds to sleep
Since:
1.0


sleep

public static void sleep(java.lang.Object self, long milliseconds, Closure onInterrupt)
Sleep for so many milliseconds, using a given closure for interrupt processing.
Parameters:
self - placeholder variable used by Groovy categories; ignored for default static methods
milliseconds - the number of milliseconds to sleep
onInterrupt - interrupt handler, InterruptedException is passed to the Closure as long as it returns false, the sleep continues
Since:
1.0


start

public static java.lang.Thread start(java.lang.Thread self, Closure closure)
Start a Thread with the given closure as a Runnable instance.
Parameters:
self - placeholder variable used by Groovy categories; ignored for default static methods
closure - the Runnable closure
Returns:
the started thread
Since:
1.0


start

public static java.lang.Thread start(java.lang.Thread self, java.lang.String name, Closure closure)
Start a Thread with a given name and the given closure as a Runnable instance.
Parameters:
self - placeholder variable used by Groovy categories; ignored for default static methods
name - the name to give the thread
closure - the Runnable closure
Returns:
the started thread
Since:
1.6


startDaemon

public static java.lang.Thread startDaemon(java.lang.Thread self, Closure closure)
Start a daemon Thread with the given closure as a Runnable instance.
Parameters:
self - placeholder variable used by Groovy categories; ignored for default static methods
closure - the Runnable closure
Returns:
the started thread
Since:
1.0


startDaemon

public static java.lang.Thread startDaemon(java.lang.Thread self, java.lang.String name, Closure closure)
Start a daemon Thread with a given name and the given closure as a Runnable instance.
Parameters:
self - placeholder variable used by Groovy categories; ignored for default static methods
name - the name to give the thread
closure - the Runnable closure
Returns:
the started thread
Since:
1.6


 

Groovy Documentation