|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport org.codehaus.groovy.runtime.DefaultGroovyMethods
public class 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.
Nested Class Summary | |
---|---|
protected static class |
DefaultGroovyMethods.ProcessRunner
A Runnable which waits for a process to complete together with a notification scheme allowing another thread to wait a maximum number of seconds for the process to complete before killing it. |
Nested classes/interfaces inherited from class org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport |
---|
DefaultGroovyMethodsSupport.RangeInfo |
Field Summary | |
---|---|
static Class[] |
additionals
|
Constructor Summary | |
---|---|
DefaultGroovyMethods()
|
Method Summary | |
---|---|
static double |
abs(Double number)
Get the absolute value |
static float |
abs(Float number)
Get the absolute value |
static long |
abs(Long number)
Get the absolute value |
static int |
abs(Number number)
Get the absolute value |
static Socket |
accept(ServerSocket serverSocket,
Closure closure)
Accepts a connection and passes the resulting Socket to the closure which runs in a new Thread. |
static void |
addShutdownHook(Object self,
Closure closure)
Allows the usage of addShutdownHook without getting the runtime first. |
static BitSet |
and(BitSet left,
BitSet right)
Bitwise AND together two BitSets. |
static Boolean |
and(Boolean left,
Boolean right)
Logical conjunction of two boolean operators. |
static Number |
and(Number left,
Number right)
Bitwise AND together two Numbers. |
static boolean |
any(Map self,
Closure closure)
Iterates over the entries of a map, and checks whether a predicate is valid for at least one entry |
static boolean |
any(Object self)
Iterates over the elements of a collection, and checks whether at least one element is true according to the Groovy Truth. |
static boolean |
any(Object self,
Closure closure)
Iterates over the contents of an object or collection, and checks whether a predicate is valid for at least one element. |
static void |
append(File file,
byte[] bytes)
Append bytes to the end of a File. |
static void |
append(File self,
InputStream stream)
Append binary data to the file. |
static void |
append(File file,
Object text)
Append the text at the end of the File. |
static void |
append(File file,
Object text,
String charset)
Append the text at the end of the File, using a specified encoding. |
static Collection |
asImmutable(Collection self)
A convenience method for creating an immutable Collection. |
static List |
asImmutable(List self)
A convenience method for creating an immutable list |
static Map |
asImmutable(Map self)
A convenience method for creating an immutable map. |
static Set |
asImmutable(Set self)
A convenience method for creating an immutable list. |
static SortedMap |
asImmutable(SortedMap self)
A convenience method for creating an immutable sorted map. |
static SortedSet |
asImmutable(SortedSet self)
A convenience method for creating an immutable sorted set. |
static List |
asList(Collection self)
Converts this collection to a List. |
static Collection |
asSynchronized(Collection self)
A convenience method for creating a synchronized Collection. |
static List |
asSynchronized(List self)
A convenience method for creating a synchronized List. |
static Map |
asSynchronized(Map self)
A convenience method for creating a synchronized Map. |
static Set |
asSynchronized(Set self)
A convenience method for creating a synchronized Set. |
static SortedMap |
asSynchronized(SortedMap self)
A convenience method for creating a synchronized SortedMap. |
static SortedSet |
asSynchronized(SortedSet self)
A convenience method for creating a synchronized SortedSet. |
static Object |
asType(Closure cl,
Class clazz)
Coerces the closure to an implementation of the given class. |
static Object |
asType(Collection col,
Class clazz)
Converts the given collection to another type. |
static Object |
asType(File f,
Class c)
Converts this File to a Writable or delegates to default
asType(Object,Class) . |
static Object |
asType(GString self,
Class c)
Converts the GString to a File, or delegates to the default asType(Object,Class) |
static Object |
asType(Map map,
Class clazz)
Coerces this map to the given type, using the map's keys as the public method names, and values as the implementation. |
static Object |
asType(Number self,
Class c)
Transform this number to a the given type, using the 'as' operator. |
static Object |
asType(Object[] ary,
Class clazz)
Converts the given array to either a List, Set, or SortedSet. |
static Object |
asType(Object obj,
Class type)
Converts a given object to a type. |
static Object |
asType(String self,
Class c)
Provides a method to perform custom 'dynamic' type conversion to the given class using the as operator. |
static File |
asWritable(File file)
Converts this File to a Writable . |
static File |
asWritable(File file,
String encoding)
Allows a file to return a Writable implementation that can output itself to a Writer stream. |
static BitSet |
bitwiseNegate(BitSet self)
Bitwise NEGATE a BitSet. |
static Pattern |
bitwiseNegate(String self)
Turns a String into a regular expression pattern |
protected static Object |
callClosureForLine(Closure closure,
String line,
int counter)
|
protected static Object |
callClosureForMapEntry(Closure closure,
Map.Entry entry)
|
protected static Object |
callClosureForMapEntryAndCounter(Closure closure,
Map.Entry entry,
int counter)
|
static String |
center(String self,
Number numberOfChars)
Center a String and pad it with spaces appended around it |
static String |
center(String self,
Number numberOfChars,
String padding)
Center a String and pad it with the characters appended around it |
static List |
collect(Collection self,
Closure closure)
Iterates through this collection transforming each entry into a new value using the closure as a transformer, returning a list of transformed values. |
static Collection |
collect(Collection self,
Collection collection,
Closure closure)
Iterates through this collection transforming each value into a new value using the closure as a transformer, returning an initial collection plus the transformed values. |
static List |
collect(Map self,
Closure closure)
Iterates through this Map transforming each entry into a new value using the closure as a transformer, returning a list of transformed values. |
static Collection |
collect(Map self,
Collection collection,
Closure closure)
Iterates through this Map transforming each entry into a new value using the closure as a transformer, returning a list of transformed values. |
static List |
collect(Object self,
Closure closure)
Iterates through this object transforming each value into a new value using the closure as a transformer, returning a list of transformed values. |
static Collection |
collect(Object self,
Collection collection,
Closure closure)
Iterates through this object transforming each object into a new value using the closure as a transformer and adding it to the collection, returning the resulting collection. |
static List |
collectAll(Collection self,
Closure closure)
Recursively iterates through this collection transforming each non-Collection value into a new value using the closure as a transformer. |
static Collection |
collectAll(Collection self,
Collection collection,
Closure closure)
Recursively iterates through this collection transforming each non-Collection value into a new value using the closure as a transformer. |
static List |
combinations(Collection self)
Adds GroovyCollections#combinations(Collection) as a method on collections. |
static int |
compareTo(Character left,
Character right)
Compare two Characters. |
static int |
compareTo(Character left,
Number right)
Compare a Character and a Number. |
static int |
compareTo(Number left,
Character right)
Compare a Number and a Character. |
static int |
compareTo(Number left,
Number right)
Compare two Numbers. |
static void |
consumeProcessErrorStream(Process self,
OutputStream err)
Gets the error stream from a process and reads it to keep the process from blocking due to a full buffer. |
static void |
consumeProcessErrorStream(Process self,
StringBuffer error)
Gets the error stream from a process and reads it to keep the process from blocking due to a full buffer. |
static void |
consumeProcessErrorStream(Process self,
Writer err)
Gets the error stream from a process and reads it to keep the process from blocking due to a full buffer. |
static void |
consumeProcessOutput(Process self)
Gets the output and error streams from a process and reads them to keep the process from blocking due to a full output buffer. |
static void |
consumeProcessOutput(Process self,
OutputStream output,
OutputStream error)
Gets the output and error streams from a process and reads them to keep the process from blocking due to a full output buffer. |
static void |
consumeProcessOutput(Process self,
StringBuffer output,
StringBuffer error)
Gets the output and error streams from a process and reads them to keep the process from blocking due to a full output buffer. |
static void |
consumeProcessOutputStream(Process self,
OutputStream output)
Gets the output stream from a process and reads it to keep the process from blocking due to a full output buffer. |
static void |
consumeProcessOutputStream(Process self,
StringBuffer output)
Gets the output stream from a process and reads it to keep the process from blocking due to a full output buffer. |
static void |
consumeProcessOutputStream(Process self,
Writer output)
Gets the output stream from a process and reads it to keep the process from blocking due to a full output buffer. |
static boolean |
contains(String self,
String text)
Provide an implementation of contains() like Collection.contains(Object) to make Strings more polymorphic. |
static int |
count(Collection self,
Object value)
Counts the number of occurrences of the given value inside this collection. |
static int |
count(Iterator self,
Object value)
Counts the number of occurrences of the given value from the items within this Iterator. |
static int |
count(String self,
String text)
Count the number of occurencies of a substring. |
protected static StringBufferWriter |
createStringBufferWriter(StringBuffer self)
|
protected static StringWriter |
createStringWriter(String self)
|
static byte[] |
decodeBase64(String value)
Decode the String from Base64 into a byte array. |
static boolean |
deleteDir(File self)
Deletes a directory with all contained files and subdirectories. |
static String |
denormalize(String self)
Return a String with lines (separated by LF, CR/LF, or CR) terminated by the platform specific line separator. |
static boolean |
disjoint(Collection left,
Collection right)
Returns true if the intersection of two collections is empty. |
static Number |
div(Character left,
Character right)
Divide one Character by another. |
static Number |
div(Character left,
Number right)
Divide a Character by a Number. |
static Number |
div(Number left,
Character right)
Divide a Number by a Character. |
static void |
downto(BigDecimal self,
Number to,
Closure closure)
Iterates from this number down to the given number, inclusive, decrementing by one each time. |
static void |
downto(BigInteger self,
Number to,
Closure closure)
Iterates from this number down to the given number, inclusive, decrementing by one each time. |
static void |
downto(double self,
Number to,
Closure closure)
Iterates from this number down to the given number, inclusive, decrementing by one each time. |
static void |
downto(Double self,
Number to,
Closure closure)
Iterates from this number down to the given number, inclusive, decrementing by one each time. |
static void |
downto(float self,
Number to,
Closure closure)
Iterates from this number down to the given number, inclusive, decrementing by one each time. |
static void |
downto(Float self,
Number to,
Closure closure)
Iterates from this number down to the given number, inclusive, decrementing by one each time. |
static void |
downto(long self,
Number to,
Closure closure)
Iterates from this number down to the given number, inclusive, decrementing by one each time. |
static void |
downto(Long self,
Number to,
Closure closure)
Iterates from this number down to the given number, inclusive, decrementing by one each time. |
static void |
downto(Number self,
Number to,
Closure closure)
Iterates from this number down to the given number, inclusive, decrementing by one each time. |
static String |
dump(Object self)
Generates a detailed dump string of an object showing its class, hashCode and fields. |
static Map |
each(Map self,
Closure closure)
Allows a Map to be iterated through using a closure. |
static Object |
each(Object self,
Closure closure)
Iterates through an aggregate type or data structure, passing each item to the given closure. |
static void |
eachByte(byte[] self,
Closure closure)
Traverse through each byte of this byte array. |
static void |
eachByte(Byte[] self,
Closure closure)
Traverse through each byte of this Byte array. |
static void |
eachByte(File self,
Closure closure)
Traverse through each byte of this File |
static void |
eachByte(InputStream is,
Closure closure)
Traverse through each byte of the specified stream. |
static void |
eachByte(URL url,
Closure closure)
Reads the InputStream from this URL, passing each byte to the given closure. |
static void |
eachDir(File self,
Closure closure)
Invokes the closure for each directory in this directory, ignoring regular files. |
static void |
eachDirMatch(File self,
Object filter,
Closure closure)
Invokes the closure for each directory whose name (dir.name) matches the given filter in the given directory - calling the isCase() method to determine if a match occurs. |
static void |
eachDirRecurse(File self,
Closure closure)
Invokes the closure for each descendant directory of this directory. |
static void |
eachFile(File self,
Closure closure)
Invokes the closure for each file in the given directory |
static void |
eachFileMatch(File self,
Object filter,
Closure closure)
Invokes the closure for each file whose name (file.name) matches the given filter in the given directory - calling the isCase() method to determine if a match occurs. |
static void |
eachFileRecurse(File self,
Closure closure)
Invokes the closure for each descendant file in this directory. |
static Object |
eachLine(File self,
Closure closure)
Iterates through this file line by line. |
static Object |
eachLine(File self,
int firstLine,
Closure closure)
Iterates through this file line by line. |
static Object |
eachLine(InputStream stream,
Closure closure)
Iterates through this stream, passing each line to the given 1 or 2 arg closure. |
static Object |
eachLine(InputStream stream,
int firstLine,
Closure closure)
Iterates through this stream, passing each line to the given 1 or 2 arg closure. |
static Object |
eachLine(InputStream stream,
String charset,
Closure closure)
Iterates through this stream reading with the provided charset, passing each line to the given 1 or 2 arg closure. |
static Object |
eachLine(InputStream stream,
String charset,
int firstLine,
Closure closure)
Iterates through this stream reading with the provided charset, passing each line to the given 1 or 2 arg closure. |
static Object |
eachLine(Reader self,
Closure closure)
Iterates through the given reader line by line. |
static Object |
eachLine(Reader self,
int firstLine,
Closure closure)
Iterates through the given reader line by line. |
static Object |
eachLine(String self,
Closure closure)
Iterates through this String line by line. |
static Object |
eachLine(String self,
int firstLine,
Closure closure)
Iterates through this String line by line. |
static Object |
eachLine(URL url,
Closure closure)
Iterates through the lines read from the URL's associated input stream passing each line to the given 1 or 2 arg closure. |
static Object |
eachLine(URL url,
int firstLine,
Closure closure)
Iterates through the lines read from the URL's associated input stream passing each line to the given 1 or 2 arg closure. |
static Object |
eachLine(URL url,
String charset,
Closure closure)
Iterates through the lines read from the URL's associated input stream passing each line to the given 1 or 2 arg closure. |
static Object |
eachLine(URL url,
String charset,
int firstLine,
Closure closure)
Iterates through the lines read from the URL's associated input stream passing each line to the given 1 or 2 arg closure. |
static String |
eachMatch(String self,
String regex,
Closure closure)
Process each regex group matched substring of the given string. |
static void |
eachObject(File self,
Closure closure)
Iterates through the given file object by object. |
static void |
eachObject(ObjectInputStream ois,
Closure closure)
Iterates through the given object stream object by object. |
static Object |
eachWithIndex(Map self,
Closure closure)
Allows a Map to be iterated through using a closure. |
static Object |
eachWithIndex(Object self,
Closure closure)
Iterates through an aggregate type or data structure, passing each item and the item's index (a counter starting at zero) to the given closure. |
static Writable |
encodeBase64(byte[] data)
Produce a Writable object which writes the Base64 encoding of the byte array. |
static Writable |
encodeBase64(Byte[] data)
Produce a Writable object which writes the Base64 encoding of the byte array. |
static Writable |
encodeBase64(byte[] data,
boolean chunked)
Produce a Writable object which writes the Base64 encoding of the byte array. |
static Writable |
encodeBase64(Byte[] data,
boolean chunked)
Produce a Writable object which writes the Base64 encoding of the byte array. |
static boolean |
equals(int[] left,
int[] right)
Compare the contents of this array to the contents of the given array. |
static boolean |
equals(List left,
List right)
Compare the contents of two Lists. |
static boolean |
equals(List left,
Object[] right)
Determines if the contents of this list are equal to the contents of the given array in the same order. |
static boolean |
equals(Object[] left,
List right)
Determines if the contents of this array are equal to the contents of the given list, in the same order. |
static boolean |
every(Map self,
Closure closure)
Iterates over the entries of a map, and checks whether a predicate is valid for all entries. |
static boolean |
every(Object self)
Iterates over every element of a collection, and checks whether all elements are true according to the Groovy Truth. |
static boolean |
every(Object self,
Closure closure)
Used to determine if the given predicate closure is valid (i.e. |
static Process |
execute(List commandList)
Executes the command specified by the String list that is the parameter. |
static Process |
execute(String self)
Executes the given string as a command line process. |
static Process |
execute(String[] commandArray)
Executes the command specified by the String array that is the parameter. |
static Process |
execute(String self,
List envp,
File dir)
Executes the command specified by the self with environments envp
under the working directory dir . |
static Process |
execute(String self,
String[] envp,
File dir)
Executes the command specified by the self with environments envp
under the working directory dir . |
static Writable |
filterLine(File self,
Closure closure)
Filters the lines of a File and creates a Writeable in return to stream the filtered lines. |
static void |
filterLine(File self,
Writer writer,
Closure closure)
Filter the lines from this File, and write them to the given writer based on the given closure predicate. |
static Writable |
filterLine(InputStream self,
Closure predicate)
Filter lines from an input stream using a closure predicate. |
static void |
filterLine(InputStream self,
Writer writer,
Closure predicate)
Uses a closure to filter lines from this InputStream and pass them to the given writer. |
static Writable |
filterLine(Reader reader,
Closure closure)
Filter the lines from this Reader, and return a Writable which can be used to stream the filtered lines to a destination. |
static void |
filterLine(Reader reader,
Writer writer,
Closure closure)
Filter the lines from a reader and write them on the writer, according to a closure which returns true if the line should be included. |
static Object |
find(Collection self,
Closure closure)
Finds the first value matching the closure condition. |
static Object |
find(Map self,
Closure closure)
Finds the first entry matching the closure condition. |
static Object |
find(Object self,
Closure closure)
Finds the first value matching the closure condition |
static Collection |
findAll(Collection self,
Closure closure)
Finds all values matching the closure condition. |
static Map |
findAll(Map self,
Closure closure)
Finds all entries matching the closure condition. |
static Collection |
findAll(Object self,
Closure closure)
Finds all items matching the closure condition. |
static int |
findIndexOf(Object self,
Closure closure)
Iterates over the elements of an iterable collection of items and returns the index of the first item that matches the condition specified in the closure. |
static int |
findIndexOf(Object self,
int startIndex,
Closure closure)
Iterates over the elements of an iterable collection of items, starting from a specified startIndex, and returns the index of the first item that matches the condition specified in the closure. |
static List |
findIndexValues(Object self,
Closure closure)
Iterates over the elements of an iterable collection of items and returns the index values of the items that match the condition specified in the closure. |
static List |
findIndexValues(Object self,
int startIndex,
Closure closure)
Iterates over the elements of an iterable collection of items, starting from a specified startIndex, and returns the index values of the items that match the condition specified in the closure. |
static int |
findLastIndexOf(Object self,
Closure closure)
Iterates over the elements of an iterable collection of items and returns the index of the last item that matches the condition specified in the closure. |
static int |
findLastIndexOf(Object self,
int startIndex,
Closure closure)
Iterates over the elements of an iterable collection of items, starting from a specified startIndex, and returns the index of the last item that matches the condition specified in the closure. |
static Object |
first(List self)
Returns the first item from the List. |
static Collection |
flatten(boolean[] self)
Flatten an array. |
static Collection |
flatten(byte[] self)
Flatten an array. |
static Collection |
flatten(char[] self)
Flatten an array. |
static Collection |
flatten(Collection self)
Flatten a collection. |
static Collection |
flatten(Collection self,
Closure flattenUsing)
Flatten a collection. |
static Collection |
flatten(double[] self)
Flatten an array. |
static Collection |
flatten(float[] self)
Flatten an array. |
static Collection |
flatten(int[] self)
Flatten an array. |
static Collection |
flatten(long[] self)
Flatten an array. |
static Collection |
flatten(Object[] self)
Flatten an array. |
static Collection |
flatten(short[] self)
Flatten an array. |
static String |
format(Date self,
String format)
Create a String representation of this date according to the given pattern. |
static Object |
get(Map map,
Object key,
Object defaultValue)
Looks up an item in a Map for the given key and returns the value - unless there is no entry for the given key in which case add the default value to the map and return that. |
static boolean |
getAt(BitSet self,
int index)
Support the subscript operator for a Bitset |
static BitSet |
getAt(BitSet self,
IntRange range)
Support retrieving a subset of a BitSet using a Range |
static Object |
getAt(boolean[] array,
Collection indices)
Support the subscript operator with a collection for a boolean array |
static Object |
getAt(boolean[] array,
IntRange range)
Support the subscript operator with an IntRange for a boolean array |
static Object |
getAt(boolean[] array,
ObjectRange range)
Support the subscript operator with an ObjectRange for a byte array |
static Object |
getAt(boolean[] array,
Range range)
Support the subscript operator with a range for a boolean array |
static Object |
getAt(byte[] array,
Collection indices)
Support the subscript operator with a collection for a byte array |
static Object |
getAt(byte[] array,
IntRange range)
Support the subscript operator with an IntRange for a byte array |
static Object |
getAt(byte[] array,
ObjectRange range)
Support the subscript operator with an ObjectRange for a byte array |
static Object |
getAt(byte[] array,
Range range)
Support the subscript operator with a range for a byte array |
static Object |
getAt(char[] array,
Collection indices)
Support the subscript operator with a collection for a char array |
static Object |
getAt(char[] array,
IntRange range)
Support the subscript operator with an IntRange for a char array |
static Object |
getAt(char[] array,
ObjectRange range)
Support the subscript operator with an ObjectRange for a char array |
static Object |
getAt(char[] array,
Range range)
Support the subscript operator with a range for a char array |
static CharSequence |
getAt(CharSequence self,
Collection indices)
Select a List of characters from a CharSequence using a Collection to identify the indices to be selected. |
static CharSequence |
getAt(CharSequence text,
EmptyRange range)
Support the range subscript operator for CharSequence or StringBuffer with EmptyRange |
static CharSequence |
getAt(CharSequence text,
int index)
Support the subscript operator for CharSequence. |
static CharSequence |
getAt(CharSequence text,
IntRange range)
Support the range subscript operator for CharSequence or StringBuffer with IntRange |
static CharSequence |
getAt(CharSequence text,
Range range)
Support the range subscript operator for CharSequence |
static List |
getAt(Collection coll,
String property)
Support the subscript operator for List |
static int |
getAt(Date self,
int field)
Support the subscript operator for a Date. |
static Object |
getAt(double[] array,
Collection indices)
Support the subscript operator with a collection for a double array |
static Object |
getAt(double[] array,
IntRange range)
Support the subscript operator with an IntRange for a double array |
static Object |
getAt(double[] array,
ObjectRange range)
Support the subscript operator with an ObjectRange for a double array |
static Object |
getAt(double[] array,
Range range)
Support the subscript operator with a range for a double array |
static Object |
getAt(float[] array,
Collection indices)
Support the subscript operator with a collection for a float array |
static Object |
getAt(float[] array,
IntRange range)
Support the subscript operator with an IntRange for a float array |
static Object |
getAt(float[] array,
ObjectRange range)
Support the subscript operator with an ObjectRange for a float array |
static Object |
getAt(float[] array,
Range range)
Support the subscript operator with a range for a float array |
static Object |
getAt(int[] array,
Collection indices)
Support the subscript operator with a collection for an int array |
static Object |
getAt(int[] array,
IntRange range)
Support the subscript operator with an IntRange for an int array |
static Object |
getAt(int[] array,
ObjectRange range)
Support the subscript operator with an ObjectRange for an int array |
static Object |
getAt(int[] array,
Range range)
Support the subscript operator with a range for an int array |
static List |
getAt(List self,
Collection indices)
Select a List of items from a List using a Collection to identify the indices to be selected. |
static Object |
getAt(List self,
int idx)
Support the subscript operator for a List. |
static List |
getAt(List self,
IntRange range)
Support the range subscript operator for a List |
static Object |
getAt(long[] array,
Collection indices)
Support the subscript operator with a collection for a long array |
static Object |
getAt(long[] array,
IntRange range)
Support the subscript operator with an IntRange for a long array |
static Object |
getAt(long[] array,
ObjectRange range)
Support the subscript operator with an ObjectRange for a long array |
static Object |
getAt(long[] array,
Range range)
Support the subscript operator with a range for a long array |
static Object |
getAt(Map self,
Object key)
Support the subscript operator for a Map. |
static List |
getAt(Matcher self,
Collection indices)
Select a List of values from a Matcher using a Collection to identify the indices to be selected. |
static Object |
getAt(Matcher matcher,
int idx)
Support the subscript operator, e.g. |
static List |
getAt(Object[] self,
Collection indices)
Select a List of items from an Object array using a Collection to identify the indices to be selected. |
static List |
getAt(Object[] array,
EmptyRange range)
|
static List |
getAt(Object[] array,
IntRange range)
|
static List |
getAt(Object[] array,
ObjectRange range)
|
static List |
getAt(Object[] array,
Range range)
Support the range subscript operator for an Array |
static Object |
getAt(Object self,
String property)
Allows the subscript operator to be used to lookup dynamic property values. |
static Object |
getAt(short[] array,
Collection indices)
Support the subscript operator with a collection for a short array |
static Object |
getAt(short[] array,
IntRange range)
Support the subscript operator with an IntRange for a short array |
static Object |
getAt(short[] array,
ObjectRange range)
Support the subscript operator with an ObjectRange for a short array |
static Object |
getAt(short[] array,
Range range)
Support the subscript operator with a range for a short array |
static String |
getAt(String self,
Collection indices)
Select a List of characters from a String using a Collection to identify the indices to be selected. |
static String |
getAt(String text,
EmptyRange range)
Support the range subscript operator for String with EmptyRange |
static String |
getAt(String text,
int index)
Support the subscript operator for String. |
static String |
getAt(String text,
IntRange range)
Support the range subscript operator for String with IntRange |
static String |
getAt(String text,
Range range)
Support the range subscript operator for String |
static char[] |
getChars(String self)
Converts the given String into an array of characters. |
static int |
getCount(Matcher matcher)
Find the number of Strings matched to the given Matcher. |
static String |
getDateString(Date self)
Return a string representation of the 'day' portion of this date according to the locale-specific DateFormat.SHORT default format. |
static String |
getDateTimeString(Date self)
Return a string representation of the date and time time portion of this Date instance, according to the locale-specific format used by DateFormat . |
static InputStream |
getErr(Process self)
An alias method so that a process appears similar to System.out, System.in, System.err; you can use process.in, process.out, process.err in a similar fashion. |
static InputStream |
getIn(Process self)
An alias method so that a process appears similar to System.out, System.in, System.err; you can use process.in, process.out, process.err in a similar fashion. |
static MetaClass |
getMetaClass(Class c)
Adds a "metaClass" property to all class objects so you can use the syntax String.metaClass.myMethod = { println "foo" } |
static MetaClass |
getMetaClass(GroovyObject obj)
Obtains a MetaClass for an object either from the registry or in the case of a GroovyObject from the object itself. |
static MetaClass |
getMetaClass(Object obj)
Obtains a MetaClass for an object either from the registry or in the case of a GroovyObject from the object itself. |
static List |
getMetaPropertyValues(Object self)
Retrieves the list of MetaProperty objects for 'self' and wraps it
in a list of PropertyValue objects that additionally provide
the value for each property of 'self'. |
static OutputStream |
getOut(Process self)
An alias method so that a process appears similar to System.out, System.in, System.err; you can use process.in, process.out, process.err in a similar fashion. |
static Map |
getProperties(Object self)
Convenience method that calls getMetaPropertyValues(Object) (self)
and provides the data in form of simple key/value pairs, i.e. |
static ClassLoader |
getRootLoader(ClassLoader self)
Iterates through the classloader parents until it finds a loader with a class named "org.codehaus.groovy.tools.RootLoader". |
protected static List |
getSubList(List self,
List splice)
|
static String |
getText(BufferedReader reader)
Read the content of the BufferedReader and return it as a String. |
static String |
getText(File file)
Read the content of the File and returns it as a String. |
static String |
getText(File file,
String charset)
Read the content of the File using the specified encoding and return it as a String. |
static String |
getText(InputStream is)
Read the content of this InputStream and return it as a String. |
static String |
getText(InputStream is,
String charset)
Read the content of this InputStream using specified charset and return it as a String. |
static String |
getText(Process self)
Read the text of the output stream of the Process. |
static String |
getText(Reader reader)
Read the content of the Reader and return it as a String. |
static String |
getText(URL url)
Read the content of this URL and returns it as a String. |
static String |
getText(URL url,
String charset)
Read the data from this URL and return it as a String. |
static String |
getTimeString(Date self)
Return a string representation of the time portion of this date according to the locale-specific DateFormat.MEDIUM default format. |
static Collection |
grep(Object self,
Object filter)
Iterates over every element of the collection and returns each item that matches the given filter - calling the
method used by switch statements. |
protected static void |
groupAnswer(Map answer,
Object element,
Object value)
Groups the current element according to the value |
static Map |
groupBy(Collection self,
Closure closure)
Sorts all collection members into groups determined by the supplied mapping closure. |
static Map |
groupBy(Map self,
Closure closure)
Groups the members of a map into sub maps determined by the supplied mapping closure. |
static Map |
groupEntriesBy(Map self,
Closure closure)
Groups all map entries into groups determined by the supplied mapping closure. |
static boolean |
hasGroup(Matcher matcher)
Check whether a Matcher contains a group or not. |
MetaProperty |
hasProperty(Object self,
String name)
|
static Object |
head(List self)
Returns the first item from the List. |
static Object |
identity(Object self,
Closure closure)
Allows the closure to be called for the object reference self synonym for 'with()'. |
static Object |
inject(Collection self,
Object value,
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 Object |
inject(Iterator self,
Object value,
Closure closure)
Iterates through the given iterator, 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 Object |
inject(Object[] self,
Object initialValue,
Closure closure)
Iterates through the given array of objects, 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 Object |
inject(Object self,
Object value,
Closure closure)
Iterates through the given object, 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)
Inspects returns the String that matches what would be typed into a terminal to create this object. |
static Number |
intdiv(Character left,
Character right)
Integer Divide two Characters. |
static Number |
intdiv(Character left,
Number right)
Integer Divide a Character by a Number. |
static Number |
intdiv(Number left,
Character right)
Integer Divide a Number by a Character. |
static Number |
intdiv(Number left,
Number right)
Integer Divide two Numbers. |
static Collection |
intersect(Collection left,
Collection right)
Create a Collection composed of the intersection of both collections. |
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 |
is(Object self,
Object other)
Identity check. |
static boolean |
isBigDecimal(String self)
Determine if a String can be parsed into a BigDecimal. |
static boolean |
isBigInteger(String self)
Determine if a String can be parsed into a BigInteger. |
static boolean |
isCase(Class caseValue,
Object switchValue)
Special 'Case' implementation for Class, which allows testing for a certain class in a switch statement. |
static boolean |
isCase(Collection caseValue,
Object switchValue)
'Case' implementation for collections which tests if the 'switch' operand is contained in any of the 'case' values. |
static boolean |
isCase(GString caseValue,
Object switchValue)
'Case' implementation for a GString, which simply calls the equivalet method for String. |
static boolean |
isCase(Number caseValue,
Number switchValue)
Special 'case' implementation for all numbers, which delegates to the compareTo() method for comparing numbers of different
types. |
static boolean |
isCase(Object caseValue,
Object switchValue)
Method for overloading the behavior of the 'case' method in switch statements. |
static boolean |
isCase(Pattern caseValue,
Object switchValue)
'Case' implementation for the Pattern class, which allows
testing a String against a number of regular expressions. |
static boolean |
isCase(String caseValue,
Object switchValue)
'Case' implementation for a String, which uses String#equals(Object) in order to allow Strings to be used in switch statements. |
static boolean |
isDigit(Character self)
Determines if a character is a digit. |
static boolean |
isDouble(String self)
Determine if a String can be parsed into a Double. |
static boolean |
isFloat(String self)
Determine if a String can be parsed into a Float. |
static boolean |
isInteger(String self)
Determine if a String can be parsed into an Integer. |
static boolean |
isLetter(Character self)
Determines if a character is a letter. |
static boolean |
isLetterOrDigit(Character self)
Determines if a character is a letter or digit. |
static boolean |
isLong(String self)
Determine if a String can be parsed into a Long. |
static boolean |
isLowerCase(Character self)
Determine if a Character is lowercase. |
static boolean |
isNumber(String self)
Determine if a String can be parsed into a Number. |
static boolean |
isUpperCase(Character self)
Determine if a Character is uppercase. |
static boolean |
isWhitespace(Character self)
Determines if a character is a whitespace character. |
static Iterator |
iterator(DataInputStream self)
Standard iterator for a data input stream which iterates through the stream content a byte at a time. |
static Iterator |
iterator(Enumeration enumeration)
Allows an Enumeration to behave like an Iterator. |
static Iterator |
iterator(File self)
Deprecated. use File#eachLine instead please |
static Iterator |
iterator(InputStream self)
Standard iterator for a input stream which iterates through the stream content in a byte-based fashion. |
static Iterator |
iterator(Iterator self)
An identity function for iterators, supporting 'duck-typing' when trying to get an iterator for each object within a collection, some of which may already be iterators. |
static Iterator |
iterator(Matcher matcher)
Returns an Iterator which traverses each match. |
static Iterator |
iterator(NodeList nodeList)
Makes NodeList iterable by returning a read-only Iterator which traverses over each Node. |
static Iterator |
iterator(Object o)
Attempts to create an Iterator for the given object by first converting it to a Collection. |
static Iterator |
iterator(Reader self)
Creates an iterator which will traverse through the reader a line at a time. |
static String |
join(Collection self,
String separator)
Concatenates the toString() representation of each
item in this collection, with the given String as a separator between
each item. |
static String |
join(Iterator self,
String separator)
Concatenates the toString() representation of each
item from the iterator, with the given String as a separator between
each item. |
static String |
join(Object[] self,
String separator)
Concatenates the toString() representation of each
items in this array, with the given String as a separator between each
item. |
static Object |
last(List self)
Returns the last item from the List. |
static Collection |
leftShift(Collection self,
Object value)
Overloads the left shift operator to provide an easy way to append objects to a Collection. |
static File |
leftShift(File file,
byte[] bytes)
Write bytes to a File. |
static File |
leftShift(File file,
InputStream data)
Append binary data to the file. |
static File |
leftShift(File file,
Object text)
Write the text to the File. |
static Map |
leftShift(Map self,
Map.Entry entry)
Overloads the left shift operator to provide an easy way to append Map.Entry values to a Map. |
static Number |
leftShift(Number self,
Number operand)
Implementation of the left shift operator for integral types. |
static void |
leftShift(ObjectOutputStream self,
Object value)
Overloads the leftShift operator to add objects to an ObjectOutputStream. |
static OutputStream |
leftShift(OutputStream self,
byte[] value)
Overloads the leftShift operator to provide an append mechanism to add bytes to a stream. |
static OutputStream |
leftShift(OutputStream self,
InputStream in)
Pipe an InputStream into an OutputStream for efficient stream copying. |
static Writer |
leftShift(OutputStream self,
Object value)
Overloads the leftShift operator to provide an append mechanism to add values to a stream. |
static OutputStream |
leftShift(Process self,
byte[] value)
Overloads the left shift operator to provide an append mechanism to pipe into a Process |
static Writer |
leftShift(Process self,
Object value)
Overloads the left shift operator (<<) to provide an append mechanism to pipe data to a Process. |
static OutputStream |
leftShift(Socket self,
byte[] value)
Overloads the left shift operator to provide an append mechanism to add bytes to the output stream of a socket |
static Writer |
leftShift(Socket self,
Object value)
Overloads the left shift operator to provide an append mechanism to add things to the output stream of a socket |
static StringBuffer |
leftShift(StringBuffer self,
Object value)
Overloads the left shift operator to provide an easy way to append multiple objects as string representations to a StringBuffer. |
static StringBuffer |
leftShift(String self,
Object value)
Overloads the left shift operator to provide an easy way to append multiple objects as string representations to a String. |
static Writer |
leftShift(Writer self,
Object value)
Overloads the left shift operator to provide a mechanism to append values to a writer. |
static Object |
max(Collection self)
Adds max() method to Collection objects. |
static Object |
max(Collection self,
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 |
max(Iterator self)
Adds max() method to Iterator objects. |
static Object |
max(Iterator self,
Closure closure)
Selects the maximum value found from the Iterator using the given closure as a comparator. |
static Object |
max(Iterator self,
Comparator comparator)
Selects the maximum value found from the Iterator using the given comparator. |
static Object |
max(Object[] self)
Adds max() method to Object arrays. |
static Object |
max(Object[] self,
Closure closure)
Selects the maximum value found from the Object array using the given closure as a comparator. |
static Object |
max(Object[] self,
Comparator comparator)
Selects the maximum value found from the Object array using the given comparator. |
static MetaClass |
metaClass(Class self,
Closure closure)
Sets/updates the metaclass for a given class to a closure. |
static MetaClass |
metaClass(Object self,
Closure closure)
Sets/updates the metaclass for a given object to a closure. |
static Object |
min(Collection self)
Adds min() method to Collection objects. |
static Object |
min(Collection self,
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 Object |
min(Iterator self)
Adds min() method to Iterator objects. |
static Object |
min(Iterator self,
Closure closure)
Selects the minimum value found from the Iterator using the given closure as a comparator. |
static Object |
min(Iterator self,
Comparator comparator)
Selects the minimum value found from the Iterator using the given comparator. |
static Object |
min(Object[] self)
Adds min() method to Object arrays. |
static Object |
min(Object[] self,
Closure closure)
Selects the minimum value found from the Object array using the given closure as a comparator. |
static Object |
min(Object[] self,
Comparator comparator)
Selects the minimum value found from the Object array using the given comparator. |
static int |
minus(Calendar self,
Calendar then)
Subtract another date from this one and return the number of days of the difference. |
static Number |
minus(Character left,
Character right)
Subtract one Characters from another by converting them both to their Integer representations. |
static Number |
minus(Character left,
Number right)
Subtract a Number from a Character. |
static int |
minus(Date self,
Date then)
Subtract another Date from this one and return the number of days of the difference. |
static Date |
minus(Date self,
int days)
Subtract a number of days from this date and returns the new date. |
static Date |
minus(Date self,
int days)
Subtract a number of days from this date and returns the new date. |
static List |
minus(List self,
Collection removeMe)
Create a List composed of the elements of the first list minus the elements of the given collection. |
static List |
minus(List self,
Object operand)
Create a new List composed of the elements of the first list minus the operand. |
static Number |
minus(Number left,
Character right)
Subtract a Character from a Number. |
static Object[] |
minus(Object[] self,
Collection removeMe)
Create an array composed of the elements of the first array minus the elements of the given collection. |
static Object[] |
minus(Object[] self,
Object operand)
Create a new object array composed of the elements of the first array minus the operand. |
static Object[] |
minus(Object[] self,
Object[] removeMe)
Create an array composed of the elements of the first array minus the elements of the given array. |
static Set |
minus(Set self,
Collection operands)
Create a Set composed of the elements of the first set minus the elements of the given collection. |
static Set |
minus(Set self,
Object operand)
Create a Set composed of the elements of the first set minus the operand. |
static String |
minus(String self,
Object target)
Remove a part of a String. |
static void |
mixin(Class self,
Class categoryClass)
Extend class globally with category methods. |
static void |
mixin(Class self,
Class[] categoryClass)
Extend class globally with category methods. |
static void |
mixin(Class self,
List categoryClasses)
Extend class globally with category methods. |
static void |
mixin(MetaClass self,
Class categoryClass)
Extend class globally with category methods. |
static void |
mixin(MetaClass self,
Class[] categoryClass)
Extend class globally with category methods. |
static void |
mixin(MetaClass self,
List categoryClasses)
Extend object with category methods. |
static Number |
mod(Number left,
Number right)
Performs a division modulus operation. |
static Number |
multiply(BigDecimal left,
BigInteger right)
Multiply a BigDecimal and a BigInteger. |
static Number |
multiply(BigDecimal left,
Double right)
Multiply a BigDecimal and a Double. |
static Number |
multiply(Character left,
Character right)
Multiply two Characters. |
static Number |
multiply(Character left,
Number right)
Multiply a Character by a Number. |
static List |
multiply(Collection self,
Number factor)
Create a List composed of the elements of this list, repeated a certain number of times. |
static Number |
multiply(Number left,
Character right)
Multiply a Number by a Character. |
static String |
multiply(String self,
Number factor)
Repeat a String a certain number of times. |
static DataInputStream |
newDataInputStream(File file)
Create a data input stream for this file |
static DataOutputStream |
newDataOutputStream(File file)
Creates a new data output stream for this file. |
static BufferedInputStream |
newInputStream(File file)
Creates a buffered input stream for this file. |
static BufferedInputStream |
newInputStream(URL url)
Creates a buffered input stream for this URL. |
static Object |
newInstance(Class c)
Convenience method to dynamically create a new instance of this class. |
static Object |
newInstance(Class c,
Object[] args)
Helper to construct a new instance from the given arguments. |
static ObjectInputStream |
newObjectInputStream(File file)
Create an object input stream for this file. |
static ObjectInputStream |
newObjectInputStream(File file,
ClassLoader classLoader)
Create an object input stream for this file using the given class loader. |
static ObjectInputStream |
newObjectInputStream(InputStream inputStream)
Create an object input stream for this input stream. |
static ObjectInputStream |
newObjectInputStream(InputStream inputStream,
ClassLoader classLoader)
Create an object input stream for this input stream using the given class loader. |
static ObjectOutputStream |
newObjectOutputStream(File file)
Create an object output stream for this file. |
static ObjectOutputStream |
newObjectOutputStream(OutputStream outputStream)
Create an object output stream for this output stream. |
static BufferedOutputStream |
newOutputStream(File file)
Create a buffered output stream for this file. |
static PrintWriter |
newPrintWriter(File file)
Create a new PrintWriter for this file. |
static PrintWriter |
newPrintWriter(File file,
String charset)
Create a new PrintWriter for this file, using specified charset. |
static PrintWriter |
newPrintWriter(Writer writer)
Create a new PrintWriter for this file, using specified charset. |
static BufferedReader |
newReader(File file)
Create a buffered reader for this file. |
static BufferedReader |
newReader(File file,
String charset)
Create a buffered reader for this file, using the specified charset as the encoding. |
static BufferedReader |
newReader(InputStream self)
Creates a reader for this input stream. |
static BufferedReader |
newReader(InputStream self,
String charset)
Creates a reader for this input stream, using the specified charset as the encoding. |
static BufferedReader |
newReader(URL url)
Creates a buffered reader for this URL. |
static BufferedReader |
newReader(URL url,
String charset)
Creates a buffered reader for this URL using the given encoding. |
static BufferedWriter |
newWriter(File file)
Create a buffered writer for this file. |
static BufferedWriter |
newWriter(File file,
boolean append)
Creates a buffered writer for this file, optionally appending to the existing file content. |
static BufferedWriter |
newWriter(File file,
String charset)
Creates a buffered writer for this file, writing data using the given encoding. |
static BufferedWriter |
newWriter(File file,
String charset,
boolean append)
Helper method to create a buffered writer for a file. |
static Character |
next(Character self)
Increment a Character by one. |
static Date |
next(Date self)
Increment a Date by one day. |
static Date |
next(Date self)
Increment a java.sql.Date by one day. |
static Number |
next(Number self)
Increment a Number by one. |
static String |
next(String self)
This method is called by the ++ operator for the class String. |
static String |
normalize(String self)
Return a String with linefeeds and carriage returns normalized to linefeeds. |
static int |
numberAwareCompareTo(Comparable self,
Comparable other)
Provides a method that compares two comparables using Groovy's default number aware comparator. |
static BitSet |
or(BitSet left,
BitSet right)
Bitwise OR together two BitSets. |
static Boolean |
or(Boolean left,
Boolean right)
Logical disjunction of two boolean operators |
static Number |
or(Number left,
Number right)
Bitwise OR together two numbers. |
static Process |
or(Process left,
Process right)
Overrides the or operator to allow one Process to asynchronously pipe data to another Process. |
static String |
padLeft(String self,
Number numberOfChars)
Pad a String with the spaces appended to the left |
static String |
padLeft(String self,
Number numberOfChars,
String padding)
Pad a String with the characters appended to the left |
static String |
padRight(String self,
Number numberOfChars)
Pad a String with the spaces appended to the right |
static String |
padRight(String self,
Number numberOfChars,
String padding)
Pad a String with the characters appended to the right |
static Process |
pipeTo(Process left,
Process right)
Allows one Process to asynchronously pipe data to another Process. |
static Number |
plus(Character left,
Character right)
Add two Characters. |
static Number |
plus(Character left,
Number right)
Add a Character and a Number. |
static Collection |
plus(Collection left,
Collection right)
Create a Collection as a union of two collections. |
static Collection |
plus(Collection left,
Object right)
Create a collection as a union of a Collection and an Object. |
static Date |
plus(Date self,
int days)
Add a number of days to this date and returns the new date. |
static Date |
plus(Date self,
int days)
Add a number of days to this date and returns the new date. |
static Map |
plus(Map left,
Map right)
Returns a new Map containing all entries from left and right ,
giving precedence to right . |
static Number |
plus(Number left,
Character right)
Add a Number and a Character. |
static String |
plus(Number value,
String right)
Appends a String to the string representation of this number. |
static String |
plus(StringBuffer left,
String value)
Appends a String to this StringBuffer. |
static String |
plus(String left,
Object value)
Appends the String representation of the given operand to this string. |
static Object |
pop(List self)
Removes the last item from the List. |
static Number |
power(Number self,
Number exponent)
Power of a Number to a certain exponent. |
static Character |
previous(Character self)
Decrement a Character by one. |
static Date |
previous(Date self)
Decrement a Date by one day. |
static Date |
previous(Date self)
Decrement a java.sql.Date by one day. |
static Number |
previous(Number self)
Decrement a Number by one. |
static String |
previous(String self)
This method is called by the -- operator for the class String. |
protected static List |
primitiveArrayGet(Object self,
Collection indices)
Implements the getAt(Collection) method for primitve type arrays. |
protected static Object |
primitiveArrayGet(Object self,
int idx)
Implements the getAt(int) method for primitve type arrays. |
protected static List |
primitiveArrayGet(Object self,
Range range)
Implements the getAt(Range) method for primitve type arrays. |
protected static Object |
primitiveArrayPut(Object self,
int idx,
Object newValue)
Implements the setAt(int idx) method for primitve type arrays. |
static void |
print(Closure self,
Object value)
Print a value to the standard output stream. |
static void |
print(Object self,
Object value)
Print a value formatted Groovy style to self if it is a Writer, otherwise to the standard output stream. |
static void |
print(Object self,
PrintWriter out)
Print to a console in interactive format. |
static void |
print(PrintStream self,
Object value)
Print a value formatted Groovy style to the print stream. |
static void |
print(PrintWriter self,
Object value)
Print a value formatted Groovy style to the print writer. |
static void |
printf(Object self,
String format,
Object arg)
Prints a formatted string using the specified format string and arguments. |
static void |
printf(Object self,
String format,
Object[] values)
Printf to a console (Only works with JDK1.5 or later). |
static void |
println(Closure self)
Print a linebreak to the standard output stream. |
static void |
println(Closure self,
Object value)
Print a value (followed by a newline) to the standard output stream. |
static void |
println(Object self)
Print a linebreak to the standard output stream. |
static void |
println(Object self,
Object value)
Print a value formatted Groovy style (followed by a newline) to self if it is a Writer, otherwise to the standard output stream. |
static void |
println(Object self,
PrintWriter out)
Print to a console in interactive format. |
static void |
println(PrintStream self,
Object value)
Print a value formatted Groovy style (followed by a newline) to the print stream. |
static void |
println(PrintWriter self,
Object value)
Print a value formatted Groovy style (followed by a newline) to the print writer. |
static boolean |
push(List self,
Object value)
Appends an item to the List. |
static void |
putAt(BitSet self,
int index,
boolean value)
Support subscript-style assignment for a BitSet. |
static void |
putAt(BitSet self,
IntRange range,
boolean value)
Support assigning a range of values with a single assignment statement. |
static void |
putAt(List self,
EmptyRange range,
Object value)
A helper method to allow lists to work with subscript operators. |
static void |
putAt(List self,
int idx,
Object value)
A helper method to allow lists to work with subscript operators. |
static void |
putAt(List self,
IntRange range,
Collection col)
List subscript assignment operator when given a range as the index and the assignment operand is a collection. |
static void |
putAt(List self,
IntRange range,
Object value)
List subscript assignment operator when given a range as the index. |
static void |
putAt(List self,
List splice,
List values)
Deprecated. replace with putAt(List self, Range range, List value) |
static void |
putAt(List self,
List splice,
Object value)
Deprecated. replace with putAt(List self, Range range, Object value) |
static Object |
putAt(Map self,
Object key,
Object value)
A helper method to allow lists to work with subscript operators |
static void |
putAt(Object self,
String property,
Object newValue)
Allows the subscript operator to be used to set dynamically named property values. |
static void |
putAt(StringBuffer self,
EmptyRange range,
Object value)
Support the range subscript operator for StringBuffer. |
static void |
putAt(StringBuffer self,
IntRange range,
Object value)
Support the range subscript operator for StringBuffer. |
static byte[] |
readBytes(File file)
Reads the content of the file into a byte array. |
static String |
readLine(InputStream stream)
Deprecated. use Reader#readLine instead please |
static String |
readLine(Reader self)
Read a single, whole line from the given Reader. |
static List |
readLines(File file)
Reads the file into a list of Strings, with one item for each line. |
static List |
readLines(InputStream stream)
Reads the stream into a list, with one element for each line. |
static List |
readLines(Reader reader)
Reads the reader into a list of Strings, with one entry for each line. |
static List |
readLines(String self)
Return the lines of a String as a List of Strings. |
static String |
replace(String self,
CharSequence target,
CharSequence replacement)
Replaces all occurrances of a literal string with another literal string. |
static String |
replaceAll(String self,
String regex,
Closure closure)
Replaces all occurrances of a captured group by the result of a closure on that text. |
List |
respondsTo(Object self,
String name)
|
static List |
respondsTo(Object self,
String name,
Object[] argTypes)
|
static Iterator |
reverse(Iterator self)
Reverses the iterator. |
static List |
reverse(List self)
Reverses the list. |
static Object[] |
reverse(Object[] self)
Reverse the items in an Object array. |
static String |
reverse(String self)
Creates a new string which is the reverse (backwards) of this string |
static List |
reverseEach(List self,
Closure closure)
Iterate over each element of the list in the reverse order. |
static Object[] |
reverseEach(Object[] self,
Closure closure)
Iterate over each element of the array in the reverse order. |
static Number |
rightShift(Number self,
Number operand)
Implementation of the right shift operator for integral types. |
static Number |
rightShiftUnsigned(Number self,
Number operand)
Implementation of the right shift (unsigned) operator for integral types. |
static long |
round(Double number)
Round the value |
static int |
round(Float number)
Get the absolute value |
static TimerTask |
runAfter(Timer timer,
int delay,
Closure closure)
Allows a simple syntax for using timers. |
static void |
setIndex(Matcher matcher,
int idx)
Set the position of the given Matcher to the given index. |
static void |
setMetaClass(Class self,
MetaClass metaClass)
Sets the metaclass for a given class. |
static void |
setMetaClass(Object self,
MetaClass metaClass)
Set the metaclass for an object |
static void |
setText(File file,
String text)
Synonym for write(text) allowing file.text = 'foo'. |
static int |
size(boolean[] array)
Allows arrays to behave similar to collections. |
static int |
size(byte[] array)
Allows arrays to behave similar to collections. |
static int |
size(char[] array)
Allows arrays to behave similar to collections. |
static int |
size(double[] array)
Allows arrays to behave similar to collections. |
static long |
size(File self)
Provide the standard Groovy size() method for File . |
static int |
size(float[] array)
Allows arrays to behave similar to collections. |
static int |
size(int[] array)
Allows arrays to behave similar to collections. |
static int |
size(Iterator self)
Provide the standard Groovy size() method for Iterator . |
static int |
size(long[] array)
Allows arrays to behave similar to collections. |
static long |
size(Matcher self)
Provide the standard Groovy size() method for Matcher . |
static int |
size(Object[] self)
Provide the standard Groovy size() method for an array. |
static int |
size(short[] array)
Allows arrays to behave similar to collections. |
static int |
size(String text)
Provide the standard Groovy size() method for String . |
static int |
size(StringBuffer buffer)
Provide the standard Groovy size() method for StringBuffer . |
static List |
sort(Collection self)
Sorts the given collection into a sorted list. |
static List |
sort(Collection self,
Closure closure)
Sorts this Collection using the given closure as a comparator. |
static List |
sort(Collection self,
Comparator comparator)
Sorts the Collection using the given comparator. |
static Iterator |
sort(Iterator self)
Sorts the given iterator items into a sorted iterator. |
static Iterator |
sort(Iterator self,
Closure closure)
Sorts the given iterator items into a sorted iterator using the closure as a comparator. |
static Iterator |
sort(Iterator self,
Comparator comparator)
Sorts the given iterator items into a sorted iterator using the comparator. |
static Map |
sort(Map self,
Closure closure)
Sorts the given map into a sorted map using the closure as a comparator. |
static Object[] |
sort(Object[] self)
Sorts the given Object array into sorted order. |
static Object[] |
sort(Object[] self,
Closure closure)
Sorts the given Object array into a newly created array using the given comparator. |
static Object[] |
sort(Object[] self,
Comparator comparator)
Sorts the given Object array into sorted order using the given comparator. |
static SortedSet |
sort(SortedSet self)
Avoids doing unnecessary work when sorting an already sorted set. |
static Collection |
split(Collection self,
Closure closure)
Splits all items into two collections based on the closure condition. |
static Collection |
split(Object self,
Closure closure)
Splits all items into two lists based on the closure condition. |
static String[] |
split(String self)
Convenience method to split a string (with whitespace as delimiter) Like tokenize, but returns an Array of Strings instead of a List |
static Object |
splitEachLine(File self,
String sep,
Closure closure)
Iterates through this file line by line, splitting on the seperator. |
static Object |
splitEachLine(InputStream stream,
String sep,
Closure closure)
Iterates through the given InputStream line by line, splitting each line using the given separator. |
static Object |
splitEachLine(InputStream stream,
String sep,
String charset,
Closure closure)
Iterates through the given InputStream line by line using the specified encoding, splitting each line using the given separator. |
static Object |
splitEachLine(Reader self,
String sep,
Closure closure)
Iterates through the given reader line by line, splitting each line using the given separator. |
static Object |
splitEachLine(String self,
String sep,
Closure closure)
Iterates through the given String line by line, splitting each line using the given separator. |
static SpreadMap |
spread(Map self)
Synonym for toSpreadMap(Map) . |
static String |
sprintf(Object self,
String format,
Object arg)
Returns a formatted string using the specified format string and arguments. |
static String |
sprintf(Object self,
String format,
Object[] values)
Sprintf to a string (Only works with JDK1.5 or later). |
static void |
step(Number self,
Number to,
Number stepNumber,
Closure closure)
Iterates from this number up to the given number using a step increment. |
static Map |
subMap(Map map,
Collection keys)
Creates a sub-Map containing the given keys. |
static Object |
sum(Collection self)
Sums the items in a collection. |
static Object |
sum(Collection self,
Closure closure)
Sums the result of apply a closure to each item of a collection. |
static Object |
sum(Collection self,
Object initialValue)
Sums the items in a collection, adding the result to some initial value. |
static Object |
sum(Collection self,
Object initialValue,
Closure closure)
Sums the result of apply a closure to each item of a collection to sum intial value. |
static Object |
sum(Iterator self)
Sums the items from an Iterator. |
static Object |
sum(Iterator self,
Object initialValue)
Sums the items from an Iterator. |
static List |
tail(List self)
Returns the items from the List excluding the first item. |
static void |
times(Number self,
Closure closure)
Executes the closure this many times, starting from zero. |
static String |
toArrayString(Object[] self)
Returns the string representation of the given array. |
static BigDecimal |
toBigDecimal(Number self)
Transform a Number into a BigDecimal |
static BigDecimal |
toBigDecimal(String self)
Parse a String into a BigDecimal |
static BigInteger |
toBigInteger(Number self)
Transform this Number into a BigInteger. |
static BigInteger |
toBigInteger(String self)
Parse a String into a BigInteger |
static Boolean |
toBoolean(String self)
Converts the given string into a Boolean object. |
static Character |
toCharacter(String self)
Converts the given string into a Character object using the first character in the string. |
static Double |
toDouble(Number self)
Transform a Number into a Double |
static Double |
toDouble(String self)
Parse a String into a Double |
static Float |
toFloat(Number self)
Transform a Number into a Float |
static Float |
toFloat(String self)
Parse a String into a Float |
static Integer |
toInteger(Number self)
Transform a Number into an Integer |
static Integer |
toInteger(String self)
Parse a String into an Integer |
static List |
tokenize(String self)
Tokenize a String (with a whitespace as the delimiter). |
static List |
tokenize(String self,
String token)
Tokenize a String based on the given string delimiter. |
static List |
toList(boolean[] array)
Converts this array to a List of the same size, with each element added to the list. |
static List |
toList(byte[] array)
Converts this array to a List of the same size, with each element added to the list. |
static List |
toList(char[] array)
Converts this array to a List of the same size, with each element added to the list. |
static List |
toList(Collection self)
Convert a collection to a List. |
static List |
toList(double[] array)
Converts this array to a List of the same size, with each element added to the list. |
static List |
toList(Enumeration self)
Convert an enumeration to a List. |
static List |
toList(float[] array)
Converts this array to a List of the same size, with each element added to the list. |
static List |
toList(int[] array)
Converts this array to a List of the same size, with each element added to the list. |
static List |
toList(Iterator self)
Convert an iterator to a List. |
static List |
toList(long[] array)
Converts this array to a List of the same size, with each element added to the list. |
static List |
toList(Object[] array)
Allows conversion of arrays into a mutable List. |
static List |
toList(short[] array)
Converts this array to a List of the same size, with each element added to the list. |
static List |
toList(String self)
Converts the given String into a List of strings of one character. |
static String |
toListString(Collection self)
Returns the string representation of the given list. |
static Long |
toLong(Number self)
Transform a Number into a Long |
static Long |
toLong(String self)
Parse a String into a Long |
static char |
toLowerCase(Character self)
Converts the character to lowercase. |
static String |
toMapString(Map self)
Returns the string representation of this map. |
static GroovyRowResult |
toRowResult(ResultSet rs)
Returns a GroovyRowResult given a ResultSet. |
static Short |
toShort(String self)
Parse a String into a Short |
static SpreadMap |
toSpreadMap(Map self)
Returns a new SpreadMap from this map. |
static SpreadMap |
toSpreadMap(Object[] self)
Creates a spreadable map from this array. |
static String |
toString(AbstractCollection self)
Returns the string representation of the given collection. |
static String |
toString(AbstractMap self)
Returns the string representation of the given map. |
static String |
toString(boolean[] self)
Returns the string representation of the given array. |
static String |
toString(byte[] self)
Returns the string representation of the given array. |
static String |
toString(char[] self)
Returns the string representation of the given array. |
static String |
toString(double[] self)
Returns the string representation of the given array. |
static String |
toString(float[] self)
Returns the string representation of the given array. |
static String |
toString(int[] self)
Returns the string representation of the given array. |
static String |
toString(long[] self)
Returns the string representation of the given array. |
static String |
toString(Object value)
Create a String representation of this object. |
static String |
toString(Object[] self)
Returns the string representation of this array's contents. |
static String |
toString(short[] self)
Returns the string representation of the given array. |
static char |
toUpperCase(Character self)
Converts the character to uppercase. |
static URI |
toURI(String self)
Transforms a String representing a URI into a URI object. |
static URL |
toURL(String self)
Transforms a String representing a URL into a URL object. |
static void |
transformChar(Reader self,
Writer writer,
Closure closure)
Transforms each character from this reader by passing it to the given closure. |
static void |
transformLine(Reader reader,
Writer writer,
Closure closure)
Transforms the lines from a reader with a Closure and write them to a writer. |
static List |
transpose(List self)
Adds GroovyCollections#transpose(List) as a method on lists. |
static Number |
unaryMinus(Number left)
Negates the number. |
static Collection |
unique(Collection self)
Modifies this collection to remove all duplicated items, using the default comparator. |
static Collection |
unique(Collection self,
Closure closure)
A convenience method for making a collection unique using a closure as a comparator. |
static Collection |
unique(Collection self,
Comparator comparator)
Remove all duplicates from a given Collection. |
static Iterator |
unique(Iterator self)
Returns an iterator equivalent to this iterator all duplicated items removed by using the default comparator. |
static Iterator |
unique(Iterator self,
Closure closure)
Returns an iterator equivalent to this iterator all duplicated items removed by using a closure as a comparator. |
static Iterator |
unique(Iterator self,
Comparator comparator)
Returns an iterator equivalent to this iterator with all duplicated items removed by using the supplied comparator. |
static void |
upto(BigDecimal self,
Number to,
Closure closure)
Iterates from this number up to the given number, inclusive, incrementing by one each time. |
static void |
upto(BigInteger self,
Number to,
Closure closure)
Iterates from this number up to the given number, inclusive, incrementing by one each time. |
static void |
upto(double self,
Number to,
Closure closure)
Iterates from this number up to the given number, inclusive, incrementing by one each time. |
static void |
upto(Double self,
Number to,
Closure closure)
Iterates from this number up to the given number, inclusive, incrementing by one each time. |
static void |
upto(float self,
Number to,
Closure closure)
Iterates from this number up to the given number, inclusive, incrementing by one each time. |
static void |
upto(Float self,
Number to,
Closure closure)
Iterates from this number up to the given number, inclusive, incrementing by one each time. |
static void |
upto(long self,
Number to,
Closure closure)
Iterates from this number up to the given number, inclusive, incrementing by one each time. |
static void |
upto(Long self,
Number to,
Closure closure)
Iterates from this number up to the given number, inclusive, incrementing by one each time. |
static void |
upto(Number self,
Number to,
Closure closure)
Iterates from this number up to the given number, inclusive, incrementing by one each time. |
static Object |
use(Object self,
Class categoryClass,
Closure closure)
Scoped use method |
static Object |
use(Object self,
List categoryClassList,
Closure closure)
Scoped use method with list of categories. |
static Object |
use(Object self,
Object[] array)
Allows you to use a list of categories, specifying the list as varargs. |
static void |
waitForOrKill(Process self,
long numberOfMillis)
Wait for the process to finish during a certain amount of time, otherwise stops the process. |
static Object |
with(Object self,
Closure closure)
Allows the closure to be called for the object reference self |
static Object |
withDataInputStream(File file,
Closure closure)
Create a new DataInputStream for this file and passes it into the closure. |
static Object |
withDataOutputStream(File file,
Closure closure)
Create a new DataOutputStream for this file and passes it into the closure. |
static Object |
withInputStream(File file,
Closure closure)
Create a new InputStream for this file and passes it into the closure. |
static Object |
withInputStream(URL url,
Closure closure)
Creates a new InputStream for this URL and passes it into the closure. |
static Object |
withObjectInputStream(File file,
ClassLoader classLoader,
Closure closure)
Create a new ObjectInputStream for this file associated with the given class loader and pass it to the closure. |
static Object |
withObjectInputStream(File file,
Closure closure)
Create a new ObjectInputStream for this file and pass it to the closure. |
static Object |
withObjectInputStream(InputStream inputStream,
ClassLoader classLoader,
Closure closure)
Create a new ObjectInputStream for this file and pass it to the closure. |
static Object |
withObjectInputStream(InputStream inputStream,
Closure closure)
Create a new ObjectInputStream for this file and pass it to the closure. |
static Object |
withObjectOutputStream(File file,
Closure closure)
Create a new ObjectOutputStream for this file and then pass it to the closure. |
static Object |
withObjectOutputStream(OutputStream outputStream,
Closure closure)
Create a new ObjectOutputStream for this output stream and then pass it to the closure. |
static Object |
withObjectStreams(Socket socket,
Closure closure)
Creates an InputObjectStream and an OutputObjectStream from a Socket, and passes them to the closure. |
static Object |
withOutputStream(File file,
Closure closure)
Creates a new OutputStream for this file and passes it into the closure. |
static void |
withOutputStream(Process self,
Closure closure)
Creates a new buffered OutputStream as stdin for this process, passes it to the closure, and ensures the stream is flushed and closed after the closure returns. |
static Object |
withPrintWriter(File file,
Closure closure)
Create a new PrintWriter for this file which is then passed it into the given closure. |
static Object |
withPrintWriter(File file,
String charset,
Closure closure)
Create a new PrintWriter with a specified charset for this file. |
static Object |
withPrintWriter(Writer writer,
Closure closure)
Create a new PrintWriter with a specified charset for this file. |
static Object |
withReader(File file,
Closure closure)
Create a new BufferedReader for this file and then passes it into the closure, ensuring the reader is closed after the closure returns. |
static Object |
withReader(File file,
String charset,
Closure closure)
Create a new BufferedReader for this file using the specified charset and then passes it into the closure, ensuring the reader is closed after the closure returns. |
static Object |
withReader(InputStream in,
Closure closure)
Helper method to create a new Reader for a stream and then passes it into the closure. |
static Object |
withReader(InputStream in,
String charset,
Closure closure)
Helper method to create a new Reader for a stream and then passes it into the closure. |
static Object |
withReader(Reader reader,
Closure closure)
Allows this reader to be used within the closure, ensuring that it is closed before this method returns. |
static Object |
withReader(URL url,
Closure closure)
Helper method to create a new BufferedReader for a URL and then passes it to the closure. |
static Object |
withReader(URL url,
String charset,
Closure closure)
Helper method to create a new Reader for a URL and then passes it to the closure. |
static Object |
withStream(InputStream stream,
Closure closure)
Allows this input stream to be used within the closure, ensuring that it is flushed and closed before this method returns. |
static Object |
withStream(OutputStream os,
Closure closure)
Passes this OutputStream to the closure, ensuring that the stream is closed after the closure returns, regardless of errors. |
static Object |
withStreams(Socket socket,
Closure closure)
Passes the Socket's InputStream and OutputStream to the closure. |
static Object |
withWriter(File file,
Closure closure)
Creates a new BufferedWriter for this file, passes it to the closure, and ensures the stream is flushed and closed after the closure returns. |
static Object |
withWriter(File file,
String charset,
Closure closure)
Creates a new BufferedWriter for this file, passes it to the closure, and ensures the stream is flushed and closed after the closure returns. |
static Object |
withWriter(OutputStream stream,
Closure closure)
Creates a writer from this stream, passing it to the given closure. |
static Object |
withWriter(OutputStream stream,
String charset,
Closure closure)
Creates a writer from this stream, passing it to the given closure. |
static void |
withWriter(Process self,
Closure closure)
Creates a new BufferedWriter as stdin for this process, passes it to the closure, and ensures the stream is flushed and closed after the closure returns. |
static Object |
withWriter(Writer writer,
Closure closure)
Allows this writer to be used within the closure, ensuring that it is flushed and closed before this method returns. |
static Object |
withWriterAppend(File file,
Closure closure)
Create a new BufferedWriter for this file in append mode. |
static Object |
withWriterAppend(File file,
String charset,
Closure closure)
Create a new BufferedWriter which will append to this file. |
static void |
write(File file,
String text)
Write the text to the File. |
static void |
write(File file,
String text,
String charset)
Write the text to the File, using the specified encoding. |
static void |
write(Writer self,
Writable writable)
A helper method so that dynamic dispatch of the writer.write(object) method will always use the more efficient Writable.writeTo(writer) mechanism if the object implements the Writable interface. |
static void |
writeLine(BufferedWriter writer,
String line)
Write the text and append a newline (using the platform's line-ending). |
static BitSet |
xor(BitSet left,
BitSet right)
Bitwise XOR together two BitSets. |
static Boolean |
xor(Boolean left,
Boolean right)
Exclusive disjunction of two boolean operators |
static Number |
xor(Number left,
Number right)
Bitwise XOR together two Numbers. |
Methods inherited from class org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport |
---|
cloneSimilarCollection, cloneSimilarMap, closeQuietly, closeWithWarning, createSimilarCollection, createSimilarCollection, createSimilarList, createSimilarMap, createSimilarOrDefaultCollection, createSimilarSet, normaliseIndex, sameType, subListBorders, subListBorders |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Class[] additionals
Constructor Detail |
---|
public DefaultGroovyMethods()
Method Detail |
---|
public static boolean is(Object self, Object other)
def same = (this is that)
self
- an objectother
- an object to compare identity with
public static Object identity(Object self, Closure closure)
self
- the object to have a closure act uponclosure
- the closure to call on the object
public static Object with(Object self, Closure closure)
self
- the object to have a closure act uponclosure
- the closure to call on the object
public static Object getAt(Object self, String property)
bean[somePropertyNameExpression]
. The normal property notation
of groovy is neater and more concise but only works with compile-time known
property names.
self
- the object to act uponproperty
- the property name of interest
public static void putAt(Object self, String property, Object newValue)
bean[somePropertyNameExpression] = foo
. The normal property notation
of groovy is neater and more concise but only works with property names which
are known at compile time.
self
- the object to act uponproperty
- the name of the property to setnewValue
- the value to setpublic static String dump(Object self)
self
- an object
public static List getMetaPropertyValues(Object self)
MetaProperty
objects for 'self' and wraps it
in a list of PropertyValue
objects that additionally provide
the value for each property of 'self'.
self
- the receiver object
PropertyValue
objectsExpando.getMetaPropertyValues()
public static Map getProperties(Object self)
getMetaPropertyValues(Object)
(self)
and provides the data in form of simple key/value pairs, i.e.&nsbp;without
type() information.
self
- the receiver object
public static Object use(Object self, Class categoryClass, Closure closure)
self
- any ObjectcategoryClass
- a category class to useclosure
- the closure to invoke with the category in place
public static void mixin(MetaClass self, List categoryClasses)
self
- any ClasscategoryClasses
- a category classes to usepublic static void mixin(Class self, List categoryClasses)
self
- any ClasscategoryClasses
- a category classes to usepublic static void mixin(Class self, Class categoryClass)
self
- any ClasscategoryClass
- a category class to usepublic static void mixin(Class self, Class[] categoryClass)
self
- any ClasscategoryClass
- a category class to usepublic static void mixin(MetaClass self, Class categoryClass)
self
- any ClasscategoryClass
- a category class to usepublic static void mixin(MetaClass self, Class[] categoryClass)
self
- any ClasscategoryClass
- a category class to usepublic static Object use(Object self, List categoryClassList, Closure closure)
self
- any ObjectcategoryClassList
- a list of category classesclosure
- the closure to invoke with the categories in place
public static void addShutdownHook(Object self, Closure closure)
self
- the object the method is called on (ignored)closure
- the shutdown hook actionpublic static Object use(Object self, Object[] array)
use(CategoryClass1, CategoryClass2) { ... }
This method saves having to wrap the the category
classes in a list.
self
- any Objectarray
- a list of category classes and a Closure
public static void print(Object self, Object value)
self
- any Objectvalue
- the value to printpublic static void print(PrintWriter self, Object value)
self
- a PrintWritervalue
- the value to printpublic static void print(PrintStream self, Object value)
self
- a PrintStreamvalue
- the value to printpublic static void print(Closure self, Object value)
self
- a generated closurevalue
- the value to printpublic static void println(Object self)
self
- any Objectpublic static void println(Closure self)
self
- a closurepublic static void println(Object self, Object value)
self
- any Objectvalue
- the value to printpublic static void println(PrintWriter self, Object value)
self
- a PrintWritervalue
- the value to printpublic static void println(PrintStream self, Object value)
self
- any Objectvalue
- the value to printpublic static void println(Closure self, Object value)
self
- a closurevalue
- the value to printpublic static void printf(Object self, String format, Object[] values)
self
- any Objectformat
- a format stringvalues
- values referenced by the format specifiers in the format string.public static String sprintf(Object self, String format, Object[] values)
self
- any Objectformat
- a format stringvalues
- values referenced by the format specifiers in the format string.
public static void printf(Object self, String format, Object arg)
printf ( "Hello, %s!\n" , [ "world" ] as String[] ) printf ( "Hello, %s!\n" , [ "Groovy" ]) printf ( "%d + %d = %d\n" , [ 1 , 2 , 1+2 ] as Integer[] ) printf ( "%d + %d = %d\n" , [ 3 , 3 , 3+3 ]) ( 1..5 ).each { printf ( "-- %d\n" , [ it ] as Integer[] ) } ( 1..5 ).each { printf ( "-- %d\n" , [ it ] as int[] ) } ( 0x41..0x45 ).each { printf ( "-- %c\n" , [ it ] as char[] ) } ( 07..011 ).each { printf ( "-- %d\n" , [ it ] as byte[] ) } ( 7..11 ).each { printf ( "-- %d\n" , [ it ] as short[] ) } ( 7..11 ).each { printf ( "-- %d\n" , [ it ] as long[] ) } ( 7..11 ).each { printf ( "-- %5.2f\n" , [ it ] as float[] ) } ( 7..11 ).each { printf ( "-- %5.2g\n" , [ it ] as double[] ) }
self
- any Objectformat
- A format stringarg
- Argument which is referenced by the format specifiers in the format
string. The type of arg
should be one of Object[], List,
int[], short[], byte[], char[], boolean[], long[], float[], or double[].public static String sprintf(Object self, String format, Object arg)
self
- any Objectformat
- A format stringarg
- Argument which is referenced by the format specifiers in the format
string. The type of arg
should be one of Object[], List,
int[], short[], byte[], char[], boolean[], long[], float[], or double[].
public static String inspect(Object self)
self
- any Object
public static void print(Object self, PrintWriter out)
self
- any Objectout
- the PrintWriter used for printingpublic static void println(Object self, PrintWriter out)
self
- any Objectout
- the PrintWriter used for printingpublic static Object invokeMethod(Object object, String method, Object arguments)
object
- any Objectmethod
- the name of the method to callarguments
- the arguments to use
public static boolean isCase(Object caseValue, Object switchValue)
switch( a ) { case b: //some code }"some code" is called when
b.isCase( a )
returns
true
.
caseValue
- the case valueswitchValue
- the switch value
public static boolean isCase(String caseValue, Object switchValue)
switch( str ) { case 'one' : // etc... }Note that this returns
true
for the case where both the
'switch' and 'case' operand is null
.
caseValue
- the case valueswitchValue
- the switch value
public static boolean isCase(GString caseValue, Object switchValue)
caseValue
- the case valueswitchValue
- the switch value
public static boolean isCase(Class caseValue, Object switchValue)
switch( obj ) { case List : // obj is a list break; case Set : // etc }
caseValue
- the case valueswitchValue
- the switch value
public static boolean isCase(Collection caseValue, Object switchValue)
switch( item ) { case firstList : // item is contained in this list // etc }
caseValue
- the case valueswitchValue
- the switch value
Collection.contains(Object)
public static boolean isCase(Pattern caseValue, Object switchValue)
Pattern
class, which allows
testing a String against a number of regular expressions.
For example:
switch( str ) { case ~/one/ : // the regex 'one' matches the value of str }Note that this returns true for the case where both the pattern and the 'switch' values are
null
.
caseValue
- the case valueswitchValue
- the switch value
public static boolean isCase(Number caseValue, Number switchValue)
compareTo()
method for comparing numbers of different
types.
caseValue
- the case valueswitchValue
- the switch value
public static Iterator unique(Iterator self)
self
- an Iterator
public static Collection unique(Collection self)
self
- a collection
public static int numberAwareCompareTo(Comparable self, Comparable other)
self
- a Comparableother
- another Comparable
public static Iterator unique(Iterator self, Closure closure)
Comparable.compareTo(Object)
or Object#equals() ).
self
- an Iteratorclosure
- a Closure used as a comparator
public static Collection unique(Collection self, Closure closure)
Comparable.compareTo(Object)
or Object#equals() ). If the
closure takes two parameters, two items from the collection
will be passed as arguments, and the closure should return an
int value (with 0 indicating the items are not unique).
self
- a Collectionclosure
- a Closure used as a comparator
public static Iterator unique(Iterator self, Comparator comparator)
self
- an Iteratorcomparator
- a Comparator
public static Collection unique(Collection self, Comparator comparator)
class Person {
def fname, lname
public String toString() {
return fname + " " + lname
}
}
class PersonComparator implements Comparator {
public int compare(Object o1, Object o2) {
Person p1 = (Person) o1
Person p2 = (Person) o2
if (p1.lname != p2.lname)
return p1.lname.compareTo(p2.lname)
else
return p1.fname.compareTo(p2.fname)
}
public boolean equals(Object obj) {
return this.equals(obj)
}
}
Person a = new Person(fname:"John", lname:"Taylor")
Person b = new Person(fname:"Clark", lname:"Taylor")
Person c = new Person(fname:"Tom", lname:"Cruz")
Person d = new Person(fname:"Clark", lname:"Taylor")
def list = [a, b, c, d]
List list2 = list.unique(new PersonComparator())
assert( list2 == list && list == [a, b, c] )
self
- a Collectioncomparator
- a Comparator
public static Object each(Object self, Closure closure)
self
- the object over which we iterateclosure
- the closure applied on each element found
public static Object eachWithIndex(Object self, Closure closure)
self
- an Objectclosure
- a Closure to operate on each item
public static Map each(Map self, Closure closure)
self
- the map over which we iterateclosure
- the closure applied on each entry of the map
public static Object eachWithIndex(Map self, Closure closure)
self
- the map over which we iterateclosure
- a Closure to operate on each item
public static List reverseEach(List self, Closure closure)
self
- a Listclosure
- a closure to which each item is passed.
public static Object[] reverseEach(Object[] self, Closure closure)
self
- an Object arrayclosure
- a closure to which each item is passed
public static Object[] reverse(Object[] self)
self
- an Object array
public static boolean every(Object self, Closure closure)
true
for all items in this data structure).
A simple example for a list:
def list = [3,4,5] def greaterThanTwo = list.every { it > 2 }
self
- the object over which we iterateclosure
- the closure predicate used for matching
public static boolean every(Map self, Closure closure)
self
- the map over which we iterateclosure
- the closure predicate used for matching
public static boolean every(Object self)
true
according to the Groovy Truth.
Equivalent to self.every({element -> element})
self
- the object over which we iterate
public static boolean any(Object self, Closure closure)
self
- the object over which we iterateclosure
- the closure predicate used for matching
public static boolean any(Map self, Closure closure)
self
- the map over which we iterateclosure
- the closure predicate used for matching
public static boolean any(Object self)
self
- the object over which we iterate
public static Collection grep(Object self, Object filter)
isCase(Object,Object)
method used by switch statements. This method can be used with different
kinds of filters like regular expressions, classes, ranges etc.
Example:
def list = ['a', 'b', 'aa', 'bc' ] def filtered = list.grep( ~/a+/ ) //contains 'a' and 'aa'
self
- the object over which we iteratefilter
- the filter to perform on the collection (using the isCase(object) method)
public static int count(Iterator self, Object value)
compareTo(value) == 0
or equals(value)
).
The iterator will become exhausted of elements after determining the count value.
self
- the Iterator from which we count the number of matching occurrencesvalue
- the value being searched for
public static int count(Collection self, Object value)
compareTo(value) == 0
or equals(value)
).
self
- the collection within which we count the number of occurrencesvalue
- the value being searched for
public static List toList(Collection self)
self
- a collection
public static List toList(Iterator self)
self
- an iterator
public static List toList(Enumeration self)
self
- an enumeration
public static List collect(Object self, Closure closure)
def list = [1, 'a', 1.23, true ] def types = list.collect { it.class }
self
- the values of the object to transformclosure
- the closure used to transform each element of the collection
public static Collection collect(Object self, Collection collection, Closure closure)
self
- the values of the object to transformcollection
- the Collection to which the transformed values are addedclosure
- the closure used to map each element of the collection
public static List collect(Collection self, Closure closure)
self
- a collectionclosure
- the closure used for mapping
public static Collection collect(Collection self, Collection collection, Closure closure)
self
- a collectioncollection
- an initial Collection to which the transformed values are addedclosure
- the closure used to transform each element of the collection
public static List collectAll(Collection self, Closure closure)
self
- a collectionclosure
- the closure used to transform each element of the collection
public static Collection collectAll(Collection self, Collection collection, Closure closure)
self
- a collectioncollection
- an initial Collection to which the transformed values are addedclosure
- the closure used to transform each element of the collection
public static Collection collect(Map self, Collection collection, Closure closure)
self
- a Mapcollection
- the Collection to which the mapped values are addedclosure
- the closure used for mapping, which can take one (Map.Entry) or two (key, value) parameters
public static List collect(Map self, Closure closure)
self
- a Mapclosure
- the closure used to map each element of the collection
public static Object find(Object self, Closure closure)
self
- an Object with an iterator returning its valuesclosure
- a closure condition
public static Object find(Collection self, Closure closure)
def list = [1,2,3] list.find { it > 1 } // returns 2
self
- a Collectionclosure
- a closure condition
public static Object find(Map self, Closure closure)
self
- a Mapclosure
- a closure condition
public static Collection findAll(Object self, Closure closure)
self
- an Object with an Iterator returning its valuesclosure
- a closure condition
public static Collection findAll(Collection self, Closure closure)
self
- a Collectionclosure
- a closure condition
public static Collection split(Object self, Closure closure)
self
- an Object with an Iterator returning its valuesclosure
- a closure condition
public static Collection split(Collection self, Closure closure)
self
- a Collection of valuesclosure
- a closure condition
public static List combinations(Collection self)
self
- a Collection of lists
GroovyCollections.combinations(java.util.Collection)
public static List transpose(List self)
self
- a List of lists
GroovyCollections.transpose(java.util.List)
public static Map findAll(Map self, Closure closure)
If the self
map is one of TreeMap, LinkedHashMap, Hashtable
or Properties, the returned Map will preserve that type, otherwise a HashMap will
be returned.
self
- a Mapclosure
- a closure condition applying on the entries
public static Map groupBy(Collection self, Closure closure)
self
- a collection to group (no map)closure
- a closure mapping entries on keys
public static Map groupEntriesBy(Map self, Closure closure)
self
- a map to groupclosure
- a closure mapping entries on keys
public static Map groupBy(Map self, Closure closure)
If the self
map is one of TreeMap, LinkedHashMap, Hashtable
or Properties, the returned Map will preserve that type, otherwise a HashMap will
be returned.
self
- a map to groupclosure
- a closure mapping entries on keys
protected static void groupAnswer(Map answer, Object element, Object value)
answer
- the map containing the resultselement
- the element to be placedvalue
- the value according to which the element will be placedprotected static Object callClosureForMapEntry(Closure closure, Map.Entry entry)
protected static Object callClosureForLine(Closure closure, String line, int counter)
protected static Object callClosureForMapEntryAndCounter(Closure closure, Map.Entry entry, int counter)
public static Object inject(Collection self, Object value, Closure closure)
self
- a Collectionvalue
- a valueclosure
- a closure
public static Object inject(Iterator self, Object value, Closure closure)
self
- a Collectionvalue
- a valueclosure
- a closure
public static Object inject(Object self, Object value, Closure closure)
self
- a Collectionvalue
- a valueclosure
- a closure
public static Object inject(Object[] self, Object initialValue, Closure closure)
self
- an Object[]initialValue
- an initialValueclosure
- a closure
public static Object sum(Collection self)
self
- Collection of values to add together
public static Object sum(Iterator self)
self
- an Iterator for the values to add together
public static Object sum(Collection self, Object initialValue)
self
- a collection of values to suminitialValue
- the items in the collection will be summed to this initial value
public static Object sum(Iterator self, Object initialValue)
self
- an Iterator for the values to add togetherinitialValue
- the items in the collection will be summed to this initial value
public static Object sum(Collection self, Closure closure)
coll.sum(closure)
is equivalent to:
coll.collect(closure).sum()
.
self
- a Collectionclosure
- a single parameter closure that returns a numeric value.
public static Object sum(Collection self, Object initialValue, Closure closure)
coll.sum(closure)
is equivalent to:
coll.collect(closure).sum()
.
self
- a Collectionclosure
- a single parameter closure that returns a numeric value.initialValue
- the closure results will be summed to this initial value
public static String join(Iterator self, String separator)
toString()
representation of each
item from the iterator, with the given String as a separator between
each item. The iterator will become exhausted of elements after
determining the resulting conjoined value.
self
- an Iterator of itemsseparator
- a String separator
public static String join(Collection self, String separator)
toString()
representation of each
item in this collection, with the given String as a separator between
each item.
self
- a Collection of objectsseparator
- a String separator
public static String join(Object[] self, String separator)
toString()
representation of each
items in this array, with the given String as a separator between each
item.
self
- an array of Objectseparator
- a String separator
public static Object min(Collection self)
self
- a Collection
GroovyCollections.min(java.util.Collection)
public static Object min(Iterator self)
self
- an Iterator
min(java.util.Collection)
public static Object min(Object[] self)
self
- an Object array
min(java.util.Collection)
public static Object min(Collection self, Comparator comparator)
self
- a Collectioncomparator
- a Comparator
public static Object min(Iterator self, Comparator comparator)
self
- an Iteratorcomparator
- a Comparator
min(java.util.Collection, java.util.Comparator)
public static Object min(Object[] self, Comparator comparator)
self
- an Object arraycomparator
- a Comparator
min(java.util.Collection, java.util.Comparator)
public static Object min(Collection self, Closure closure)
self
- a Collectionclosure
- a closure used as a comparator
public static Object min(Iterator self, Closure closure)
self
- an Iteratorclosure
- a closure used as a comparator
min(java.util.Collection, groovy.lang.Closure)
public static Object min(Object[] self, Closure closure)
self
- an Object arrayclosure
- a closure used as a comparator
min(java.util.Collection, groovy.lang.Closure)
public static Object max(Collection self)
self
- a Collection
GroovyCollections.max(java.util.Collection)
public static Object max(Iterator self)
self
- an Iterator
GroovyCollections.max(java.util.Collection)
public static Object max(Object[] self)
self
- an Object array
max(java.util.Collection)
public static Object max(Collection self, Closure closure)
self
- a Collectionclosure
- a closure used as a comparator
public static Object max(Iterator self, Closure closure)
self
- an Iteratorclosure
- a closure used as a comparator
max(java.util.Collection, groovy.lang.Closure)
public static Object max(Object[] self, Closure closure)
self
- an Object arrayclosure
- a closure used as a comparator
max(java.util.Collection, groovy.lang.Closure)
public static Object max(Collection self, Comparator comparator)
self
- a Collectioncomparator
- a Comparator
public static Object max(Iterator self, Comparator comparator)
self
- an Iteratorcomparator
- a Comparator
public static Object max(Object[] self, Comparator comparator)
self
- an Object arraycomparator
- a Comparator
public static int size(Iterator self)
size()
method for Iterator
.
The iterator will become exhausted of elements after determining the size value.
self
- an Iterator
public static int size(String text)
size()
method for String
.
text
- a String
public static int size(StringBuffer buffer)
size()
method for StringBuffer
.
buffer
- a StringBuffer
public static long size(File self)
size()
method for File
.
self
- a file object
public static long size(Matcher self)
size()
method for Matcher
.
self
- a matcher object
public static int size(Object[] self)
size()
method for an array.
self
- an Array of objects
public static CharSequence getAt(CharSequence text, int index)
text
- a CharSequenceindex
- the index of the Character to get
public static String getAt(String text, int index)
text
- a Stringindex
- the index of the Character to get
public static CharSequence getAt(CharSequence text, Range range)
text
- a CharSequencerange
- a Range
public static CharSequence getAt(CharSequence text, IntRange range)
text
- a CharSequencerange
- an IntRange
public static CharSequence getAt(CharSequence text, EmptyRange range)
text
- a CharSequencerange
- an EmptyRange
public static String getAt(String text, IntRange range)
text
- a Stringrange
- an IntRange
public static String getAt(String text, EmptyRange range)
text
- a Stringrange
- an EmptyRange
public static String getAt(String text, Range range)
text
- a Stringrange
- a Range
public static String reverse(String self)
self
- a String
public static URL toURL(String self) throws MalformedURLException
self
- the String representing a URL
MalformedURLException
- is thrown if the URL is not well formed.public static URI toURI(String self) throws URISyntaxException
self
- the String representing a URI
URISyntaxException
- is thrown if the URI is not well formed.public static Pattern bitwiseNegate(String self)
self
- a String to convert into a regular expression
public static String replaceAll(String self, String regex, Closure closure)
For examples,
assert "FOOBAR-FOOBAR-" == "foobar-FooBar-".replaceAll("(([fF][oO]{2})[bB]ar)", { Object[] it -> it[0].toUpperCase() }) Here, it[0] is the global string of the matched group it[1] is the first string in the matched group it[2] is the second string in the matched group assert "FOO-FOO-" == "foobar-FooBar-".replaceAll("(([fF][oO]{2})[bB]ar)", { x, y, z -> z.toUpperCase() }) Here, x is the global string of the matched group y is the first string in the matched group z is the second string in the matched group
Note that unlike String.replaceAll(String pattern, String replacement), where the replacement string treats '$' and '\' specially (for group substitution), the result of the closure is converted to a string and that value is used literally for the replacement.
self
- a Stringregex
- the capturing regexclosure
- the closure to apply on each captured group
Matcher.quoteReplacement(String)
public static String replace(String self, CharSequence target, CharSequence replacement)
self
- a Stringtarget
- the character sequence to search forreplacement
- the character sequence to replace the matches with
java.lang.String.replace(CharSequence, CharSequence)
public static String padLeft(String self, Number numberOfChars, String padding)
self
- a String objectnumberOfChars
- the total number of characterspadding
- the charaters used for padding
public static String padLeft(String self, Number numberOfChars)
self
- a String objectnumberOfChars
- the total number of characters
public static String padRight(String self, Number numberOfChars, String padding)
self
- a String objectnumberOfChars
- the total number of characterspadding
- the charaters used for padding
public static String padRight(String self, Number numberOfChars)
self
- a String objectnumberOfChars
- the total number of characters
public static String center(String self, Number numberOfChars, String padding)
self
- a String objectnumberOfChars
- the total number of characterspadding
- the charaters used for padding
public static String center(String self, Number numberOfChars)
self
- a String objectnumberOfChars
- the total number of characters
public static Object getAt(Matcher matcher, int idx)
def p = /ab[d|f]/ def m = "abcabdabeabf" =~ p assert 2 == m.count assert 2 == m.size() // synonym for m.getCount() assert ! m.hasGroup() assert 0 == m.groupCount() def matches = ["abd", "abf"] for (i in 0..<m.count) { assert m[i] == matches[i] }For an example using group matches,
def p = /(?:ab([c|d|e|f]))/ def m = "abcabdabeabf" =~ p assert 4 == m.count assert m.hasGroup() assert 1 == m.groupCount() def matches = [["abc", "c"], ["abd", "d"], ["abe", "e"], ["abf", "f"]] for (i in 0..<m.count) { assert m[i] == matches[i] }For another example using group matches,
def m = "abcabdabeabfabxyzabx" =~ /(?:ab([d|x-z]+))/ assert 3 == m.count assert m.hasGroup() assert 1 == m.groupCount() def matches = [["abd", "d"], ["abxyz", "xyz"], ["abx", "x"]] for (i in 0..<m.count) { assert m[i] == matches[i] }
matcher
- a Matcheridx
- an index
public static void setIndex(Matcher matcher, int idx)
matcher
- a Matcheridx
- the index numberpublic static int getCount(Matcher matcher)
matcher
- a Matcher
public static boolean hasGroup(Matcher matcher)
matcher
- a Matcher
true
if matcher contains at least one group.public static List getAt(List self, IntRange range)
self
- a Listrange
- a Range indicating the items to get
List.subList(int,int)
public static List getAt(List self, Collection indices)
self
- a Listindices
- a Collection of indices
public static List getAt(Object[] self, Collection indices)
self
- an Array of Objectsindices
- a Collection of indices
public static CharSequence getAt(CharSequence self, Collection indices)
self
- a CharSequenceindices
- a Collection of indices
public static String getAt(String self, Collection indices)
self
- a Stringindices
- a Collection of indices
public static List getAt(Matcher self, Collection indices)
self
- a Matcherindices
- a Collection of indices
public static Map subMap(Map map, Collection keys)
map
- a Mapkeys
- a Collection of keys
public static Object get(Map map, Object key, Object defaultValue)
map
- a Mapkey
- the key to lookup the value ofdefaultValue
- the value to return and add to the map for this key if
there is no entry for the given key
public static List getAt(Object[] array, Range range)
array
- an Array of Objectsrange
- a Range
public static List getAt(Object[] array, IntRange range)
array
- an Array of Objectsrange
- an IntRange
public static List getAt(Object[] array, EmptyRange range)
array
- an Array of Objectsrange
- an EmptyRange
public static List getAt(Object[] array, ObjectRange range)
array
- an Array of Objectsrange
- an ObjectRange
public static List toList(Object[] array)
array
- an Array of Objects
public static Object getAt(List self, int idx)
self
- a Listidx
- an index
public static int getAt(Date self, int field)
self
- a Datefield
- a Calendar field, e.g. MONTH
Calendar
public static void putAt(List self, int idx, Object value)
self
- a Listidx
- an indexvalue
- the value to put at the given indexpublic static void putAt(StringBuffer self, IntRange range, Object value)
self
- a StringBufferrange
- a Rangevalue
- the object that's toString() will be insertedpublic static void putAt(StringBuffer self, EmptyRange range, Object value)
self
- a StringBufferrange
- a Rangevalue
- the object that's toString() will be insertedpublic static void putAt(List self, EmptyRange range, Object value)
self
- a Listrange
- the subset of the list to setvalue
- the values to put at the given sublist or a Collection of valuespublic static void putAt(List self, IntRange range, Collection col)
myList[3..5] = anotherList
. Items in the given
range are relaced with items from the collection.
self
- a Listrange
- the subset of the list to setcol
- the collection of values to put at the given sublistpublic static void putAt(List self, IntRange range, Object value)
myList[3..5] = newItem
. Items in the given
range are relaced with the operand. The value
operand is
always treated as a single value.
self
- a Listrange
- the subset of the list to setvalue
- the value to put at the given sublistpublic static void putAt(List self, List splice, List values)
self
- a Listsplice
- the subset of the list to setvalues
- the value to put at the given sublistpublic static void putAt(List self, List splice, Object value)
self
- a Listsplice
- the subset of the list to setvalue
- the value to put at the given sublistprotected static List getSubList(List self, List splice)
public static Object getAt(Map self, Object key)
self
- a Mapkey
- an Object as a key for the map
public static Map plus(Map left, Map right)
left
and right
,
giving precedence to right
. Any keys appearing in both Maps
will appear in the resultant map with values from the right
operand. If the left
map is one of TreeMap, LinkedHashMap, Hashtable
or Properties, the returned Map will preserve that type, otherwise a HashMap will
be returned.
Roughly equivalent to Map m = new HashMap(); m.putAll(left); m.putAll(right); return m;
but with some additional logic to preserve the left
Map type for common cases as
described above.
left
- a Mapright
- a Map
public static Object putAt(Map self, Object key, Object value)
self
- a Mapkey
- an Object as a key for the mapvalue
- the value to put into the map
public static List getAt(Collection coll, String property)
coll
- a Collectionproperty
- a String
public static Map asImmutable(Map self)
self
- a Map
Collections.unmodifiableMap(java.util.Map)
public static SortedMap asImmutable(SortedMap self)
self
- a SortedMap
Collections.unmodifiableSortedMap(java.util.SortedMap)
public static List asImmutable(List self)
self
- a List
Collections.unmodifiableList(java.util.List)
public static Set asImmutable(Set self)
self
- a Set
Collections.unmodifiableSet(java.util.Set)
public static SortedSet asImmutable(SortedSet self)
self
- a SortedSet
Collections.unmodifiableSortedSet(java.util.SortedSet)
public static Collection asImmutable(Collection self)
self
- a Collection
Collections.unmodifiableCollection(java.util.Collection)
public static Map asSynchronized(Map self)
self
- a Map
Collections.synchronizedMap(java.util.Map)
public static SortedMap asSynchronized(SortedMap self)
self
- a SortedMap
Collections.synchronizedSortedMap(java.util.SortedMap)
public static Collection asSynchronized(Collection self)
self
- a Collection
Collections.synchronizedCollection(java.util.Collection)
public static List asSynchronized(List self)
self
- a List
Collections.synchronizedList(java.util.List)
public static Set asSynchronized(Set self)
self
- a Set
Collections.synchronizedSet(java.util.Set)
public static SortedSet asSynchronized(SortedSet self)
self
- a SortedSet
Collections.synchronizedSortedSet(java.util.SortedSet)
public static SpreadMap spread(Map self)
toSpreadMap(Map)
.
self
- a map
public static SpreadMap toSpreadMap(Map self)
SpreadMap
from this map.
For examples, if there is defined a function like as
, then all of the following three have the same meaning.def fn(a, b, c, d) { return a + b + c + d }
println fn(a:1, [b:2, c:3].toSpreadMap(), d:4) println fn(a:1, *:[b:2, c:3], d:4) println fn(a:1, b:2, c:3, d:4)
self
- a list to be converted into a spreadmap
SpreadMap.SpreadMap(java.util.Map)
public static SpreadMap toSpreadMap(Object[] self)
self
- an object array
SpreadMap.SpreadMap(java.lang.Object[])
public static List sort(Collection self)
self
- the collection to be sorted
public static Map sort(Map self, Closure closure)
self
- the map to be sortedclosure
- a Closure used as a comparator
public static Object[] sort(Object[] self)
self
- the array to be sorted
public static Iterator sort(Iterator self)
self
- the Iterator to be sorted
public static Iterator sort(Iterator self, Comparator comparator)
self
- the Iterator to be sortedcomparator
- a Comparator used for comparing items
public static List sort(Collection self, Comparator comparator)
self
- a collection to be sortedcomparator
- a Comparator used for the comparison
public static Object[] sort(Object[] self, Comparator comparator)
self
- the array to be sortedcomparator
- a Comparator used for the comparison
public static Iterator sort(Iterator self, Closure closure)
self
- the Iterator to be sortedclosure
- a Closure used as a comparator
public static Object[] sort(Object[] self, Closure closure)
self
- the array to be sortedclosure
- a Closure used as a comparator
public static List sort(Collection self, Closure closure)
self
- a Collection to be sortedclosure
- a Closure used as a comparator
public static SortedSet sort(SortedSet self)
self
- an identity function for an already sorted set
public static Object pop(List self)
self
- a List
NoSuchElementException
- if the list is empty and you try to pop() it.public static boolean push(List self, Object value)
self
- a Listvalue
- element to be appended to this list.
NoSuchElementException
- if the list is empty and you try to pop() it.public static Object last(List self)
self
- a List
NoSuchElementException
- if the list is empty and you try to access the last() item.public static Object first(List self)
self
- a List
NoSuchElementException
- if the list is empty and you try to access the first() item.public static Object head(List self)
self
- a List
NoSuchElementException
- if the list is empty and you try to access the head() item.public static List tail(List self)
self
- a List
NoSuchElementException
- if the list is empty and you try to access the tail() item.public static List asList(Collection self)
self
- a collection to be converted into a List
public static Object asType(Collection col, Class clazz)
col
- a collectionclazz
- the desired class
asType(Object,Class)
public static Object asType(Object[] ary, Class clazz)
ary
- an arrayclazz
- the desired class
asType(Object,Class)
public static Object asType(Closure cl, Class clazz)
cl
- the implementation of the single methodclazz
- the target type
public static Object asType(Map map, Class clazz)
map
- this mapclazz
- the target type
public static List reverse(List self)
self
- a List
public static Iterator reverse(Iterator self)
self
- an Iterator
public static Collection plus(Collection left, Collection right)
left
- the left Collectionright
- the right Collection
public static Collection plus(Collection left, Object right)
left
- a Collectionright
- an object to add/append
public static List multiply(Collection self, Number factor)
self
- a Collectionfactor
- the number of times to append
public static Collection intersect(Collection left, Collection right)
left
- a Collectionright
- a Collection
public static boolean disjoint(Collection left, Collection right)
true
if the intersection of two collections is empty.
left
- a Collectionright
- a Collection
true
if the intersection of two collections
is empty, false
otherwise.public static boolean equals(int[] left, int[] right)
left
- an int arrayright
- the operand array.
public static boolean equals(Object[] left, List right)
false
if either collection is null
.
left
- this arrayright
- the list being compared
public static boolean equals(List left, Object[] right)
false
if either collection is null
.
left
- this Listright
- this Object[] being compared to
public static boolean equals(List left, List right)
null
, the result
is false
.
left
- this Listright
- the List being compared to.
true
if the contents of both lists are identical,
false
otherwise.public static Set minus(Set self, Collection operands)
self
- a set objectoperands
- the items to remove from the set
public static Set minus(Set self, Object operand)
self
- a set objectoperand
- the operand to remove from the set
public static Object[] minus(Object[] self, Collection removeMe)
self
- an object arrayremoveMe
- a Collection of elements to remove
public static Object[] minus(Object[] self, Object[] removeMe)
self
- an object arrayremoveMe
- an array of elements to remove
public static List minus(List self, Collection removeMe)
self
- a ListremoveMe
- a Collection of elements to remove
public static List minus(List self, Object operand)
self
- a List objectoperand
- an element to remove from the list
public static Object[] minus(Object[] self, Object operand)
self
- an object arrayoperand
- an element to remove from the array
public static Collection flatten(Collection self)
self
- a Collection to flatten
public static Collection flatten(Object[] self)
self
- an Array to flatten
public static Collection flatten(boolean[] self)
self
- a boolean Array to flatten
public static Collection flatten(byte[] self)
self
- a byte Array to flatten
public static Collection flatten(char[] self)
self
- a char Array to flatten
public static Collection flatten(short[] self)
self
- a short Array to flatten
public static Collection flatten(int[] self)
self
- an int Array to flatten
public static Collection flatten(long[] self)
self
- a long Array to flatten
public static Collection flatten(float[] self)
self
- a float Array to flatten
public static Collection flatten(double[] self)
self
- a double Array to flatten
public static Collection flatten(Collection self, Closure flattenUsing)
self
- a CollectionflattenUsing
- a closure to determine how to flatten non-Array, non-Collection elements
public static Collection leftShift(Collection self, Object value)
self
- a Collectionvalue
- an Object to be added to the collection.
public static Map leftShift(Map self, Map.Entry entry)
self
- a Mapentry
- a Map.Entry to be added to the Map.
public static StringBuffer leftShift(String self, Object value)
self
- a Stringvalue
- an Obect
protected static StringWriter createStringWriter(String self)
protected static StringBufferWriter createStringBufferWriter(StringBuffer self)
public static StringBuffer leftShift(StringBuffer self, Object value)
self
- a StringBuffervalue
- a value to append
public static Writer leftShift(Writer self, Object value) throws IOException
self
- a Writervalue
- a value to append
IOException
- if an I/O error occurs.public static Number leftShift(Number self, Number operand)
self
- a Number objectoperand
- the shift distance by which to left shift the number
public static Number rightShift(Number self, Number operand)
self
- a Number objectoperand
- the shift distance by which to right shift the number
public static Number rightShiftUnsigned(Number self, Number operand)
self
- a Number objectoperand
- the shift distance by which to right shift (unsigned) the number
public static void write(Writer self, Writable writable) throws IOException
self
- a Writerwritable
- an object implementing the Writable interface
IOException
- if an I/O error occurs.public static Writer leftShift(OutputStream self, Object value) throws IOException
self
- an OutputStreamvalue
- a value to append
IOException
- if an I/O error occurs.public static void leftShift(ObjectOutputStream self, Object value) throws IOException
self
- an ObjectOutputStreamvalue
- an object to write to the stream
IOException
- if an I/O error occurs.public static OutputStream leftShift(OutputStream self, InputStream in) throws IOException
self
- stream on which to writein
- stream to read from
IOException
- if an I/O error occurs.public static OutputStream leftShift(OutputStream self, byte[] value) throws IOException
self
- an OutputStreamvalue
- a value to append
IOException
- if an I/O error occurs.public static Object getAt(byte[] array, Range range)
array
- a byte arrayrange
- a range indicating the indices for the items to retrieve
public static Object getAt(char[] array, Range range)
array
- a char arrayrange
- a range indicating the indices for the items to retrieve
public static Object getAt(short[] array, Range range)
array
- a short arrayrange
- a range indicating the indices for the items to retrieve
public static Object getAt(int[] array, Range range)
array
- an int arrayrange
- a range indicating the indices for the items to retrieve
public static Object getAt(long[] array, Range range)
array
- a long arrayrange
- a range indicating the indices for the items to retrieve
public static Object getAt(float[] array, Range range)
array
- a float arrayrange
- a range indicating the indices for the items to retrieve
public static Object getAt(double[] array, Range range)
array
- a double arrayrange
- a range indicating the indices for the items to retrieve
public static Object getAt(boolean[] array, Range range)
array
- a boolean arrayrange
- a range indicating the indices for the items to retrieve
public static Object getAt(byte[] array, IntRange range)
array
- a byte arrayrange
- an IntRange indicating the indices for the items to retrieve
public static Object getAt(char[] array, IntRange range)
array
- a char arrayrange
- an IntRange indicating the indices for the items to retrieve
public static Object getAt(short[] array, IntRange range)
array
- a short arrayrange
- an IntRange indicating the indices for the items to retrieve
public static Object getAt(int[] array, IntRange range)
array
- an int arrayrange
- an IntRange indicating the indices for the items to retrieve
public static Object getAt(long[] array, IntRange range)
array
- a long arrayrange
- an IntRange indicating the indices for the items to retrieve
public static Object getAt(float[] array, IntRange range)
array
- a float arrayrange
- an IntRange indicating the indices for the items to retrieve
public static Object getAt(double[] array, IntRange range)
array
- a double arrayrange
- an IntRange indicating the indices for the items to retrieve
public static Object getAt(boolean[] array, IntRange range)
array
- a boolean arrayrange
- an IntRange indicating the indices for the items to retrieve
public static Object getAt(byte[] array, ObjectRange range)
array
- a byte arrayrange
- an ObjectRange indicating the indices for the items to retrieve
public static Object getAt(char[] array, ObjectRange range)
array
- a char arrayrange
- an ObjectRange indicating the indices for the items to retrieve
public static Object getAt(short[] array, ObjectRange range)
array
- a short arrayrange
- an ObjectRange indicating the indices for the items to retrieve
public static Object getAt(int[] array, ObjectRange range)
array
- an int arrayrange
- an ObjectRange indicating the indices for the items to retrieve
public static Object getAt(long[] array, ObjectRange range)
array
- a long arrayrange
- an ObjectRange indicating the indices for the items to retrieve
public static Object getAt(float[] array, ObjectRange range)
array
- a float arrayrange
- an ObjectRange indicating the indices for the items to retrieve
public static Object getAt(double[] array, ObjectRange range)
array
- a double arrayrange
- an ObjectRange indicating the indices for the items to retrieve
public static Object getAt(boolean[] array, ObjectRange range)
array
- a byte arrayrange
- an ObjectRange indicating the indices for the items to retrieve
public static Object getAt(byte[] array, Collection indices)
array
- a byte arrayindices
- a collection of indices for the items to retrieve
public static Object getAt(char[] array, Collection indices)
array
- a char arrayindices
- a collection of indices for the items to retrieve
public static Object getAt(short[] array, Collection indices)
array
- a short arrayindices
- a collection of indices for the items to retrieve
public static Object getAt(int[] array, Collection indices)
array
- an int arrayindices
- a collection of indices for the items to retrieve
public static Object getAt(long[] array, Collection indices)
array
- a long arrayindices
- a collection of indices for the items to retrieve
public static Object getAt(float[] array, Collection indices)
array
- a float arrayindices
- a collection of indices for the items to retrieve
public static Object getAt(double[] array, Collection indices)
array
- a double arrayindices
- a collection of indices for the items to retrieve
public static Object getAt(boolean[] array, Collection indices)
array
- a boolean arrayindices
- a collection of indices for the items to retrieve
public static boolean getAt(BitSet self, int index)
self
- a BitSetindex
- index to retrieve
BitSet
public static BitSet getAt(BitSet self, IntRange range)
self
- a BitSetrange
- a Range defining the desired subset
BitSet
,
IntRange
public static void putAt(BitSet self, IntRange range, boolean value)
self
- a BitSetrange
- the range of values to setvalue
- valueBitSet
,
Range
public static void putAt(BitSet self, int index, boolean value)
self
- a BitSetindex
- index of the entry to setvalue
- valueBitSet
public static int size(boolean[] array)
array
- a boolean array
Array.getLength(Object)
public static int size(byte[] array)
array
- a byte array
Array.getLength(Object)
public static int size(char[] array)
array
- a char array
Array.getLength(Object)
public static int size(short[] array)
array
- a short array
Array.getLength(Object)
public static int size(int[] array)
array
- an int array
Array.getLength(Object)
public static int size(long[] array)
array
- a long array
Array.getLength(Object)
public static int size(float[] array)
array
- a float array
Array.getLength(Object)
public static int size(double[] array)
array
- a double array
Array.getLength(Object)
public static List toList(byte[] array)
array
- an array
public static List toList(boolean[] array)
array
- a boolean array
public static List toList(char[] array)
array
- a char array
public static List toList(short[] array)
array
- a short array
public static List toList(int[] array)
array
- an int array
public static List toList(long[] array)
array
- a long array
public static List toList(float[] array)
array
- a float array
public static List toList(double[] array)
array
- a double array
public static Writable encodeBase64(Byte[] data, boolean chunked)
RFC 4648
.
data
- Byte array to be encodedchunked
- whether or not the Base64 encoded data should be MIME chunked
public static Writable encodeBase64(Byte[] data)
RFC 4648
.
data
- Byte array to be encoded
public static Writable encodeBase64(byte[] data, boolean chunked)
RFC 4648
.
data
- byte array to be encodedchunked
- whether or not the Base64 encoded data should be MIME chunked
public static Writable encodeBase64(byte[] data)
RFC 4648
.
data
- byte array to be encoded
public static byte[] decodeBase64(String value)
value
- the string to be decoded
protected static Object primitiveArrayGet(Object self, int idx)
self
- an array objectidx
- the index of interest
protected static List primitiveArrayGet(Object self, Range range)
self
- an array objectrange
- the range of indices of interest
protected static List primitiveArrayGet(Object self, Collection indices)
self
- an array objectindices
- the indices of interest
protected static Object primitiveArrayPut(Object self, int idx, Object newValue)
self
- an objectidx
- the index of interestnewValue
- the new value to be put into the index of interest
public static Character toCharacter(String self)
self
- a String
public static Boolean toBoolean(String self)
self
- a String
public static String[] split(String self)
self
- the string to split
public static List tokenize(String self, String token)
self
- a Stringtoken
- the delimiter
StringTokenizer.StringTokenizer(java.lang.String, java.lang.String)
public static List tokenize(String self)
self
- a String
StringTokenizer.StringTokenizer(java.lang.String)
public static String plus(String left, Object value)
left
- a Stringvalue
- any Object
public static String plus(Number value, String right)
value
- a Numberright
- a String
public static String plus(StringBuffer left, String value)
left
- a StringBuffervalue
- a String
public static String minus(String self, Object target)
self
- a Stringtarget
- an object representing the part to remove
public static boolean contains(String self, String text)
Collection.contains(Object)
to make Strings more polymorphic.
This method is not required on JDK 1.5 onwards
self
- a Stringtext
- a String to look for
public static int count(String self, String text)
self
- a Stringtext
- a substring
public static String next(String self)
self
- a String
public static String previous(String self)
self
- a String
public static Process execute(String self) throws IOException
self
- a command line String
IOException
- if an IOException occurs.public static Process execute(String[] commandArray) throws IOException
String
array that is the parameter.
The first item in the array is the command the others are the parameters. For more
control over the process mechanism in JDK 1.5 you can use
java.lang.ProcessBuilder
.
commandArray
- an array of String containing the command name and
parameters as separate items in the array.
- Returns:
- the Process which has just started for this command line string.
- Throws:
IOException
- if an IOException occurs.- Since:
- 1.0
public static Process execute(String self, String[] envp, File dir) throws IOException
self
with environments envp
under the working directory dir
.
For more control over the process mechanism in JDK 1.5 you can use java.lang.ProcessBuilder
.
self
- a command line String to be executed.envp
- an array of Strings, each element of which
has environment variable settings in the format
name=value, or
null if the subprocess should inherit
the environment of the current process.dir
- the working directory of the subprocess, or
null if the subprocess should inherit
the working directory of the current process.
IOException
- if an IOException occurs.public static Process execute(List commandList) throws IOException
String
list that is the parameter.
The first item in the array is the command the others are the parameters. All entries
must be String
s. For more control over the process mechanism in JDK 1.5 you
can use java.lang.ProcessBuilder
.
commandList
- a list of String containing the command name and
parameters as separate items in the list.
- Returns:
- the Process which has just started for this command line string.
- Throws:
IOException
- if an IOException occurs.- Since:
- 1.0
public static Process execute(String self, List envp, File dir) throws IOException
self
with environments envp
under the working directory dir
.
For more control over the process mechanism in JDK 1.5 you can use java.lang.ProcessBuilder
.
self
- a command line String to be executed.envp
- a List of Strings, each member of which
has environment variable settings in the format
name=value, or
null if the subprocess should inherit
the environment of the current process.dir
- the working directory of the subprocess, or
null if the subprocess should inherit
the working directory of the current process.
IOException
- if an IOException occurs.public static String multiply(String self, Number factor)
self
- a String to be repeatedfactor
- the number of times the String should be repeated
IllegalArgumentException
- if the number of repetitions is < 0public static String toString(boolean[] self)
self
- an array
public static String toString(byte[] self)
self
- an array
public static String toString(char[] self)
self
- an array
public static String toString(short[] self)
self
- an array
public static String toString(int[] self)
self
- an array
public static String toString(long[] self)
self
- an array
public static String toString(float[] self)
self
- an array
public static String toString(double[] self)
self
- an array
public static String toString(AbstractMap self)
self
- a Map
toMapString(Map)
public static String toMapString(Map self)
{one=1, two=2, three=3}
.
self
- a Map
public static String toString(AbstractCollection self)
[1, 2, a]
.
self
- a Collection
toListString(Collection)
public static String toListString(Collection self)
[1, 2, a]
.
self
- a Collection
public static String toString(Object[] self)
self
- an Object[]
toArrayString(Object[])
public static String toArrayString(Object[] self)
{1, 2, "a"}
.
self
- an Object[]
public static String toString(Object value)
value
- an object
public static Character next(Character self)
self
- a Character
public static Number next(Number self)
self
- a Number
public static Character previous(Character self)
self
- a Character
public static Number previous(Number self)
self
- a Number
public static Number plus(Character left, Number right)
left
- a Characterright
- a Number
Integer.valueOf(String)
public static Number plus(Number left, Character right)
left
- a Numberright
- a Character
Integer.valueOf(String)
public static Number plus(Character left, Character right)
left
- a Characterright
- a Character
plus(Number, Character)
public static int compareTo(Character left, Number right)
left
- a Characterright
- a Number
public static int compareTo(Number left, Character right)
left
- a Numberright
- a Character
public static int compareTo(Character left, Character right)
left
- a Characterright
- a Character
public static int compareTo(Number left, Number right)
left
- a Numberright
- another Number to compare to
public static Number minus(Character left, Number right)
left
- a Characterright
- a Number
public static Number minus(Number left, Character right)
left
- a Numberright
- a Character
public static Number minus(Character left, Character right)
left
- a Characterright
- a Character
public static Number multiply(Character left, Number right)
left
- a Characterright
- a Number
public static Number multiply(Number left, Character right)
left
- a Numberright
- a Character
public static Number multiply(Character left, Character right)
left
- a Characterright
- another Character
public static Number multiply(BigDecimal left, Double right)
left
- a BigDecimalright
- a Double
public static Number multiply(BigDecimal left, BigInteger right)
left
- a BigDecimalright
- a BigInteger
public static Number power(Number self, Number exponent)
self
- a Numberexponent
- a Number exponent
public static Number div(Character left, Number right)
left
- a Characterright
- a Number
public static Number div(Number left, Character right)
left
- a Numberright
- a Character
public static Number div(Character left, Character right)
left
- a Characterright
- another Character
public static Number intdiv(Character left, Number right)
left
- a Characterright
- a Number
public static Number intdiv(Number left, Character right)
left
- a Numberright
- a Character
public static Number intdiv(Character left, Character right)
left
- a Characterright
- another Character
public static Number intdiv(Number left, Number right)
left
- a Numberright
- another Number
public static Number or(Number left, Number right)
left
- a Numberright
- another Number to bitwise OR
public static Number and(Number left, Number right)
left
- a Numberright
- another Number to bitwise AND
public static BitSet and(BitSet left, BitSet right)
left
- a BitSetright
- another BitSet to bitwise AND
public static BitSet xor(BitSet left, BitSet right)
left
- a BitSetright
- another BitSet to bitwise AND
public static BitSet bitwiseNegate(BitSet self)
self
- a BitSet
public static BitSet or(BitSet left, BitSet right)
left
- a BitSetright
- another BitSet to bitwise AND
public static Number xor(Number left, Number right)
left
- a Numberright
- another Number to bitwse XOR
public static Number mod(Number left, Number right)
left
- a Numberright
- another Number to mod
public static Number unaryMinus(Number left)
-10
left
- a Number
public static void times(Number self, Closure closure)
10.times { println it }Prints the numbers 0 through 9.
self
- a Numberclosure
- the closure to call a number of timespublic static void upto(Number self, Number to, Closure closure)
self
- a Numberto
- another Number to go up toclosure
- the closure to callpublic static void upto(long self, Number to, Closure closure)
self
- a longto
- the end numberclosure
- the code to execute for each numberpublic static void upto(Long self, Number to, Closure closure)
self
- a Longto
- the end numberclosure
- the code to execute for each numberpublic static void upto(float self, Number to, Closure closure)
self
- a floatto
- the end numberclosure
- the code to execute for each numberpublic static void upto(Float self, Number to, Closure closure)
self
- a Floatto
- the end numberclosure
- the code to execute for each numberpublic static void upto(double self, Number to, Closure closure)
self
- a doubleto
- the end numberclosure
- the code to execute for each numberpublic static void upto(Double self, Number to, Closure closure)
self
- a Doubleto
- the end numberclosure
- the code to execute for each numberpublic static void upto(BigInteger self, Number to, Closure closure)
0.upto( 10 ) { println it }Prints numbers 0 to 10
self
- a BigIntegerto
- the end numberclosure
- the code to execute for each numberpublic static void upto(BigDecimal self, Number to, Closure closure)
0.upto( 10 ) { println it }Prints numbers 0.1, 1.1, 2.1... to 9.1
self
- a BigDecimalto
- the end numberclosure
- the code to execute for each numberpublic static void downto(Number self, Number to, Closure closure)
self
- a Numberto
- another Number to go down toclosure
- the closure to callpublic static void downto(long self, Number to, Closure closure)
self
- a longto
- the end numberclosure
- the code to execute for each numberpublic static void downto(Long self, Number to, Closure closure)
self
- a Longto
- the end numberclosure
- the code to execute for each numberpublic static void downto(float self, Number to, Closure closure)
self
- a floatto
- the end numberclosure
- the code to execute for each numberpublic static void downto(Float self, Number to, Closure closure)
self
- a Floatto
- the end numberclosure
- the code to execute for each numberpublic static void downto(double self, Number to, Closure closure)
self
- a doubleto
- the end numberclosure
- the code to execute for each numberpublic static void downto(Double self, Number to, Closure closure)
self
- a Doubleto
- the end numberclosure
- the code to execute for each numberpublic static void downto(BigInteger self, Number to, Closure closure)
self
- a BigIntegerto
- the end numberclosure
- the code to execute for each numberpublic static void downto(BigDecimal self, Number to, Closure closure)
10.5.downto(0) { println it }Prints numbers 10.5, 9.5 ... to 0.5.
self
- a BigDecimalto
- the end numberclosure
- the code to execute for each numberpublic static void step(Number self, Number to, Number stepNumber, Closure closure)
0.step( 10, 2 ) { println it }Prints even numbers 0 through 8.
self
- a Number to start withto
- a Number to go up to, exclusivestepNumber
- a Number representing the step incrementclosure
- the closure to callpublic static int abs(Number number)
number
- a Number
public static long abs(Long number)
number
- a Long
public static float abs(Float number)
number
- a Float
public static double abs(Double number)
number
- a Double
public static int round(Float number)
number
- a Float
public static long round(Double number)
number
- a Double
public static Integer toInteger(String self)
self
- a String
public static Long toLong(String self)
self
- a String
public static Short toShort(String self)
self
- a String
public static Float toFloat(String self)
self
- a String
public static Double toDouble(String self)
self
- a String
public static BigInteger toBigInteger(String self)
self
- a String
public static BigDecimal toBigDecimal(String self)
self
- a String
public static boolean isInteger(String self)
self
- a String
public static boolean isLong(String self)
self
- a String
public static boolean isFloat(String self)
self
- a String
public static boolean isDouble(String self)
self
- a String
public static boolean isBigInteger(String self)
self
- a String
public static boolean isBigDecimal(String self)
self
- a String
public static boolean isNumber(String self)
self
- a String
isBigDecimal(String)
public static boolean isUpperCase(Character self)
self
- a Character
Character.isUpperCase(char)
public static boolean isLowerCase(Character self)
self
- a Character
Character.isLowerCase(char)
public static boolean isLetter(Character self)
self
- a Character
Character.isLetter(char)
public static boolean isDigit(Character self)
self
- a Character
Character.isDigit(char)
public static boolean isLetterOrDigit(Character self)
self
- a Character
Character.isLetterOrDigit(char)
public static boolean isWhitespace(Character self)
self
- a Character
Character.isWhitespace(char)
public static char toUpperCase(Character self)
self
- a Character to convert
Character.isUpperCase(char)
,
String.toUpperCase()
public static char toLowerCase(Character self)
self
- a Character to convert
Character.isLowerCase(char)
,
String.toLowerCase()
public static Integer toInteger(Number self)
self
- a Number
public static Long toLong(Number self)
self
- a Number
public static Float toFloat(Number self)
self
- a Number
public static Double toDouble(Number self)
self
- a Number
public static BigDecimal toBigDecimal(Number self)
self
- a Number
public static Object asType(Number self, Class c)
asType(Object,Class)
:
self
- this numberc
- the desired type of the transformed result
public static BigInteger toBigInteger(Number self)
self
- a Number
public static Date next(Date self)
self
- a Date
public static Date next(Date self)
self
- a java.sql.Date
public static Date previous(Date self)
self
- a Date
public static Date previous(Date self)
self
- a java.sql.Date
public static Date plus(Date self, int days)
self
- a Datedays
- the number of days to increase
public static Date plus(Date self, int days)
self
- a java.sql.Datedays
- the number of days to increase
public static Date minus(Date self, int days)
self
- a Datedays
- the number of days to subtract
public static Date minus(Date self, int days)
self
- a java.sql.Datedays
- the number of days to subtract
public static int minus(Calendar self, Calendar then)
self
- a Calendarthen
- another Calendar
public static int minus(Date self, Date then)
self
- a Datethen
- another Date
public static String format(Date self, String format)
Create a String representation of this date according to the given pattern.
For example, if the system timezone is GMT,
new Date(0).format('MM/dd/yy')
would return the string
"01/01/70"
. See documentation for SimpleDateFormat
for format pattern use.
Note that a new DateFormat instance is created for every invocation of this method (for thread safety).
self
- format
- the format pattern to use according to SimpleDateFormat
SimpleDateFormat
public static String getDateString(Date self)
Return a string representation of the 'day' portion of this date
according to the locale-specific DateFormat.SHORT
default format.
For an "en_UK" system locale, this would be dd/MM/yy
.
Note that a new DateFormat instance is created for every invocation of this method (for thread safety).
self
-
DateFormat.getDateInstance(int)
,
DateFormat.SHORT
public static String getTimeString(Date self)
Return a string representation of the time portion of this date
according to the locale-specific DateFormat.MEDIUM
default format.
For an "en_UK" system locale, this would be HH:MM:ss
.
Note that a new DateFormat instance is created for every invocation of this method (for thread safety).
self
-
DateFormat.getTimeInstance(int)
,
DateFormat.MEDIUM
public static String getDateTimeString(Date self)
Return a string representation of the date and time time portion of
this Date instance, according to the locale-specific format used by
DateFormat
. This method uses the DateFormat.SHORT
preset for the day portion and DateFormat.MEDIUM
for the time
portion of the output string.
Note that a new DateFormat instance is created for every invocation of this method (for thread safety).
self
-
DateFormat.getDateTimeInstance(int, int)
public static Boolean and(Boolean left, Boolean right)
left
- left operatorright
- right operator
public static Boolean or(Boolean left, Boolean right)
left
- left operatorright
- right operator
public static Boolean xor(Boolean left, Boolean right)
left
- left operatorright
- right operator
public static ObjectOutputStream newObjectOutputStream(File file) throws IOException
file
- a file
IOException
- if an IOException occurs.public static ObjectOutputStream newObjectOutputStream(OutputStream outputStream) throws IOException
outputStream
- an output stream
IOException
- if an IOException occurs.public static Object withObjectOutputStream(File file, Closure closure) throws IOException
file
- a Fileclosure
- a closure
IOException
- if an IOException occurs.withStream(OutputStream,Closure)
public static Object withObjectOutputStream(OutputStream outputStream, Closure closure) throws IOException
outputStream
- am output streamclosure
- a closure
IOException
- if an IOException occurs.withStream(OutputStream,Closure)
public static ObjectInputStream newObjectInputStream(File file) throws IOException
file
- a file
IOException
- if an IOException occurs.public static ObjectInputStream newObjectInputStream(InputStream inputStream) throws IOException
inputStream
- an input stream
IOException
- if an IOException occurs.public static ObjectInputStream newObjectInputStream(InputStream inputStream, ClassLoader classLoader) throws IOException
inputStream
- an input streamclassLoader
- the class loader to use when loading the class
IOException
- if an IOException occurs.public static ObjectInputStream newObjectInputStream(File file, ClassLoader classLoader) throws IOException
file
- a fileclassLoader
- the class loader to use when loading the class
IOException
- if an IOException occurs.public static void eachObject(File self, Closure closure) throws IOException, ClassNotFoundException
self
- a Fileclosure
- a closure
IOException
- if an IOException occurs.
ClassNotFoundException
- if the class is not found.eachObject(ObjectInputStream,Closure)
public static void eachObject(ObjectInputStream ois, Closure closure) throws IOException, ClassNotFoundException
ois
- an ObjectInputStream, closed after the operationclosure
- a closure
IOException
- if an IOException occurs.
ClassNotFoundException
- if the class is not found.public static Object withObjectInputStream(File file, Closure closure) throws IOException
file
- a Fileclosure
- a closure
IOException
- if an IOException occurs.withStream(InputStream,Closure)
public static Object withObjectInputStream(File file, ClassLoader classLoader, Closure closure) throws IOException
file
- a FileclassLoader
- the class loader to use when loading the classclosure
- a closure
IOException
- if an IOException occurs.withStream(InputStream,Closure)
public static Object withObjectInputStream(InputStream inputStream, Closure closure) throws IOException
inputStream
- an input streamclosure
- a closure
IOException
- if an IOException occurs.withStream(InputStream,Closure)
public static Object withObjectInputStream(InputStream inputStream, ClassLoader classLoader, Closure closure) throws IOException
inputStream
- an input streamclassLoader
- the class loader to use when loading the classclosure
- a closure
IOException
- if an IOException occurs.withStream(InputStream,Closure)
public static Object eachLine(String self, Closure closure) throws IOException
self
- a Stringclosure
- a closure
IOException
- if an error occurseachLine(String, int, groovy.lang.Closure)
public static Object eachLine(String self, int firstLine, Closure closure) throws IOException
self
- a StringfirstLine
- the count of the first lineclosure
- a closure
IOException
- if an error occurspublic static Object eachLine(File self, Closure closure) throws IOException
self
- a Fileclosure
- a closure
IOException
- if an IOException occurs.eachLine(java.io.File, int, groovy.lang.Closure)
public static Object eachLine(File self, int firstLine, Closure closure) throws IOException
self
- a FilefirstLine
- the count of the first lineclosure
- a closure
IOException
- if an IOException occurs.eachLine(java.io.Reader, int, groovy.lang.Closure)
public static Object eachLine(InputStream stream, String charset, Closure closure) throws IOException
stream
- a streamcharset
- opens the stream with a specified charsetclosure
- a closure
IOException
- if an IOException occurs.eachLine(java.io.InputStream, String, int, groovy.lang.Closure)
public static Object eachLine(InputStream stream, String charset, int firstLine, Closure closure) throws IOException
stream
- a streamcharset
- opens the stream with a specified charsetfirstLine
- the count of the first lineclosure
- a closure
IOException
- if an IOException occurs.eachLine(Reader,Closure)
public static Object eachLine(InputStream stream, Closure closure) throws IOException
stream
- a streamclosure
- a closure
IOException
- if an IOException occurs.eachLine(java.io.InputStream, int, groovy.lang.Closure)
public static Object eachLine(InputStream stream, int firstLine, Closure closure) throws IOException
stream
- a streamfirstLine
- the count of the first lineclosure
- a closure
IOException
- if an IOException occurs.eachLine(java.io.Reader, int, groovy.lang.Closure)
public static Object eachLine(URL url, Closure closure) throws IOException
url
- a URL to open and readclosure
- a closure to apply on each line
IOException
- if an IOException occurs.eachLine(java.net.URL, int, groovy.lang.Closure)
public static Object eachLine(URL url, int firstLine, Closure closure) throws IOException
url
- a URL to open and readfirstLine
- the count of the first lineclosure
- a closure to apply on each line
IOException
- if an IOException occurs.eachLine(java.io.InputStream, int, groovy.lang.Closure)
public static Object eachLine(URL url, String charset, Closure closure) throws IOException
url
- a URL to open and readcharset
- opens the stream with a specified charsetclosure
- a closure to apply on each line
IOException
- if an IOException occurs.eachLine(java.net.URL, String, int, groovy.lang.Closure)
public static Object eachLine(URL url, String charset, int firstLine, Closure closure) throws IOException
url
- a URL to open and readcharset
- opens the stream with a specified charsetfirstLine
- the count of the first lineclosure
- a closure to apply on each line
IOException
- if an IOException occurs.eachLine(java.io.Reader, int, groovy.lang.Closure)
public static Object eachLine(Reader self, Closure closure) throws IOException
self
- a Reader, closed after the method returnsclosure
- a closure
IOException
- if an IOException occurs.public static Object eachLine(Reader self, int firstLine, Closure closure) throws IOException
self
- a Reader, closed after the method returnsfirstLine
- the count of the first lineclosure
- a closure which will be passed each line (or for 2 argument closures the line and count)
IOException
- if an IOException occurs.public static Object splitEachLine(File self, String sep, Closure closure) throws IOException
self
- a Filesep
- a String separatorclosure
- a closure
IOException
- if an IOException occurs.splitEachLine(Reader,String,Closure)
public static Object splitEachLine(Reader self, String sep, Closure closure) throws IOException
self
- a Reader, closed after the method returnssep
- a String separatorclosure
- a closure
IOException
- if an IOException occurs.String.split(String)
public static Object splitEachLine(InputStream stream, String sep, String charset, Closure closure) throws IOException
stream
- an InputStreamsep
- a String separatorcharset
- opens the stream with a specified charsetclosure
- a closure
IOException
- if an IOException occurs.splitEachLine(Reader,String,Closure)
public static Object splitEachLine(InputStream stream, String sep, Closure closure) throws IOException
stream
- an InputStreamsep
- a String separatorclosure
- a closure
IOException
- if an IOException occurs.splitEachLine(Reader,String,Closure)
public static Object splitEachLine(String self, String sep, Closure closure) throws IOException
self
- a Stringsep
- a String separatorclosure
- a closure
IOException
- if an error occursString.split(String)
public static String readLine(Reader self) throws IOException
self
- a Reader
IOException
- if an IOException occurs.public static String readLine(InputStream stream) throws IOException
stream
- an InputStream
IOException
- if an IOException occurs.public static List readLines(String self) throws IOException
self
- a String object
IOException
- if an error occurspublic static String denormalize(String self)
self
- a String object
public static String normalize(String self)
self
- a String object
public static List readLines(File file) throws IOException
file
- a File
IOException
- if an IOException occurs.public static String getText(File file, String charset) throws IOException
file
- the file whose content we want to readcharset
- the charset used to read the content of the file
IOException
- if an IOException occurs.public static String getText(File file) throws IOException
file
- the file whose content we want to read
IOException
- if an IOException occurs.public static String getText(URL url) throws IOException
url
- URL to read content from
IOException
- if an IOException occurs.public static String getText(URL url, String charset) throws IOException
url
- URL to read content fromcharset
- opens the stream with a specified charset
IOException
- if an IOException occurs.URLConnection.getInputStream()
public static String getText(InputStream is) throws IOException
is
- an input stream
IOException
- if an IOException occurs.public static String getText(InputStream is, String charset) throws IOException
is
- an input streamcharset
- opens the stream with a specified charset
IOException
- if an IOException occurs.public static String getText(Reader reader) throws IOException
reader
- a Reader whose content we want to read
IOException
- if an IOException occurs.getText(BufferedReader)
public static String getText(BufferedReader reader) throws IOException
reader
- a BufferedReader whose content we want to read
IOException
- if an IOException occurs.public static void writeLine(BufferedWriter writer, String line) throws IOException
writer
- a BufferedWriterline
- the line to write
IOException
- if an IOException occurs.public static void write(File file, String text) throws IOException
file
- a Filetext
- the text to write to the File
IOException
- if an IOException occurs.public static void setText(File file, String text) throws IOException
file
- a Filetext
- the text to write to the File
IOException
- if an IOException occurs.write(File, String)
public static File leftShift(File file, Object text) throws IOException
file
- a Filetext
- the text to write to the File
IOException
- if an IOException occurs.public static File leftShift(File file, byte[] bytes) throws IOException
file
- a Filebytes
- the byte array to append to the end of the File
IOException
- if an IOException occurs.public static File leftShift(File file, InputStream data) throws IOException
append(File, InputStream)
file
- data
-
IOException
public static void write(File file, String text, String charset) throws IOException
file
- a Filetext
- the text to write to the Filecharset
- the charset used
IOException
- if an IOException occurs.public static void append(File file, Object text) throws IOException
file
- a Filetext
- the text to append at the end of the File
IOException
- if an IOException occurs.public static void append(File file, byte[] bytes) throws IOException
file
- a Filebytes
- the byte array to append to the end of the File
IOException
- if an IOException occurs.public static void append(File self, InputStream stream) throws IOException
self
- stream
- stream to read data from.
IOException
public static void append(File file, Object text, String charset) throws IOException
file
- a Filetext
- the text to append at the end of the Filecharset
- the charset used
IOException
- if an IOException occurs.public static List readLines(Reader reader) throws IOException
reader
- a Reader
IOException
- if an IOException occurs.public static void eachFile(File self, Closure closure) throws FileNotFoundException, IllegalArgumentException
self
- a Fileclosure
- a closure
FileNotFoundException
- if the given directory does not exist
IllegalArgumentException
- if the provided File object does not represent a directoryFile.listFiles()
public static void eachDir(File self, Closure closure) throws FileNotFoundException, IllegalArgumentException
self
- a directoryclosure
- a closure
FileNotFoundException
- if the given directory does not exist
IllegalArgumentException
- if the provided File object does not represent a directorypublic static void eachFileRecurse(File self, Closure closure) throws FileNotFoundException, IllegalArgumentException
self
- a Fileclosure
- a closure
FileNotFoundException
- if the given directory does not exist
IllegalArgumentException
- if the provided File object does not represent a directorypublic static void eachDirRecurse(File self, Closure closure) throws FileNotFoundException, IllegalArgumentException
self
- a directoryclosure
- a closure
FileNotFoundException
- if the given directory does not exist
IllegalArgumentException
- if the provided File object does not represent a directoryeachFileRecurse(File,Closure,boolean)
public static void eachFileMatch(File self, Object filter, Closure closure) throws FileNotFoundException, IllegalArgumentException
self
- a filefilter
- the filter to perform on the directory (using the isCase(object) method)closure
- the closure to invoke
FileNotFoundException
- if the given directory does not exist
IllegalArgumentException
- if the provided File object does not represent a directorypublic static void eachDirMatch(File self, Object filter, Closure closure) throws FileNotFoundException, IllegalArgumentException
self
- a filefilter
- the filter to perform on the directory (using the isCase(object) method)closure
- the closure to invoke
FileNotFoundException
- if the given directory does not exist
IllegalArgumentException
- if the provided File object does not represent a directorypublic static boolean deleteDir(File self)
The method returns
public static TimerTask runAfter(Timer timer, int delay, Closure closure)
timer
- a timer objectdelay
- the delay in milliseconds before running the closure codeclosure
- the closure to invoke
public static BufferedReader newReader(File file) throws IOException
file
- a File
IOException
- if an IOException occurs.public static BufferedReader newReader(File file, String charset) throws FileNotFoundException, UnsupportedEncodingException
file
- a Filecharset
- the charset for this File
FileNotFoundException
- if the File was not found
UnsupportedEncodingException
- if the encoding specified is not supportedpublic static BufferedReader newReader(InputStream self)
self
- an input stream
public static BufferedReader newReader(InputStream self, String charset) throws UnsupportedEncodingException
self
- an input streamcharset
- the charset for this input stream
UnsupportedEncodingException
- if the encoding specified is not supportedpublic static Object withReader(File file, Closure closure) throws IOException
file
- a file objectclosure
- a closure
IOException
- if an IOException occurs.public static Object withReader(File file, String charset, Closure closure) throws IOException
file
- a file objectcharset
- the charset for this input streamclosure
- a closure
IOException
- if an IOException occurs.public static BufferedOutputStream newOutputStream(File file) throws IOException
file
- a file object
IOException
- if an IOException occurs.public static DataOutputStream newDataOutputStream(File file) throws IOException
file
- a file object
IOException
- if an IOException occurs.public static Object withOutputStream(File file, Closure closure) throws IOException
file
- a Fileclosure
- a closure
IOException
- if an IOException occurs.withStream(OutputStream,Closure)
public static Object withInputStream(File file, Closure closure) throws IOException
file
- a Fileclosure
- a closure
IOException
- if an IOException occurs.withStream(InputStream,Closure)
public static Object withInputStream(URL url, Closure closure) throws IOException
url
- a URLclosure
- a closure
IOException
- if an IOException occurs.withStream(InputStream,Closure)
public static Object withDataOutputStream(File file, Closure closure) throws IOException
file
- a Fileclosure
- a closure
IOException
- if an IOException occurs.withStream(OutputStream,Closure)
public static Object withDataInputStream(File file, Closure closure) throws IOException
file
- a Fileclosure
- a closure
IOException
- if an IOException occurs.withStream(InputStream,Closure)
public static BufferedWriter newWriter(File file) throws IOException
file
- a File
IOException
- if an IOException occurs.public static BufferedWriter newWriter(File file, boolean append) throws IOException
file
- a Fileappend
- true if data should be appended to the file
IOException
- if an IOException occurs.public static BufferedWriter newWriter(File file, String charset, boolean append) throws IOException
file
- a Filecharset
- the name of the encoding used to write in this fileappend
- true if in append mode
IOException
- if an IOException occurs.public static BufferedWriter newWriter(File file, String charset) throws IOException
file
- a Filecharset
- the name of the encoding used to write in this file
IOException
- if an IOException occurs.public static Object withWriter(File file, Closure closure) throws IOException
file
- a Fileclosure
- a closure
IOException
- if an IOException occurs.public static Object withWriter(File file, String charset, Closure closure) throws IOException
file
- a Filecharset
- the charset usedclosure
- a closure
IOException
- if an IOException occurs.public static Object withWriterAppend(File file, String charset, Closure closure) throws IOException
file
- a Filecharset
- the charset usedclosure
- a closure
IOException
- if an IOException occurs.public static Object withWriterAppend(File file, Closure closure) throws IOException
file
- a Fileclosure
- a closure
IOException
- if an IOException occurs.public static PrintWriter newPrintWriter(File file) throws IOException
file
- a File
IOException
- if an IOException occurs.public static PrintWriter newPrintWriter(File file, String charset) throws IOException
file
- a Filecharset
- the charset
IOException
- if an IOException occurs.public static PrintWriter newPrintWriter(Writer writer)
writer
- a writer
public static Object withPrintWriter(File file, Closure closure) throws IOException
file
- a Fileclosure
- the closure to invoke with the PrintWriter
IOException
- if an IOException occurs.public static Object withPrintWriter(File file, String charset, Closure closure) throws IOException
file
- a Filecharset
- the charsetclosure
- the closure to invoke with the PrintWriter
IOException
- if an IOException occurs.public static Object withPrintWriter(Writer writer, Closure closure) throws IOException
writer
- a writerclosure
- the closure to invoke with the PrintWriter
IOException
- if an IOException occurs.public static Object withWriter(Writer writer, Closure closure) throws IOException
writer
- the writer which is used and then closedclosure
- the closure that the writer is passed into
IOException
- if an IOException occurs.public static Object withReader(Reader reader, Closure closure) throws IOException
reader
- the reader which is used and then closedclosure
- the closure that the writer is passed into
IOException
- if an IOException occurs.public static Object withStream(InputStream stream, Closure closure) throws IOException
stream
- the stream which is used and then closedclosure
- the closure that the stream is passed into
IOException
- if an IOException occurs.public static List readLines(InputStream stream) throws IOException
stream
- a stream
IOException
- if an IOException occurs.readLines(Reader)
public static Object withReader(URL url, Closure closure) throws IOException
url
- a URLclosure
- the closure to invoke with the reader
IOException
- if an IOException occurs.public static Object withReader(URL url, String charset, Closure closure) throws IOException
url
- a URLcharset
- the charset usedclosure
- the closure to invoke with the reader
IOException
- if an IOException occurs.public static Object withReader(InputStream in, Closure closure) throws IOException
in
- a streamclosure
- the closure to invoke with the InputStream
IOException
- if an IOException occurs.InputStreamReader
public static Object withReader(InputStream in, String charset, Closure closure) throws IOException
in
- a streamcharset
- the charset used to decode the streamclosure
- the closure to invoke with the reader
IOException
- if an IOException occurs.InputStreamReader
public static Object withWriter(OutputStream stream, Closure closure) throws IOException
stream
- the stream which is used and then closedclosure
- the closure that the writer is passed into
IOException
- if an IOException occurs.withWriter(Writer,Closure)
public static Object withWriter(OutputStream stream, String charset, Closure closure) throws IOException
stream
- the stream which is used and then closedcharset
- the charset usedclosure
- the closure that the writer is passed into
IOException
- if an IOException occurs.withWriter(Writer,Closure)
public static Object withStream(OutputStream os, Closure closure) throws IOException
os
- the stream which is used and then closedclosure
- the closure that the stream is passed into
IOException
- if an IOException occurs.public static BufferedInputStream newInputStream(File file) throws FileNotFoundException
file
- a File
FileNotFoundException
- if the file is not found.public static BufferedInputStream newInputStream(URL url) throws MalformedURLException, IOException
url
- a URL
MalformedURLException
- is thrown if the URL is not well formed
IOException
- if an I/O error occurs while creating the input streampublic static BufferedReader newReader(URL url) throws MalformedURLException, IOException
url
- a URL
MalformedURLException
- is thrown if the URL is not well formed
IOException
- if an I/O error occurs while creating the input streampublic static BufferedReader newReader(URL url, String charset) throws MalformedURLException, IOException
url
- a URLcharset
- opens the stream with a specified charset
MalformedURLException
- is thrown if the URL is not well formed
IOException
- if an I/O error occurs while creating the input streampublic static DataInputStream newDataInputStream(File file) throws FileNotFoundException
file
- a File
FileNotFoundException
- if the file is not found.public static void eachByte(File self, Closure closure) throws IOException
self
- a Fileclosure
- a closure
IOException
- if an IOException occurs.eachByte(InputStream,Closure)
public static void eachByte(Byte[] self, Closure closure)
self
- a Byte arrayclosure
- a closureeach(Object,Closure)
public static void eachByte(byte[] self, Closure closure)
self
- a byte arrayclosure
- a closureeach(Object,Closure)
public static void eachByte(InputStream is, Closure closure) throws IOException
is
- stream to iterate over, closed after the method callclosure
- closure to apply to each byte
IOException
- if an IOException occurs.public static void eachByte(URL url, Closure closure) throws IOException
url
- url to iterate overclosure
- closure to apply to each byte
IOException
- if an IOException occurs.eachByte(InputStream,Closure)
public static void transformChar(Reader self, Writer writer, Closure closure) throws IOException
self
- a Reader objectwriter
- a Writer to receive the transformed charactersclosure
- a closure that performs the required transformation
IOException
- if an IOException occurs.public static void transformLine(Reader reader, Writer writer, Closure closure) throws IOException
reader
- Lines of text to be transformed. Reader is closed afterwards.writer
- Where transformed lines are written. Writer is closed afterwards.closure
- Single parameter closure that is called to transform each line of
text from the reader, before writing it to the writer.
IOException
- if an IOException occurs.public static void filterLine(Reader reader, Writer writer, Closure closure) throws IOException
reader
- a reader, closed after the callwriter
- a writer, closed after the callclosure
- the closure which returns booleans
IOException
- if an IOException occurs.public static Writable filterLine(File self, Closure closure) throws IOException
self
- a Fileclosure
- a closure which returns a boolean indicating to filter
the line or not
IOException
- if self
is not readablefilterLine(Reader,Closure)
public static void filterLine(File self, Writer writer, Closure closure) throws IOException
self
- a Filewriter
- a writer destination to write filtered lines toclosure
- a closure which takes each line as a parameter and returns
true
if the line should be written to this writer.
IOException
- if self
is not readablefilterLine(Reader,Writer,Closure)
public static Writable filterLine(Reader reader, Closure closure)
true
if the line should be passed to the writer.
reader
- this readerclosure
- a closure used for filtering
public static GroovyRowResult toRowResult(ResultSet rs) throws SQLException
rs
- a ResultSet
SQLException
- if a database error occurspublic static Writable filterLine(InputStream self, Closure predicate)
true
if the line should be passed to the writer.
self
- an input streampredicate
- a closure which returns boolean and takes a line
filterLine(Reader, Closure)
public static void filterLine(InputStream self, Writer writer, Closure predicate) throws IOException
true
if the line should be passed to the
writer.
self
- the InputStreamwriter
- a writer to write output topredicate
- a closure which returns true if a line should be accepted
IOException
- if an IOException occurs.filterLine(Reader,Writer,Closure)
public static byte[] readBytes(File file) throws IOException
file
- a File
IOException
- if an IOException occurs.public static Object withStreams(Socket socket, Closure closure) throws IOException
socket
- a Socketclosure
- a Closure
IOException
- if an IOException occurs.public static Object withObjectStreams(Socket socket, Closure closure) throws IOException
socket
- this Socketclosure
- a Closure
IOException
- if an IOException occurs.public static Writer leftShift(Socket self, Object value) throws IOException
self
- a Socketvalue
- a value to append
IOException
- if an IOException occurs.public static OutputStream leftShift(Socket self, byte[] value) throws IOException
self
- a Socketvalue
- a value to append
IOException
- if an IOException occurs.public static Socket accept(ServerSocket serverSocket, Closure closure) throws IOException
serverSocket
- a ServerSocketclosure
- a Closure
IOException
- if an IOException occurs.ServerSocket.accept()
public static File asWritable(File file)
Writable
.
file
- a File
public static Object asType(File f, Class c)
Writable
or delegates to default
asType(Object,Class)
.
f
- a Filec
- the desired class
public static File asWritable(File file, String encoding)
file
- a Fileencoding
- the encoding to be used when reading the file's contents
public static List toList(String self)
self
- a String
public static char[] getChars(String self)
self
- a String
String.toCharArray()
public static Object asType(GString self, Class c)
asType(Object,Class)
self
- a GStringc
- the desired class
public static Object asType(String self, Class c)
Provides a method to perform custom 'dynamic' type conversion
to the given class using the as
operator.
'123' as Double
By default, the following types are supported:
asType(Object,Class)
.
self
- a Stringc
- the desired class
public static InputStream getIn(Process self)
self
- a Process instance
public static String getText(Process self) throws IOException
self
- a Process instance
IOException
- if an IOException occurs.public static InputStream getErr(Process self)
self
- a Process instance
public static OutputStream getOut(Process self)
self
- a Process instance
public static Writer leftShift(Process self, Object value) throws IOException
self
- a Process instancevalue
- a value to append
IOException
- if an IOException occurs.public static OutputStream leftShift(Process self, byte[] value) throws IOException
self
- a Process instancevalue
- data to append
IOException
- if an IOException occurs.public static void waitForOrKill(Process self, long numberOfMillis)
self
- a ProcessnumberOfMillis
- the number of milliseconds to wait before stopping the processpublic static void consumeProcessOutput(Process self)
self
- a Processpublic static void consumeProcessOutput(Process self, StringBuffer output, StringBuffer error)
self
- a Processoutput
- a StringBuffer to capture the process stdouterror
- a StringBuffer to capture the process stderrpublic static void consumeProcessOutput(Process self, OutputStream output, OutputStream error)
self
- a Processoutput
- an OutputStream to capture the process stdouterror
- an OutputStream to capture the process stderrpublic static void consumeProcessErrorStream(Process self, StringBuffer error)
self
- a Processerror
- a StringBuffer to capture the process stderrpublic static void consumeProcessErrorStream(Process self, OutputStream err)
self
- a Processerr
- an OutputStream to capture the process stderrpublic static void consumeProcessErrorStream(Process self, Writer err)
self
- a Processerr
- a Writer to capture the process stderrpublic static void consumeProcessOutputStream(Process self, StringBuffer output)
self
- a Processoutput
- a StringBuffer to capture the process stdoutpublic static void consumeProcessOutputStream(Process self, OutputStream output)
self
- a Processoutput
- an OutputStream to capture the process stdoutpublic static void consumeProcessOutputStream(Process self, Writer output)
self
- a Processoutput
- a Writer to capture the process stdoutpublic static void withWriter(Process self, Closure closure)
self
- a Processclosure
- a closurepublic static void withOutputStream(Process self, Closure closure)
self
- a Processclosure
- a closurepublic static Process pipeTo(Process left, Process right) throws IOException
left
- a Process instanceright
- a Process to pipe output to
IOException
- if an IOException occurs.public static Process or(Process left, Process right) throws IOException
left
- a Process instanceright
- a Process to pipe output to
IOException
- if an IOException occurs.public static String eachMatch(String self, String regex, Closure closure)
self
- the source stringregex
- a Regex stringclosure
- a closure with one parameter or as much parameters as groups
public static int findIndexOf(Object self, Closure closure)
self
- the iteration object over which to iterateclosure
- the filter to perform a match on the collection
public static int findIndexOf(Object self, int startIndex, Closure closure)
self
- the iteration object over which to iteratestartIndex
- start matching from this indexclosure
- the filter to perform a match on the collection
public static int findLastIndexOf(Object self, Closure closure)
self
- the iteration object over which to iterateclosure
- the filter to perform a match on the collection
public static int findLastIndexOf(Object self, int startIndex, Closure closure)
self
- the iteration object over which to iteratestartIndex
- start matching from this indexclosure
- the filter to perform a match on the collection
public static List findIndexValues(Object self, Closure closure)
self
- the iteration object over which to iterateclosure
- the filter to perform a match on the collection
public static List findIndexValues(Object self, int startIndex, Closure closure)
self
- the iteration object over which to iteratestartIndex
- start matching from this indexclosure
- the filter to perform a match on the collection
public static ClassLoader getRootLoader(ClassLoader self)
null
will be returned. The name is used for comparison because
a direct comparison using == may fail as the class may be loaded through
different classloaders.
self
- a ClassLoader
RootLoader
public static Object asType(Object obj, Class type)
obj
- the object to converttype
- the goal type
public static Object newInstance(Class c)
c
- a class
public static Object newInstance(Class c, Object[] args)
newInstance(null)
or simply
newInstance()
for the default (no-arg) constructor.
c
- a classargs
- the constructor arguments
public static MetaClass getMetaClass(Class c)
String.metaClass.myMethod = { println "foo" }
c
- The java.lang.Class instance
public static MetaClass getMetaClass(Object obj)
obj
- The object in question
public static MetaClass getMetaClass(GroovyObject obj)
obj
- The object in question
public static void setMetaClass(Class self, MetaClass metaClass)
self
- the class whose metaclass we wish to setmetaClass
- the new MetaClasspublic static void setMetaClass(Object self, MetaClass metaClass)
self
- the object whose metaclass we want to setmetaClass
- the new metaclass valuepublic static MetaClass metaClass(Class self, Closure closure)
self
- the class whose metaclass we wish to updateclosure
- the closure representing the new metaclass
GroovyRuntimeException
- if the metaclass can't be set for this classpublic static MetaClass metaClass(Object self, Closure closure)
self
- the object whose metaclass we wish to updateclosure
- the closure representing the new metaclass
GroovyRuntimeException
- if the metaclass can't be set for this objectpublic static Iterator iterator(Object o)
o
- an object
DefaultTypeTransformation.asCollection(Object)
public static Iterator iterator(Enumeration enumeration)
remove()
method is unsupported since the
underlying Enumeration does not provide a mechanism for removing items.
enumeration
- an Enumeration object
public static Iterator iterator(NodeList nodeList)
nodeList
- a NodeList
public static Iterator iterator(Matcher matcher)
Iterator
which traverses each match.
matcher
- a Matcher object
Matcher.group()
public static Iterator iterator(Reader self)
self
- a Reader object
BufferedReader.readLine()
public static Iterator iterator(InputStream self)
self
- an InputStream object
public static Iterator iterator(DataInputStream self)
self
- a DataInputStream object
public static Iterator iterator(File self) throws IOException
self
- a file object
IOException
- if there is a problem processing the file (e.g. file is not found)public static Iterator iterator(Iterator self)
self
- an iterator object
public static List respondsTo(Object self, String name, Object[] argTypes)
MetaObjectProtocol.respondsTo(Object,String, Object[])
public List respondsTo(Object self, String name)
MetaObjectProtocol.respondsTo(Object,String, Object[])
public MetaProperty hasProperty(Object self, String name)
MetaObjectProtocol.hasProperty(Object,String)
|
Copyright © 2003-2009 The Codehaus. All rights reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |