|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.codehaus.groovy.runtime.DefaultGroovyMethods
This class defines all the new groovy methods which appear on normal JDK classes inside the Groovy environment. Static methods are used with the first parameter the destination class.
Constructor Summary | |
DefaultGroovyMethods()
|
Method Summary | |
static double |
abs(Double number)
|
static float |
abs(Float number)
|
static long |
abs(Long number)
|
static int |
abs(Number number)
|
static boolean |
any(Object self,
groovy.lang.Closure closure)
|
static Number |
decrement(Number self)
|
static Number |
divide(Number left,
Number right)
|
static void |
each(Collection self,
groovy.lang.Closure closure)
Allows objects to be iterated through using a closure |
static void |
each(Map self,
groovy.lang.Closure closure)
Allows objects to be iterated through using a closure |
static void |
each(Object self,
groovy.lang.Closure closure)
Allows objects to be iterated through using a closure |
static void |
eachFile(File self,
groovy.lang.Closure closure)
Invokes the closure for each file in the given directory |
static void |
eachLine(File self,
groovy.lang.Closure closure)
Iterates through the given file line by line |
static boolean |
every(Object self,
groovy.lang.Closure closure)
|
static Object |
find(Collection self,
groovy.lang.Closure closure)
Finds the first value matching the closure condition |
static Object |
find(Map self,
groovy.lang.Closure closure)
Finds the first value matching the closure condition |
static Object |
find(Object self,
groovy.lang.Closure closure)
Finds the first value matching the closure condition |
static List |
findAll(Collection self,
groovy.lang.Closure closure)
Finds all values matching the closure condition |
static List |
findAll(Map self,
groovy.lang.Closure closure)
Finds all values matching the closure condition |
static Object |
findAll(Object self,
groovy.lang.Closure closure)
Finds all values matching the closure condition |
static List |
flatten(List self)
|
static List |
get(Collection coll,
String property)
Support the subscript operator for List |
static Object |
get(List list,
groovy.lang.Range range)
Support the range subscript operator for a List |
static Object |
get(String text,
int index)
Support the subscript operator for String |
static Object |
get(String text,
groovy.lang.Range range)
Support the range subscript operator for String |
static List |
immutable(List self)
A convenience method for creating an immutable list |
static Map |
immutable(Map self)
A convenience method for creating an immutable map |
static Set |
immutable(Set self)
A convenience method for creating an immutable list |
static SortedMap |
immutable(SortedMap self)
A convenience method for creating an immutable sorted map |
static SortedSet |
immutable(SortedSet self)
A convenience method for creating an immutable sorted set |
static Number |
increment(Number self)
|
static Object |
inject(Collection self,
Object value,
groovy.lang.Closure closure)
Iterates through the given collection, passing in the initial value to the closure along with the current iterated item then passing into the next iteration the value of the previous closure. |
static String |
inspect(Object self)
Generates a detailed inspection string of an object showing its class, hashCode and fields |
static List |
intersect(List left,
Collection right)
|
static Object |
invokeMethod(Object object,
String method,
Object arguments)
Provide a dynamic method invocation method which can be overloaded in classes to implement dynamic proxies easily. |
static boolean |
isCase(Class caseValue,
Object switchValue)
|
static boolean |
isCase(Collection caseValue,
Object switchValue)
|
static boolean |
isCase(Object caseValue,
Object switchValue)
|
static boolean |
isCase(Pattern caseValue,
Object switchValue)
|
static boolean |
isCase(String caseValue,
Object switchValue)
|
static boolean |
isFloatingPoint(Number number)
|
static boolean |
isLong(Number number)
|
static String |
join(Collection self,
String separator)
Concatenates all of the items of the collection together with the given string as a separator |
static List |
map(Collection self,
groovy.lang.Closure closure)
Collects the values of the closure |
static List |
map(Map self,
groovy.lang.Closure closure)
Collects the values of the closure |
static List |
map(Object self,
groovy.lang.Closure closure)
Maps the values of a collection to new values using the |
static Object |
max(Collection self)
Selects the maximum value found in the collection |
static Object |
max(Collection self,
groovy.lang.Closure closure)
Selects the maximum value found in the collection using the given closure as a comparator |
static Object |
max(Collection self,
Comparator comparator)
Selects the maximum value found in the collection using the given comparator |
static Object |
min(Collection self)
Selects the minimum value found in the collection |
static Object |
min(Collection self,
groovy.lang.Closure closure)
Selects the minimum value found in the collection using the given closure as a comparator |
static Object |
min(Collection self,
Comparator comparator)
Selects the minimum value found in the collection using the given comparator |
static List |
minus(List self,
Collection removeMe)
|
static Number |
minus(Number left,
Number right)
|
static String |
minus(String left,
Object value)
|
static List |
multiply(List self,
Number factor)
|
static Number |
multiply(Number left,
Number right)
|
static String |
multiply(String self,
Number factor)
|
static BufferedReader |
newReader(File file)
Helper method to create a buffered reader for a file |
static BufferedWriter |
newWriter(File file)
Helper method to create a buffered writer for a file |
static List |
plus(List left,
Collection right)
|
static List |
plus(List left,
Object right)
|
static Number |
plus(Number left,
Number right)
|
static String |
plus(String left,
Object value)
|
static Number |
power(Number self,
Number exponent)
|
static void |
print(Object self,
Object value)
Print to a console in interactive format |
static void |
print(Object self,
PrintWriter out)
Print to a console in interactive format |
static void |
println(Object self,
Object value)
Print to a console in interactive format along with a newline |
static void |
println(Object self,
PrintWriter out)
Print to a console in interactive format |
static void |
put(List self,
Number n,
Object value)
A helper method to allow lists to work with subscript operators |
static void |
query(Connection connection,
groovy.lang.GString gstring,
groovy.lang.Closure closure)
Iterates through the result set of an SQL query passing the result set into the closure |
static List |
readLines(File file)
Reads the file into a list of Strings for each line |
static List |
reverse(List self)
Reverses the list |
static long |
round(Double number)
|
static int |
round(Float number)
|
static int |
size(String text)
Makes a String look like a Collection by adding support for the size() method |
static List |
sort(List self)
A convenience method for sorting a List |
static List |
sort(List self,
groovy.lang.Closure closure)
A convenience method for sorting a List using a closure as a comparator |
static List |
sort(List self,
Comparator comparator)
A convenience method for sorting a List with a specific comparator |
static void |
step(Number self,
Number to,
Number stepNumber,
groovy.lang.Closure closure)
Iterates from this number up to the given number using a step increment |
static void |
times(Number self,
groovy.lang.Closure closure)
Iterates a number of times |
static String |
toConsoleOutput(Object self)
|
static Object |
tokenize(String self)
|
static Object |
tokenize(String self,
String token)
|
protected static String |
toString(Object value)
|
static void |
upto(Number self,
Number to,
groovy.lang.Closure closure)
Iterates from this number up to the given number |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DefaultGroovyMethods()
Method Detail |
public static String inspect(Object self)
public static void print(Object self, Object value)
public static void println(Object self, Object value)
public static String toConsoleOutput(Object self)
public static void print(Object self, PrintWriter out)
public static void println(Object self, PrintWriter out)
public static Object invokeMethod(Object object, String method, Object arguments)
public static boolean isCase(Object caseValue, Object switchValue)
public static boolean isCase(String caseValue, Object switchValue)
public static boolean isCase(Class caseValue, Object switchValue)
public static boolean isCase(Collection caseValue, Object switchValue)
public static boolean isCase(Pattern caseValue, Object switchValue)
public static void put(List self, Number n, Object value)
public static void each(Object self, groovy.lang.Closure closure)
closure
- public static void each(Collection self, groovy.lang.Closure closure)
closure
- public static void each(Map self, groovy.lang.Closure closure)
closure
- public static boolean every(Object self, groovy.lang.Closure closure)
public static boolean any(Object self, groovy.lang.Closure closure)
public static List map(Object self, groovy.lang.Closure closure)
closure
- public static List map(Collection self, groovy.lang.Closure closure)
closure
- public static List map(Map self, groovy.lang.Closure closure)
closure
- public static Object find(Object self, groovy.lang.Closure closure)
closure
- public static Object find(Collection self, groovy.lang.Closure closure)
closure
- public static Object find(Map self, groovy.lang.Closure closure)
closure
- public static Object findAll(Object self, groovy.lang.Closure closure)
closure
- public static List findAll(Collection self, groovy.lang.Closure closure)
closure
- public static List findAll(Map self, groovy.lang.Closure closure)
closure
- public static Object inject(Collection self, Object value, groovy.lang.Closure closure)
closure
- public static String join(Collection self, String separator)
public static Object max(Collection self)
public static Object max(Collection self, Comparator comparator)
public static Object min(Collection self)
public static Object min(Collection self, Comparator comparator)
public static Object min(Collection self, groovy.lang.Closure closure)
public static Object max(Collection self, groovy.lang.Closure closure)
public static int size(String text)
text
-
public static Object get(String text, int index)
text
-
public static Object get(String text, groovy.lang.Range range)
public static Object get(List list, groovy.lang.Range range)
public static List get(Collection coll, String property)
public static Map immutable(Map self)
public static SortedMap immutable(SortedMap self)
public static List immutable(List self)
public static Set immutable(Set self)
public static SortedSet immutable(SortedSet self)
public static List sort(List self)
public static List sort(List self, Comparator comparator)
public static List sort(List self, groovy.lang.Closure closure)
public static List reverse(List self)
public static List plus(List left, Collection right)
public static List plus(List left, Object right)
public static List multiply(List self, Number factor)
public static List intersect(List left, Collection right)
public static List minus(List self, Collection removeMe)
public static List flatten(List self)
public static Object tokenize(String self, String token)
public static Object tokenize(String self)
public static String plus(String left, Object value)
public static String minus(String left, Object value)
public static String multiply(String self, Number factor)
protected static String toString(Object value)
public static Number increment(Number self)
public static Number decrement(Number self)
public static Number plus(Number left, Number right)
public static Number minus(Number left, Number right)
public static Number multiply(Number left, Number right)
public static Number power(Number self, Number exponent)
public static Number divide(Number left, Number right)
public static boolean isLong(Number number)
public static boolean isFloatingPoint(Number number)
public static void times(Number self, groovy.lang.Closure closure)
public static void upto(Number self, Number to, groovy.lang.Closure closure)
public static void step(Number self, Number to, Number stepNumber, groovy.lang.Closure closure)
public static int abs(Number number)
public static long abs(Long number)
public static float abs(Float number)
public static double abs(Double number)
public static int round(Float number)
public static long round(Double number)
public static void eachLine(File self, groovy.lang.Closure closure) throws IOException
IOException
public static List readLines(File file) throws IOException
IOException
public static void eachFile(File self, groovy.lang.Closure closure)
public static BufferedReader newReader(File file) throws FileNotFoundException
file
-
FileNotFoundException
public static BufferedWriter newWriter(File file) throws IOException
file
-
FileNotFoundException
IOException
public static void query(Connection connection, groovy.lang.GString gstring, groovy.lang.Closure closure) throws SQLException
connection
- closure
-
SQLException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |