|
Groovy 1.7.11 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.groovy.runtime.DefaultGroovyMethodsSupport
org.codehaus.groovy.runtime.DefaultGroovyMethods
public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport
This class defines new groovy methods which appear on normal JDK
classes inside the Groovy environment. Static methods are used with the
first parameter being the destination class,
i.e. public static String reverse(String self)
provides a reverse()
method for String
.
NOTE: While this class contains many 'public' static methods, it is primarily regarded as an internal class (its internal package name suggests this also). We value backwards compatibility of these methods when used within Groovy but value less backwards compatibility at the Java method call level. I.e. future versions of Groovy may remove or move a method call in this file but would normally aim to keep the method available from within Groovy.
Field Summary | |
---|---|
static Class[] |
additionals
|
Method Summary | |
---|---|
static int
|
abs(Number number)
Truncate the value |
static long
|
abs(Long number)
|
static float
|
abs(Float number)
|
static double
|
abs(Double number)
|
static Socket
|
accept(ServerSocket serverSocket, Closure closure)
|
static Socket
|
accept(ServerSocket serverSocket, boolean runInANewThread, Closure closure)
|
static boolean
|
addAll(Collection self, T[] items)
Adds all of the elements in the specified array to this collection. |
static boolean
|
addAll(List self, int index, T[] items)
|
static void
|
addShutdownHook(Object self, Closure closure)
Allows the usage of addShutdownHook without getting the runtime first. |
static Number
|
and(Number left, Number right)
|
static BitSet
|
and(BitSet left, BitSet right)
Iterates from this number up to the given number, inclusive, incrementing by one each time. |
static Boolean
|
and(Boolean left, Boolean right)
Create an object input stream for this input stream using the given class loader. |
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 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 void
|
append(File file, Object text)
|
static void
|
append(File file, byte[] bytes)
|
static void
|
append(File self, InputStream stream)
|
static void
|
append(File file, Object text, String charset)
|
static boolean
|
asBoolean(Object object)
Coerce a Matcher instance to a boolean value. |
static boolean
|
asBoolean(Boolean bool)
|
static boolean
|
asBoolean(Matcher matcher)
|
static boolean
|
asBoolean(Collection collection)
Coerce an iterator instance to a boolean value. |
static boolean
|
asBoolean(Map map)
Coerce an enumeration instance to a boolean value. |
static boolean
|
asBoolean(Iterator iterator)
|
static boolean
|
asBoolean(Enumeration enumeration)
|
static boolean
|
asBoolean(CharSequence string)
|
static boolean
|
asBoolean(Object[] array)
|
static boolean
|
asBoolean(byte[] array)
|
static boolean
|
asBoolean(short[] array)
|
static boolean
|
asBoolean(int[] array)
|
static boolean
|
asBoolean(long[] array)
|
static boolean
|
asBoolean(float[] array)
|
static boolean
|
asBoolean(double[] array)
|
static boolean
|
asBoolean(boolean[] array)
|
static boolean
|
asBoolean(char[] array)
Coerce a number to a boolean value. |
static boolean
|
asBoolean(Character character)
@deprecated use SqlGroovyMethods#asBoolean(GroovyResultSet) |
static boolean
|
asBoolean(Number number)
|
static boolean
|
asBoolean(GroovyResultSet grs)
|
static Map
|
asImmutable(Map self)
A convenience method for creating an immutable list |
static SortedMap
|
asImmutable(SortedMap self)
|
static List
|
asImmutable(List self)
|
static Set
|
asImmutable(Set self)
|
static SortedSet
|
asImmutable(SortedSet self)
|
static Collection
|
asImmutable(Collection self)
A convenience method for creating a synchronized SortedMap. |
static List
|
asList(Collection self)
Coerce an Boolean instance to a boolean value. |
static Map
|
asSynchronized(Map self)
|
static SortedMap
|
asSynchronized(SortedMap self)
|
static Collection
|
asSynchronized(Collection self)
|
static List
|
asSynchronized(List self)
|
static Set
|
asSynchronized(Set self)
|
static SortedSet
|
asSynchronized(SortedSet self)
|
static Object
|
asType(Collection col, Class clazz)
|
static Object
|
asType(Object[] ary, Class clazz)
Converts the given array to either a List, Set, or SortedSet. |
static Object
|
asType(Closure cl, 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(Map map, Class clazz)
Reverses the list. |
static Object
|
asType(Number self, Class c)
Create a new ObjectOutputStream for this file and then pass it to the closure. |
static Object
|
asType(File f, Class c)
@deprecated use ProcessGroovyMethods#leftShift(Process, byte[]) |
static Object
|
asType(GString self, Class c)
@deprecated use ProcessGroovyMethods#waitForProcessOutput(Process, OutputStream, OutputStream) |
static Object
|
asType(String self, Class c)
@deprecated use ProcessGroovyMethods#consumeProcessErrorStream(Process, Appendable) |
static Object
|
asType(Object obj, Class type)
Sets the metaclass for a given class. |
static File
|
asWritable(File file)
@deprecated use ProcessGroovyMethods#getOut(Process) |
static File
|
asWritable(File file, String encoding)
@deprecated use ProcessGroovyMethods#consumeProcessOutput(Process) |
static Pattern
|
bitwiseNegate(String self)
|
static BitSet
|
bitwiseNegate(BitSet self)
|
protected static Object
|
callClosureForLine(Closure closure, String line, int counter)
|
protected static Object
|
callClosureForMapEntry(Closure closure, def entry)
|
protected static Object
|
callClosureForMapEntryAndCounter(Closure closure, def entry, int counter)
|
static String
|
capitalize(String self)
|
static String
|
center(String self, Number numberOfChars, String padding)
|
static String
|
center(String self, Number numberOfChars)
|
static void
|
clearTime(Date self)
|
static void
|
clearTime(def self)
|
static void
|
clearTime(Calendar self)
|
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)
|
static List
|
collect(Collection self, Closure closure)
|
static Collection
|
collect(Collection self, Collection collection, Closure closure)
|
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(Map self, Closure closure)
|
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)
|
static Map
|
collectEntries(Map self, Map result, Closure closure)
|
static Map
|
collectEntries(Map self, Closure closure)
|
static Map
|
collectEntries(Collection self, Map result, Closure closure)
|
static Map
|
collectEntries(Object[] self, Map result, Closure closure)
|
static Map
|
collectEntries(Collection self, Closure closure)
|
static Map
|
collectEntries(Object[] self, Closure closure)
|
static List
|
combinations(Collection self)
Adds GroovyCollections#combinations(Collection) as a method on collections. |
static int
|
compareTo(Character left, Number right)
|
static int
|
compareTo(Number left, Character right)
|
static int
|
compareTo(Character left, Character right)
|
static int
|
compareTo(Number left, Number right)
|
static Thread
|
consumeProcessErrorStream(Process self, OutputStream err)
|
static Thread
|
consumeProcessErrorStream(Process self, StringBuffer error)
|
static Thread
|
consumeProcessErrorStream(Process self, Writer err)
|
static void
|
consumeProcessOutput(Process self)
|
static void
|
consumeProcessOutput(Process self, StringBuffer output, StringBuffer error)
|
static void
|
consumeProcessOutput(Process self, OutputStream output, OutputStream error)
|
static Thread
|
consumeProcessOutputStream(Process self, StringBuffer output)
|
static Thread
|
consumeProcessOutputStream(Process self, Writer output)
|
static Thread
|
consumeProcessOutputStream(Process self, OutputStream output)
|
static boolean
|
contains(String self, String text)
Executes the command specified by |
static boolean
|
containsAll(Collection self, Object[] items)
|
static Number
|
count(Iterator self, Object value)
Counts the number of occurrences of the given value from the items within this Iterator. |
static Number
|
count(Collection self, Object value)
Counts the number of occurrences of the given value inside this collection. |
static Number
|
count(Object[] self, Object value)
|
static Number
|
count(int[] self, Object value)
|
static Number
|
count(long[] self, Object value)
|
static Number
|
count(short[] self, Object value)
|
static Number
|
count(char[] self, Object value)
|
static Number
|
count(boolean[] self, Object value)
|
static Number
|
count(double[] self, Object value)
|
static Number
|
count(float[] self, Object value)
|
static Number
|
count(byte[] self, Object value)
|
static int
|
count(String self, String text)
|
protected static StringBufferWriter
|
createStringBufferWriter(StringBuffer self)
|
protected static StringWriter
|
createStringWriter(String self)
|
static byte[]
|
decodeBase64(String value)
|
static boolean
|
deleteDir(File self)
Creates a new data output stream for this file. |
static String
|
denormalize(String self)
|
static boolean
|
disjoint(Collection left, Collection right)
Compare the contents of this array to the contents of the given array. |
static Number
|
div(Character left, Number right)
Bitwise AND together two Numbers. |
static Number
|
div(Number left, Character right)
|
static Number
|
div(Character left, Character right)
|
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 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)
|
static void
|
downto(float self, Number to, Closure closure)
|
static void
|
downto(Float self, Number to, Closure closure)
|
static void
|
downto(double self, Number to, Closure closure)
|
static void
|
downto(Double self, Number to, Closure closure)
|
static void
|
downto(BigInteger self, Number to, Closure closure)
|
static void
|
downto(BigDecimal self, Number to, Closure closure)
Get the absolute value |
static String
|
dump(Object self)
Generates a detailed dump string of an object showing its class, hashCode and fields. |
static T
|
each(T self, Closure closure)
Iterates through an aggregate type or data structure, passing each item to the given closure. |
static Map
|
each(Map self, Closure closure)
Allows a Map to be iterated through using a closure. |
static void
|
eachByte(File self, Closure closure)
Transforms the lines from a reader with a Closure and write them to a writer. |
static void
|
eachByte(File self, int bufferLen, Closure closure)
|
static void
|
eachByte(Byte[] self, Closure closure)
|
static void
|
eachByte(byte[] self, 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 void
|
eachByte(InputStream is, Closure closure)
|
static void
|
eachByte(InputStream is, int bufferLen, Closure closure)
Filters the lines of a File and creates a Writeable in return to stream the filtered lines. |
static void
|
eachByte(URL url, Closure closure)
Filters the lines of a File and creates a Writeable in return to stream the filtered lines. |
static void
|
eachByte(URL url, int bufferLen, Closure closure)
|
static void
|
eachDir(File self, Closure closure)
Invokes the closure for each descendant file in this directory tree. |
static void
|
eachDirMatch(File self, Object nameFilter, 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 void
|
eachDirRecurse(File self, Closure closure)
|
static void
|
eachFile(File self, FileType fileType, Closure closure)
|
static void
|
eachFile(File self, Closure closure)
|
static void
|
eachFileMatch(File self, FileType fileType, Object nameFilter, Closure closure)
Create a buffered reader for this file, using the specified charset as the encoding. |
static void
|
eachFileMatch(File self, Object nameFilter, Closure closure)
Creates a reader for this input stream, using the specified charset as the encoding. |
static void
|
eachFileRecurse(File self, FileType fileType, Closure closure)
Invokes the closure specified with key 'visit' in the options Map for each descendant file in this directory tree. |
static void
|
eachFileRecurse(File self, Closure closure)
Deletes a directory with all contained files and subdirectories. |
static Object
|
eachLine(String self, Closure closure)
Iterates through this stream, passing each line to the given 1 or 2 arg closure. |
static Object
|
eachLine(String self, int firstLine, Closure closure)
Iterates through this stream, passing each line to the given 1 or 2 arg closure. |
static Object
|
eachLine(File self, 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(File self, String charset, Closure closure)
|
static Object
|
eachLine(File self, int firstLine, Closure closure)
|
static Object
|
eachLine(File self, String charset, int firstLine, Closure closure)
|
static Object
|
eachLine(InputStream stream, String charset, Closure closure)
|
static Object
|
eachLine(InputStream stream, String charset, int firstLine, Closure closure)
|
static Object
|
eachLine(InputStream stream, Closure closure)
|
static Object
|
eachLine(InputStream stream, int firstLine, Closure closure)
|
static Object
|
eachLine(URL url, Closure closure)
|
static Object
|
eachLine(URL url, int firstLine, Closure closure)
|
static Object
|
eachLine(URL url, String charset, Closure closure)
|
static Object
|
eachLine(URL url, String charset, int firstLine, Closure closure)
Iterates through this file line by line, splitting each line using the given regex separator Pattern. |
static Object
|
eachLine(Reader self, Closure closure)
|
static Object
|
eachLine(Reader self, int firstLine, Closure closure)
|
static String
|
eachMatch(String self, String regex, Closure closure)
|
static String
|
eachMatch(String self, Pattern pattern, Closure closure)
|
static void
|
eachObject(File self, Closure closure)
|
static void
|
eachObject(ObjectInputStream ois, Closure closure)
|
static Iterator
|
eachPermutation(Collection self, Closure closure)
|
static Object
|
eachWithIndex(Object self, Closure closure)
|
static Map
|
eachWithIndex(Map self, Closure closure)
Allows a Map to be iterated through using a closure. |
static Writable
|
encodeBase64(Byte[] data, boolean chunked)
@deprecated moved to DateGroovyMethods.getAt |
static Writable
|
encodeBase64(Byte[] data)
|
static Writable
|
encodeBase64(byte[] data, boolean chunked)
|
static Writable
|
encodeBase64(byte[] data)
|
static boolean
|
equals(int[] left, int[] right)
Determines if the contents of this array are equal to the contents of the given list, in the same order. |
static boolean
|
equals(Object[] left, List right)
|
static boolean
|
equals(List left, Object[] right)
|
static boolean
|
equals(List left, List right)
|
static boolean
|
every(Object self, Closure closure)
|
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 |
static Process
|
execute(String self)
Executes the command specified by the |
static Process
|
execute(String self, String[] envp, File dir)
Executes the command specified by the given list. |
static Process
|
execute(String self, List envp, File dir)
|
static Process
|
execute(String[] commandArray)
|
static Process
|
execute(String[] commandArray, String[] envp, File dir)
|
static Process
|
execute(String[] commandArray, List envp, File dir)
Returns the string representation of the given array. |
static Process
|
execute(List commands)
Returns the string representation of the given array. |
static Process
|
execute(List commands, String[] envp, File dir)
Returns the string representation of the given array. |
static Process
|
execute(List commands, List envp, File dir)
Returns the string representation of the given array. |
static String
|
expand(String self)
|
static String
|
expand(String self, int tabStop)
|
static String
|
expandLine(String self, int tabStop)
Tokenize a String based on the given string delimiter. |
static void
|
filterLine(Reader reader, Writer writer, Closure closure)
Filter lines from an input stream using a closure predicate. |
static Writable
|
filterLine(File self, Closure closure)
Uses a closure to filter lines from this InputStream and pass them to the given writer. |
static Writable
|
filterLine(File self, String charset, Closure closure)
|
static void
|
filterLine(File self, Writer writer, Closure closure)
|
static void
|
filterLine(File self, Writer writer, String charset, Closure closure)
|
static Writable
|
filterLine(Reader reader, Closure closure)
|
static Writable
|
filterLine(InputStream self, Closure predicate)
Passes the Socket's InputStream and OutputStream to the closure. |
static Writable
|
filterLine(InputStream self, String charset, Closure predicate)
|
static void
|
filterLine(InputStream self, Writer writer, Closure predicate)
|
static void
|
filterLine(InputStream self, Writer writer, String charset, Closure predicate)
|
static Writable
|
filterLine(URL self, Closure predicate)
Overloads the left shift operator to provide an append mechanism to add things to the output stream of a socket |
static Writable
|
filterLine(URL self, String charset, Closure predicate)
|
static void
|
filterLine(URL self, Writer writer, Closure predicate)
|
static void
|
filterLine(URL self, Writer writer, String charset, Closure predicate)
|
static Object
|
find(Object self, Closure closure)
Finds the first value matching the closure condition |
static T
|
find(Collection self, Closure closure)
Finds the first value matching the closure condition. |
static def
|
find(Map self, Closure closure)
|
static String
|
find(String self, String regex)
|
static String
|
find(String self, Pattern pattern)
|
static String
|
find(String self, String regex, Closure closure)
|
static String
|
find(String self, Pattern pattern, Closure closure)
|
static Collection
|
findAll(Collection self, Closure closure)
|
static Collection
|
findAll(Object self, Closure closure)
|
static Map
|
findAll(Map self, Closure closure)
|
static List
|
findAll(String self, String regex)
Finds all occurrences of a regular expression Pattern within a String. |
static List
|
findAll(String self, Pattern pattern)
|
static List
|
findAll(String self, String regex, Closure closure)
|
static List
|
findAll(String self, Pattern pattern, Closure closure)
|
static int
|
findIndexOf(Object self, Closure closure)
|
static int
|
findIndexOf(Object self, int startIndex, Closure closure)
|
static List
|
findIndexValues(Object self, Closure closure)
Convenience method to dynamically create a new instance of this class. |
static List
|
findIndexValues(Object self, Number startIndex, Closure closure)
|
static int
|
findLastIndexOf(Object self, Closure closure)
|
static int
|
findLastIndexOf(Object self, int startIndex, Closure closure)
|
static Object
|
findResult(Object self, Object defaultResult, Closure closure)
|
static Object
|
findResult(Object self, Closure closure)
|
static Object
|
findResult(Collection self, Object defaultResult, Closure closure)
|
static Object
|
findResult(Collection self, Closure closure)
|
static Object
|
findResult(Map self, Object defaultResult, Closure closure)
|
static Object
|
findResult(Map self, Closure closure)
|
static T
|
first(List self)
|
static T
|
first(T[] self)
|
static Collection
|
flatten(Collection self)
Flatten an array. |
static Collection
|
flatten(Object[] self)
|
static Collection
|
flatten(boolean[] self)
|
static Collection
|
flatten(byte[] self)
|
static Collection
|
flatten(char[] self)
|
static Collection
|
flatten(short[] self)
|
static Collection
|
flatten(int[] self)
|
static Collection
|
flatten(long[] self)
|
static Collection
|
flatten(float[] self)
Flatten a collection. |
static Collection
|
flatten(double[] self)
|
static Collection
|
flatten(Collection self, Closure flattenUsing)
Overloads the left shift operator to provide an easy way to append objects to a Collection. |
static String
|
format(Date self, String format)
|
static String
|
format(Calendar self, String pattern)
|
static V
|
get(Map map, K key, V defaultValue)
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 CharSequence
|
getAt(CharSequence text, int index)
Support the subscript operator for String. |
static String
|
getAt(String text, int index)
Support the range subscript operator for CharSequence |
static CharSequence
|
getAt(CharSequence text, Range range)
|
static CharSequence
|
getAt(CharSequence text, IntRange range)
Support the range subscript operator for CharSequence or StringBuffer with IntRange |
static CharSequence
|
getAt(CharSequence text, EmptyRange range)
Support the range subscript operator for String with IntRange |
static String
|
getAt(String text, IntRange range)
Support the range subscript operator for String with EmptyRange |
static String
|
getAt(String text, EmptyRange range)
Support the range subscript operator for String |
static String
|
getAt(String text, Range range)
|
static Object
|
getAt(Matcher matcher, int idx)
|
static List
|
getAt(List self, Range range)
|
static List
|
getAt(List self, EmptyRange range)
|
static List
|
getAt(List 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(T[] 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 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 self, Collection indices)
Select a List of values from a Matcher using a Collection to identify the indices to be selected. |
static List
|
getAt(Matcher self, Collection indices)
Creates a sub-Map containing the given keys. |
static List
|
getAt(T[] array, Range range)
@param array an Array of Objects |
static List
|
getAt(T[] array, IntRange range)
@param array an Array of Objects |
static List
|
getAt(T[] array, EmptyRange range)
|
static List
|
getAt(T[] array, ObjectRange range)
|
static T
|
getAt(List self, int idx)
|
static T
|
getAt(Iterator self, int idx)
|
static V
|
getAt(Map self, K key)
Support the subscript operator for a Map. |
static List
|
getAt(Collection coll, String property)
A convenience method for creating an immutable map. |
static List
|
getAt(byte[] array, Range range)
Support the subscript operator with a range for an int array |
static List
|
getAt(char[] array, Range range)
|
static List
|
getAt(short[] array, Range range)
|
static List
|
getAt(int[] array, Range range)
|
static List
|
getAt(long[] array, Range range)
|
static List
|
getAt(float[] array, Range range)
|
static List
|
getAt(double[] array, Range range)
|
static List
|
getAt(boolean[] array, Range range)
|
static List
|
getAt(byte[] array, IntRange range)
|
static List
|
getAt(char[] array, IntRange range)
|
static List
|
getAt(short[] array, IntRange range)
|
static List
|
getAt(int[] array, IntRange range)
|
static List
|
getAt(long[] array, IntRange range)
|
static List
|
getAt(float[] array, IntRange range)
|
static List
|
getAt(double[] array, IntRange range)
|
static List
|
getAt(boolean[] array, IntRange range)
|
static List
|
getAt(byte[] array, ObjectRange range)
|
static List
|
getAt(char[] array, ObjectRange range)
|
static List
|
getAt(short[] array, ObjectRange range)
|
static List
|
getAt(int[] array, ObjectRange range)
|
static List
|
getAt(long[] array, ObjectRange range)
|
static List
|
getAt(float[] array, ObjectRange range)
|
static List
|
getAt(double[] array, ObjectRange range)
|
static List
|
getAt(boolean[] array, ObjectRange range)
|
static List
|
getAt(byte[] array, Collection indices)
|
static List
|
getAt(char[] array, Collection indices)
|
static List
|
getAt(short[] array, Collection indices)
|
static List
|
getAt(int[] array, Collection indices)
|
static List
|
getAt(long[] array, Collection indices)
|
static List
|
getAt(float[] array, Collection indices)
|
static List
|
getAt(double[] array, Collection indices)
|
static List
|
getAt(boolean[] array, Collection indices)
|
static boolean
|
getAt(BitSet self, int index)
|
static BitSet
|
getAt(BitSet self, IntRange range)
|
static int
|
getAt(Date self, int field)
|
static byte[]
|
getBytes(File file)
Write the text to the File. |
static byte[]
|
getBytes(URL url)
|
static byte[]
|
getBytes(InputStream is)
|
static char[]
|
getChars(String self)
@deprecated use ProcessGroovyMethods#waitForProcessOutput(Process) |
static int
|
getCount(Matcher matcher)
Check whether a Matcher contains a group or not. |
static String
|
getDateString(Date self)
|
static String
|
getDateTimeString(Date self)
|
static InputStream
|
getErr(Process self)
|
static InputStream
|
getIn(Process self)
@deprecated use ProcessGroovyMethods#withWriter(Process, Closure) |
static MetaClass
|
getMetaClass(Class c)
|
static MetaClass
|
getMetaClass(Object obj)
Attempts to create an Iterator for the given object by first converting it to a Collection. |
static MetaClass
|
getMetaClass(GroovyObject obj)
|
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)
|
static Map
|
getProperties(Object self)
Convenience method that calls getMetaPropertyValues(java.lang.Object)(self) and provides the data in form of simple key/value pairs, i.e. |
static ClassLoader
|
getRootLoader(ClassLoader self)
Obtains a MetaClass for an object either from the registry or in the case of a GroovyObject from the object itself. |
protected static List
|
getSubList(List self, List splice)
|
static String
|
getText(File file, String charset)
|
static String
|
getText(File file)
|
static String
|
getText(URL url)
|
static String
|
getText(URL url, String charset)
|
static String
|
getText(InputStream is)
|
static String
|
getText(InputStream is, String charset)
|
static String
|
getText(Reader reader)
Synonym for write(text) allowing file.text = 'foo'. |
static String
|
getText(BufferedReader reader)
|
static String
|
getText(Process self)
|
static String
|
getTimeString(Date self)
|
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 |
protected static void
|
groupAnswer(Map answer, T element, Object value)
Groups the current element according to the value |
static Map
|
groupBy(Collection self, Closure closure)
|
static Map
|
groupBy(Map self, Closure closure)
|
static Map
|
groupEntriesBy(Map self, Closure closure)
|
static boolean
|
hasGroup(Matcher matcher)
|
static MetaProperty
|
hasProperty(Object self, String name)
@deprecated moved to DateGroovyMethods.clearTime |
static T
|
head(List self)
Returns the items from the List excluding the first item. |
static T
|
head(T[] self)
|
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)
|
static Object
|
inject(Iterator self, Object value, Closure closure)
|
static Object
|
inject(Object self, Object value, Closure closure)
|
static Object
|
inject(Object[] self, Object initialValue, Closure 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, Number right)
|
static Number
|
intdiv(Number left, Character right)
|
static Number
|
intdiv(Character left, Character right)
Performs a division modulus operation. |
static Number
|
intdiv(Number left, Number right)
Negates the number. |
static Collection
|
intersect(Collection left, Collection right)
|
static Map
|
intersect(Map left, Map right)
Returns |
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
|
isAllWhitespace(String self)
|
static boolean
|
isBigDecimal(String self)
|
static boolean
|
isBigInteger(String self)
|
static boolean
|
isCase(Object caseValue, Object switchValue)
Method for overloading the behavior of the 'case' method in switch statements. |
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
|
isCase(GString caseValue, Object switchValue)
'Case' implementation for a GString, which simply calls the equivalet method for String. |
static boolean
|
isCase(Class caseValue, Object switchValue)
|
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(Map caseValue, Object switchValue)
|
static boolean
|
isCase(Pattern caseValue, Object switchValue)
|
static boolean
|
isCase(Number caseValue, Number switchValue)
Special 'case' implementation for all numbers, which delegates to the
|
static boolean
|
isDigit(Character self)
|
static boolean
|
isDouble(String self)
|
static boolean
|
isFloat(String self)
Determines if a character is a digit. |
static boolean
|
isInteger(String self)
|
static boolean
|
isLetter(Character self)
|
static boolean
|
isLetterOrDigit(Character self)
|
static boolean
|
isLong(String self)
Determines if a character is a letter. |
static boolean
|
isLowerCase(Character self)
|
static boolean
|
isNumber(String self)
Transform a Number into an Integer |
static boolean
|
isUpperCase(Character self)
Transform a Number into a Long |
static boolean
|
isWhitespace(Character self)
|
static Iterator
|
iterator(T[] a)
Standard iterator for a input stream which iterates through the stream content in a byte-based fashion. |
static Iterator
|
iterator(Object o)
|
static Iterator
|
iterator(Enumeration enumeration)
|
static Iterator
|
iterator(Matcher matcher)
Just throws a DeprecationException. |
static Iterator
|
iterator(Reader self)
Returns an object satisfying Groovy truth if the implementing MetaClass responds to a method with the given name and arguments types. |
static Iterator
|
iterator(InputStream self)
@deprecated moved to XmlGroovyMethods.iterator |
static Iterator
|
iterator(DataInputStream self)
@deprecated moved to DateGroovyMethods.next |
static Iterator
|
iterator(File self)
@deprecated moved to DateGroovyMethods.next |
static Iterator
|
iterator(Iterator self)
@deprecated moved to DateGroovyMethods.minus |
static Iterator
|
iterator(def nodeList)
@deprecated moved to DateGroovyMethods.clearTime |
static String
|
join(Iterator self, String separator)
Concatenates the |
static String
|
join(Collection self, String separator)
|
static String
|
join(Object[] self, String separator)
Concatenates the |
static T
|
last(List self)
|
static T
|
last(T[] self)
|
static Collection
|
leftShift(Collection self, T value)
Overloads the left shift operator to provide an easy way to append Map.Entry values to a Map. |
static BlockingQueue
|
leftShift(BlockingQueue self, T value)
|
static Map
|
leftShift(Map self, def entry)
|
static Map
|
leftShift(Map self, Map other)
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)
|
static StringBuffer
|
leftShift(StringBuffer self, Object value)
Implementation of the right shift operator for integral types. |
static Writer
|
leftShift(Writer self, Object value)
Implementation of the right shift (unsigned) operator for integral types. |
static Number
|
leftShift(Number self, Number operand)
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 Writer
|
leftShift(OutputStream self, Object value)
|
static void
|
leftShift(ObjectOutputStream self, Object value)
|
static OutputStream
|
leftShift(OutputStream self, InputStream in)
Support the subscript operator with a range for a byte array |
static OutputStream
|
leftShift(OutputStream self, byte[] value)
Support the subscript operator with a range for a char array |
static File
|
leftShift(File file, Object text)
|
static File
|
leftShift(File file, byte[] bytes)
|
static File
|
leftShift(File file, InputStream data)
|
static Writer
|
leftShift(Socket self, Object value)
Converts the GString to a File, or delegates to the default asType(java.lang.Object, java.lang.Class) |
static OutputStream
|
leftShift(Socket self, byte[] value)
|
static Writer
|
leftShift(Process self, Object value)
|
static OutputStream
|
leftShift(Process self, byte[] value)
|
static boolean
|
matches(String self, Pattern pattern)
|
static def
|
max(Map self, Closure closure)
|
static T
|
max(Collection self)
Adds max() method to Iterator objects. |
static T
|
max(Iterator self)
Adds max() method to Object arrays. |
static T
|
max(T[] self)
|
static T
|
max(Collection self, Closure closure)
|
static T
|
max(Iterator self, Closure closure)
Selects the maximum value found from the Iterator using the closure to determine the correct ordering. |
static T
|
max(T[] self, Closure closure)
Selects the maximum value found in the collection using the given comparator. |
static T
|
max(Collection self, Comparator comparator)
|
static T
|
max(Iterator self, Comparator comparator)
Selects the maximum value found from the Object array using the given comparator. |
static T
|
max(T[] self, Comparator comparator)
Provide the standard Groovy |
static MetaClass
|
metaClass(Class self, Closure closure)
|
static MetaClass
|
metaClass(Object self, Closure closure)
Creates an iterator which will traverse through the reader a line at a time. |
static T
|
min(Collection self)
Adds min() method to Collection objects. |
static T
|
min(Iterator self)
Adds min() method to Object arrays. |
static T
|
min(T[] self)
Selects the minimum value found in the collection using the given comparator. |
static T
|
min(Collection self, Comparator comparator)
|
static T
|
min(Iterator self, Comparator comparator)
Selects the minimum value found from the Object array using the given comparator. |
static T
|
min(T[] self, Comparator comparator)
|
static T
|
min(Collection self, Closure closure)
|
static def
|
min(Map self, Closure closure)
Selects an entry in the map having the minimum calculated value as determined by the supplied closure. |
static T
|
min(Iterator self, Closure closure)
|
static T
|
min(T[] self, Closure closure)
Adds max() method to Collection objects. |
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 an array composed of the elements of the first array minus the elements of the given array. |
static T[]
|
minus(T[] self, Collection removeMe)
Create a List composed of the elements of the first list minus every occurrence of elements of the given collection. |
static T[]
|
minus(T[] self, T[] removeMe)
|
static List
|
minus(List self, Collection removeMe)
|
static List
|
minus(List self, Object operand)
Create a new List composed of the elements of the first list minus every occurrence of the operand. |
static T[]
|
minus(T[] self, Object operand)
Flatten a collection. |
static Map
|
minus(Map self, Map operands)
Flatten an array. |
static String
|
minus(String self, Object target)
Executes the command specified by |
static Number
|
minus(Character left, Number right)
|
static Number
|
minus(Number left, Character right)
|
static Number
|
minus(Character left, Character right)
Power of a BigDecimal to an integer certain exponent. |
static Date
|
minus(Date self, int days)
|
static def
|
minus(def self, int days)
|
static int
|
minus(Calendar self, Calendar then)
|
static int
|
minus(Date self, Date then)
|
static void
|
mixin(MetaClass self, List categoryClasses)
Extend object with category methods. |
static void
|
mixin(Class self, List categoryClasses)
Extend class globally with category methods. |
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(MetaClass self, Class categoryClass)
Extend class globally with category methods. |
static void
|
mixin(MetaClass self, Class[] categoryClass)
Extend class globally with category methods. |
static Number
|
mod(Number left, Number right)
|
static List
|
multiply(Collection self, Number factor)
|
static String
|
multiply(String self, Number factor)
Returns the string representation of the given map. |
static Number
|
multiply(Character left, Number right)
|
static Number
|
multiply(Number left, Character right)
|
static Number
|
multiply(Character left, Character right)
|
static Number
|
multiply(BigDecimal left, Double right)
Power of a long to an integer certain exponent. |
static Number
|
multiply(BigDecimal left, BigInteger right)
Divide a Character by a Number. |
static DataInputStream
|
newDataInputStream(File file)
|
static DataOutputStream
|
newDataOutputStream(File file)
|
static BufferedInputStream
|
newInputStream(File file)
Reads the InputStream from this URL, passing each byte to the given closure. |
static BufferedInputStream
|
newInputStream(URL url)
|
static T
|
newInstance(Class c)
Sets/updates the metaclass for a given object to a closure. |
static T
|
newInstance(Class c, Object[] args)
|
static ObjectInputStream
|
newObjectInputStream(File file)
|
static ObjectInputStream
|
newObjectInputStream(InputStream inputStream)
|
static ObjectInputStream
|
newObjectInputStream(InputStream inputStream, ClassLoader classLoader)
|
static ObjectInputStream
|
newObjectInputStream(File file, ClassLoader classLoader)
Iterates through this String line by line. |
static ObjectOutputStream
|
newObjectOutputStream(File file)
Iterates through the given object stream object by object. |
static ObjectOutputStream
|
newObjectOutputStream(OutputStream outputStream)
|
static BufferedOutputStream
|
newOutputStream(File file)
|
static PrintWriter
|
newPrintWriter(File file)
|
static PrintWriter
|
newPrintWriter(File file, String charset)
|
static PrintWriter
|
newPrintWriter(Writer writer)
|
static BufferedReader
|
newReader(File file)
Create a new DataInputStream for this file and passes it into the closure. |
static BufferedReader
|
newReader(File file, String charset)
Create a buffered writer for this file. |
static BufferedReader
|
newReader(InputStream self)
|
static BufferedReader
|
newReader(InputStream self, String charset)
Helper method to create a buffered writer for a file. |
static BufferedReader
|
newReader(URL url)
|
static BufferedReader
|
newReader(URL url, String charset)
|
static BufferedWriter
|
newWriter(File file)
Create a new PrintWriter for this file, using specified charset. |
static BufferedWriter
|
newWriter(File file, boolean append)
Create a new PrintWriter for this file which is then passed it into the given closure. |
static BufferedWriter
|
newWriter(File file, String charset, boolean append)
Create a new PrintWriter with a specified charset for this file. |
static BufferedWriter
|
newWriter(File file, String charset)
Create a new PrintWriter with a specified charset for this file. |
static String
|
next(String self)
Executes the command specified by the given |
static Character
|
next(Character self)
|
static Number
|
next(Number self)
|
static Date
|
next(Date self)
|
static def
|
next(def self)
|
static String
|
normalize(String self)
Reads the URL contents into a list, with one element for each line. |
static int
|
numberAwareCompareTo(Comparable self, Comparable other)
Provides a method that compares two comparables using Groovy's default number aware comparator. |
static Number
|
or(Number left, Number right)
|
static BitSet
|
or(BitSet left, BitSet right)
Iterates from this number up to the given number, inclusive, incrementing by one each time. |
static Boolean
|
or(Boolean left, Boolean right)
Create an object input stream for this file using the given class loader. |
static Process
|
or(Process left, Process right)
|
static String
|
padLeft(String self, Number numberOfChars, String padding)
|
static String
|
padLeft(String self, Number numberOfChars)
Pad a String to a minimum length specified by numberOfChars, adding the supplied padding String as many times as needed to the right. |
static String
|
padRight(String self, Number numberOfChars, String padding)
|
static String
|
padRight(String self, Number numberOfChars)
Pad a String to a minimum length specified by numberOfChars, appending the supplied padding String around the original as many times as needed keeping it centered. |
static Set
|
permutations(List self)
|
static Process
|
pipeTo(Process left, Process right)
|
static Map
|
plus(Map left, Map right)
A helper method to allow maps to work with subscript operators |
static Map
|
plus(Map self, Collection entries)
|
static Collection
|
plus(Collection left, Collection right)
|
static Collection
|
plus(Collection left, T right)
|
static String
|
plus(String left, Object value)
|
static String
|
plus(Number value, String right)
|
static String
|
plus(StringBuffer left, String value)
|
static Number
|
plus(Character left, Number right)
Subtract a Character from a Number. |
static Number
|
plus(Number left, Character right)
Subtract one Character from another. |
static Number
|
plus(Character left, Character right)
Multiply a Character by a Number. |
static Date
|
plus(Date self, int days)
|
static def
|
plus(def self, int days)
|
static T
|
pop(List self)
|
static Number
|
power(Number self, Number exponent)
|
static Number
|
power(BigDecimal self, Integer exponent)
Divide one Character by another. |
static Number
|
power(BigInteger self, Integer exponent)
|
static Number
|
power(Integer self, Integer exponent)
Integer Divide two Characters. |
static Number
|
power(Long self, Integer exponent)
Integer Divide two Numbers. |
static String
|
previous(String self)
Executes the command specified by the |
static Character
|
previous(Character self)
Compare two Numbers. |
static Number
|
previous(Number self)
|
static Date
|
previous(Date self)
|
static def
|
previous(def self)
|
protected static Object
|
primitiveArrayGet(Object self, int idx)
|
protected static List
|
primitiveArrayGet(Object self, Range range)
|
protected static List
|
primitiveArrayGet(Object self, Collection indices)
Convenience method to capitalize the first letter of a string (typically the first letter of a word). |
protected static Object
|
primitiveArrayPut(Object self, int idx, Object newValue)
Expands all tabs into spaces with tabStops of size 8. |
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(PrintWriter self, Object value)
Print a value formatted Groovy style to the print writer. |
static void
|
print(PrintStream self, Object value)
Print a value formatted Groovy style to the print stream. |
static void
|
print(Closure self, Object value)
Print a value to the standard output stream. |
static void
|
print(Object self, PrintWriter out)
Print to a console in interactive format. |
static void
|
printf(Object self, String format, Object[] values)
Printf to a console (Only works with JDK1.5 or later). |
static void
|
printf(Object self, String format, Object arg)
Prints a formatted string using the specified format string and arguments. |
static void
|
println(Object self)
Print a linebreak to the standard output stream. |
static void
|
println(Closure 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(PrintWriter self, Object value)
Print a value formatted Groovy style (followed by a newline) to the print writer. |
static void
|
println(PrintStream self, Object value)
Print a value formatted Groovy style (followed by a newline) to the print 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, PrintWriter out)
Print to a console in interactive format. |
static boolean
|
push(List self, T value)
|
static Map
|
putAll(Map self, Collection entries)
|
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(List self, int idx, T 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 void
|
putAt(StringBuffer self, EmptyRange range, Object value)
|
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, EmptyRange range, Collection value)
|
static void
|
putAt(List self, IntRange range, Collection col)
List subscript assignment operator when given a range as the index. |
static void
|
putAt(List self, IntRange range, Object value)
|
static void
|
putAt(List self, List splice, List values)
|
static void
|
putAt(List self, List splice, Object value)
|
static V
|
putAt(Map self, K key, V value)
|
static void
|
putAt(BitSet self, IntRange range, boolean value)
Support assigning a range of values with a single assignment statement. |
static void
|
putAt(BitSet self, int index, boolean value)
Converts this array to a List of the same size, with each element added to the list. |
static byte[]
|
readBytes(File file)
|
static String
|
readLine(Reader self)
|
static List
|
readLines(String self)
Read the content of this URL and returns it as a String. |
static List
|
readLines(File file)
|
static List
|
readLines(File file, String charset)
|
static List
|
readLines(InputStream stream)
|
static List
|
readLines(InputStream stream, String charset)
|
static List
|
readLines(URL self)
|
static List
|
readLines(URL self, String charset)
|
static List
|
readLines(Reader reader)
|
static boolean
|
removeAll(Collection self, T[] items)
|
static boolean
|
removeAll(Collection self, Closure closure)
Removes the elements in this collection that are matched according to the specified closure condition. |
static boolean
|
renameTo(File self, String newPathName)
Creates a new OutputStream for this file and passes it into the closure. |
static String
|
replaceAll(String self, Pattern pattern, String replacement)
|
static String
|
replaceAll(String self, String regex, Closure closure)
Replaces the first occurrence of a captured group by the result of a closure call on that text. |
static String
|
replaceAll(String self, Pattern pattern, Closure closure)
|
static String
|
replaceFirst(String self, Pattern pattern, String replacement)
Replaces all substrings of a String that match the given compiled regular expression with the given replacement. |
static String
|
replaceFirst(String self, String regex, Closure closure)
Get a replacement corresponding to the matched pattern for DefaultGroovyMethods.replaceAll. |
static String
|
replaceFirst(String self, Pattern pattern, Closure closure)
|
static List
|
respondsTo(Object self, String name, Object[] argTypes)
@deprecated moved to DateGroovyMethods.minus |
static List
|
respondsTo(Object self, String name)
@deprecated moved to DateGroovyMethods.getTimeString |
static boolean
|
retainAll(Collection self, T[] items)
|
static boolean
|
retainAll(Collection self, Closure closure)
|
static T[]
|
reverse(T[] self)
|
static String
|
reverse(String self)
Creates a new string which is the reverse (backwards) of this string |
static List
|
reverse(List self)
Reverses the iterator. |
static Iterator
|
reverse(Iterator self)
|
static Map
|
reverseEach(Map self, Closure closure)
Allows a Map to be iterated through in reverse order using a closure. |
static List
|
reverseEach(List self, Closure closure)
Iterate over each element of the list in the reverse order. |
static T[]
|
reverseEach(T[] self, Closure closure)
|
static Number
|
rightShift(Number self, Number operand)
Overloads the leftShift operator to provide an append mechanism to add values to a stream. |
static Number
|
rightShiftUnsigned(Number self, Number operand)
Overloads the leftShift operator to add objects to an ObjectOutputStream. |
static int
|
round(Float number)
|
static float
|
round(Float number, int precision)
|
static long
|
round(Double number)
Determine if a String can be parsed into an Integer. |
static double
|
round(Double number, int precision)
|
static TimerTask
|
runAfter(Timer timer, int delay, Closure closure)
|
static void
|
setBytes(File file, byte[] bytes)
Append the text at the end of the File. |
static void
|
setBytes(OutputStream os, byte[] bytes)
|
static void
|
setIndex(Matcher matcher, int idx)
|
static void
|
setMetaClass(Class self, MetaClass metaClass)
|
static void
|
setMetaClass(Object self, MetaClass metaClass)
Returns an Iterator which traverses each match. |
static void
|
setText(File file, String text)
Append the text at the end of the File, using a specified encoding. |
static void
|
setText(File file, String text, String charset)
This method is used to throw useful exceptions when the eachFile* and eachDir closure methods are used incorrectly. |
static int
|
size(Iterator self)
|
static int
|
size(String text)
Provide the standard Groovy |
static int
|
size(StringBuffer buffer)
Provide the standard Groovy |
static long
|
size(File self)
Provide the standard Groovy |
static long
|
size(Matcher self)
Provide the standard Groovy |
static int
|
size(Object[] self)
Support the subscript operator for CharSequence. |
static int
|
size(boolean[] array)
|
static int
|
size(byte[] array)
|
static int
|
size(char[] array)
Converts this array to a List of the same size, with each element added to the list. |
static int
|
size(short[] array)
Converts this array to a List of the same size, with each element added to the list. |
static int
|
size(int[] array)
|
static int
|
size(long[] array)
|
static int
|
size(float[] array)
|
static int
|
size(double[] array)
|
static List
|
sort(Collection self)
|
static Map
|
sort(Map self, Closure closure)
|
static Map
|
sort(Map self, Comparator comparator)
Sorts the given Object array into sorted order. |
static Map
|
sort(Map self)
Sorts the given iterator items into a sorted iterator. |
static T[]
|
sort(T[] self)
Sorts the given iterator items into a sorted iterator using the comparator. |
static Iterator
|
sort(Iterator self)
Sorts the Collection using the given comparator. |
static Iterator
|
sort(Iterator self, Comparator comparator)
Sorts the given Object array into sorted order using the given comparator. |
static List
|
sort(Collection self, Comparator comparator)
|
static T[]
|
sort(T[] self, Comparator comparator)
|
static Iterator
|
sort(Iterator self, Closure closure)
|
static T[]
|
sort(T[] self, Closure closure)
|
static List
|
sort(Collection self, Closure closure)
Avoids doing unnecessary work when sorting an already sorted set. |
static SortedSet
|
sort(SortedSet self)
Provides an easy way to append multiple Map.Entry values to a Map. |
static Collection
|
split(Object self, Closure closure)
|
static Collection
|
split(Collection self, Closure closure)
|
static String[]
|
split(String self)
Replaces sequences of whitespaces with tabs. |
static String[]
|
split(GString self)
Remove a part of a String. |
static Object
|
splitEachLine(File self, String regex, Closure closure)
Iterates through the input stream associated with this URL line by line, splitting each line using the given regex separator. |
static Object
|
splitEachLine(File self, Pattern pattern, Closure closure)
|
static Object
|
splitEachLine(File self, String regex, String charset, Closure closure)
|
static Object
|
splitEachLine(File self, Pattern pattern, String charset, Closure closure)
|
static Object
|
splitEachLine(URL self, String regex, Closure closure)
|
static Object
|
splitEachLine(URL self, Pattern pattern, Closure closure)
|
static Object
|
splitEachLine(URL self, String regex, String charset, Closure closure)
|
static Object
|
splitEachLine(URL self, Pattern pattern, String charset, Closure closure)
|
static Object
|
splitEachLine(Reader self, String regex, Closure closure)
Iterates through the given InputStream line by line, splitting each line using the given separator Pattern. |
static Object
|
splitEachLine(Reader self, Pattern pattern, Closure closure)
Iterates through the given String line by line, splitting each line using the given separator Pattern. |
static Object
|
splitEachLine(InputStream stream, String regex, String charset, Closure closure)
Read a single, whole line from the given Reader. |
static Object
|
splitEachLine(InputStream stream, Pattern pattern, String charset, Closure closure)
|
static Object
|
splitEachLine(InputStream stream, String regex, Closure closure)
|
static Object
|
splitEachLine(InputStream stream, Pattern pattern, Closure closure)
|
static Object
|
splitEachLine(String self, String regex, Closure closure)
|
static Object
|
splitEachLine(String self, Pattern pattern, Closure closure)
|
static SpreadMap
|
spread(Map self)
|
static String
|
sprintf(Object self, String format, Object[] values)
Sprintf to a string (Only works with JDK1.5 or later). |
static String
|
sprintf(Object self, String format, Object arg)
Returns a formatted string using the specified format string and arguments. |
static void
|
step(Number self, Number to, Number stepNumber, Closure closure)
Get the absolute value |
static String
|
stripIndent(String self)
|
static String
|
stripIndent(String self, int numChars)
|
static String
|
stripMargin(String self)
Strip leading whitespace/control characters followed by marginChar from every line in a String. |
static String
|
stripMargin(String self, String marginChar)
|
static String
|
stripMargin(String self, char marginChar)
|
static Map
|
subMap(Map map, Collection keys)
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 Set
|
subsequences(List self)
|
static Object
|
sum(Collection self)
Sums the items in an array. |
static Object
|
sum(Object[] self)
Sums the items from an Iterator. |
static Object
|
sum(Iterator self)
Sums the items in a collection, adding the result to some initial value. |
static Object
|
sum(Collection self, Object initialValue)
Sums the items in an array, adding the result to some initial value. |
static Object
|
sum(Object[] self, Object initialValue)
Sums the items from an Iterator, adding the result to some initial value. |
static Object
|
sum(Iterator self, Object initialValue)
|
static Object
|
sum(Collection self, Closure closure)
Sums the result of apply a closure to each item of a collection. |
static Object
|
sum(Object[] self, Closure closure)
|
static Object
|
sum(Iterator self, Closure closure)
|
static Object
|
sum(Collection self, Object initialValue, Closure closure)
|
static Object
|
sum(Object[] self, Object initialValue, Closure closure)
|
static Object
|
sum(Iterator self, Object initialValue, Closure closure)
|
static List
|
tail(List self)
|
static T[]
|
tail(T[] self)
Converts this Collection to a List. |
static void
|
times(Number self, Closure closure)
Iterates from this number up to the given number, inclusive, incrementing by one each time. |
static String
|
toArrayString(Object[] self)
|
static BigDecimal
|
toBigDecimal(String self)
Determine if a Character is uppercase. |
static BigDecimal
|
toBigDecimal(Number self)
Create an object output stream for this file. |
static BigInteger
|
toBigInteger(String self)
|
static BigInteger
|
toBigInteger(Number self)
Create an object input stream for this file. |
static Boolean
|
toBoolean(String self)
Expands all tabs into spaces. |
static Boolean
|
toBoolean(Boolean self)
Replaces sequences of whitespaces with tabs using tabStops of size 8. |
static Character
|
toCharacter(String self)
|
static Double
|
toDouble(String self)
|
static Double
|
toDouble(Number self)
|
static Float
|
toFloat(String self)
|
static Float
|
toFloat(Number self)
|
static Integer
|
toInteger(String self)
|
static Integer
|
toInteger(Number self)
|
static List
|
toList(Collection self)
|
static List
|
toList(Iterator self)
|
static List
|
toList(Enumeration self)
Convert an enumeration to a List. |
static List
|
toList(T[] array)
|
static List
|
toList(byte[] array)
Implements the getAt(int) method for primitve type arrays. |
static List
|
toList(boolean[] array)
Implements the getAt(Range) method for primitve type arrays. |
static List
|
toList(char[] array)
|
static List
|
toList(short[] array)
|
static List
|
toList(int[] array)
Implements the setAt(int idx) method for primitve type arrays. |
static List
|
toList(long[] array)
|
static List
|
toList(float[] array)
|
static List
|
toList(double[] array)
|
static List
|
toList(String self)
@deprecated use ProcessGroovyMethods#consumeProcessOutput(Process, OutputStream, OutputStream) |
static String
|
toListString(Collection self)
|
static String
|
toListString(Collection self, int maxSize)
Add a Number and a Character. |
static Long
|
toLong(String self)
|
static Long
|
toLong(Number self)
|
static char
|
toLowerCase(Character self)
Transform this Number into a BigInteger. |
static String
|
toMapString(Map self)
Increment a Number by one. |
static String
|
toMapString(Map self, int maxSize)
Decrement a Character by one. |
static def
|
toRowResult(def rs)
@deprecated moved to DateGroovyMethods.format |
static Short
|
toShort(String self)
Determine if a String can be parsed into a BigInteger. |
static SpreadMap
|
toSpreadMap(Map self)
Creates a spreadable map from this array. |
static SpreadMap
|
toSpreadMap(Object[] self)
|
static String
|
toString(boolean[] self)
Returns the string representation of this map. |
static String
|
toString(byte[] self)
|
static String
|
toString(char[] self)
|
static String
|
toString(short[] self)
|
static String
|
toString(int[] self)
|
static String
|
toString(long[] self)
Returns the string representation of this array's contents. |
static String
|
toString(float[] self)
Returns the string representation of the given array. |
static String
|
toString(double[] self)
Create a String representation of this object. |
static String
|
toString(AbstractMap self)
Increment a Character by one. |
static String
|
toString(AbstractCollection self)
Decrement a Number by one. |
static String
|
toString(Object[] self)
|
static String
|
toString(Object value)
|
static URI
|
toURI(String self)
|
static URL
|
toURL(String self)
Turns a String into a regular expression Pattern |
static char
|
toUpperCase(Character self)
|
static List
|
tokenize(String self, String token)
|
static List
|
tokenize(String self, Character token)
|
static List
|
tokenize(String self)
|
static String
|
tr(String self, String sourceSet, String replacementSet)
Tells whether or not self matches the given compiled regular expression Pattern. |
static void
|
transformChar(Reader self, Writer writer, Closure closure)
|
static void
|
transformLine(Reader reader, Writer writer, Closure closure)
|
static List
|
transpose(List self)
|
static void
|
traverse(File self, Map options, Closure closure)
Invokes the closure for each descendant file in this directory. |
static void
|
traverse(File self, Closure closure)
|
static void
|
traverse(File self, Map options)
|
static float
|
trunc(Float number, int precision)
Parse a String into a BigInteger |
static float
|
trunc(Float number)
Parse a String into a BigDecimal |
static double
|
trunc(Double number)
|
static double
|
trunc(Double number, int precision)
Determine if a String can be parsed into a Float. |
static Number
|
unaryMinus(Number left)
|
static String
|
unexpand(String self)
Tokenize a String (with a whitespace as the delimiter). |
static String
|
unexpand(String self, int tabStop)
Appends the String representation of the given operand to this string. |
static String
|
unexpandLine(String self, int tabStop)
Appends a String to the string representation of this number. |
static Iterator
|
unique(Iterator self)
|
static Collection
|
unique(Collection self)
|
static Iterator
|
unique(Iterator self, Closure closure)
|
static Collection
|
unique(Collection self, Closure closure)
|
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 Collection
|
unique(Collection self, Comparator comparator)
|
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 void
|
upto(long self, Number to, Closure closure)
|
static void
|
upto(Long self, Number to, Closure closure)
|
static void
|
upto(float self, Number to, Closure closure)
|
static void
|
upto(Float self, Number to, Closure closure)
|
static void
|
upto(double self, Number to, Closure closure)
|
static void
|
upto(Double self, Number to, Closure closure)
|
static void
|
upto(BigInteger self, Number to, Closure closure)
Iterates from this number down to the given number, inclusive, decrementing by one each time. |
static void
|
upto(BigDecimal self, Number to, Closure closure)
Iterates from this number down to the given number, inclusive, decrementing 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)
|
static void
|
waitForProcessOutput(Process self)
|
static void
|
waitForProcessOutput(Process self, StringBuffer output, StringBuffer error)
|
static void
|
waitForProcessOutput(Process self, OutputStream output, OutputStream error)
|
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 PrintWriter for this file, using specified charset. |
static Object
|
withDataOutputStream(File file, Closure closure)
Create a new PrintWriter for this file. |
static Map
|
withDefault(Map self, Closure init)
Sorts the given collection into a sorted list. |
static Object
|
withInputStream(File file, Closure closure)
|
static Object
|
withInputStream(URL url, Closure closure)
|
static Object
|
withObjectInputStream(File file, Closure closure)
Iterates through this file line by line. |
static Object
|
withObjectInputStream(File file, ClassLoader classLoader, Closure closure)
Iterates through this file line by line. |
static Object
|
withObjectInputStream(InputStream inputStream, Closure closure)
Iterates through this stream reading with the provided charset, passing each line to the given 1 or 2 arg closure. |
static Object
|
withObjectInputStream(InputStream inputStream, ClassLoader classLoader, Closure closure)
Iterates through this stream reading with the provided charset, passing each line to the given 1 or 2 arg closure. |
static Object
|
withObjectOutputStream(File file, Closure closure)
|
static Object
|
withObjectOutputStream(OutputStream outputStream, Closure closure)
|
static Object
|
withObjectStreams(Socket socket, Closure closure)
Converts the given String into a List of strings of one character. |
static Object
|
withOutputStream(File file, Closure closure)
|
static void
|
withOutputStream(Process self, Closure closure)
|
static Object
|
withPrintWriter(File file, Closure closure)
|
static Object
|
withPrintWriter(File file, String charset, Closure closure)
|
static Object
|
withPrintWriter(Writer writer, Closure closure)
|
static Object
|
withReader(File file, Closure closure)
|
static Object
|
withReader(File file, String charset, Closure closure)
|
static Object
|
withReader(Reader reader, Closure closure)
Creates a buffered input stream for this file. |
static Object
|
withReader(URL url, Closure closure)
Create a data input stream for this file |
static Object
|
withReader(URL url, String charset, Closure closure)
|
static Object
|
withReader(InputStream in, Closure closure)
|
static Object
|
withReader(InputStream in, String charset, Closure closure)
Traverse through each byte of this byte array. |
static Object
|
withStream(InputStream stream, Closure closure)
Creates a buffered reader for this URL. |
static Object
|
withStream(OutputStream os, Closure closure)
|
static Object
|
withStreams(Socket socket, Closure closure)
Converts this File to a Writable or delegates to default asType(java.lang.Object, java.lang.Class). |
static Object
|
withWriter(File file, Closure closure)
Allows this reader to be used within the closure, ensuring that it is closed before this method returns. |
static Object
|
withWriter(File file, String charset, Closure closure)
|
static Object
|
withWriter(Writer writer, Closure closure)
|
static Object
|
withWriter(OutputStream stream, Closure closure)
Traverse through each byte of the specified stream. |
static Object
|
withWriter(OutputStream stream, String charset, Closure closure)
|
static void
|
withWriter(Process self, Closure closure)
|
static Object
|
withWriterAppend(File file, String charset, Closure closure)
|
static Object
|
withWriterAppend(File file, Closure closure)
Helper method to create a new BufferedReader for a URL and then passes it to the closure. |
static void
|
write(Writer self, Writable writable)
Pipe an InputStream into an OutputStream for efficient stream copying. |
static void
|
write(File file, String text)
|
static void
|
write(File file, String text, String charset)
|
static void
|
writeLine(BufferedWriter writer, String line)
Append bytes to the end of a File. |
static BitSet
|
xor(BitSet left, BitSet right)
|
static Number
|
xor(Number left, Number right)
|
static Boolean
|
xor(Boolean left, Boolean right)
Iterates through the given file object by object. |
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Field Detail |
---|
public static final Class[] additionals
Method Detail |
---|
public static int abs(Number number)
number
- a Double
public static long abs(Long number)
public static float abs(Float number)
public static double abs(Double number)
public static Socket accept(ServerSocket serverSocket, Closure closure)
public static Socket accept(ServerSocket serverSocket, boolean runInANewThread, Closure closure)
public static boolean addAll(Collection self, T[] items)
items
- array containing elements to be added to this collection
public static boolean addAll(List self, int index, T[] items)
public static void addShutdownHook(Object self, Closure closure)
self
- the object the method is called on (ignored)closure
- the shutdown hook action
public static Number and(Number left, Number right)
public static BitSet and(BitSet left, BitSet right)
self
- a Numberto
- another Number to go up toclosure
- the closure to call
public static Boolean and(Boolean left, Boolean right)
inputStream
- an input streamclassLoader
- the class loader to use when loading the class
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)
assert [2:3, 4:5, 5:10].any { key, value -> key * 2 == value } assert ![2:3, 4:5, 5:10].any { entry -> entry.key == entry.value * 2 }
self
- the map over which we iterateclosure
- the 1 or 2 arg closure predicate used for matching
public static boolean any(Object self)
self
- the object over which we iterate
public static void append(File file, Object text)
public static void append(File file, byte[] bytes)
public static void append(File self, InputStream stream)
public static void append(File file, Object text, String charset)
public static boolean asBoolean(Object object)
matcher
- the matcher
public static boolean asBoolean(Boolean bool)
public static boolean asBoolean(Matcher matcher)
public static boolean asBoolean(Collection collection)
iterator
- the iterator
public static boolean asBoolean(Map map)
enumeration
- the enumeration
public static boolean asBoolean(Iterator iterator)
public static boolean asBoolean(Enumeration enumeration)
public static boolean asBoolean(CharSequence string)
public static boolean asBoolean(Object[] array)
public static boolean asBoolean(byte[] array)
public static boolean asBoolean(short[] array)
public static boolean asBoolean(int[] array)
public static boolean asBoolean(long[] array)
public static boolean asBoolean(float[] array)
public static boolean asBoolean(double[] array)
public static boolean asBoolean(boolean[] array)
public static boolean asBoolean(char[] array)
number
- the number
public static boolean asBoolean(Character character)
public static boolean asBoolean(Number number)
if (col instanceof SortedSet) return col; public static boolean asBoolean(GroovyResultSet grs)
public static Map asImmutable(Map self)
self
- a List
public static SortedMap asImmutable(SortedMap self)
public static List asImmutable(List self)
public static Set asImmutable(Set self)
public static SortedSet asImmutable(SortedSet self)
public static Collection asImmutable(Collection self)
self
- a SortedMap
public static List asList(Collection self)
bool
- the Boolean
public static Map asSynchronized(Map self)
public static SortedMap asSynchronized(SortedMap self)
public static Collection asSynchronized(Collection self)
public static List asSynchronized(List self)
public static Set asSynchronized(Set self)
public static SortedSet asSynchronized(SortedSet self)
public static Object asType(Collection col, Class clazz)
public static Object asType(Object[] ary, Class clazz)
ary
- an arrayclazz
- the desired class
public static Object asType(Closure cl, Class clazz)
map
- this mapclazz
- the target type
public static Object asType(Map map, Class clazz)
def list = ["a", 4, false] assert list.reverse() == [false, 4, "a"] assert list == ["a", 4, false]
self
- a List
public static Object asType(Number self, Class c)
file
- a Fileclosure
- a closure
public static Object asType(File f, Class c)
public static Object asType(GString self, Class c)
public static Object asType(String self, Class c)
public static Object asType(Object obj, Class type)
self
- the class whose metaclass we wish to setmetaClass
- the new MetaClass
public static File asWritable(File file)
public static File asWritable(File file, String encoding)
public static Pattern bitwiseNegate(String self)
public static BitSet bitwiseNegate(BitSet self)
protected static Object callClosureForLine(Closure closure, String line, int counter)
protected static Object callClosureForMapEntry(Closure closure, def entry)
protected static Object callClosureForMapEntryAndCounter(Closure closure, def entry, int counter)
public static String capitalize(String self)
public static String center(String self, Number numberOfChars, String padding)
public static String center(String self, Number numberOfChars)
public static void clearTime(Date self)
public static void clearTime(def self)
public static void clearTime(Calendar self)
public static List collect(Object self, Closure closure)
def list = [1, 'a', 1.23, true ] def types = list.collect { it.class } assert types == [Integer, String, BigDecimal, Boolean]
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)
public static List collect(Collection self, Closure closure)
public static Collection collect(Collection self, Collection collection, Closure closure)
public static Collection collect(Map self, Collection collection, Closure closure)
assert [a:1, b:2].collect( [] as HashSet ) { key, value -> key*value } == ["a", "bb"] as Set assert [3:20, 2:30].collect( [] as HashSet ) { entry -> entry.key * entry.value } == [60] as Set
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)
public static List collectAll(Collection self, Closure closure)
assert [2,[4,6],[8],[]] == [1,[2,3],[4],[]].collectAll { it * 2 }
self
- a collectionclosure
- the closure used to transform each element of the collection
public static Collection collectAll(Collection self, Collection collection, Closure closure)
public static Map collectEntries(Map self, Map result, Closure closure)
public static Map collectEntries(Map self, Closure closure)
public static Map collectEntries(Collection self, Map result, Closure closure)
public static Map collectEntries(Object[] self, Map result, Closure closure)
public static Map collectEntries(Collection self, Closure closure)
public static Map collectEntries(Object[] self, Closure closure)
public static List combinations(Collection self)
assert [['a', 'b'],[1, 2, 3]].combinations() == [['a', 1], ['b', 1], ['a', 2], ['b', 2], ['a', 3], ['b', 3]]
self
- a Collection of lists
public static int compareTo(Character left, Number right)
public static int compareTo(Number left, Character right)
public static int compareTo(Character left, Character right)
public static int compareTo(Number left, Number right)
Object value = iter.next(); public static Thread consumeProcessErrorStream(Process self, OutputStream err)
return result; public static Thread consumeProcessErrorStream(Process self, StringBuffer error)
* @param closure the filter to perform a match on the collection public static Thread consumeProcessErrorStream(Process self, Writer err)
* @param closure the filter to perform a match on the collection public static void consumeProcessOutput(Process self)
Object value = iter.next(); public static void consumeProcessOutput(Process self, StringBuffer output, StringBuffer error)
} public static void consumeProcessOutput(Process self, OutputStream output, OutputStream error)
/** public static Thread consumeProcessOutputStream(Process self, StringBuffer output)
* @return a list of numbers corresponding to the index values of all matched objects public static Thread consumeProcessOutputStream(Process self, Writer output)
Object value = iter.next(); public static Thread consumeProcessOutputStream(Process self, OutputStream output)
public static boolean contains(String self, String text)
self
with environment defined by envp
and under the working directory dir
.
For more control over Process construction you can use
java.lang.ProcessBuilder
(JDK 1.5+).
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.
public static boolean containsAll(Collection self, Object[] items)
public static Number 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 Number count(Collection self, Object value)
compareTo(value) == 0
or equals(value)
).
assert [2,4,2,1,3,5,2,4,3].count(4) == 2
self
- the collection within which we count the number of occurrencesvalue
- the value being searched for
public static Number count(Object[] self, Object value)
public static Number count(int[] self, Object value)
public static Number count(long[] self, Object value)
public static Number count(short[] self, Object value)
public static Number count(char[] self, Object value)
public static Number count(boolean[] self, Object value)
public static Number count(double[] self, Object value)
public static Number count(float[] self, Object value)
public static Number count(byte[] self, Object value)
public static int count(String self, String text)
protected static StringBufferWriter createStringBufferWriter(StringBuffer self)
protected static StringWriter createStringWriter(String self)
public static byte[] decodeBase64(String value)
public static boolean deleteDir(File self)
file
- a file object
public static String denormalize(String self)
public static boolean disjoint(Collection left, Collection right)
left
- an int arrayright
- the operand array.
public static Number div(Character left, Number right)
left
- a Numberright
- another Number to bitwise AND
public static Number div(Number left, Character right)
public static Number div(Character left, Character right)
public static void downto(Number self, Number to, Closure closure)
self
- a doubleto
- the end numberclosure
- the code to execute for each number
public static void downto(long self, Number to, Closure closure)
self
- a BigIntegerto
- the end numberclosure
- the code to execute for each number
public static void downto(Long self, Number to, Closure closure)
public static void downto(float self, Number to, Closure closure)
public static void downto(Float self, Number to, Closure closure)
public static void downto(double self, Number to, Closure closure)
public static void downto(Double self, Number to, Closure closure)
public static void downto(BigInteger self, Number to, Closure closure)
public static void downto(BigDecimal self, Number to, Closure closure)
number
- a Number
public static String dump(Object self)
self
- an object
public static T each(T self, Closure closure)
self
- the object over which we iterateclosure
- the closure applied on each element found
public static Map each(Map self, Closure closure)
def result = "" [a:1, b:3].each { key, value -> result += "$key$value" } assert result == "a1b3"
def result = "" [a:1, b:3].each { entry -> result += entry } assert result == "a=1b=3"In general, the order in which the map contents are processed cannot be guaranteed. In practise, specialized forms of Map, e.g. a TreeMap will have its contents processed according to the natural ordering of the map.
self
- the map over which we iterateclosure
- the 1 or 2 arg closure applied on each entry of the map
public static void eachByte(File self, Closure closure)
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.
public static void eachByte(File self, int bufferLen, Closure closure)
public static void eachByte(Byte[] self, Closure closure)
public static void eachByte(byte[] self, Closure closure)
reader
- a reader, closed after the callwriter
- a writer, closed after the callclosure
- the closure which returns booleans
public static void eachByte(InputStream is, Closure closure)
public static void eachByte(InputStream is, int bufferLen, Closure closure)
self
is not readableself
- a Fileclosure
- a closure which returns a boolean indicating to filter
the line or not
public static void eachByte(URL url, Closure closure)
self
- a Filecharset
- opens the file with a specified charsetclosure
- a closure which returns a boolean indicating to filter
the line or not
public static void eachByte(URL url, int bufferLen, Closure closure)
public static void eachDir(File self, Closure closure)
self
- a Fileclosure
- the Closure to invoke on each file/directory and optionally returning a FileVisitResult value
which can be used to control subsequent processing
public static void eachDirMatch(File self, Object nameFilter, Closure closure)
file
- a file objectcharset
- the charset for this input streamclosure
- a closure
public static void eachDirRecurse(File self, Closure closure)
public static void eachFile(File self, FileType fileType, Closure closure)
public static void eachFile(File self, Closure closure)
public static void eachFileMatch(File self, FileType fileType, Object nameFilter, Closure closure)
file
- a Filecharset
- the charset for this File
public static void eachFileMatch(File self, Object nameFilter, Closure closure)
self
- an input streamcharset
- the charset for this input stream
public static void eachFileRecurse(File self, FileType fileType, Closure closure)
self
- a Fileoptions
- a Map of options to alter the traversal behavior
public static void eachFileRecurse(File self, Closure closure)
The method returns
self
- a File
public static Object eachLine(String self, Closure closure)
stream
- a streamclosure
- a closure (arg 1 is line, optional arg 2 is line number starting at line 1)
public static Object eachLine(String self, int firstLine, Closure closure)
stream
- a streamfirstLine
- the line number value used for the first line (default is 1, set to 0 to start counting from 0)closure
- a closure (arg 1 is line, optional arg 2 is line number)
public static Object eachLine(File self, Closure closure)
url
- a URL to open and readclosure
- a closure to apply on each line (arg 1 is line, optional arg 2 is line number starting at line 1)
public static Object eachLine(File self, String charset, Closure closure)
public static Object eachLine(File self, int firstLine, Closure closure)
public static Object eachLine(File self, String charset, int firstLine, Closure closure)
public static Object eachLine(InputStream stream, String charset, Closure closure)
public static Object eachLine(InputStream stream, String charset, int firstLine, Closure closure)
public static Object eachLine(InputStream stream, Closure closure)
public static Object eachLine(InputStream stream, int firstLine, Closure closure)
public static Object eachLine(URL url, Closure closure)
public static Object eachLine(URL url, int firstLine, Closure closure)
public static Object eachLine(URL url, String charset, Closure closure)
public static Object eachLine(URL url, String charset, int firstLine, Closure closure)
self
- a Filepattern
- the regular expression Pattern for the delimitercharset
- opens the file with a specified charsetclosure
- a closure
public static Object eachLine(Reader self, Closure closure)
public static Object eachLine(Reader self, int firstLine, Closure closure)
public static String eachMatch(String self, String regex, Closure closure)
public static String eachMatch(String self, Pattern pattern, Closure closure)
public static void eachObject(File self, Closure closure)
public static void eachObject(ObjectInputStream ois, Closure closure)
public static Iterator eachPermutation(Collection self, Closure closure)
public static Object eachWithIndex(Object self, Closure closure)
public static Map eachWithIndex(Map self, Closure closure)
def result = "" [a:1, b:3].eachWithIndex { key, value, index -> result += "$index($key$value)" } assert result == "0(a1)1(b3)"
def result = "" [a:1, b:3].eachWithIndex { entry, index -> result += "$index($entry)" } assert result == "0(a=1)1(b=3)"
self
- the map over which we iterateclosure
- a 2 or 3 arg Closure to operate on each item
@Deprecated public static Writable encodeBase64(Byte[] data, boolean chunked)
public static Writable encodeBase64(Byte[] data)
public static Writable encodeBase64(byte[] data, boolean chunked)
public static Writable encodeBase64(byte[] data)
public static boolean equals(int[] left, int[] right)
false
if either collection is null
.
left
- this arrayright
- the list being compared
public static boolean equals(Object[] left, List right)
public static boolean equals(List left, Object[] right)
public static boolean equals(List left, List right)
public static boolean every(Object self, Closure closure)
public static boolean every(Map self, Closure closure)
def map = [a:1, b:2.0, c:2L] assert !map.every { key, value -> value instanceof Integer } assert map.every { entry -> entry.value instanceof Number }
self
- the map over which we iterateclosure
- the 1 or 2 arg 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 Process execute(String self)
String
array given in the first parameter,
with the environment defined by envp
and under the working directory dir
.
The first item in the array is the command; the others are the parameters.
For more control over Process construction you can use
java.lang.ProcessBuilder
(JDK 1.5+).
commandArray
- an array of String containing the command name and
parameters as separate items in the array.
envp
- a List of Objects (converted to Strings using toString), 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.
public static Process execute(String self, String[] envp, File dir)
For more control over Process construction you can use
java.lang.ProcessBuilder
(JDK 1.5+).
commands
- a list containing the command name and
parameters as separate items in the list.
public static Process execute(String self, List envp, File dir)
public static Process execute(String[] commandArray)
public static Process execute(String[] commandArray, String[] envp, File dir)
public static Process execute(String[] commandArray, List envp, File dir)
self
- an array
public static Process execute(List commands)
self
- an array
public static Process execute(List commands, String[] envp, File dir)
self
- an array
public static Process execute(List commands, List envp, File dir)
self
- an array
public static String expand(String self)
public static String expand(String self, int tabStop)
public static String expandLine(String self, int tabStop)
self
- a Stringtoken
- the delimiter
public static void filterLine(Reader reader, Writer writer, Closure closure)
true
if the line should be passed to the writer.self
- an input streamcharset
- opens the stream with a specified charsetpredicate
- a closure which returns boolean and takes a line
public static Writable filterLine(File self, Closure closure)
true
if the line should be passed to the
writer.self
- the InputStreamwriter
- a writer to write output tocharset
- opens the stream with a specified charsetpredicate
- a closure which returns true if a line should be accepted
public static Writable filterLine(File self, String charset, Closure closure)
public static void filterLine(File self, Writer writer, Closure closure)
public static void filterLine(File self, Writer writer, String charset, Closure closure)
public static Writable filterLine(Reader reader, Closure closure)
public static Writable filterLine(InputStream self, Closure predicate)
socket
- a Socketclosure
- a Closure
public static Writable filterLine(InputStream self, String charset, Closure predicate)
public static void filterLine(InputStream self, Writer writer, Closure predicate)
public static void filterLine(InputStream self, Writer writer, String charset, Closure predicate)
public static Writable filterLine(URL self, Closure predicate)
self
- a Socketvalue
- a value to append
public static Writable filterLine(URL self, String charset, Closure predicate)
public static void filterLine(URL self, Writer writer, Closure predicate)
public static void filterLine(URL self, Writer writer, String charset, Closure predicate)
public static Object find(Object self, Closure closure)
self
- an Object with an iterator returning its valuesclosure
- a closure condition
public static T find(Collection self, Closure closure)
def list = [1,2,3] assert 2 == list.find { it > 1 }
self
- a Collectionclosure
- a closure condition
public static def find(Map self, Closure closure)
public static String find(String self, String regex)
public static String find(String self, Pattern pattern)
public static String find(String self, String regex, Closure closure)
public static String find(String self, Pattern pattern, Closure closure)
public static Collection findAll(Collection self, Closure closure)
public static Collection findAll(Object self, Closure closure)
public static Map findAll(Map self, Closure closure)
public static List findAll(String self, String regex)
For example, if the pattern doesn't match, it returns an empty list:
assert [] == "foo".findAll(~/(\w*) Fish/)
Any regular expression matches are returned in a list, and all regex capture groupings are ignored, only the full match is returned:
def expected = ["One Fish", "Two Fish", "Red Fish", "Blue Fish"] assert expected == "One Fish, Two Fish, Red Fish, Blue Fish".findAll(~/(\w*) Fish/)
self
- a Stringpattern
- the compiled regex Pattern
public static List findAll(String self, Pattern pattern)
public static List findAll(String self, String regex, Closure closure)
public static List findAll(String self, Pattern pattern, Closure closure)
public static int findIndexOf(Object self, Closure closure)
public static int findIndexOf(Object self, int startIndex, Closure closure)
public static List findIndexValues(Object self, Closure closure)
c
- a class
public static List findIndexValues(Object self, Number startIndex, Closure closure)
public static int findLastIndexOf(Object self, Closure closure)
public static int findLastIndexOf(Object self, int startIndex, Closure closure)
public static Object findResult(Object self, Object defaultResult, Closure closure)
public static Object findResult(Object self, Closure closure)
public static Object findResult(Collection self, Object defaultResult, Closure closure)
public static Object findResult(Collection self, Closure closure)
public static Object findResult(Map self, Object defaultResult, Closure closure)
public static Object findResult(Map self, Closure closure)
public static T first(List self)
public static T first(T[] self)
public static Collection flatten(Collection self)
self
- a boolean Array to flatten
public static Collection flatten(Object[] self)
public static Collection flatten(boolean[] self)
public static Collection flatten(byte[] self)
public static Collection flatten(char[] self)
public static Collection flatten(short[] self)
public static Collection flatten(int[] self)
public static Collection flatten(long[] self)
public static Collection flatten(float[] self)
self
- a CollectionflattenUsing
- a closure to determine how to flatten non-Array, non-Collection elements
public static Collection flatten(double[] self)
public static Collection flatten(Collection self, Closure flattenUsing)
def list = [1,2] list << 3 assert list == [1,2,3]
self
- a Collectionvalue
- an Object to be added to the collection.
public static String format(Date self, String format)
public static String format(Calendar self, String pattern)
public static V get(Map map, K key, V defaultValue)
array
- an Array of Objectsrange
- a Range
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 CharSequence getAt(CharSequence text, int index)
text
- a Stringindex
- the index of the Character to get
public static String getAt(String text, int index)
text
- a CharSequencerange
- a Range
public static CharSequence getAt(CharSequence text, Range range)
public static CharSequence getAt(CharSequence text, IntRange range)
text
- a CharSequencerange
- an IntRange
public static CharSequence getAt(CharSequence text, EmptyRange range)
text
- a Stringrange
- an IntRange
public static String getAt(String text, IntRange range)
text
- a Stringrange
- an EmptyRange
public static String getAt(String text, EmptyRange range)
text
- a Stringrange
- a Range
public static String getAt(String text, Range range)
public static Object getAt(Matcher matcher, int idx)
public static List getAt(List self, Range range)
public static List getAt(List self, EmptyRange range)
public static List getAt(List self, Collection indices)
self
- an Array of Objectsindices
- a Collection of indices
public static List getAt(T[] self, Collection indices)
self
- a CharSequenceindices
- a Collection of indices
public static CharSequence getAt(CharSequence self, Collection indices)
self
- a Stringindices
- a Collection of indices
public static String getAt(String self, Collection indices)
self
- a Matcherindices
- a Collection of indices
public static List getAt(Matcher self, Collection indices)
assert [1:10, 2:20, 4:40].subMap( [2, 4] ) == [2:20, 4:40]
map
- a Mapkeys
- a Collection of keys
public static List getAt(T[] array, Range range)
array
- an Array of Objectsrange
- an EmptyRange
public static List getAt(T[] array, IntRange range)
array
- an Array of Objectsrange
- an ObjectRange
public static List getAt(T[] array, EmptyRange range)
public static List getAt(T[] array, ObjectRange range)
public static T getAt(List self, int idx)
public static T getAt(Iterator self, int idx)
public static V getAt(Map self, K key)
def map = [a:10] assert map["a"] == 10
self
- a Mapkey
- an Object as a key for the map
public static List getAt(Collection coll, String property)
self
- a Map
* Support the subscript operator with a range for a long array public static List getAt(byte[] array, Range range)
array
- an int arrayrange
- a range indicating the indices for the items to retrieve
* Support the subscript operator with a range for a float array public static List getAt(char[] array, Range range)
* Support the subscript operator with a range for a double array public static List getAt(short[] array, Range range)
* Support the subscript operator with a range for a boolean array public static List getAt(int[] array, Range range)
* Support the subscript operator with an IntRange for a byte array public static List getAt(long[] array, Range range)
* Support the subscript operator with an IntRange for a char array public static List getAt(float[] array, Range range)
* Support the subscript operator with an IntRange for a short array public static List getAt(double[] array, Range range)
* Support the subscript operator with an IntRange for an int array public static List getAt(boolean[] array, Range range)
* Support the subscript operator with an IntRange for a long array public static List getAt(byte[] array, IntRange range)
* Support the subscript operator with an IntRange for a float array public static List getAt(char[] array, IntRange range)
* Support the subscript operator with an IntRange for a double array public static List getAt(short[] array, IntRange range)
* Support the subscript operator with an IntRange for a boolean array public static List getAt(int[] array, IntRange range)
* Support the subscript operator with an ObjectRange for a byte array public static List getAt(long[] array, IntRange range)
* Support the subscript operator with an ObjectRange for a char array public static List getAt(float[] array, IntRange range)
* Support the subscript operator with an ObjectRange for a short array public static List getAt(double[] array, IntRange range)
* Support the subscript operator with an ObjectRange for an int array public static List getAt(boolean[] array, IntRange range)
* Support the subscript operator with an ObjectRange for a long array public static List getAt(byte[] array, ObjectRange range)
* Support the subscript operator with an ObjectRange for a float array public static List getAt(char[] array, ObjectRange range)
* Support the subscript operator with an ObjectRange for a double array public static List getAt(short[] array, ObjectRange range)
* Support the subscript operator with an ObjectRange for a byte array public static List getAt(int[] array, ObjectRange range)
* Support the subscript operator with a collection for a byte array public static List getAt(long[] array, ObjectRange range)
* Support the subscript operator with a collection for a char array public static List getAt(float[] array, ObjectRange range)
* Support the subscript operator with a collection for a short array public static List getAt(double[] array, ObjectRange range)
* Support the subscript operator with a collection for an int array public static List getAt(boolean[] array, ObjectRange range)
* Support the subscript operator with a collection for a long array public static List getAt(byte[] array, Collection indices)
* Support the subscript operator with a collection for a float array public static List getAt(char[] array, Collection indices)
* Support the subscript operator with a collection for a double array public static List getAt(short[] array, Collection indices)
* Support the subscript operator with a collection for a boolean array public static List getAt(int[] array, Collection indices)
* Support the subscript operator for a Bitset public static List getAt(long[] array, Collection indices)
* Support retrieving a subset of a BitSet using a Range public static List getAt(float[] array, Collection indices)
BitSet result = new BitSet(); public static List getAt(double[] array, Collection indices)
} public static List getAt(boolean[] array, Collection indices)
public static boolean getAt(BitSet self, int index)
public static BitSet getAt(BitSet self, IntRange range)
public static int getAt(Date self, int field)
public static byte[] getBytes(File file)
file
- a Filetext
- the text to write to the File
public static byte[] getBytes(URL url)
public static byte[] getBytes(InputStream is)
public static char[] getChars(String self)
public static int getCount(Matcher matcher)
matcher
- a Matchertrue
if matcher contains at least one group.
public static String getDateString(Date self)
public static String getDateTimeString(Date self)
} public static InputStream getErr(Process self)
} public static InputStream getIn(Process self)
public static MetaClass getMetaClass(Class c)
public static MetaClass getMetaClass(Object obj)
a
- an array
public static MetaClass getMetaClass(GroovyObject obj)
public static List getMetaPropertyValues(Object self)
self
- the receiver object
* @param self the source string public static OutputStream getOut(Process self)
public static Map getProperties(Object self)
self
- the receiver object
public static ClassLoader getRootLoader(ClassLoader self)
obj
- The object in question
protected static List getSubList(List self, List splice)
public static String getText(File file, String charset)
public static String getText(File file)
public static String getText(URL url)
public static String getText(URL url, String charset)
public static String getText(InputStream is)
public static String getText(InputStream is, String charset)
public static String getText(Reader reader)
file
- a Filetext
- the text to write to the File
public static String getText(BufferedReader reader)
* @param self the source string public static String getText(Process self)
public static String getTimeString(Date self)
public static Collection grep(Object self, Object filter)
isCase(java.lang.Object, java.lang.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 object (using the isCase(java.lang.Object, java.lang.Object) method)
protected static void groupAnswer(Map answer, T element, Object value)
answer
- the map containing the resultselement
- the element to be placedvalue
- the value according to which the element will be placed
public static Map groupBy(Collection self, Closure closure)
public static Map groupBy(Map self, Closure closure)
public static Map groupEntriesBy(Map self, Closure closure)
public static boolean hasGroup(Matcher matcher)
public static MetaProperty hasProperty(Object self, String name)
public static T head(List self)
def list = [3, 4, 2] assert list.tail() == [4, 2] assert list == [3, 4, 2]
self
- a List
public static T head(T[] self)
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 inject(Collection self, Object value, Closure closure)
public static Object inject(Iterator self, Object value, Closure closure)
public static Object inject(Object self, Object value, Closure closure)
public static Object inject(Object[] self, Object initialValue, Closure closure)
public static String inspect(Object self)
self
- any Object
public static Number intdiv(Character left, Number right)
public static Number intdiv(Number left, Character right)
public static Number intdiv(Character left, Character right)
left
- a Numberright
- another Number to mod
public static Number intdiv(Number left, Number right)
-10
left
- a Number
public static Collection intersect(Collection left, Collection right)
public static Map intersect(Map left, Map right)
true
if the intersection of two collections is empty.
assert [1,2,3].disjoint([3,4,5]) == false
assert [1,2].disjoint([3,4]) == true
left
- a Collectionright
- a Collectiontrue
if the intersection of two collections
is empty, false
otherwise.
public 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 is(Object self, Object other)
def same = this.is(that)
self
- an objectother
- an object to compare identity with
public static boolean isAllWhitespace(String self)
public static boolean isBigDecimal(String self)
public static boolean isBigInteger(String self)
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)
public static boolean isCase(Collection caseValue, Object switchValue)
switch( 3 ) { case [1,3,5]: assert true break default: assert false }
caseValue
- the case valueswitchValue
- the switch value
public static boolean isCase(Map caseValue, Object switchValue)
public static boolean isCase(Pattern caseValue, Object switchValue)
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 boolean isDigit(Character self)
public static boolean isDouble(String self)
public static boolean isFloat(String self)
self
- a Character
public static boolean isInteger(String self)
public static boolean isLetter(Character self)
public static boolean isLetterOrDigit(Character self)
public static boolean isLong(String self)
self
- a Character
public static boolean isLowerCase(Character self)
public static boolean isNumber(String self)
self
- a Number
public static boolean isUpperCase(Character self)
self
- a Number
public static boolean isWhitespace(Character self)
public static Iterator iterator(T[] a)
self
- an InputStream object
public static Iterator iterator(Object o)
public static Iterator iterator(Enumeration enumeration)
public static Iterator iterator(Matcher matcher)
self
- a file object
public static Iterator iterator(Reader self)
Returns an object satisfying Groovy truth if the implementing MetaClass responds to a method with the given name and arguments types.
Note that this method's return value is based on realised methods and does not take into account objects or classes that implement invokeMethod or methodMissing
This method is "safe" in that it will always return a value and never throw an exception
self
- The object to inspectname
- The name of the method of interestargTypes
- The argument types to match against
public static Iterator iterator(InputStream self)
public static Iterator iterator(DataInputStream self)
public static Iterator iterator(File self)
public static Iterator iterator(Iterator self)
@Deprecated public static Iterator iterator(def nodeList)
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)
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 T last(List self)
public static T last(T[] self)
public static Collection leftShift(Collection self, T value)
self
- a Mapentry
- a Map.Entry to be added to the Map.
public static BlockingQueue leftShift(BlockingQueue self, T value)
public static Map leftShift(Map self, def entry)
public static Map leftShift(Map self, Map other)
self
- a StringBuffervalue
- a value to append
public static StringBuffer leftShift(String self, Object value)
public static StringBuffer leftShift(StringBuffer self, Object value)
self
- a Number objectoperand
- the shift distance by which to right shift the number
public static Writer leftShift(Writer self, Object value)
self
- a Number objectoperand
- the shift distance by which to right shift (unsigned) the number
public static Number leftShift(Number self, Number operand)
self
- a Writerwritable
- an object implementing the Writable interface
public static Writer leftShift(OutputStream self, Object value)
public static void leftShift(ObjectOutputStream self, Object value)
public static OutputStream leftShift(OutputStream self, InputStream in)
array
- a byte arrayrange
- a range indicating the indices for the items to retrieve
public static OutputStream leftShift(OutputStream self, byte[] value)
array
- a char arrayrange
- a range indicating the indices for the items to retrieve
public static File leftShift(File file, Object text)
public static File leftShift(File file, byte[] bytes)
public static File leftShift(File file, InputStream data)
public static Writer leftShift(Socket self, Object value)
self
- a GStringc
- the desired class
public static OutputStream leftShift(Socket self, byte[] value)
each(m, closure); public static Writer leftShift(Process self, Object value)
* @param self the iteration object over which to iterate public static OutputStream leftShift(Process self, byte[] value)
public static boolean matches(String self, Pattern pattern)
public static def max(Map self, Closure closure)
public static T max(Collection self)
self
- an Iterator
public static T max(Iterator self)
self
- an Object array
public static T max(T[] self)
public static T max(Collection self, Closure closure)
public static T max(Iterator self, Closure closure)
self
- an Iteratorclosure
- a Closure used to determine the correct ordering
public static T max(T[] self, Closure closure)
assert "hello" == ["hello","hi","hey"].max( { a, b -> a.length() <=> b.length() } as Comparator )
self
- a Collectioncomparator
- a Comparator
public static T max(Collection self, Comparator comparator)
public static T max(Iterator self, Comparator comparator)
self
- an Object arraycomparator
- a Comparator
public static T max(T[] self, Comparator comparator)
size()
method for Iterator
.
The iterator will become exhausted of elements after determining the size value.
self
- an Iterator
public static MetaClass metaClass(Class self, Closure closure)
public static MetaClass metaClass(Object self, Closure closure)
self
- a Reader object
public static T min(Collection self)
assert 2 == [4,2,5].min()
self
- a Collection
public static T min(Iterator self)
self
- an Object array
public static T min(T[] self)
assert "hi" == ["hello","hi","hey"].min( { a, b -> a.length() <=> b.length() } as Comparator )
self
- a Collectioncomparator
- a Comparator
public static T min(Collection self, Comparator comparator)
public static T min(Iterator self, Comparator comparator)
self
- an Object arraycomparator
- a Comparator
public static T min(T[] self, Comparator comparator)
public static T min(Collection self, Closure closure)
public static def min(Map self, Closure closure)
def zoo = [monkeys:6, lions:5, tigers:7] def leastCommonEntry = zoo.min{ it.value } assert leastCommonEntry.value == 5 def mostCommonEntry = zoo.min{ a, b -> b.value <=> a.value } // double negative! assert mostCommonEntry.value == 7Edge case for multiple min values:
def zoo = [monkeys:6, lions:5, tigers:7] def lastCharOfName = { e -> e.key[-1] } def ans = zoo.min(lastCharOfName) // some random entry assert lastCharOfName(ans) == 's'
self
- a Mapclosure
- a 1 or 2 arg Closure used to determine the correct ordering
public static T min(Iterator self, Closure closure)
public static T min(T[] self, Closure closure)
assert 5 == [2,3,1,5,4].max()
self
- a Collection
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
- an object arrayremoveMe
- an array of elements to remove
public static T[] minus(T[] self, Collection removeMe)
assert [1, "a", true, true, false, 5.3] - [true, 5.3] == [1, "a", false]
self
- a ListremoveMe
- a Collection of elements to remove
if (Number.class.isInstance(t)) { public static T[] minus(T[] self, T[] removeMe)
public static List minus(List self, Collection removeMe)
public static List minus(List self, Object operand)
assert ["a", 5, 5, true] - 5 == ["a", true]
self
- a List objectoperand
- an element to remove from the list
public static T[] minus(T[] self, Object operand)
assert [1,2,3,4,5] == [1,[2,3],[[4]],[],5].flatten()
self
- a Collection to flatten
public static Map minus(Map self, Map operands)
self
- an Array to flatten
public static String minus(String self, Object target)
self
as a command-line process.
For more control over Process construction you can use
java.lang.ProcessBuilder
(JDK 1.5+).
self
- a command line String
public static Number minus(Character left, Number right)
public static Number minus(Number left, Character right)
public static Number minus(Character left, Character right)
self
- a BigDecimalexponent
- an Integer exponent
public static Date minus(Date self, int days)
public static def minus(def self, int days)
public static int minus(Calendar self, Calendar then)
public static int minus(Date self, Date then)
public static void mixin(MetaClass self, List categoryClasses)
self
- any ClasscategoryClasses
- a category classes to use
public static void mixin(Class self, List categoryClasses)
self
- any ClasscategoryClasses
- a category classes to use
public static void mixin(Class self, Class categoryClass)
self
- any ClasscategoryClass
- a category class to use
public static void mixin(Class self, Class[] categoryClass)
self
- any ClasscategoryClass
- a category class to use
public static void mixin(MetaClass self, Class categoryClass)
self
- any ClasscategoryClass
- a category class to use
public static void mixin(MetaClass self, Class[] categoryClass)
self
- any ClasscategoryClass
- a category class to use
public static Number mod(Number left, Number right)
public static List multiply(Collection self, Number factor)
public static String multiply(String self, Number factor)
self
- a Map
public static Number multiply(Character left, Number right)
public static Number multiply(Number left, Character right)
public static Number multiply(Character left, Character right)
public static Number multiply(BigDecimal left, Double right)
self
- a Longexponent
- an Integer exponent
public static Number multiply(BigDecimal left, BigInteger right)
left
- a Characterright
- a Number
public static DataInputStream newDataInputStream(File file)
public static DataOutputStream newDataOutputStream(File file)
public static BufferedInputStream newInputStream(File file)
url
- url to iterate overclosure
- closure to apply to each byte
public static BufferedInputStream newInputStream(URL url)
public static T newInstance(Class c)
self
- the object whose metaclass we wish to updateclosure
- the closure representing the new metaclass
public static T newInstance(Class c, Object[] args)
public static ObjectInputStream newObjectInputStream(File file)
public static ObjectInputStream newObjectInputStream(InputStream inputStream)
public static ObjectInputStream newObjectInputStream(InputStream inputStream, ClassLoader classLoader)
public static ObjectInputStream newObjectInputStream(File file, ClassLoader classLoader)
self
- a StringfirstLine
- the line number value used for the first line (default is 1, set to 0 to start counting from 0)closure
- a closure (arg 1 is line, optional arg 2 is line number)
public static ObjectOutputStream newObjectOutputStream(File file)
ois
- an ObjectInputStream, closed after the operationclosure
- a closure
public static ObjectOutputStream newObjectOutputStream(OutputStream outputStream)
public static BufferedOutputStream newOutputStream(File file)
public static PrintWriter newPrintWriter(File file)
public static PrintWriter newPrintWriter(File file, String charset)
public static PrintWriter newPrintWriter(Writer writer)
public static BufferedReader newReader(File file)
file
- a Fileclosure
- a closure
public static BufferedReader newReader(File file, String charset)
file
- a File
public static BufferedReader newReader(InputStream self)
public static BufferedReader newReader(InputStream self, String charset)
file
- a Filecharset
- the name of the encoding used to write in this fileappend
- true if in append mode
public static BufferedReader newReader(URL url)
public static BufferedReader newReader(URL url, String charset)
public static BufferedWriter newWriter(File file)
writer
- a writer
public static BufferedWriter newWriter(File file, boolean append)
file
- a Fileclosure
- the closure to invoke with the PrintWriter
public static BufferedWriter newWriter(File file, String charset, boolean append)
file
- a Filecharset
- the charsetclosure
- the closure to invoke with the PrintWriter
public static BufferedWriter newWriter(File file, String charset)
writer
- a writerclosure
- the closure to invoke with the PrintWriter
public static String next(String self)
String
array.
The first item in the array is the command; the others are the parameters.
For more control over Process construction you can use
java.lang.ProcessBuilder
(JDK 1.5+).
commandArray
- an array of String containing the command name and
parameters as separate items in the array.
public static Character next(Character self)
public static Number next(Number self)
public static Date next(Date self)
public static def next(def self)
public static String normalize(String self)
self
- a URL
public static int numberAwareCompareTo(Comparable self, Comparable other)
self
- a Comparableother
- another Comparable
public static Number or(Number left, Number right)
public static BitSet or(BitSet left, BitSet right)
self
- a Longto
- the end numberclosure
- the code to execute for each number
public static Boolean or(Boolean left, Boolean right)
file
- a fileclassLoader
- the class loader to use when loading the class
Class current = self.getClass(); public static Process or(Process left, Process right)
public static String padLeft(String self, Number numberOfChars, String padding)
public static String padLeft(String self, Number numberOfChars)
['A', 'BB', 'CCC', 'DDDD'].each{ println it.padRight(5, '#') + it.size() }will produce output like:
A####1 BB###2 CCC##3 DDDD#4
self
- a String objectnumberOfChars
- the total minimum number of characters of the resulting stringpadding
- the charaters used for padding
public static String padRight(String self, Number numberOfChars, String padding)
public static String padRight(String self, Number numberOfChars)
['A', 'BB', 'CCC', 'DDDD'].each{ println '|' + it.center(6, '+') + '|' }will produce output like:
|++A+++| |++BB++| |+CCC++| |+DDDD+|
self
- a String objectnumberOfChars
- the total minimum number of characters of the resulting stringpadding
- the charaters used for padding
public static Set permutations(List self)
while (true) { public static Process pipeTo(Process left, Process right)
public static Map plus(Map left, Map right)
self
- a Mapkey
- an Object as a key for the mapvalue
- the value to put into the map
public static Map plus(Map self, Collection entries)
public static Collection plus(Collection left, Collection right)
public static Collection plus(Collection left, T right)
public static String plus(String left, Object value)
public static String plus(Number value, String right)
public static String plus(StringBuffer left, String value)
public static Number plus(Character left, Number right)
left
- a Numberright
- a Character
public static Number plus(Number left, Character right)
left
- a Characterright
- a Character
public static Number plus(Character left, Character right)
left
- a Characterright
- a Number
public static Date plus(Date self, int days)
public static def plus(def self, int days)
public static T pop(List self)
public static Number power(Number self, Number exponent)
public static Number power(BigDecimal self, Integer exponent)
left
- a Characterright
- another Character
public static Number power(BigInteger self, Integer exponent)
public static Number power(Integer self, Integer exponent)
left
- a Characterright
- another Character
public static Number power(Long self, Integer exponent)
left
- a Numberright
- another Number
public static String previous(String self)
String
array given in the first parameter,
with the environment defined by envp
and under the working directory dir
.
The first item in the array is the command; the others are the parameters.
For more control over Process construction you can use
java.lang.ProcessBuilder
(JDK 1.5+).
commandArray
- an array of String containing the command name and
parameters as separate items in the array.
envp
- an array 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.
public static Character previous(Character self)
left
- a Numberright
- another Number to compare to
public static Number previous(Number self)
public static Date previous(Date self)
public static def previous(def self)
protected static Object primitiveArrayGet(Object self, int idx)
protected static List primitiveArrayGet(Object self, Range range)
protected static List primitiveArrayGet(Object self, Collection indices)
assert 'h'.capitalize() == 'H' assert 'hello'.capitalize() == 'Hello' assert 'hello world'.capitalize() == 'Hello world' assert 'Hello World' == 'hello world'.split(' ').collect{ it.capitalize() }.join(' ')
self
- The string to capitalize
protected static Object primitiveArrayPut(Object self, int idx, Object newValue)
self
- A String to expand
public static void print(Object self, Object value)
self
- any Objectvalue
- the value to print
public static void print(PrintWriter self, Object value)
self
- a PrintWritervalue
- the value to print
public static void print(PrintStream self, Object value)
self
- a PrintStreamvalue
- the value to print
public static void print(Closure self, Object value)
self
- a generated closurevalue
- the value to print
public static void print(Object self, PrintWriter out)
self
- any Objectout
- the PrintWriter used for printing
public 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 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 void println(Object self)
self
- any Object
public static void println(Closure self)
self
- a closure
public static void println(Object self, Object value)
self
- any Objectvalue
- the value to print
public static void println(PrintWriter self, Object value)
self
- a PrintWritervalue
- the value to print
public static void println(PrintStream self, Object value)
self
- any Objectvalue
- the value to print
public static void println(Closure self, Object value)
self
- a closurevalue
- the value to print
public static void println(Object self, PrintWriter out)
self
- any Objectout
- the PrintWriter used for printing
public static boolean push(List self, T value)
public static Map putAll(Map self, Collection entries)
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 set
public static void putAt(List self, int idx, T value)
self
- a StringBufferrange
- a Rangevalue
- the object that's toString() will be inserted
public static void putAt(StringBuffer self, IntRange range, Object value)
self
- a StringBufferrange
- a Rangevalue
- the object that's toString() will be inserted
public static void putAt(StringBuffer self, EmptyRange range, Object value)
public static void putAt(List self, EmptyRange range, Object value)
def list = ["a", true] list[1..<1] = [4, 3, 2] assert list == ["a", 4, 3, 2, true]
self
- a Listrange
- the (in this case empty) subset of the list to setvalue
- the Collection of values
public static void putAt(List self, EmptyRange range, Collection value)
public static void putAt(List self, IntRange range, Collection col)
def myList = [4, 3, 5, 1, 2, 8, 10] myList[3..5] = "b" assert myList == [4, 3, 5, "b", 10]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 sublist
public static void putAt(List self, IntRange range, Object value)
public static void putAt(List self, List splice, List values)
public static void putAt(List self, List splice, Object value)
public static V putAt(Map self, K key, V value)
public static void putAt(BitSet self, IntRange range, boolean value)
self
- a BitSetrange
- the range of values to setvalue
- value
public static void putAt(BitSet self, int index, boolean value)
array
- a byte array
public static byte[] readBytes(File file)
public static String readLine(Reader self)
public static List readLines(String self)
url
- URL to read content from
public static List readLines(File file)
public static List readLines(File file, String charset)
public static List readLines(InputStream stream)
public static List readLines(InputStream stream, String charset)
public static List readLines(URL self)
public static List readLines(URL self, String charset)
public static List readLines(Reader reader)
public static boolean removeAll(Collection self, T[] items)
public static boolean removeAll(Collection self, Closure closure)
self
- a Collection to be modifiedclosure
- a closure condition
public static boolean renameTo(File self, String newPathName)
file
- a Fileclosure
- a closure
public static String replaceAll(String self, Pattern pattern, String replacement)
public static String replaceAll(String self, String regex, Closure closure)
For example (with some replaceAll variants thrown in for comparison purposes),
assert "hellO world" == "hello world".replaceFirst("(o)") { it[0].toUpperCase() } // first match assert "hellO wOrld" == "hello world".replaceAll("(o)") { it[0].toUpperCase() } // all matches assert '1-FISH, two fish' == "one fish, two fish".replaceFirst(/([a-z]{3})\s([a-z]{4})/) { [one:1, two:2][it[1]] + '-' + it[2].toUpperCase() } assert '1-FISH, 2-FISH' == "one fish, two fish".replaceAll(/([a-z]{3})\s([a-z]{4})/) { [one:1, two:2][it[1]] + '-' + it[2].toUpperCase() }
self
- a Stringregex
- the capturing regexclosure
- the closure to apply on the first captured group
public static String replaceAll(String self, Pattern pattern, Closure closure)
public static String replaceFirst(String self, Pattern pattern, String replacement)
Note that backslashes (\) and dollar signs ($) in the replacement string may cause the results to be different than if it were being treated as a literal replacement string; see Matcher.replaceAll. Use Matcher.quoteReplacement to suppress the special meaning of these characters, if desired.
self
- the string that is to be matchedpattern
- the regex Pattern to which the string of interest is to be matchedreplacement
- the string to be substituted for the first match
public static String replaceFirst(String self, String regex, Closure closure)
matcher
- the matcher object used for matchingclosure
- specified with replaceAll() to get replacement
public static String replaceFirst(String self, Pattern pattern, Closure closure)
public static List respondsTo(Object self, String name, Object[] argTypes)
public static List respondsTo(Object self, String name)
public static boolean retainAll(Collection self, T[] items)
public static boolean retainAll(Collection self, Closure closure)
* true
for all items in this data structure).
public static T[] reverse(T[] self)
public static String reverse(String self)
self
- a String
public static List reverse(List self)
self
- an Iterator
public static Iterator reverse(Iterator self)
public static Map reverseEach(Map self, Closure closure)
self
- the map over which we iterateclosure
- the 1 or 2 arg closure applied on each entry of the map
public static List reverseEach(List self, Closure closure)
def result = [] [1,2,3].reverseEach { result << it } assert result == [3,2,1]
self
- a Listclosure
- a closure to which each item is passed.
public static T[] reverseEach(T[] self, Closure closure)
public static Number rightShift(Number self, Number operand)
self
- an OutputStreamvalue
- a value to append
public static Number rightShiftUnsigned(Number self, Number operand)
self
- an ObjectOutputStreamvalue
- an object to write to the stream
public static int round(Float number)
public static float round(Float number, int precision)
public static long round(Double number)
self
- a String
public static double round(Double number, int precision)
public static TimerTask runAfter(Timer timer, int delay, Closure closure)
public static void setBytes(File file, byte[] bytes)
file
- a Filetext
- the text to append at the end of the File
public static void setBytes(OutputStream os, byte[] bytes)
public static void setIndex(Matcher matcher, int idx)
public static void setMetaClass(Class self, MetaClass metaClass)
public static void setMetaClass(Object self, MetaClass metaClass)
matcher
- a Matcher object
public static void setText(File file, String text)
file
- a Filetext
- the text to append at the end of the Filecharset
- the charset used
public static void setText(File file, String text, String charset)
dir
- The directory to check
public static int size(Iterator self)
public static int size(String text)
size()
method for StringBuffer
.
buffer
- a StringBuffer
public static int size(StringBuffer buffer)
size()
method for File
.
self
- a file object
public static long size(File self)
size()
method for Matcher
.
self
- a matcher object
public static long size(Matcher self)
size()
method for an array.
self
- an Array of objects
public static int size(Object[] self)
text
- a CharSequenceindex
- the index of the Character to get
public static int size(boolean[] array)
public static int size(byte[] array)
public static int size(char[] array)
array
- a short array
public static int size(short[] array)
array
- an int array
public static int size(int[] array)
public static int size(long[] array)
public static int size(float[] array)
public static int size(double[] array)
public static List sort(Collection self)
public static Map sort(Map self, Closure closure)
public static Map sort(Map self, Comparator comparator)
self
- the array to be sorted
public static Map sort(Map self)
self
- the Iterator to be sorted
public static T[] sort(T[] self)
self
- the Iterator to be sortedcomparator
- a Comparator used for comparing items
public static Iterator sort(Iterator self)
assert ["hi","hey","hello"] == ["hello","hi","hey"].sort( { a, b -> a.length() <=> b.length() } as Comparator )
assert ["hello","Hey","hi"] == ["hello","hi","Hey"].sort(String.CASE_INSENSITIVE_ORDER)
self
- a collection to be sortedcomparator
- a Comparator used for the comparison
public static Iterator sort(Iterator self, Comparator comparator)
self
- the array to be sortedcomparator
- a Comparator used for the comparison
public static List sort(Collection self, Comparator comparator)
public static T[] sort(T[] self, Comparator comparator)
public static Iterator sort(Iterator self, Closure closure)
Collections.sort(list, new OrderBy(closure)); public static T[] sort(T[] self, Closure closure)
public static List sort(Collection self, Closure closure)
self
- an identity function for an already sorted set
public static SortedSet sort(SortedSet self)
self
- a Mapentries
- a Collection of Map.Entry items to be added to the Map.
public static Collection split(Object self, Closure closure)
public static Collection split(Collection self, Closure closure)
public static String[] split(String self)
self
- A String to unexpandtabStop
- The number of spaces a tab represents
public static String[] split(GString self)
self
- a Stringtarget
- an object representing the part to remove
public static Object splitEachLine(File self, String regex, Closure closure)
self
- a URL to open and readregex
- the delimiting regular expressioncharset
- opens the file with a specified charsetclosure
- a closure
public static Object splitEachLine(File self, Pattern pattern, Closure closure)
public static Object splitEachLine(File self, String regex, String charset, Closure closure)
public static Object splitEachLine(File self, Pattern pattern, String charset, Closure closure)
public static Object splitEachLine(URL self, String regex, Closure closure)
public static Object splitEachLine(URL self, Pattern pattern, Closure closure)
public static Object splitEachLine(URL self, String regex, String charset, Closure closure)
public static Object splitEachLine(URL self, Pattern pattern, String charset, Closure closure)
public static Object splitEachLine(Reader self, String regex, Closure closure)
stream
- an InputStreampattern
- the regular expression Pattern for the delimiterclosure
- a closure
public static Object splitEachLine(Reader self, Pattern pattern, Closure closure)
self
- a Stringpattern
- the regular expression Pattern for the delimiterclosure
- a closure
public static Object splitEachLine(InputStream stream, String regex, String charset, Closure closure)
self
- a Reader
public static Object splitEachLine(InputStream stream, Pattern pattern, String charset, Closure closure)
public static Object splitEachLine(InputStream stream, String regex, Closure closure)
public static Object splitEachLine(InputStream stream, Pattern pattern, Closure closure)
public static Object splitEachLine(String self, String regex, Closure closure)
public static Object splitEachLine(String self, Pattern pattern, Closure closure)
public static SpreadMap spread(Map self)
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 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 void step(Number self, Number to, Number stepNumber, Closure closure)
number
- a Double
public static String stripIndent(String self)
public static String stripIndent(String self, int numChars)
public static String stripMargin(String self)
Strip leading whitespace/control characters followed by marginChar from every line in a String.
self
- The String to strip the margin frommarginChar
- Any character that serves as margin delimiter
public static String stripMargin(String self, String marginChar)
public static String stripMargin(String self, char marginChar)
public static Map subMap(Map map, Collection keys)
def map=[:] map.get("a", []) << 5 assert map == [a:[5]]
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 Set subsequences(List self)
public static Object sum(Collection self)
self
- The array of values to add together
public static Object sum(Object[] self)
self
- an Iterator for the values to add together
public static Object sum(Iterator self)
assert 5+1+2+3+4 == [1,2,3,4].sum(5)
self
- a collection of values to suminitialValue
- the items in the collection will be summed to this initial value
public static Object sum(Collection self, Object initialValue)
self
- an array of values to suminitialValue
- the items in the array will be summed to this initial value
public static Object sum(Object[] 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(Iterator self, Object initialValue)
public static Object sum(Collection self, Closure closure)
coll.sum(closure)
is equivalent to:
coll.collect(closure).sum()
.
assert 4+6+10+12 == [2,3,5,6].sum() { it * 2 }
self
- a Collectionclosure
- a single parameter closure that returns a numeric value.
public static Object sum(Object[] self, Closure closure)
public static Object sum(Iterator self, Closure closure)
public static Object sum(Collection self, Object initialValue, Closure closure)
public static Object sum(Object[] self, Object initialValue, Closure closure)
public static Object sum(Iterator self, Object initialValue, Closure closure)
public static List tail(List self)
public static T[] tail(T[] self)
Example usage:
assert new HashSet().asList() instanceof List
self
- a collection to be converted into a List
public static void times(Number self, Closure closure)
self
- a doubleto
- the end numberclosure
- the code to execute for each number
public static String toArrayString(Object[] self)
public static BigDecimal toBigDecimal(String self)
self
- a Character
public static BigDecimal toBigDecimal(Number self)
file
- a file
public static BigInteger toBigInteger(String self)
public static BigInteger toBigInteger(Number self)
file
- a file
public static Boolean toBoolean(String self)
self
- A line to expandtabStop
- The number of spaces a tab represents
public static Boolean toBoolean(Boolean self)
self
- A String to unexpand
public static Character toCharacter(String self)
public static Double toDouble(String self)
public static Double toDouble(Number self)
public static Float toFloat(String self)
public static Float toFloat(Number self)
public static Integer toInteger(String self)
public static Integer toInteger(Number self)
public static List toList(Collection self)
public static List toList(Iterator self)
public static List toList(Enumeration self)
self
- an enumeration
public static List toList(T[] array)
/** public static List toList(byte[] array)
self
- an array objectidx
- the index of interest
} public static List toList(boolean[] array)
self
- an array objectrange
- the range of indices of interest
*/ public static List toList(char[] array)
return answer; public static List toList(short[] array)
Array.set(self, normaliseIndex(idx, Array.getLength(self)), newValue); public static List toList(int[] array)
self
- an objectidx
- the index of interestnewValue
- the new value to be put into the index of interest
* @since 1.0 public static List toList(long[] array)
* @since 1.0 public static List toList(float[] array)
* Identity conversion which returns Boolean.TRUE for a true Boolean and Boolean.FALSE for a false Boolean. public static List toList(double[] array)
public static List toList(String self)
public static String toListString(Collection self)
public static String toListString(Collection self, int maxSize)
left
- a Numberright
- a Character
public static Long toLong(String self)
public static Long toLong(Number self)
public static char toLowerCase(Character self)
self
- a Number
public static String toMapString(Map self)
self
- a Number
public static String toMapString(Map self, int maxSize)
self
- a Character
@Deprecated public static def toRowResult(def rs)
public static Short toShort(String self)
self
- a String
public static SpreadMap toSpreadMap(Map self)
self
- an object array
public static SpreadMap toSpreadMap(Object[] self)
public static String toString(boolean[] self)
[one:1, two:2, three:3]
.
self
- a MapmaxSize
- stop after approximately this many characters and append '...'
public static String toString(byte[] self)
public static String toString(char[] self)
public static String toString(short[] self)
public static String toString(int[] self)
public static String toString(long[] self)
self
- an Object[]
public static String toString(float[] self)
{1, 2, "a"}
.
self
- an Object[]
public static String toString(double[] self)
value
- an object
public static String toString(AbstractMap self)
self
- a Character
public static String toString(AbstractCollection self)
self
- a Number
public static String toString(Object[] self)
public static String toString(Object value)
public static URI toURI(String self)
public static URL toURL(String self)
self
- a String to convert into a regular expression
public static char toUpperCase(Character self)
public static List tokenize(String self, String token)
public static List tokenize(String self, Character token)
public static List tokenize(String self)
public static String tr(String self, String sourceSet, String replacementSet)
self
- the string that is to be matchedpattern
- the regex Pattern to which the string of interest is to be matched
public static void transformChar(Reader self, Writer writer, Closure closure)
public static void transformLine(Reader reader, Writer writer, Closure closure)
public static List transpose(List self)
public static void traverse(File self, Map options, Closure closure)
self
- a Fileclosure
- a closure
public static void traverse(File self, Closure closure)
public static void traverse(File self, Map options)
public static float trunc(Float number, int precision)
self
- a String
public static float trunc(Float number)
self
- a String
public static double trunc(Double number)
public static double trunc(Double number, int precision)
self
- a String
public static Number unaryMinus(Number left)
public static String unexpand(String self)
self
- a String
public static String unexpand(String self, int tabStop)
left
- a Stringvalue
- any Object
public static String unexpandLine(String self, int tabStop)
value
- a Numberright
- a String
public static Iterator unique(Iterator self)
public static Collection unique(Collection self)
public static Iterator unique(Iterator self, Closure closure)
public static Collection unique(Collection self, Closure closure)
public static Iterator unique(Iterator self, Comparator comparator)
self
- an Iteratorcomparator
- a Comparator
public static Collection unique(Collection self, Comparator comparator)
public static void upto(Number self, Number to, Closure closure)
self
- a Doubleto
- the end numberclosure
- the code to execute for each number
public static void upto(long self, Number to, Closure closure)
public static void upto(Long self, Number to, Closure closure)
public static void upto(float self, Number to, Closure closure)
public static void upto(Float self, Number to, Closure closure)
public static void upto(double self, Number to, Closure closure)
public static void upto(Double self, Number to, Closure closure)
public static void upto(BigInteger self, Number to, Closure closure)
self
- a longto
- the end numberclosure
- the code to execute for each number
public static void upto(BigDecimal self, Number to, Closure closure)
self
- a floatto
- the end numberclosure
- the code to execute for each number
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 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 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 waitForOrKill(Process self, long numberOfMillis)
* @param self the iteration object over which to iterate public static void waitForProcessOutput(Process self)
public static void waitForProcessOutput(Process self, StringBuffer output, StringBuffer error)
* @param closure the filter to perform a match on the collection public static void waitForProcessOutput(Process self, OutputStream output, OutputStream error)
public static Object with(Object self, Closure closure)
def b = new StringBuilder().with { append('foo') append('bar') return it } assert b.toString() == 'foobar'This is commonly used to simplify object creation, such as this example:
def p = new Person().with { firstName = 'John' lastName = 'Doe' return it }
self
- the object to have a closure act uponclosure
- the closure to call on the object
public static Object withDataInputStream(File file, Closure closure)
file
- a Filecharset
- the charset
public static Object withDataOutputStream(File file, Closure closure)
file
- a File
public static Map withDefault(Map self, Closure init)
assert [1,2,3] == [3,1,2].sort()
self
- the collection to be sorted
public static Object withInputStream(File file, Closure closure)
public static Object withInputStream(URL url, Closure closure)
public static Object withObjectInputStream(File file, Closure closure)
self
- a FilefirstLine
- the line number value used for the first line (default is 1, set to 0 to start counting from 0)closure
- a closure (arg 1 is line, optional arg 2 is line number)
public static Object withObjectInputStream(File file, ClassLoader classLoader, Closure closure)
self
- a Filecharset
- opens the file with a specified charsetfirstLine
- the line number value used for the first line (default is 1, set to 0 to start counting from 0)closure
- a closure (arg 1 is line, optional arg 2 is line number)
public static Object withObjectInputStream(InputStream inputStream, Closure closure)
stream
- a streamcharset
- opens the stream with a specified charsetclosure
- a closure (arg 1 is line, optional arg 2 is line number starting at line 1)
public static Object withObjectInputStream(InputStream inputStream, ClassLoader classLoader, Closure closure)
stream
- a streamcharset
- opens the stream with a specified charsetfirstLine
- the line number value used for the first line (default is 1, set to 0 to start counting from 0)closure
- a closure (arg 1 is line, optional arg 2 is line number)
public static Object withObjectOutputStream(File file, Closure closure)
public static Object withObjectOutputStream(OutputStream outputStream, Closure closure)
public static Object withObjectStreams(Socket socket, Closure closure)
self
- a String
public static Object withOutputStream(File file, Closure closure)
* different classloaders. public static void withOutputStream(Process self, Closure closure)
public static Object withPrintWriter(File file, Closure closure)
public static Object withPrintWriter(File file, String charset, Closure closure)
public static Object withPrintWriter(Writer writer, Closure closure)
public static Object withReader(File file, Closure closure)
public static Object withReader(File file, String charset, Closure closure)
public static Object withReader(Reader reader, Closure closure)
file
- a File
public static Object withReader(URL url, Closure closure)
file
- a File
public static Object withReader(URL url, String charset, Closure closure)
public static Object withReader(InputStream in, Closure closure)
public static Object withReader(InputStream in, String charset, Closure closure)
self
- a byte arrayclosure
- a closure
public static Object withStream(InputStream stream, Closure closure)
url
- a URL
public static Object withStream(OutputStream os, Closure closure)
public static Object withStreams(Socket socket, Closure closure)
f
- a Filec
- the desired class
public static Object withWriter(File file, Closure closure)
reader
- the reader which is used and then closedclosure
- the closure that the writer is passed into
public static Object withWriter(File file, String charset, Closure closure)
public static Object withWriter(Writer writer, Closure closure)
public static Object withWriter(OutputStream stream, Closure closure)
is
- stream to iterate over, closed after the method callclosure
- closure to apply to each byte
public static Object withWriter(OutputStream stream, String charset, Closure closure)
return result; public static void withWriter(Process self, Closure closure)
public static Object withWriterAppend(File file, String charset, Closure closure)
public static Object withWriterAppend(File file, Closure closure)
url
- a URLclosure
- the closure to invoke with the reader
public static void write(Writer self, Writable writable)
self
- stream on which to writein
- stream to read from
public static void write(File file, String text)
public static void write(File file, String text, String charset)
public static void writeLine(BufferedWriter writer, String line)
file
- a Filebytes
- the byte array to append to the end of the File
public static BitSet xor(BitSet left, BitSet right)
public static Number xor(Number left, Number right)
public static Boolean xor(Boolean left, Boolean right)
self
- a Fileclosure
- a closure
Copyright © 2003-2010 The Codehaus. All rights reserved.