Groovy 1.8.7

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

java.lang.Object
  org.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.

Authors:
James Strachan
Jeremy Rayner
Sam Pullara
Rod Cope
Guillaume Laforge
John Wilson
Hein Meling
Dierk Koenig
Pilho Kim
Marc Guillemot
Russel Winder
bing ran
Jochen Theodorou
Paul King
Michael Baehr
Joachim Baumann
Alex Tkachman
Ted Naleid
Brad Long
Jim Jagielski
Rodolfo Velasco
jeremi Joslin
Hamlet D'Arcy
Cedric Champeau
Tim Yates
Dinko Srkoc
Andre Steingress


Field Summary
static Class[] additionals

 
Method Summary
static int abs(Number number)

Truncate the value

static long abs(Long number)

Parse a String into an Integer

static float abs(Float number)

Parse a String into a Long

static double abs(Double number)

Parse a String into a Short

static Socket accept(ServerSocket serverSocket, Closure closure)

Converts the GString to a File, or delegates to the default asType(java.lang.Object, java.lang.Class)

static Socket accept(ServerSocket serverSocket, boolean runInANewThread, Closure closure)

static boolean addAll(Collection self, Object[] items)

Modifies the collection by adding all of the elements in the specified array to the collection.

static boolean addAll(List self, int index, Object[] 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)

static Boolean and(Boolean left, Boolean right)

Create an object input stream for this input stream.

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)

Invokes the closure for each descendant file in this directory.

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)

static boolean asBoolean(Boolean bool)

static boolean asBoolean(Matcher matcher)

static boolean asBoolean(Collection collection)

static boolean asBoolean(Map map)

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)

static boolean asBoolean(Character character)

static boolean asBoolean(Number number)

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)

A convenience method for creating a synchronized Map.

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)

Creates a new List with the identical contents to this list but in reverse order.

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)

static Object asType(GString self, Class c)

static Object asType(String self, Class c)

Iterates over the elements of an iterable collection of items and returns the index of the last item that matches the condition specified in the closure.

static Object asType(CharSequence self, Class c)

Iterates over the elements of an iterable collection of items and returns the index values of the items that match the condition specified in the closure.

static Object asType(Object obj, Class type)

Sets the metaclass for a given class.

static File asWritable(File file)

static File asWritable(File file, String encoding)

static Pattern bitwiseNegate(String self)

static Pattern bitwiseNegate(CharSequence self)

static BitSet bitwiseNegate(BitSet self)

protected static Object callClosureForLine(Closure closure, String line, int counter)

protected static Object callClosureForMapEntry(Closure closure, Map.Entry entry)

protected static Object callClosureForMapEntryAndCounter(Closure closure, Map.Entry entry, int counter)

static String capitalize(String self)

Expands all tabs into spaces.

static CharSequence capitalize(CharSequence self)

Replaces sequences of whitespaces with tabs using tabStops of size 8.

static String center(String self, Number numberOfChars, String padding)

Pad a CharSequence to a minimum length specified by numberOfChars, appending the supplied padding CharSequence around the original as many times as needed keeping it centered.

static CharSequence center(CharSequence self, Number numberOfChars, CharSequence padding)

Pad a String to a minimum length specified by numberOfChars by adding the space character around it as many times as needed so that it remains centered.

static String center(String self, Number numberOfChars)

static CharSequence center(CharSequence self, Number numberOfChars)

static List collate(List self, int size)

static List collate(List self, int size, int step)

static List collate(List self, int size, boolean keepRemainder)

static List collate(List self, int size, int step, boolean keepRemainder)

static List collect(Object self, Closure transform)

Iterates through this aggregate Object transforming each item into a new value using the transform closure, returning a list of transformed values.

static Collection collect(Object self)

static Collection collect(Object self, Collection collector, Closure transform)

static List collect(Collection self, Closure transform)

static List collect(Collection self)

static Collection collect(Collection self, Collection collector, Closure transform)

static Collection collect(Map self, Collection collector, Closure transform)

static List collect(Map self, Closure transform)

static List collectAll(Collection self, Closure transform)

Deprecated alias for collectNested

static Collection collectAll(Collection self, Collection collector, Closure transform)

static Map collectEntries(Map self, Map collector, Closure transform)

static Map collectEntries(Map self, Closure transform)

static Map collectEntries(Collection self, Closure transform)

static Map collectEntries(Collection self)

static Map collectEntries(Collection self, Map collector, Closure transform)

static Map collectEntries(Collection self, Map collector)

static Map collectEntries(Object[] self, Map collector, Closure transform)

static Map collectEntries(Object[] self, Map collector)

static Map collectEntries(Object[] self, Closure transform)

static Map collectEntries(Object[] self)

static List collectMany(Collection self, Closure projection)

Projects each item from a source collection to a collection and concatenates (flattens) the resulting collections into a single list.

static Collection collectMany(Collection self, Collection collector, Closure projection)

static List collectMany(Object[] self, Closure projection)

static List collectMany(Iterator self, Closure projection)

static List collectNested(Collection self, Closure transform)

Deprecated alias for collectNested

static Collection collectNested(Collection self, Collection collector, Closure transform)

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 boolean contains(String self, String text)

Checks whether the array contains the given value.

static boolean contains(CharSequence self, CharSequence text)

Checks whether the array contains the given value.

static boolean contains(int[] self, Object value)

Checks whether the array contains the given value.

static boolean contains(long[] self, Object value)

Count the number of occurrences of a substring.

static boolean contains(short[] self, Object value)

static boolean contains(char[] self, Object value)

static boolean contains(boolean[] self, Object value)

static boolean contains(double[] self, Object value)

static boolean contains(float[] self, Object value)

This method is called by the -- operator for the class String.

static boolean contains(byte[] self, Object value)

static boolean contains(Object[] self, Object value)

static boolean containsAll(Collection self, Object[] items)

static Number count(Iterator self, Object value)

static Number count(Iterator self, Closure closure)

Counts the number of occurrences which satisfy the given closure 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(Collection self, Closure closure)

static Number count(Map self, Closure closure)

static Number count(Object[] self, Object value)

Counts the number of occurrences of the given value inside this array.

static Number count(Object[] self, Closure closure)

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)

static int count(CharSequence self, CharSequence text)

static Map countBy(Collection self, Closure closure)

static Map countBy(Object[] self, Closure closure)

static Map countBy(Iterator self, Closure closure)

static Map countBy(Map self, Closure closure)

Groups the current element according to the value

protected static StringBufferWriter createStringBufferWriter(StringBuffer self)

protected static StringWriter createStringWriter(String self)

static boolean deleteDir(File self)

Creates a new data output stream for this file.

static String denormalize(String self)

static CharSequence denormalize(CharSequence self)

Reads the stream into a list, with one element for each line.

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 BitSets.

static Number div(Number left, Character right)

Bitwise XOR together two BitSets.

static Number div(Character left, Character right)

Bitwise NEGATE a BitSet.

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)

Iterates from this number down to the given number, inclusive, decrementing by one each time.

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 List drop(List self, int num)

Drops the given number of elements from the head of this Iterable.

static List drop(Iterable self, int num)

Drops the given number of elements from the head of this array if they are available.

static Object[] drop(Object[] self, int num)

Drops the given number of key/value pairs from the head of this map if they are available.

static Map drop(Map self, int num)

Drops the given number of elements from the head of this iterator if they are available.

static Iterator drop(Iterator self, int num)

Drops the given number of chars from the head of this CharSequence if they are available.

static CharSequence drop(CharSequence self, int num)

static List dropWhile(List self, Closure condition)

Returns a suffix of this Iterable where elements are dropped from the front while the given closure evaluates to true.

static List dropWhile(Iterable self, Closure condition)

static Map dropWhile(Map self, Closure condition)

Create a suffix of the given array by dropping as many elements as possible from the front of the original array such that calling the given closure condition evaluates to true when passed each of the dropped elements.

static Object[] dropWhile(Object[] self, Closure condition)

Creates an Iterator that returns a suffix of the elements from an original Iterator.

static Iterator dropWhile(Iterator self, Closure condition)

static String dump(Object self)

Generates a detailed dump string of an object showing its class, hashCode and fields.

static Object each(Object 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)

static void eachByte(File self, int bufferLen, Closure closure)

static void eachByte(Byte[] self, Closure closure)

static void eachByte(byte[] self, Closure closure)

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 Writable in return to stream the filtered lines.

static void eachByte(URL url, Closure closure)

Filter the lines from this File, and write them to the given writer based on the given closure predicate.

static void eachByte(URL url, int bufferLen, Closure closure)

Filter the lines from this File, and write them to the given writer based on the given closure predicate.

static void eachDir(File self, Closure closure)

static void eachDirMatch(File self, Object nameFilter, Closure closure)

Create a buffered output stream for this file.

static void eachDirRecurse(File self, Closure closure)

Create a buffered reader for this file.

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)

Create a new BufferedReader for this file and then passes it into the closure, ensuring the reader is closed after the closure returns.

static void eachFileRecurse(File self, FileType fileType, Closure closure)

static void eachFileRecurse(File self, Closure closure)

Renames the file.

static Object eachLine(String self, Closure closure)

static Object eachLine(CharSequence self, Closure closure)

static Object eachLine(String self, int firstLine, Closure closure)

static Object eachLine(CharSequence self, int firstLine, Closure closure)

static Object eachLine(File self, Closure 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)

Iterates through the given reader line by line.

static Object eachLine(InputStream stream, String charset, Closure closure)

Iterates through the given reader line by line.

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)

static Object eachLine(Reader self, Closure closure)

static Object eachLine(Reader self, int firstLine, Closure closure)

Iterates through the input stream associated with this URL line by line, splitting each line using the given regex separator Pattern.

static String eachMatch(String self, String regex, Closure closure)

static String eachMatch(CharSequence self, CharSequence regex, Closure closure)

static String eachMatch(String self, Pattern pattern, Closure closure)

Converts a given object to a type.

static String eachMatch(CharSequence 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 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 equals(Set self, Set other)

static boolean equals(Map self, Map other)

Create a Set composed of the elements of the first Set minus the elements of the given Collection.

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 true according to the Groovy Truth.

static Process execute(String self)

static Process execute(String self, String[] envp, File dir)

static Process execute(String self, List envp, File dir)

static Process execute(String[] commandArray)

static Process execute(String[] commandArray, String[] envp, File dir)

Repeat a String a certain number of times.

static Process execute(String[] commandArray, List envp, File dir)

Repeat a CharSequence a certain number of times.

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)

Replaces sequences of whitespaces with tabs using tabStops of size 8.

static CharSequence expand(CharSequence self)

Replaces sequences of whitespaces with tabs.

static String expand(String self, int tabStop)

static CharSequence expand(CharSequence self, int tabStop)

Replaces sequences of whitespaces with tabs.

static String expandLine(String self, int tabStop)

static CharSequence expandLine(CharSequence self, int tabStop)

Replaces sequences of whitespaces with tabs within a line.

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)

Uses a closure to filter lines from this URL and pass them to the given writer.

static void filterLine(File self, Writer writer, String charset, Closure closure)

Uses a closure to filter lines from this URL and pass them to the given writer.

static Writable filterLine(Reader reader, Closure closure)

Reads the content of the file into a byte array.

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)

static Writable filterLine(URL self, String charset, Closure predicate)

Accepts a connection and passes the resulting Socket to the closure which runs in a new Thread.

static void filterLine(URL self, Writer writer, Closure predicate)

Accepts a connection and passes the resulting Socket to the closure which runs in a new Thread or the calling thread, as needed.

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 Object find(Object self)

Treats the object as iterable, iterating through the values it represents and returns the first non-null result obtained from calling the closure, otherwise returns the defaultResult.

static Object find(Collection self, Closure closure)

static Object find(Collection self)

static Map.Entry find(Map self, Closure closure)

static String find(String self, String regex)

Finds the first occurrence of a regular expression CharSequence within a CharSequence.

static CharSequence find(CharSequence self, CharSequence regex)

static String find(String self, Pattern pattern)

Finds the first occurrence of a compiled regular expression Pattern within a CharSequence.

static CharSequence find(CharSequence self, Pattern pattern)

static String find(String self, String regex, Closure closure)

Returns the result of calling a closure with the first occurrence of a regular expression found within a CharSequence.

static CharSequence find(CharSequence self, CharSequence regex, Closure closure)

static String find(String self, Pattern pattern, Closure closure)

static CharSequence find(CharSequence self, Pattern pattern, Closure closure)

Returns a (possibly empty) list of all occurrences of a regular expression (in String format) found within a String.

static Collection findAll(Collection self, Closure closure)

static Collection findAll(Collection self)

Finds all items matching the closure condition.

static Collection findAll(Object self, Closure closure)

static Collection findAll(Object self)

static Map findAll(Map self, Closure closure)

static List findAll(String self, String regex)

static List findAll(CharSequence self, CharSequence regex)

static List findAll(String self, Pattern pattern)

Returns a (possibly empty) list of all occurrences of a regular expression (in Pattern format) found within a CharSequence.

static List findAll(CharSequence self, Pattern pattern)

static List findAll(String self, String regex, Closure closure)

Finds all occurrences of a capturing regular expression CharSequence within a CharSequence.

static List findAll(CharSequence self, CharSequence regex, Closure closure)

static List findAll(String self, Pattern pattern, Closure closure)

Finds all occurrences of a compiled regular expression Pattern within a CharSequence.

static List findAll(CharSequence 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)

Adds a "metaClass" property to all class objects so you can use the syntax String.metaClass.myMethod = { println "foo" }

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 Collection findResults(Collection self, Closure filteringTransform)

static Collection findResults(Map self, Closure filteringTransform)

static Object first(List self)

static Object first(Iterable self)

static Object first(Object[] self)

Returns the first item from the Object array.

static Collection flatten(Collection self)

Flatten an array.

static Collection flatten(Object[] self)

Flatten an array.

static Collection flatten(boolean[] self)

Flatten an array.

static Collection flatten(byte[] self)

Flatten an array.

static Collection flatten(char[] self)

Flatten an array.

static Collection flatten(short[] self)

Flatten an array.

static Collection flatten(int[] self)

static Collection flatten(long[] self)

static Collection flatten(float[] self)

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 Object get(Map map, Object key, Object 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)

static String getAt(String text, int index)

static CharSequence getAt(CharSequence text, Range range)

static CharSequence getAt(CharSequence text, IntRange range)

Support the range subscript operator for CharSequence or StringBuffer with EmptyRange

static CharSequence getAt(CharSequence text, EmptyRange range)

static String getAt(String text, IntRange range)

static String getAt(String text, EmptyRange range)

static String getAt(String text, Range range)

static Object getAt(Matcher matcher, int idx)

Set the position of the given Matcher to the given index.

static List getAt(List self, Range range)

static List getAt(List self, EmptyRange range)

static List getAt(List self, Collection indices)

static List getAt(Object[] 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)

static List getAt(Matcher self, Collection indices)

static List getAt(Object[] array, Range range)

static List getAt(Object[] array, IntRange range)

@param array an Array of Objects

static List getAt(Object[] array, EmptyRange range)

Allows conversion of arrays into a mutable List.

static List getAt(Object[] array, ObjectRange range)

Support the subscript operator for a List.

static Object getAt(List self, int idx)

static Object getAt(Iterator self, int idx)

static Object getAt(Map self, Object key)

Returns a new Map containing all entries from left and right, giving precedence to right.

static List getAt(Collection coll, String property)

static List getAt(byte[] array, Range range)

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 byte[] getBytes(File file)

Write the text to the File.

static byte[] getBytes(URL url)

static byte[] getBytes(InputStream is)

Write the text to the File, using the specified encoding.

static char[] getChars(String self)

Iterates over the elements of an iterable collection of items and returns the index of the first item that matches the condition specified in the closure.

static char[] getChars(CharSequence self)

static int getCount(Matcher matcher)

Check whether a Matcher contains a group or not.

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)

Attempts to create an Iterator for the given object by first converting it to a Collection.

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 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)

Read the content of this URL and returns it as a byte[].

static String getText(File file)

static String getText(URL url)

static String getText(URL url, Map parameters)

Write the bytes from the byte array to the File.

static String getText(URL url, String charset)

Write the byte[] to the output stream.

static String getText(URL url, Map parameters, String charset)

Write the text and append a newline (using the platform's line-ending).

static String getText(InputStream is)

Write the text to the File.

static String getText(InputStream is, String charset)

static String getText(Reader reader)

static String getText(BufferedReader reader)

static Collection grep(Object self, Object filter)

Iterates over the collection of items which this Object represents and returns each item that matches the given filter - calling the isCase(java.lang.Object, java.lang.Object) method used by switch statements.

static Collection grep(Object self)

Iterates over the collection of items which this Object represents and returns each item that matches using the IDENTITY Closure as a filter - effectively returning all elements which satisfy Groovy truth.

protected static void groupAnswer(Map answer, Object element, Object value)

static Map groupBy(Collection self, Closure closure)

static Map groupBy(Collection self, Object... closures)

static Map groupBy(Collection self, List closures)

Sorts all collection members into (sub)groups determined by the supplied mapping closures.

static Map groupBy(Map self, Closure closure)

static Map groupBy(Map self, Object... closures)

static Map groupBy(Map self, List closures)

Groups the members of a map into sub maps determined by the supplied mapping closures.

static Map groupEntriesBy(Map self, Closure closure)

static boolean hasGroup(Matcher matcher)

static MetaProperty hasProperty(Object self, String name)

static Object head(List self)

Returns the items from the List excluding the first item.

static Object head(Object[] self)

static Object identity(Object self, Closure closure)

Allows the closure to be called for the object reference self.

static Boolean implies(Boolean left, Boolean right)

static Object inject(Collection self, Closure closure)

static Object inject(Collection self, Object initialValue, Closure closure)

static Object inject(Map self, Object initialValue, Closure closure)

static Object inject(Iterator self, Object initialValue, Closure closure)

static Object inject(Object self, Closure closure)

static Object inject(Object self, Object initialValue, Closure closure)

Iterates through the given array as with inject(Object[],initialValue,closure), but using the first element of the array as the initialValue, and then iterating the remaining elements of the array.

static Object inject(Object[] self, Closure closure)

Iterates through the given array, passing in the initial value to the closure along with the first item.

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)

Bitwise OR together two BitSets.

static Number intdiv(Number left, Character right)

Bitwise XOR together two Numbers.

static Number intdiv(Character left, Character right)

Performs a division modulus operation.

static Number intdiv(Number left, Number right)

static Collection intersect(Collection left, Collection right)

Create a Map composed of the intersection of both maps.

static Map intersect(Map left, Map right)

Returns true if the intersection of two collections is empty.

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 isAllWhitespace(CharSequence self)

static boolean isBigDecimal(String self)

Determine if a CharSequence can be parsed as a Long.

static boolean isBigDecimal(CharSequence self)

static boolean isBigInteger(String self)

static boolean isBigInteger(CharSequence 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(CharSequence caseValue, Object switchValue)

'Case' implementation for a CharSequence, which simply calls the equivalent method for String.

static boolean isCase(GString caseValue, Object switchValue)

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 compareTo() method for comparing numbers of different types.

static boolean isDigit(Character self)

Transform a Number into a BigDecimal

static boolean isDouble(String self)

Parse a CharSequence into a BigInteger

static boolean isDouble(CharSequence self)

static boolean isFloat(String self)

Parse a CharSequence into a Double

static boolean isFloat(CharSequence self)

Determines if a character is a whitespace character.

static boolean isInteger(String self)

static boolean isInteger(CharSequence self)

static boolean isLetter(Character self)

static boolean isLetterOrDigit(Character self)

static boolean isLong(String self)

static boolean isLong(CharSequence self)

Determines if a character is a letter or digit.

static boolean isLowerCase(Character self)

Transform a Number into a Double

static boolean isNumber(String self)

Determine if a CharSequence can be parsed as a Float.

static boolean isNumber(CharSequence self)

static boolean isUpperCase(Character self)

Transform a Number into a Float

static boolean isWhitespace(Character self)

static Iterator iterator(Object[] 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)

An identity function for iterators, supporting 'duck-typing' when trying to get an iterator for each object within a collection, some of which may already be iterators.

static Iterator iterator(Reader self)

static Iterator iterator(InputStream self)

static Iterator iterator(DataInputStream self)

static Iterator iterator(Iterator self)

static String join(Iterator self, String separator)

Concatenates the toString() representation of each item in this collection, with the given String as a separator between each item.

static String join(Collection self, String separator)

static String join(Object[] self, String separator)

static Object last(List self)

static Object last(Iterable self)

Returns the last item from the array.

static Object last(Object[] self)

static Collection leftShift(Collection self, Object value)

Overloads the left shift operator to provide an easy way to append Map.Entry values to a Map.

static BlockingQueue leftShift(BlockingQueue self, Object value)

Overloads the left shift operator to provide an easy way to append multiple objects as string representations to a String.

static Map leftShift(Map self, Map.Entry entry)

Overloads the left shift operator to provide an easy way to append multiple objects as string representations to a CharSequence.

static Map leftShift(Map self, Map other)

Overloads the left shift operator to provide syntactic sugar for appending to a StringBuilder.

static StringBuffer leftShift(String self, Object value)

Overloads the left shift operator to provide an easy way to append multiple objects as string representations to a StringBuffer.

static StringBuilder leftShift(CharSequence self, Object value)

static StringBuilder leftShift(StringBuilder self, Object value)

static StringBuffer leftShift(StringBuffer self, Object value)

static Writer leftShift(Writer self, Object value)

static Number leftShift(Number self, Number operand)

static Writer leftShift(OutputStream self, Object value)

static void leftShift(ObjectOutputStream self, Object value)

static OutputStream leftShift(OutputStream self, InputStream in)

static OutputStream leftShift(OutputStream self, byte[] value)

Support the subscript operator with a range for a short array

static File leftShift(File file, Object text)

Invokes the closure for each 'child' file in this 'parent' folder/directory.

static File leftShift(File file, byte[] bytes)

static File leftShift(File file, InputStream data)

Invokes the closure for each 'child' file in this 'parent' folder/directory.

static Writer leftShift(Socket self, Object value)

Converts the given String into a Set of unique strings of one character.

static OutputStream leftShift(Socket self, byte[] value)

Converts the given CharSequence into an array of characters.

static boolean matches(String self, Pattern pattern)

static boolean matches(CharSequence self, Pattern pattern)

static Map.Entry max(Map self, Closure closure)

static Object max(Collection self)

static Object max(Iterator self)

static Object max(Object[] self)

static Object max(Collection self, Closure closure)

static Object max(Iterator self, Closure closure)

static Object max(Object[] self, Closure closure)

Selects the maximum value found in the collection using the given comparator.

static Object max(Collection self, Comparator comparator)

Selects the maximum value found from the Iterator using the given comparator.

static Object max(Iterator self, Comparator comparator)

Selects the maximum value found from the Object array using the given comparator.

static Object max(Object[] self, Comparator comparator)

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 Object min(Collection self)

Adds min() method to Iterator objects.

static Object min(Iterator self)

static Object min(Object[] self)

static Object min(Collection self, Comparator comparator)

Selects the minimum value found from the Iterator using the given comparator.

static Object min(Iterator self, Comparator comparator)

Selects the minimum value found from the Object array using the given comparator.

static Object min(Object[] self, Comparator comparator)

static Object min(Collection self, Closure closure)

static Map.Entry min(Map self, Closure closure)

static Object min(Iterator self, Closure closure)

static Object min(Object[] self, Closure closure)

Adds max() method to Collection objects.

static Set minus(Set self, Collection removeMe)

Create a Set composed of the elements of the first Set minus the elements from the given Iterable.

static Set minus(Set self, Iterable removeMe)

Create an array composed of the elements of the first array minus the elements of the given Iterable.

static Set minus(Set self, Object removeMe)

static Object[] minus(Object[] self, Iterable removeMe)

static Object[] minus(Object[] self, Object[] removeMe)

static List minus(List self, Collection removeMe)

static List minus(List self, Iterable removeMe)

Create a List composed of the elements of the first list minus every occurrence of elements of the given Iterable.

static List minus(List self, Object removeMe)

static Object[] minus(Object[] self, Object removeMe)

static Map minus(Map self, Map removeMe)

Flatten an array.

static String minus(String self, Object target)

static CharSequence minus(CharSequence self, Object target)

Checks whether the array contains the given value.

static Number minus(Character left, Number right)

Power of a Number to a certain exponent.

static Number minus(Number left, Character right)

static Number minus(Character left, Character right)

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 array.

static CharSequence multiply(CharSequence self, Number factor)

Returns the string representation of this map.

static Number multiply(Character left, Number right)

Power of a BigInteger to an integer certain exponent.

static Number multiply(Number left, Character right)

Power of an integer to an integer certain exponent.

static Number multiply(Character left, Character right)

static Number multiply(BigDecimal left, Double right)

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)

Traverse through each byte of this Byte array.

static BufferedInputStream newInputStream(URL url)

Traverse through each the specified stream reading bytes into a buffer and calling the 2 parameter closure with this buffer and the number of bytes.

static BufferedInputStream newInputStream(URL url, Map parameters)

static Object newInstance(Class c)

Sets/updates the metaclass for a given class to a closure.

static Object 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)

static ObjectOutputStream newObjectOutputStream(File file)

static ObjectOutputStream newObjectOutputStream(OutputStream outputStream)

static BufferedOutputStream newOutputStream(File file)

static PrintWriter newPrintWriter(File file)

static PrintWriter newPrintWriter(File file, String charset)

Helper method to create a new Reader for a stream and then passes it into the closure.

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)

static BufferedReader newReader(InputStream self)

static BufferedReader newReader(InputStream self, String charset)

static BufferedReader newReader(URL url)

static BufferedReader newReader(URL url, Map parameters)

Reads the InputStream from this URL, passing a byte[] and a number of bytes to the given closure.

static BufferedReader newReader(URL url, String charset)

Transforms each character from this reader by passing it to the given closure.

static BufferedReader newReader(URL url, Map parameters, String charset)

static BufferedWriter newWriter(File file)

static BufferedWriter newWriter(File file, boolean append)

static BufferedWriter newWriter(File file, String charset, boolean append)

static BufferedWriter newWriter(File file, String charset)

Allows this writer to be used within the closure, ensuring that it is flushed and closed before this method returns.

static String next(String self)

static CharSequence next(CharSequence self)

Executes the command specified by the given String array.

static Character next(Character self)

static Number next(Number self)

static String normalize(String self)

static CharSequence normalize(CharSequence self)

Read the content of the File and returns it as a String.

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)

static Boolean or(Boolean left, Boolean right)

static String padLeft(String self, Number numberOfChars, String padding)

Pad a CharSequence to a minimum length specified by numberOfChars, adding the supplied padding CharSequence as many times as needed to the left.

static CharSequence padLeft(CharSequence self, Number numberOfChars, CharSequence padding)

static String padLeft(String self, Number numberOfChars)

Pad a CharSequence to a minimum length specified by numberOfChars by adding the space character to the left as many times as needed.

static CharSequence padLeft(CharSequence self, Number numberOfChars)

static String padRight(String self, Number numberOfChars, String padding)

Pad a CharSequence to a minimum length specified by numberOfChars, adding the supplied padding CharSequence as many times as needed to the right.

static CharSequence padRight(CharSequence self, Number numberOfChars, CharSequence padding)

static String padRight(String self, Number numberOfChars)

static CharSequence padRight(CharSequence self, Number numberOfChars)

static Set permutations(List self)

static Map plus(Map left, Map right)

Support the subscript operator for Collection.

static Object[] plus(Object[] left, Object[] right)

static Object[] plus(Object[] left, Object right)

static Object[] plus(Object[] left, Collection right)

static Object[] plus(Object[] left, Iterable right)

Create a Collection as a union of a Collection and an Iterable.

static Collection plus(Collection left, Collection right)

static Collection plus(Collection left, Iterable right)

static List plus(List self, int index, Object[] items)

Creates a new List by inserting all of the elements in the given additions List to the elements from the original List at the specified index.

static List plus(List self, int index, List additions)

Creates a new List by inserting all of the elements in the given Iterable to the elements from this List at the specified index.

static List plus(List self, int index, Iterable additions)

Synonym for toSpreadMap(java.util.Map).

static Collection plus(Collection left, Object right)

static Map plus(Map self, Collection entries)

static String plus(String left, Object value)

Checks whether the array contains the given value.

static CharSequence plus(CharSequence left, Object value)

Checks whether the array contains the given value.

static String plus(Number value, String right)

static String plus(StringBuffer left, String value)

static Number plus(Character left, Number right)

static Number plus(Number left, Character right)

static Number plus(Character left, Character right)

static Object pop(List self)

Returns a new Map containing all entries from self and entries, giving precedence to entries.

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)

Integer Divide a Number by a Character.

static Number power(Integer self, Integer exponent)

Integer Divide two Characters.

static Number power(Long self, Integer exponent)

Bitwise OR together two numbers.

static String previous(String self)

static CharSequence previous(CharSequence self)

static Character previous(Character self)

@todo maybe a double dispatch thing to handle new large numbers?

static Number previous(Number self)

protected static Object primitiveArrayGet(Object self, int idx)

Convenience method to split a string (with whitespace as delimiter) Like tokenize, but returns an Array of Strings instead of a List

protected static List primitiveArrayGet(Object self, Range range)

protected static List primitiveArrayGet(Object self, Collection indices)

protected static Object primitiveArrayPut(Object self, int idx, Object newValue)

Convenience method to capitalize the first letter of a CharSequence.

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, Object 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, Object value)

Support the range subscript operator for StringBuffer.

static void putAt(StringBuffer self, IntRange range, Object value)

A helper method to allow lists to work with subscript operators.

static void putAt(StringBuffer self, EmptyRange range, Object value)

static void putAt(List self, EmptyRange range, Object value)

static void putAt(List self, EmptyRange range, Collection value)

List subscript assignment operator when given a range as the index and the assignment operand is a collection.

static void putAt(List self, IntRange range, 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)

A helper method to allow lists to work with subscript operators.

static void putAt(List self, List splice, Object value)

static Object putAt(Map self, Object key, Object 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)

Converts this File to a Writable.

static String readLine(Reader self)

static List readLines(String self)

static List readLines(CharSequence self)

static List readLines(File file)

Read the data from this URL and return it as a String.

static List readLines(File file, String charset)

Read the content of this InputStream and return it as a String.

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, Object[] items)

static boolean removeAll(Collection self, Closure condition)

Modifies this collection by removing the elements that are matched according to the specified closure condition.

static boolean renameTo(File self, String newPathName)

Create a new InputStream for this file and passes it into the closure.

static String replaceAll(String self, Pattern pattern, String replacement)

Replaces all substrings of a CharSequence that match the given compiled regular expression with the given replacement.

static CharSequence replaceAll(CharSequence self, Pattern pattern, CharSequence replacement)

static String replaceAll(String self, String regex, Closure closure)

Replaces all occurrences of a captured group by the result of a closure on that text.

static CharSequence replaceAll(CharSequence self, CharSequence regex, Closure closure)

static CharSequence replaceAll(CharSequence self, CharSequence regex, CharSequence replacement)

static String replaceAll(String self, Pattern pattern, Closure closure)

Replaces all occurrences of a captured group by the result of a closure call on that text.

static String replaceAll(CharSequence self, Pattern pattern, Closure closure)

static String replaceFirst(String self, Pattern pattern, String replacement)

Replaces the first substring of a CharSequence that matches the given compiled regular expression with the given replacement.

static CharSequence replaceFirst(CharSequence self, Pattern pattern, CharSequence replacement)

static String replaceFirst(String self, String regex, Closure closure)

static String replaceFirst(CharSequence self, CharSequence regex, CharSequence replacement)

static String replaceFirst(CharSequence self, CharSequence regex, Closure closure)

static String replaceFirst(String self, Pattern pattern, Closure closure)

Replaces the first occurrence of a captured group by the result of a closure call on that text.

static String replaceFirst(CharSequence self, Pattern pattern, Closure closure)

static List respondsTo(Object self, String name, Object[] argTypes)

static List respondsTo(Object self, String name)

static boolean retainAll(Collection self, Object[] items)

static boolean retainAll(Collection self, Closure condition)

static String reverse(String self)

Creates a new string which is the reverse (backwards) of this string

static CharSequence reverse(CharSequence self)

static List reverse(List self)

Reverses the elements in a list.

static List reverse(List self, boolean mutate)

Reverse the items in an array.

static Object[] reverse(Object[] self)

Reverses the iterator.

static Object[] reverse(Object[] self, boolean mutate)

Create a List composed of the elements of this list, repeated a certain number of times.

static Iterator reverse(Iterator self)

Create a Collection composed of the intersection of both collections.

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 Object[] reverseEach(Object[] self, Closure closure)

static Number rightShift(Number self, Number operand)

static Number rightShiftUnsigned(Number self, Number operand)

static int round(Float number)

Parse a String into a Float

static float round(Float number, int precision)

Parse a String into a Double

static long round(Double number)

static double round(Double number, int precision)

Determine if a String can be parsed into a Long.

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)

Find the number of Strings matched to the given Matcher.

static void setMetaClass(Class self, MetaClass metaClass)

Allows an Enumeration to behave like an Iterator.

static void setMetaClass(Object self, MetaClass metaClass)

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)

Provide the standard Groovy size() method for String.

static int size(String text)

Provide the standard Groovy size() method for CharSequence.

static int size(CharSequence text)

static int size(StringBuffer buffer)

static long size(File self)

static long size(Matcher self)

static int size(Object[] self)

static int size(boolean[] array)

static int size(byte[] array)

static int size(char[] array)

static int size(short[] array)

static int size(int[] array)

static int size(long[] array)

Converts this array to a List of the same size, with each element added to the list.

static int size(float[] array)

Converts this array to a List of the same size, with each element added to the list.

static int size(double[] array)

static List sort(Collection self)

static List sort(Collection self, boolean mutate)

static Map sort(Map self, Closure closure)

static Map sort(Map self, Comparator comparator)

Modifies this array so that its elements are in sorted order.

static Map sort(Map self)

static Object[] sort(Object[] self)

static Object[] sort(Object[] self, boolean mutate)

Sorts the given iterator items into a sorted iterator using the comparator.

static Iterator sort(Iterator self)

static Iterator sort(Iterator self, Comparator comparator)

static List sort(Collection self, Comparator comparator)

static List sort(Collection self, boolean mutate, Comparator comparator)

static Object[] sort(Object[] self, Comparator comparator)

static Object[] sort(Object[] self, boolean mutate, Comparator comparator)

static Iterator sort(Iterator self, Closure closure)

static Object[] sort(Object[] self, Closure closure)

static Object[] sort(Object[] self, boolean mutate, Closure closure)

Sorts this Collection using the given Closure to determine the correct ordering.

static List sort(Collection self, Closure closure)

Sorts this Collection using the given Closure to determine the correct ordering.

static List sort(Collection self, boolean mutate, Closure closure)

Avoids doing unnecessary work when sorting an already sorted set (i.e. an identity function for an already sorted set).

static SortedSet sort(SortedSet self)

static SortedMap sort(SortedMap self)

static Collection split(Object self, Closure closure)

static Collection split(Collection self, Closure closure)

static String[] split(String self)

static CharSequence[] split(CharSequence self)

Expands all tabs into spaces.

static String[] split(GString self)

Appends a String to the string representation of this number.

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)

Iterates through the given InputStream line by line using the specified encoding, splitting each line using the given separator.

static Object splitEachLine(URL self, String regex, String charset, Closure closure)

Iterates through the given InputStream line by line using the specified encoding, splitting each line using the given separator Pattern.

static Object splitEachLine(URL self, Pattern pattern, String charset, Closure closure)

Iterates through the given InputStream line by line, splitting each line using the given separator.

static Object splitEachLine(Reader self, String regex, Closure closure)

static Object splitEachLine(Reader self, Pattern pattern, Closure closure)

Iterates through the given CharSequence line by line, splitting each line using the given separator.

static Object splitEachLine(InputStream stream, String regex, String charset, Closure closure)

Iterates through the given CharSequence line by line, splitting each line using the given separator Pattern.

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(CharSequence self, CharSequence regex, Closure closure)

static Object splitEachLine(String self, Pattern pattern, Closure closure)

static Object splitEachLine(CharSequence self, Pattern pattern, Closure closure)

Return a String with lines (separated by LF, CR/LF, or CR) terminated by the platform specific line separator.

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 CharSequence stripIndent(CharSequence self)

True if a String only contains whitespace characters.

static String stripIndent(String self, int numChars)

static CharSequence stripIndent(CharSequence self, int numChars)

Transforms a String representing a URL into a URL object.

static String stripMargin(String self)

static CharSequence stripMargin(CharSequence self)

static String stripMargin(String self, String marginChar)

static String stripMargin(CharSequence self, CharSequence marginChar)

static String stripMargin(String self, char marginChar)

static CharSequence stripMargin(CharSequence 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)

static Object sum(Iterator self)

static Object sum(Collection self, Object initialValue)

static Object sum(Object[] self, Object initialValue)

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 an array.

static Object sum(Object[] self, Closure closure)

Sums the result of apply a closure to each item returned from an iterator.

static Object sum(Iterator self, Closure closure)

Sums the result of applying a closure to each item of a collection to some initial value.

static Object sum(Collection self, Object initialValue, Closure closure)

Sums the result of applying a closure to each item of an array to some initial value.

static Object sum(Object[] self, Object initialValue, Closure closure)

Sums the result of applying a closure to each item of an Iterator to some initial value.

static Object sum(Iterator self, Object initialValue, Closure closure)

static List tail(List self)

static Object[] tail(Object[] self)

static List take(List self, int num)

Returns the first num elements from the head of this array.

static Object[] take(Object[] self, int num)

Returns the first num elements from the head of this Iterable.

static List take(Iterable self, int num)

Returns a new map containing the first num elements from the head of this map.

static Map take(Map self, int num)

static Iterator take(Iterator self, int num)

static CharSequence take(CharSequence self, int num)

static List takeWhile(List self, Closure condition)

Returns a List containing the longest prefix of the elements from this Iterable where each element passed to the given closure evaluates to true.

static List takeWhile(Iterable self, Closure condition)

Returns the longest prefix of this Map where each entry (or key/value pair) when passed to the given closure evaluates to true.

static Map takeWhile(Map self, Closure condition)

Returns the longest prefix of this array where each element passed to the given closure evaluates to true.

static Object[] takeWhile(Object[] self, Closure condition)

static Iterator takeWhile(Iterator self, Closure condition)

static CharSequence takeWhile(CharSequence self, Closure closure)

@param array an Array of Objects

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)

Compare a Character and a Number.

static BigDecimal toBigDecimal(String self)

static BigDecimal toBigDecimal(CharSequence self)

static BigDecimal toBigDecimal(Number self)

Exclusive disjunction of two boolean operators

static BigInteger toBigInteger(String self)

static BigInteger toBigInteger(CharSequence self)

static BigInteger toBigInteger(Number self)

Create an object input stream for this file.

static Boolean toBoolean(String self)

static Boolean toBoolean(Boolean self)

static Character toCharacter(String self)

Expands all tabs into spaces with tabStops of size 8.

static Double toDouble(String self)

static Double toDouble(CharSequence self)

static Double toDouble(Number self)

Logical implication of two boolean operators

static Float toFloat(String self)

static Float toFloat(CharSequence self)

static Float toFloat(Number self)

Logical disjunction of two boolean operators

static Integer toInteger(String self)

Determine if a String can be parsed into a Double.

static Integer toInteger(CharSequence self)

static Integer toInteger(Number self)

static List toList(Collection self)

static List toList(Iterator self)

static List toList(Iterable self)

static List toList(Enumeration self)

static List toList(Object[] array)

static List toList(byte[] array)

static List toList(boolean[] array)

static List toList(char[] array)

static List toList(short[] array)

static List toList(int[] array)

static List toList(long[] array)

static List toList(float[] array)

static List toList(double[] array)

static List toList(String self)

static List toList(CharSequence self)

static String toListString(Collection self)

static String toListString(Collection self, int maxSize)

static Long toLong(String self)

static Long toLong(CharSequence self)

static Long toLong(Number self)

static char toLowerCase(Character self)

Transform this Number into a BigInteger.

static String toMapString(Map self)

static String toMapString(Map self, int maxSize)

static Set toSet(byte[] array)

static Set toSet(boolean[] array)

Convert an iterator to a Set.

static Set toSet(char[] array)

Convert an enumeration to a Set.

static Set toSet(short[] array)

static Set toSet(int[] array)

static Set toSet(long[] array)

static Set toSet(float[] array)

static Set toSet(double[] array)

static Set toSet(Collection self)

static Set toSet(Iterator self)

static Set toSet(Enumeration self)

static Set toSet(String self)

static Set toSet(CharSequence self)

static Short toShort(String self)

static Short toShort(CharSequence self)

static SpreadMap toSpreadMap(Map self)

Creates a spreadable map from this list.

static SpreadMap toSpreadMap(Object[] self)

static SpreadMap toSpreadMap(List self)

static String toString(boolean[] self)

static String toString(byte[] self)

static String toString(char[] self)

Returns the string representation of the given list.

static String toString(short[] self)

static String toString(int[] self)

static String toString(long[] self)

static String toString(float[] self)

static String toString(double[] self)

static String toString(AbstractMap self)

static String toString(AbstractCollection self)

static String toString(Object[] self)

static String toString(Object value)

static URI toURI(String self)

static URI toURI(CharSequence self)

static URL toURL(String self)

static URL toURL(CharSequence self)

static char toUpperCase(Character self)

static List tokenize(String self, String token)

Appends a String to this StringBuffer.

static List tokenize(CharSequence self, CharSequence token)

Remove a part of a String.

static List tokenize(String self, Character token)

static List tokenize(CharSequence self, Character token)

static List tokenize(String self)

static List tokenize(CharSequence self)

static String tr(String self, String sourceSet, String replacementSet)

Translates a string by replacing characters from the sourceSet with characters from replacementSet.

static CharSequence tr(CharSequence self, CharSequence sourceSet, CharSequence replacementSet)

Tells whether or not a CharSequence matches the given compiled regular expression Pattern.

static void transformChar(Reader self, Writer writer, Closure closure)

Filter the lines from this Reader, and return a Writable which can be used to stream the filtered lines to a destination.

static void 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)

Invokes the closure for each file whose name (file.name) matches the given nameFilter in the given directory - calling the isCase(java.lang.Object, java.lang.Object) method to determine if a match occurs.

static void traverse(File self, Map options)

Invokes the closure for each subdirectory whose name (dir.name) matches the given nameFilter in the given directory - calling the isCase(java.lang.Object, java.lang.Object) method to determine if a match occurs.

static float trunc(Float number, int precision)

static float trunc(Float number)

static double trunc(Double number)

static double trunc(Double number, int precision)

static Number unaryMinus(Number left)

static String unexpand(String self)

static CharSequence unexpand(CharSequence self)

static String unexpand(String self, int tabStop)

static CharSequence unexpand(CharSequence self, int tabStop)

Tokenize a CharSequence based on the given character delimiter.

static String unexpandLine(String self, int tabStop)

static CharSequence unexpandLine(CharSequence self, int tabStop)

Appends the String representation of the given operand to this string.

static Iterator unique(Iterator self)

static Collection unique(Collection self)

static Collection unique(Collection self, boolean mutate)

static Iterator unique(Iterator self, Closure closure)

static Collection unique(Collection self, Closure closure)

static Collection unique(Collection self, boolean mutate, 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 Collection unique(Collection self, boolean mutate, 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)

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(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 Object with(Object self, Closure closure)

Allows the closure to be called for the object reference self.

static Object withDataInputStream(File file, Closure closure)

static Object withDataOutputStream(File file, Closure closure)

Create a new PrintWriter for this file.

static Map withDefault(Map self, Closure init)

static List withDefault(List self, Closure init)

static List withEagerDefault(List self, Closure init)

Sorts the Collection.

static Object withInputStream(File file, Closure closure)

Create a new BufferedWriter which will append to this file.

static Object withInputStream(URL url, Closure closure)

Create a new BufferedWriter for this file in append mode.

static List withLazyDefault(List self, Closure init)

static Object withObjectInputStream(File file, Closure closure)

Iterates through this file line by line.

static Object withObjectInputStream(File file, ClassLoader classLoader, Closure closure)

static Object withObjectInputStream(InputStream inputStream, Closure closure)

static Object withObjectInputStream(InputStream inputStream, ClassLoader classLoader, Closure closure)

static Object withObjectOutputStream(File file, Closure closure)

static Object withObjectOutputStream(OutputStream outputStream, Closure closure)

Create a new ObjectInputStream for this file and pass it to the 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 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)

Write a Byte Order Mark at the beginning of the file

static Object withReader(Reader reader, Closure closure)

Creates a buffered input stream for this file.

static Object withReader(URL url, Closure closure)

Creates a buffered input stream for this URL.

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)

Creates a buffered reader for this URL using the given encoding.

static Object withStream(InputStream stream, Closure closure)

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)

Allows this input stream to be used within the closure, ensuring that it is flushed and closed before this method returns.

static Object withWriter(Writer writer, Closure closure)

static Object withWriter(OutputStream stream, Closure closure)

Creates a buffered reader for this URL using the given encoding.

static Object withWriter(OutputStream stream, String charset, Closure closure)

Create a data input stream for this file

static Object withWriterAppend(File file, String charset, Closure closure)

static Object withWriterAppend(File file, Closure closure)

static void write(Writer self, Writable writable)

static void write(File file, String text)

Append binary data to the file.

static void write(File file, String text, String charset)

static void writeLine(BufferedWriter writer, String line)

static BitSet xor(BitSet left, BitSet right)

Iterates from this number up to the given number, inclusive, incrementing by one each time.

static Number xor(Number left, Number right)

Iterates from this number up to the given number, inclusive, incrementing by one each time.

static Boolean xor(Boolean left, Boolean right)

 
Methods inherited from class DefaultGroovyMethodsSupport
cloneSimilarCollection, cloneSimilarMap, closeQuietly, closeWithWarning, createSimilarArray, createSimilarCollection, createSimilarCollection, createSimilarList, createSimilarMap, createSimilarOrDefaultCollection, createSimilarSet, normaliseIndex, sameType, subListBorders, subListBorders
 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

additionals

public static final Class[] additionals


 
Method Detail

abs

public static int abs(Number number)
Truncate the value
Parameters:
number - a Double
Returns:
the Double truncated to 0 decimal places (i.e. a synonym for floor)
Since:
1.6.0


abs

public static long abs(Long number)
Parse a String into an Integer
Parameters:
self - a String
Returns:
an Integer
Since:
1.0


abs

public static float abs(Float number)
Parse a String into a Long
Parameters:
self - a String
Returns:
a Long
Since:
1.0


abs

public static double abs(Double number)
Parse a String into a Short
Parameters:
self - a String
Returns:
a Short
Since:
1.5.7


accept

public static Socket accept(ServerSocket serverSocket, Closure closure)
Converts the GString to a File, or delegates to the default asType(java.lang.Object, java.lang.Class)
Parameters:
self - a GString
c - the desired class
Returns:
the converted object
Since:
1.5.0


accept

public static Socket accept(ServerSocket serverSocket, boolean runInANewThread, Closure closure)


addAll

public static boolean addAll(Collection self, Object[] items)
Modifies the collection by adding all of the elements in the specified array to the collection. The behavior of this operation is undefined if the specified array is modified while the operation is in progress. See also plus or the '+' operator if wanting to produce a new collection containing additional items but while leaving the original collection unchanged.
Parameters:
self - a Collection to be modified
items - array containing elements to be added to this collection
Returns:
true if this collection changed as a result of the call
See Also:
Collection.addAll
Since:
1.7.2


addAll

public static boolean addAll(List self, int index, Object[] items)


addShutdownHook

public static void addShutdownHook(Object self, Closure closure)
Allows the usage of addShutdownHook without getting the runtime first.
Parameters:
self - the object the method is called on (ignored)
closure - the shutdown hook action
Since:
1.5.0


and

public static Number and(Number left, Number right)


and

public static BitSet and(BitSet left, BitSet right)


and

public static Boolean and(Boolean left, Boolean right)
Create an object input stream for this input stream.
throws:
IOException if an IOException occurs.
Parameters:
inputStream - an input stream
Returns:
an object input stream
Since:
1.5.0


any

public 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.
Parameters:
self - the object over which we iterate
closure - the closure predicate used for matching
Returns:
true if any iteration for the object matches the closure predicate
Since:
1.0


any

public 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. If the closure takes one parameter then it will be passed the Map.Entry otherwise if the closure takes two parameters then it will be passed the key and the value.
 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 }
 
Parameters:
self - the map over which we iterate
closure - the 1 or 2 arg closure predicate used for matching
Returns:
true if any entry in the map matches the closure predicate
Since:
1.5.0


any

public 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. Equivalent to self.any({element -> element})
Parameters:
self - the object over which we iterate
Returns:
true if any item in the collection matches the closure predicate
Since:
1.5.0


append

public static void append(File file, Object text)
Invokes the closure for each descendant file in this directory. Sub-directories are recursively searched in a depth-first fashion. Both regular files and subdirectories may be passed to the closure depending on the value of fileType.
throws:
FileNotFoundException if the given directory does not exist
throws:
IllegalArgumentException if the provided File object does not represent a directory
Parameters:
self - a file object
fileType - if normal files or directories or both should be processed
closure - the closure to invoke on each file
Since:
1.7.1


append

public static void append(File file, byte[] bytes)


append

public static void append(File self, InputStream stream)


append

public static void append(File file, Object text, String charset)


asBoolean

public static boolean asBoolean(Object object)


asBoolean

public static boolean asBoolean(Boolean bool)


asBoolean

public static boolean asBoolean(Matcher matcher)


asBoolean

public static boolean asBoolean(Collection collection)


asBoolean

public static boolean asBoolean(Map map)


asBoolean

public static boolean asBoolean(Iterator iterator)


asBoolean

public static boolean asBoolean(Enumeration enumeration)


asBoolean

public static boolean asBoolean(CharSequence string)


asBoolean

public static boolean asBoolean(Object[] array)


asBoolean

public static boolean asBoolean(byte[] array)


asBoolean

public static boolean asBoolean(short[] array)


asBoolean

public static boolean asBoolean(int[] array)


asBoolean

public static boolean asBoolean(long[] array)


asBoolean

public static boolean asBoolean(float[] array)


asBoolean

public static boolean asBoolean(double[] array)


asBoolean

public static boolean asBoolean(boolean[] array)


asBoolean

public static boolean asBoolean(char[] array)


asBoolean

public static boolean asBoolean(Character character)


asBoolean

public static boolean asBoolean(Number number)


asImmutable

public static Map asImmutable(Map self)
A convenience method for creating an immutable list
Parameters:
self - a List
Returns:
an immutable List
See Also:
Collections.unmodifiableList
Since:
1.0


asImmutable

public static SortedMap asImmutable(SortedMap self)


asImmutable

public static List asImmutable(List self)


asImmutable

public static Set asImmutable(Set self)


asImmutable

public static SortedSet asImmutable(SortedSet self)
A convenience method for creating a synchronized Map.
Parameters:
self - a Map
Returns:
a synchronized Map
See Also:
Collections.synchronizedMap
Since:
1.0


asImmutable

public static Collection asImmutable(Collection self)
A convenience method for creating a synchronized SortedMap.
Parameters:
self - a SortedMap
Returns:
a synchronized SortedMap
See Also:
Collections.synchronizedSortedMap
Since:
1.0


asList

public static List asList(Collection self)
Coerce an Boolean instance to a boolean value.
Parameters:
bool - the Boolean
Returns:
the boolean value
Since:
1.7.0


asSynchronized

public static Map asSynchronized(Map self)


asSynchronized

public static SortedMap asSynchronized(SortedMap self)


asSynchronized

public static Collection asSynchronized(Collection self)


asSynchronized

public static List asSynchronized(List self)


asSynchronized

public static Set asSynchronized(Set self)


asSynchronized

public static SortedSet asSynchronized(SortedSet self)


asType

try {
public static Object asType(Collection col, Class clazz)


asType

} catch (GroovyRuntimeException cause) {
public static Object asType(Object[] ary, Class clazz)
Converts the given array to either a List, Set, or SortedSet. If the given class is something else, the call is deferred to {link #asType(Object,Class)}.
Parameters:
ary - an array
clazz - the desired class
Returns:
the object resulting from this type conversion
See Also:
asType(java.lang.Object, java.lang.Class)
Since:
1.5.1


asType

try {
public 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. Typically the value would be a closure which behaves like the method implementation.
Parameters:
map - this map
clazz - the target type
Returns:
a Proxy of the given type, which defers calls to this map's elements.
Since:
1.0


asType

/**
public static Object asType(Map map, Class clazz)
Creates a new List with the identical contents to this list but in reverse order.
 def list = ["a", 4, false]
 assert list.reverse() == [false, 4, "a"]
 assert list == ["a", 4, false]
 
Parameters:
self - a List
Returns:
a reversed List
See Also:
reverse(List, boolean)
Since:
1.0


asType

* returns.
public static Object asType(Number self, Class c)
Create a new ObjectOutputStream for this file and then pass it to the closure. This method ensures the stream is closed after the closure returns.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
closure - a closure
Returns:
the value returned by the closure
See Also:
withStream(java.io.OutputStream, groovy.lang.Closure)
Since:
1.5.0


asType

* @param self a CharSequence
public static Object asType(File f, Class c)


asType

break;
public static Object asType(GString self, Class c)


asType

}
public static Object asType(String self, Class c)
Iterates over the elements of an iterable collection of items and returns the index of the last item that matches the condition specified in the closure.
Parameters:
self - the iteration object over which to iterate
closure - the filter to perform a match on the collection
Returns:
an integer that is the index of the last matched object or -1 if no match was found
Since:
1.5.2


asType

public static Object asType(CharSequence self, Class c)
Iterates over the elements of an iterable collection of items and returns the index values of the items that match the condition specified in the closure.
Parameters:
self - the iteration object over which to iterate
closure - the filter to perform a match on the collection
Returns:
a list of numbers corresponding to the index values of all matched objects
Since:
1.5.2


asType

}
public static Object asType(Object obj, Class type)
Sets the metaclass for a given class.
Parameters:
self - the class whose metaclass we wish to set
metaClass - the new MetaClass
Since:
1.6.0


asWritable

public static File asWritable(File file)


asWritable

public static File asWritable(File file, String encoding)


bitwiseNegate

public static Pattern bitwiseNegate(String self)


bitwiseNegate

public static Pattern bitwiseNegate(CharSequence self)


bitwiseNegate

public static BitSet bitwiseNegate(BitSet self)


callClosureForLine

protected static Object callClosureForLine(Closure closure, String line, int counter)


callClosureForMapEntry

protected static Object callClosureForMapEntry(Closure closure, Map.Entry entry)


callClosureForMapEntryAndCounter

protected static Object callClosureForMapEntryAndCounter(Closure closure, Map.Entry entry, int counter)


capitalize

public static String capitalize(String self)
Expands all tabs into spaces. Assumes the CharSequence represents a single line of text.
Parameters:
self - A line to expand
tabStop - The number of spaces a tab represents
Returns:
The expanded CharSequence
See Also:
expandLine(String, int)
Since:
1.8.2


capitalize

public static CharSequence capitalize(CharSequence self)
Replaces sequences of whitespaces with tabs using tabStops of size 8.
Parameters:
self - A String to unexpand
Returns:
The unexpanded String
See Also:
unexpand(java.lang.String, int)
Since:
1.7.3


center

public static String center(String self, Number numberOfChars, String padding)
Pad a CharSequence to a minimum length specified by numberOfChars, appending the supplied padding CharSequence around the original as many times as needed keeping it centered.
Parameters:
self - a CharSequence object
numberOfChars - the total minimum number of characters of the resulting CharSequence
padding - the characters used for padding
Returns:
the CharSequence centered with padded characters around it
See Also:
center(String, Number, String)
Since:
1.8.2


center

public static CharSequence center(CharSequence self, Number numberOfChars, CharSequence padding)
Pad a String to a minimum length specified by numberOfChars by adding the space character around it as many times as needed so that it remains centered. If the String is already the same size or bigger than the target numberOfChars, then the original String is returned. An example:
 ['A', 'BB', 'CCC', 'DDDD'].each{ println '|' + it.center(6) + '|' }
 
will produce output like:
 |  A   |
 |  BB  |
 | CCC  |
 | DDDD |
 
Parameters:
self - a String object
numberOfChars - the total minimum number of characters of the resulting string
Returns:
the String centered with padded characters around it
See Also:
center(String, Number, String)
Since:
1.0


center

public static String center(String self, Number numberOfChars)


center

public static CharSequence center(CharSequence self, Number numberOfChars)


collate

public static List collate(List self, int size)


collate

public static List collate(List self, int size, int step)


collate

public static List collate(List self, int size, boolean keepRemainder)


collate

public static List collate(List self, int size, int step, boolean keepRemainder)


collect

public static List collect(Object self, Closure transform)
Iterates through this aggregate Object transforming each item into a new value using the transform closure, returning a list of transformed values. Example:
def list = [1, 'a', 1.23, true ]
 def types = list.collect { it.class }
 assert types == [Integer, String, BigDecimal, Boolean]
Parameters:
self - an aggregate Object with an Iterator returning its items
transform - the closure used to transform each item of the aggregate object
Returns:
a List of the transformed values
Since:
1.0


collect

public static Collection collect(Object self)


collect

public static Collection collect(Object self, Collection collector, Closure transform)


collect

public static List collect(Collection self, Closure transform)


collect

public static List collect(Collection self)


collect

public static Collection collect(Collection self, Collection collector, Closure transform)


collect

public static Collection collect(Map self, Collection collector, Closure transform)


collect

public static List collect(Map self, Closure transform)


collectAll

public static List collectAll(Collection self, Closure transform)
Deprecated alias for collectNested
deprecated:
Use collectNested instead
See Also:
collectNested(Collection, Closure)


collectAll

public static Collection collectAll(Collection self, Collection collector, Closure transform)


collectEntries

public static Map collectEntries(Map self, Map collector, Closure transform)


collectEntries

public static Map collectEntries(Map self, Closure transform)


collectEntries

public static Map collectEntries(Collection self, Closure transform)


collectEntries

public static Map collectEntries(Collection self)


collectEntries

public static Map collectEntries(Collection self, Map collector, Closure transform)


collectEntries

public static Map collectEntries(Collection self, Map collector)


collectEntries

public static Map collectEntries(Object[] self, Map collector, Closure transform)


collectEntries

public static Map collectEntries(Object[] self, Map collector)


collectEntries

public static Map collectEntries(Object[] self, Closure transform)


collectEntries

public static Map collectEntries(Object[] self)


collectMany

public static List collectMany(Collection self, Closure projection)
Projects each item from a source collection to a collection and concatenates (flattens) the resulting collections into a single list.

 def nums = 1..10
 def squaresAndCubesOfEvens = nums.collectMany{ it % 2 ? [] : [it**2, it**3] }
 assert squaresAndCubesOfEvens == [4, 8, 16, 64, 36, 216, 64, 512, 100, 1000]

 def animals = ['CAT', 'DOG', 'ELEPHANT'] as Set
 def smallAnimals = animals.collectMany{ it.size() > 3 ? [] : [it.toLowerCase()] }
 assert smallAnimals == ['cat', 'dog']

 def orig = nums as Set
 def origPlusIncrements = orig.collectMany{ [it, it+1] }
 assert origPlusIncrements.size() == orig.size() * 2
 assert origPlusIncrements.unique().size() == orig.size() + 1
 
Parameters:
self - a collection
projection - a projecting Closure returning a collection of items
Returns:
a list created from the projected collections concatenated (flattened) together
See Also:
sum(java.util.Collection, groovy.lang.Closure)
Since:
1.8.1


collectMany

public static Collection collectMany(Collection self, Collection collector, Closure projection)


collectMany

public static List collectMany(Object[] self, Closure projection)


collectMany

public static List collectMany(Iterator self, Closure projection)


collectNested

public static List collectNested(Collection self, Closure transform)
Deprecated alias for collectNested
deprecated:
Use collectNested instead
See Also:
collectNested(Collection, Collection, Closure)


collectNested

public static Collection collectNested(Collection self, Collection collector, Closure transform)


combinations

public static List combinations(Collection self)
Adds GroovyCollections#combinations(Collection) as a method on collections.

Example usage:

assert [['a', 'b'],[1, 2, 3]].combinations() == [['a', 1], ['b', 1], ['a', 2], ['b', 2], ['a', 3], ['b', 3]]
Parameters:
self - a Collection of lists
Returns:
a List of the combinations found
See Also:
GroovyCollections.combinations
Since:
1.5.0


compareTo

public static int compareTo(Character left, Number right)


compareTo

public static int compareTo(Number left, Character right)


compareTo

public static int compareTo(Character left, Character right)


compareTo

public static int compareTo(Number left, Number right)


contains

public static boolean contains(String self, String text)
Checks whether the array contains the given value.
Parameters:
self - the array we are searching
value - the value being searched for
Returns:
true if the array contains the value
Since:
1.8.6


contains

public static boolean contains(CharSequence self, CharSequence text)
Checks whether the array contains the given value.
Parameters:
self - the array we are searching
value - the value being searched for
Returns:
true if the array contains the value
Since:
1.8.6


contains

public static boolean contains(int[] self, Object value)
Checks whether the array contains the given value.
Parameters:
self - the array we are searching
value - the value being searched for
Returns:
true if the array contains the value
Since:
1.8.6


contains

public static boolean contains(long[] self, Object value)
Count the number of occurrences of a substring.
Parameters:
self - a String
text - a substring
Returns:
the number of occurrences of the given string inside this String
Since:
1.0


contains

public static boolean contains(short[] self, Object value)


contains

public static boolean contains(char[] self, Object value)


contains

public static boolean contains(boolean[] self, Object value)


contains

public static boolean contains(double[] self, Object value)


contains

public static boolean contains(float[] self, Object value)
This method is called by the -- operator for the class String. It decrements the last character in the given string. If the character in the string is Character.MIN_VALUE it will be deleted. The empty string can't be decremented.
Parameters:
self - a String
Returns:
a String with a decremented digit at the end
Since:
1.0


contains

public static boolean contains(byte[] self, Object value)


contains

public static boolean contains(Object[] self, Object value)


containsAll

public static boolean containsAll(Collection self, Object[] items)


count

public static Number count(Iterator self, Object value)


count

public static Number count(Iterator self, Closure closure)
Counts the number of occurrences which satisfy the given closure from the items within this Iterator. The iterator will become exhausted of elements after determining the count value.

Example usage:

assert [2,4,2,1,3,5,2,4,3].toSet().iterator().count{ it % 2 == 0 } == 2
Parameters:
self - the Iterator from which we count the number of matching occurrences
closure - a closure condition
Returns:
the number of occurrences
Since:
1.8.0


count

public static Number count(Collection self, Object value)
Counts the number of occurrences of the given value inside this collection. Comparison is done using Groovy's == operator (using compareTo(value) == 0 or equals(value) ).

Example usage:

assert [2,4,2,1,3,5,2,4,3].count(4) == 2
Parameters:
self - the collection within which we count the number of occurrences
value - the value being searched for
Returns:
the number of occurrences
Since:
1.0


count

public static Number count(Collection self, Closure closure)


count

public static Number count(Map self, Closure closure)


count

public static Number count(Object[] self, Object value)
Counts the number of occurrences of the given value inside this array. Comparison is done using Groovy's == operator (using compareTo(value) == 0 or equals(value) ).
Parameters:
self - the array within which we count the number of occurrences
value - the value being searched for
Returns:
the number of occurrences
Since:
1.6.4


count

public static Number count(Object[] self, Closure closure)


count

public static Number count(int[] self, Object value)


count

public static Number count(long[] self, Object value)


count

public static Number count(short[] self, Object value)


count

public static Number count(char[] self, Object value)


count

public static Number count(boolean[] self, Object value)


count

public static Number count(double[] self, Object value)


count

public static Number count(float[] self, Object value)


count

public static Number count(byte[] self, Object value)


count

public static int count(String self, String text)


count

public static int count(CharSequence self, CharSequence text)


countBy

public static Map countBy(Collection self, Closure closure)


countBy

public static Map countBy(Object[] self, Closure closure)


countBy

public static Map countBy(Iterator self, Closure closure)


countBy

public static Map countBy(Map self, Closure closure)
Groups the current element according to the value
Parameters:
answer - the map containing the results
element - the element to be placed
value - the value according to which the element will be placed
Since:
1.5.0


createStringBufferWriter

protected static StringBufferWriter createStringBufferWriter(StringBuffer self)


createStringWriter

protected static StringWriter createStringWriter(String self)


deleteDir

public static boolean deleteDir(File self)
Creates a new data output stream for this file.
throws:
IOException if an IOException occurs.
Parameters:
file - a file object
Returns:
the created DataOutputStream
Since:
1.5.0


denormalize

public static String denormalize(String self)


denormalize

public static CharSequence denormalize(CharSequence self)
Reads the stream into a list, with one element for each line.
throws:
IOException if an IOException occurs.
Parameters:
stream - a stream
Returns:
a List of lines
See Also:
readLines(java.io.Reader)
Since:
1.0


disjoint

public static boolean disjoint(Collection left, Collection right)
Compare the contents of this array to the contents of the given array.
Parameters:
left - an int array
right - the array being compared
Returns:
true if the contents of both arrays are equal.
Since:
1.5.0


div

public static Number div(Character left, Number right)
Bitwise AND together two BitSets.
Parameters:
left - a BitSet
right - another BitSet to bitwise AND
Returns:
the bitwise AND of both BitSets
Since:
1.5.0


div

public static Number div(Number left, Character right)
Bitwise XOR together two BitSets. Called when the '^' operator is used between two bit sets.
Parameters:
left - a BitSet
right - another BitSet to bitwise AND
Returns:
the bitwise XOR of both BitSets
Since:
1.5.0


div

public static Number div(Character left, Character right)
Bitwise NEGATE a BitSet.
Parameters:
self - a BitSet
Returns:
the bitwise NEGATE of the BitSet
Since:
1.5.0


downto

public static void downto(Number self, Number to, Closure closure)
Iterates from this number down to the given number, inclusive, decrementing by one each time.
Parameters:
self - a double
to - the end number
closure - the code to execute for each number
Since:
1.0


downto

public static void downto(long self, Number to, Closure closure)
Iterates from this number down to the given number, inclusive, decrementing by one each time.
Parameters:
self - a BigInteger
to - the end number
closure - the code to execute for each number
Since:
1.0


downto

public static void downto(Long self, Number to, Closure closure)


downto

public static void downto(float self, Number to, Closure closure)
Iterates from this number down to the given number, inclusive, decrementing by one each time. Each number is passed to the closure. Example:
10.5.downto(0) {
   println it
 }
Prints numbers 10.5, 9.5 ... to 0.5.
Parameters:
self - a BigDecimal
to - the end number
closure - the code to execute for each number
Since:
1.0


downto

public static void downto(Float self, Number to, Closure closure)


downto

public static void downto(double self, Number to, Closure closure)


downto

public static void downto(Double self, Number to, Closure closure)


downto

public static void downto(BigInteger self, Number to, Closure closure)


downto

public static void downto(BigDecimal self, Number to, Closure closure)
Get the absolute value
Parameters:
number - a Number
Returns:
the absolute value of that Number
Since:
1.0


drop

public static List drop(List self, int num)
Drops the given number of elements from the head of this Iterable.
 class AbcIterable implements Iterable {
     Iterator iterator() { "abc".iterator() }
 }
 def abc = new AbcIterable()
 assert abc.drop(0) == ['a', 'b', 'c']
 assert abc.drop(1) == ['b', 'c']
 assert abc.drop(3) == []
 assert abc.drop(5) == []
 
Parameters:
self - the original Iterable
num - the number of elements to drop from this Iterable
Returns:
a List consisting of all the elements of this Iterable minus the first num elements, or an empty list if it has less then num elements.
Since:
1.8.7


drop

public static List drop(Iterable self, int num)
Drops the given number of elements from the head of this array if they are available.
 String[] strings = [ 'a', 'b', 'c' ]
 assert strings.drop( 0 ) == [ 'a', 'b', 'c' ] as String[]
 assert strings.drop( 2 ) == [ 'c' ] as String[]
 assert strings.drop( 5 ) == [] as String[]
 
Parameters:
self - the original array
num - the number of elements to drop from this array
Returns:
an array consisting of all elements of this array except the first num ones, or else the empty array, if this array has less than num elements.
Since:
1.8.1


drop

public static Object[] drop(Object[] self, int num)
Drops the given number of key/value pairs from the head of this map if they are available.
 def strings = [ 'a':10, 'b':20, 'c':30 ]
 assert strings.drop( 0 ) == [ 'a':10, 'b':20, 'c':30 ]
 assert strings.drop( 2 ) == [ 'c':30 ]
 assert strings.drop( 5 ) == [:]
 
If the map instance does not have ordered keys, then this function could drop a random num entries. Groovy by default uses LinkedHashMap, so this shouldn't be an issue in the main.
Parameters:
self - the original map
num - the number of elements to drop from this map
Returns:
a map consisting of all key/value pairs of this map except the first num ones, or else the empty map, if this map has less than num elements.
Since:
1.8.1


drop

public static Map drop(Map self, int num)
Drops the given number of elements from the head of this iterator if they are available. The original iterator is stepped along by num elements.
 def iteratorCompare( Iterator a, List b ) {
     a.collect { it } == b
 }
 def iter = [ 1, 2, 3, 4, 5 ].listIterator()
 assert iteratorCompare( iter.drop( 0 ), [ 1, 2, 3, 4, 5 ] )
 iter = [ 1, 2, 3, 4, 5 ].listIterator()
 assert iteratorCompare( iter.drop( 2 ), [ 3, 4, 5 ] )
 iter = [ 1, 2, 3, 4, 5 ].listIterator()
 assert iteratorCompare( iter.drop( 5 ), [] )
 
Parameters:
self - the original iterator
num - the number of elements to drop from this iterator
Returns:
The iterator stepped along by num elements if they exist.
Since:
1.8.1


drop

public static Iterator drop(Iterator self, int num)
Drops the given number of chars from the head of this CharSequence if they are available.
     def text = "Groovy"
     assert text.drop( 0 ) == 'Groovy'
     assert text.drop( 2 ) == 'oovy'
     assert text.drop( 7 ) == ''
 
Parameters:
self - the original CharSequence
num - the number of characters to drop from this iterator
Returns:
a CharSequence consisting of all characters except the first num ones, or else an empty String, if this CharSequence has less than num characters.
Since:
1.8.1


drop

public static CharSequence drop(CharSequence self, int num)


dropWhile

public static List dropWhile(List self, Closure condition)
Returns a suffix of this Iterable where elements are dropped from the front while the given closure evaluates to true.
 class AbcIterable implements Iterable {
     Iterator iterator() { "abc".iterator() }
 }
 def abc = new AbcIterable()
 assert abc.dropWhile{ it < 'b' } == ['b', 'c']
 assert abc.dropWhile{ it <= 'b' } == ['c']
 
Parameters:
self - an Iterable
condition - the closure that must evaluate to true to continue dropping elements
Returns:
the shortest suffix of the given Iterable such that the given closure condition evaluates to true for each element dropped from the front of the Iterable
Since:
1.8.7


dropWhile

public static List dropWhile(Iterable self, Closure condition)


dropWhile

public static Map dropWhile(Map self, Closure condition)
Create a suffix of the given array by dropping as many elements as possible from the front of the original array such that calling the given closure condition evaluates to true when passed each of the dropped elements.
 def nums = [ 1, 3, 2 ] as Integer[]
 assert nums.dropWhile{ it <= 3 } == [ ] as Integer[]
 assert nums.dropWhile{ it < 3 } == [ 3, 2 ] as Integer[]
 assert nums.dropWhile{ it != 2 } == [ 2 ] as Integer[]
 assert nums.dropWhile{ it == 0 } == [ 1, 3, 2 ] as Integer[]
 
Parameters:
self - the original array
condition - the closure that must evaluate to true to continue dropping elements
Returns:
the shortest suffix of the given array such that the given closure condition evaluates to true for each element dropped from the front of the array
Since:
1.8.7


dropWhile

public static Object[] dropWhile(Object[] self, Closure condition)
Creates an Iterator that returns a suffix of the elements from an original Iterator. As many elements as possible are dropped from the front of the original Iterator such that calling the given closure condition evaluates to true when passed each of the dropped elements.

 def a = 0
 def iter = [ hasNext:{ a < 10 }, next:{ a++ } ] as Iterator
 assert [].iterator().dropWhile{ it < 3 }.toList() == []
 assert [1, 2, 3, 4, 5].iterator().dropWhile{ it < 3 }.toList() == [ 3, 4, 5 ]
 assert iter.dropWhile{ it < 5 }.toList() == [ 5, 6, 7, 8, 9 ]
 
Parameters:
self - the Iterator
condition - the closure that must evaluate to true to continue dropping elements
Returns:
the shortest suffix of elements from the given Iterator such that the given closure condition evaluates to true for each element dropped from the front of the Iterator
Since:
1.8.7


dropWhile

public static Iterator dropWhile(Iterator self, Closure condition)


dump

public static String dump(Object self)
Generates a detailed dump string of an object showing its class, hashCode and fields.
Parameters:
self - an object
Returns:
the dump representation
Since:
1.0


each

public static Object each(Object self, Closure closure)
Iterates through an aggregate type or data structure, passing each item to the given closure. Custom types may utilize this method by simply providing an "iterator()" method. The items returned from the resulting iterator will be passed to the closure.
Parameters:
self - the object over which we iterate
closure - the closure applied on each element found
Returns:
the self Object
Since:
1.0


each

public static Map each(Map self, Closure closure)
Allows a Map to be iterated through using a closure. If the closure takes one parameter then it will be passed the Map.Entry otherwise if the closure takes two parameters then it will be passed the key and the value.
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.
Parameters:
self - the map over which we iterate
closure - the 1 or 2 arg closure applied on each entry of the map
Returns:
returns the self parameter
Since:
1.5.0


eachByte

public static void eachByte(File self, Closure closure)


eachByte

public static void eachByte(File self, int bufferLen, Closure closure)


eachByte

public static void eachByte(Byte[] self, Closure closure)


eachByte

public static void eachByte(byte[] self, Closure closure)


eachByte

public static void eachByte(InputStream is, Closure closure)


eachByte

public static void eachByte(InputStream is, int bufferLen, Closure closure)
Filters the lines of a File and creates a Writable in return to stream the filtered lines.
throws:
IOException if self is not readable
Parameters:
self - a File
closure - a closure which returns a boolean indicating to filter the line or not
Returns:
a Writable closure
See Also:
filterLine(java.io.Reader, groovy.lang.Closure)
Since:
1.0


eachByte

public static void eachByte(URL url, Closure closure)
Filter the lines from this File, and write them to the given writer based on the given closure predicate.
throws:
IOException if self is not readable
Parameters:
self - a File
writer - a writer destination to write filtered lines to
closure - a closure which takes each line as a parameter and returns true if the line should be written to this writer.
See Also:
filterLine(java.io.Reader, java.io.Writer, groovy.lang.Closure)
Since:
1.0


eachByte

public static void eachByte(URL url, int bufferLen, Closure closure)
Filter the lines from this File, and write them to the given writer based on the given closure predicate.
throws:
IOException if an IO error occurs
Parameters:
self - a File
writer - a writer destination to write filtered lines to
charset - opens the file with a specified charset
closure - a closure which takes each line as a parameter and returns true if the line should be written to this writer.
See Also:
filterLine(java.io.Reader, java.io.Writer, groovy.lang.Closure)
Since:
1.6.8


eachDir

public static void eachDir(File self, Closure closure)


eachDirMatch

public static void eachDirMatch(File self, Object nameFilter, Closure closure)
Create a buffered output stream for this file.
throws:
IOException if an IOException occurs.
Parameters:
file - a file object
Returns:
the created OutputStream
Since:
1.0


eachDirRecurse

public static void eachDirRecurse(File self, Closure closure)
Create a buffered reader for this file.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
Returns:
a BufferedReader
Since:
1.0


eachFile

public static void eachFile(File self, FileType fileType, Closure closure)


eachFile

public static void eachFile(File self, Closure closure)


eachFileMatch

public 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.
throws:
FileNotFoundException if the File was not found
throws:
UnsupportedEncodingException if the encoding specified is not supported
Parameters:
file - a File
charset - the charset for this File
Returns:
a BufferedReader
Since:
1.0


eachFileMatch

public static void eachFileMatch(File self, Object nameFilter, Closure closure)
Create a new BufferedReader for this file and then passes it into the closure, ensuring the reader is closed after the closure returns.
throws:
IOException if an IOException occurs.
Parameters:
file - a file object
closure - a closure
Returns:
the value returned by the closure
Since:
1.5.2


eachFileRecurse

public static void eachFileRecurse(File self, FileType fileType, Closure closure)


eachFileRecurse

public static void eachFileRecurse(File self, Closure closure)
Renames the file. It's a shortcut for File.renameTo
Parameters:
self - a File
newPathName - The new pathname for the named file
Returns:
true if and only if the renaming succeeded; false otherwise
Since:
1.7.4


eachLine

public static Object eachLine(String self, Closure closure)


eachLine

public static Object eachLine(CharSequence self, Closure closure)


eachLine

public static Object eachLine(String self, int firstLine, Closure closure)


eachLine

public static Object eachLine(CharSequence self, int firstLine, Closure closure)


eachLine

public static Object eachLine(File self, Closure closure)


eachLine

public static Object eachLine(File self, String charset, Closure closure)


eachLine

public static Object eachLine(File self, int firstLine, Closure closure)


eachLine

public static Object eachLine(File self, String charset, int firstLine, Closure closure)
Iterates through the given reader line by line. Each line is passed to the given 1 or 2 arg closure. If the closure has two arguments, the line count is passed as the second argument. The Reader is closed before this method returns.
throws:
IOException if an IOException occurs.
Parameters:
self - a Reader, closed after the method returns
closure - a closure (arg 1 is line, optional arg 2 is line number starting at line 1)
Returns:
the last value returned by the closure
See Also:
eachLine(java.io.Reader, int, groovy.lang.Closure)
Since:
1.5.6


eachLine

public static Object eachLine(InputStream stream, String charset, Closure closure)
Iterates through the given reader line by line. Each line is passed to the given 1 or 2 arg closure. If the closure has two arguments, the line count is passed as the second argument. The Reader is closed before this method returns.
throws:
IOException if an IOException occurs.
Parameters:
self - a Reader, closed after the method returns
firstLine - the line number value used for the first line (default is 1, set to 0 to start counting from 0)
closure - a closure which will be passed each line (or for 2 arg closures the line and line count)
Returns:
the last value returned by the closure
Since:
1.5.7


eachLine

public static Object eachLine(InputStream stream, String charset, int firstLine, Closure closure)


eachLine

public static Object eachLine(InputStream stream, Closure closure)


eachLine

public static Object eachLine(InputStream stream, int firstLine, Closure closure)


eachLine

public static Object eachLine(URL url, Closure closure)


eachLine

public static Object eachLine(URL url, int firstLine, Closure closure)


eachLine

public static Object eachLine(URL url, String charset, Closure closure)


eachLine

public static Object eachLine(URL url, String charset, int firstLine, Closure closure)


eachLine

public static Object eachLine(Reader self, Closure closure)


eachLine

public static Object eachLine(Reader self, int firstLine, Closure closure)
Iterates through the input stream associated with this URL line by line, splitting each line using the given regex separator Pattern. For each line, the given closure is called with a single parameter being the list of strings computed by splitting the line around matches of the given regular expression. Finally the resources used for processing the URL are closed.
throws:
IOException if an IOException occurs.
Parameters:
self - a URL to open and read
pattern - the regular expression Pattern for the delimiter
closure - a closure
Returns:
the last value returned by the closure
See Also:
splitEachLine(java.io.Reader, java.util.regex.Pattern, groovy.lang.Closure)
Since:
1.6.8


eachMatch

public static String eachMatch(String self, String regex, Closure closure)


eachMatch

public static String eachMatch(CharSequence self, CharSequence regex, Closure closure)


eachMatch

public static String eachMatch(String self, Pattern pattern, Closure closure)
Converts a given object to a type. This method is used through the "as" operator and is overloadable as any other operator.
Parameters:
obj - the object to convert
type - the goal type
Returns:
the resulting object
Since:
1.0


eachMatch

public static String eachMatch(CharSequence self, Pattern pattern, Closure closure)


eachObject

public static void eachObject(File self, Closure closure)


eachObject

public static void eachObject(ObjectInputStream ois, Closure closure)


eachPermutation

public static Iterator eachPermutation(Collection self, Closure closure)


eachWithIndex

public static Object eachWithIndex(Object self, Closure closure)


eachWithIndex

public static Map eachWithIndex(Map self, Closure closure)
Allows a Map to be iterated through using a closure. If the closure takes two parameters then it will be passed the Map.Entry and the item's index (a counter starting at zero) otherwise if the closure takes three parameters then it will be passed the key, the value, and the index.
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)"
Parameters:
self - the map over which we iterate
closure - a 2 or 3 arg Closure to operate on each item
Returns:
the self Object
Since:
1.5.0


equals

public 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. This returns false if either collection is null.
Parameters:
left - an array
right - the List being compared
Returns:
true if the contents of both collections are equal
Since:
1.5.0


equals

public static boolean equals(Object[] left, List right)


equals

public static boolean equals(List left, Object[] right)


equals

public static boolean equals(List left, List right)


equals

public static boolean equals(Set self, Set other)


equals

public static boolean equals(Map self, Map other)
Create a Set composed of the elements of the first Set minus the elements of the given Collection.
Parameters:
self - a Set object
removeMe - the items to remove from the Set
Returns:
the resulting Set
Since:
1.5.0


every

public static boolean every(Object self, Closure closure)


every

public static boolean every(Map self, Closure closure)
Iterates over the entries of a map, and checks whether a predicate is valid for all entries. If the closure takes one parameter then it will be passed the Map.Entry otherwise if the closure takes two parameters then it will be passed the key and the value.
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 }
Parameters:
self - the map over which we iterate
closure - the 1 or 2 arg Closure predicate used for matching
Returns:
true if every entry of the map matches the closure predicate
Since:
1.5.0


every

public static boolean every(Object self)
Iterates over every element of a collection, and checks whether all elements are true according to the Groovy Truth. Equivalent to self.every({element -> element})
Parameters:
self - the object over which we iterate
Returns:
true if every item in the collection matches the closure predicate
Since:
1.5.0


execute

public static Process execute(String self)


execute

public static Process execute(String self, String[] envp, File dir)


execute

public static Process execute(String self, List envp, File dir)


execute

public static Process execute(String[] commandArray)


execute

public static Process execute(String[] commandArray, String[] envp, File dir)
Repeat a String a certain number of times.
throws:
IllegalArgumentException if the number of repetitions is < 0
Parameters:
self - a String to be repeated
factor - the number of times the String should be repeated
Returns:
a String composed of a repetition
Since:
1.0


execute

public static Process execute(String[] commandArray, List envp, File dir)
Repeat a CharSequence a certain number of times.
throws:
IllegalArgumentException if the number of repetitions is < 0
Parameters:
self - a CharSequence to be repeated
factor - the number of times the CharSequence should be repeated
Returns:
a CharSequence composed of a repetition
Since:
1.8.2


execute

public static Process execute(List commands)
Returns the string representation of the given array.
Parameters:
self - an array
Returns:
the string representation
Since:
1.6.0


execute

public static Process execute(List commands, String[] envp, File dir)
Returns the string representation of the given array.
Parameters:
self - an array
Returns:
the string representation
Since:
1.6.0


execute

public static Process execute(List commands, List envp, File dir)
Returns the string representation of the given array.
Parameters:
self - an array
Returns:
the string representation
Since:
1.6.0


expand

public static String expand(String self)
Replaces sequences of whitespaces with tabs using tabStops of size 8.
Parameters:
self - A CharSequence to unexpand
Returns:
The unexpanded CharSequence
See Also:
unexpand(java.lang.String)
Since:
1.8.2


expand

public static CharSequence expand(CharSequence self)
Replaces sequences of whitespaces with tabs.
Parameters:
self - A String to unexpand
tabStop - The number of spaces a tab represents
Returns:
The unexpanded String
Since:
1.7.3


expand

public static String expand(String self, int tabStop)


expand

public static CharSequence expand(CharSequence self, int tabStop)
Replaces sequences of whitespaces with tabs.
Parameters:
self - A CharSequence to unexpand
tabStop - The number of spaces a tab represents
Returns:
The unexpanded CharSequence
See Also:
unexpand(String, int)
Since:
1.8.2


expandLine

public static String expandLine(String self, int tabStop)


expandLine

public static CharSequence expandLine(CharSequence self, int tabStop)
Replaces sequences of whitespaces with tabs within a line.
Parameters:
self - A line to unexpand
tabStop - The number of spaces a tab represents
Returns:
The unexpanded CharSequence
See Also:
unexpandLine(String, int)
Since:
1.8.2


filterLine

public static void filterLine(Reader reader, Writer writer, Closure closure)
Filter lines from an input stream using a closure predicate. The closure will be passed each line as a String, and it should return true if the line should be passed to the writer.
throws:
UnsupportedEncodingException if the encoding specified is not supported
Parameters:
self - an input stream
charset - opens the stream with a specified charset
predicate - a closure which returns boolean and takes a line
Returns:
a writable which writes out the filtered lines
See Also:
filterLine(java.io.Reader, groovy.lang.Closure)
Since:
1.6.8


filterLine

public static Writable filterLine(File self, Closure closure)
Uses a closure to filter lines from this InputStream and pass them to the given writer. The closure will be passed each line as a String, and it should return true if the line should be passed to the writer.
throws:
IOException if an IOException occurs.
Parameters:
self - the InputStream
writer - a writer to write output to
charset - opens the stream with a specified charset
predicate - a closure which returns true if a line should be accepted
See Also:
filterLine(java.io.Reader, java.io.Writer, groovy.lang.Closure)
Since:
1.6.8


filterLine

public static Writable filterLine(File self, String charset, Closure closure)


filterLine

public static void filterLine(File self, Writer writer, Closure closure)
Uses a closure to filter lines from this URL and pass them to the given writer. The closure will be passed each line as a String, and it should return true if the line should be passed to the writer.
throws:
IOException if an IOException occurs.
Parameters:
self - the URL
writer - a writer to write output to
predicate - a closure which returns true if a line should be accepted
See Also:
filterLine(java.io.Reader, java.io.Writer, groovy.lang.Closure)
Since:
1.6.8


filterLine

public static void filterLine(File self, Writer writer, String charset, Closure closure)
Uses a closure to filter lines from this URL and pass them to the given writer. The closure will be passed each line as a String, and it should return true if the line should be passed to the writer.
throws:
IOException if an IOException occurs.
Parameters:
self - the URL
writer - a writer to write output to
charset - opens the URL with a specified charset
predicate - a closure which returns true if a line should be accepted
See Also:
filterLine(java.io.Reader, java.io.Writer, groovy.lang.Closure)
Since:
1.6.8


filterLine

public static Writable filterLine(Reader reader, Closure closure)
Reads the content of the file into a byte array.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
Returns:
a byte array with the contents of the file.
Since:
1.0


filterLine

public static Writable filterLine(InputStream self, Closure predicate)
Passes the Socket's InputStream and OutputStream to the closure. The streams will be closed after the closure returns, even if an exception is thrown.
throws:
IOException if an IOException occurs.
Parameters:
socket - a Socket
closure - a Closure
Returns:
the value returned by the closure
Since:
1.5.2


filterLine

public static Writable filterLine(InputStream self, String charset, Closure predicate)


filterLine

public static void filterLine(InputStream self, Writer writer, Closure predicate)


filterLine

public static void filterLine(InputStream self, Writer writer, String charset, Closure predicate)


filterLine

public static Writable filterLine(URL self, Closure predicate)


filterLine

public static Writable filterLine(URL self, String charset, Closure predicate)
Accepts a connection and passes the resulting Socket to the closure which runs in a new Thread.
throws:
IOException if an IOException occurs.
Parameters:
serverSocket - a ServerSocket
closure - a Closure
Returns:
a Socket
See Also:
ServerSocket.accept
Since:
1.0


filterLine

public static void filterLine(URL self, Writer writer, Closure predicate)
Accepts a connection and passes the resulting Socket to the closure which runs in a new Thread or the calling thread, as needed.
throws:
IOException if an IOException occurs.
Parameters:
serverSocket - a ServerSocket
runInANewThread - This flag should be true, if the closure should be invoked in a new thread, else false.
closure - a Closure
Returns:
a Socket
See Also:
ServerSocket.accept
Since:
1.7.6


filterLine

public static void filterLine(URL self, Writer writer, String charset, Closure predicate)


find

public static Object find(Object self, Closure closure)
Finds the first value matching the closure condition
Parameters:
self - an Object with an iterator returning its values
closure - a closure condition
Returns:
the first Object found or null if none was found
Since:
1.0


find

public static Object find(Object self)
Treats the object as iterable, iterating through the values it represents and returns the first non-null result obtained from calling the closure, otherwise returns the defaultResult.
Parameters:
self - an Object with an iterator returning its values
defaultResult - an Object that should be returned if all closure results are null
closure - a closure that returns a non-null value when processing should stop
Returns:
the first non-null result of the closure, otherwise the default value
Since:
1.7.5


find

public static Object find(Collection self, Closure closure)


find

public static Object find(Collection self)


find

public static Map.Entry find(Map self, Closure closure)


find

public static String find(String self, String regex)
Finds the first occurrence of a regular expression CharSequence within a CharSequence.
Parameters:
self - a CharSequence
regex - the capturing regex
Returns:
a CharSequence containing the matched portion, or null if the regex doesn't match
See Also:
find(String, Pattern)
Since:
1.8.2


find

public static CharSequence find(CharSequence self, CharSequence regex)


find

public static String find(String self, Pattern pattern)
Finds the first occurrence of a compiled regular expression Pattern within a CharSequence.
Parameters:
self - a CharSequence
pattern - the compiled regex Pattern
Returns:
a CharSequence containing the matched portion, or null if the regex pattern doesn't match
See Also:
find(String, Pattern)
Since:
1.8.2


find

public static CharSequence find(CharSequence self, Pattern pattern)


find

public static String find(String self, String regex, Closure closure)
Returns the result of calling a closure with the first occurrence of a regular expression found within a CharSequence. If the regex doesn't match, the closure will not be called and find will return null.
Parameters:
self - a CharSequence
regex - the capturing regex CharSequence
closure - the closure that will be passed the full match, plus each of the capturing groups
Returns:
a CharSequence containing the result of the closure, or null if the regex pattern doesn't match
See Also:
find(String, Pattern, Closure)
Since:
1.8.2


find

public static CharSequence find(CharSequence self, CharSequence regex, Closure closure)


find

public static String find(String self, Pattern pattern, Closure closure)


find

public static CharSequence find(CharSequence self, Pattern pattern, Closure closure)
Returns a (possibly empty) list of all occurrences of a regular expression (in String format) found within a String.

For example, if the regex 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/)
 
If you need to work with capture groups, then use the closure version of this method or use Groovy's matcher operators or use eachMatch.

Parameters:
self - a String
regex - the capturing regex String
Returns:
a List containing all full matches of the regex within the string, an empty list will be returned if there are no matches
Since:
1.6.1


findAll

public static Collection findAll(Collection self, Closure closure)


findAll

public static Collection findAll(Collection self)
Finds all items matching the closure condition.
Parameters:
self - an Object with an Iterator returning its values
closure - a closure condition
Returns:
a List of the values found
Since:
1.6.0


findAll

public static Collection findAll(Object self, Closure closure)


findAll

public static Collection findAll(Object self)


findAll

public static Map findAll(Map self, Closure closure)


findAll

public static List findAll(String self, String regex)


findAll

public static List findAll(CharSequence self, CharSequence regex)


findAll

public static List findAll(String self, Pattern pattern)
Returns a (possibly empty) list of all occurrences of a regular expression (in Pattern format) found within a CharSequence.
Parameters:
self - a CharSequence
pattern - the compiled regex Pattern
Returns:
a List containing all full matches of the Pattern within the CharSequence, an empty list will be returned if there are no matches
See Also:
findAll(String, Pattern)
Since:
1.8.2


findAll

public static List findAll(CharSequence self, Pattern pattern)


findAll

public static List findAll(String self, String regex, Closure closure)
Finds all occurrences of a capturing regular expression CharSequence within a CharSequence.
Parameters:
self - a CharSequence
regex - the capturing regex CharSequence
closure - will be passed the full match plus each of the capturing groups
Returns:
a List containing all full matches of the regex within the CharSequence, an empty list will be returned if there are no matches
See Also:
findAll(String, String, Closure)
Since:
1.8.2


findAll

public static List findAll(CharSequence self, CharSequence regex, Closure closure)


findAll

public static List findAll(String self, Pattern pattern, Closure closure)
Finds all occurrences of a compiled regular expression Pattern within a CharSequence.
Parameters:
self - a CharSequence
pattern - the compiled regex Pattern
closure - will be passed the full match plus each of the capturing groups
Returns:
a List containing all full matches of the regex Pattern within the CharSequence, an empty list will be returned if there are no matches
See Also:
findAll(String, Pattern, Closure)
Since:
1.8.2


findAll

public static List findAll(CharSequence self, Pattern pattern, Closure closure)


findIndexOf

public static int findIndexOf(Object self, Closure closure)


findIndexOf

public static int findIndexOf(Object self, int startIndex, Closure closure)


findIndexValues

public static List findIndexValues(Object self, Closure closure)
Convenience method to dynamically create a new instance of this class. Calls the default constructor.
Parameters:
c - a class
Returns:
a new instance of this class
Since:
1.0


findIndexValues

public static List findIndexValues(Object self, Number startIndex, Closure closure)
Adds a "metaClass" property to all class objects so you can use the syntax String.metaClass.myMethod = { println "foo" }
Parameters:
c - The java.lang.Class instance
Returns:
An MetaClass instance
Since:
1.5.0


findLastIndexOf

public static int findLastIndexOf(Object self, Closure closure)


findLastIndexOf

public static int findLastIndexOf(Object self, int startIndex, Closure closure)


findResult

public static Object findResult(Object self, Object defaultResult, Closure closure)


findResult

public static Object findResult(Object self, Closure closure)


findResult

public static Object findResult(Collection self, Object defaultResult, Closure closure)


findResult

public static Object findResult(Collection self, Closure closure)


findResult

public static Object findResult(Map self, Object defaultResult, Closure closure)


findResult

public static Object findResult(Map self, Closure closure)


findResults

public static Collection findResults(Collection self, Closure filteringTransform)


findResults

public static Collection findResults(Map self, Closure filteringTransform)


first

public static Object first(List self)


first

public static Object first(Iterable self)


first

public static Object first(Object[] self)
Returns the first item from the Object array.
def array = [3, 4, 2].toArray()
 assert array.head() == 3
throws:
NoSuchElementException if the array is empty and you try to access the head() item.
Parameters:
self - an Object array
Returns:
the first item from the Object array
Since:
1.7.3


flatten

public static Collection flatten(Collection self)
Flatten an array. This array and any nested arrays or collections have their contents (recursively) added to the new collection.
Parameters:
self - a byte Array to flatten
Returns:
a flattened Collection
Since:
1.6.0


flatten

public static Collection flatten(Object[] self)
Flatten an array. This array and any nested arrays or collections have their contents (recursively) added to the new collection.
Parameters:
self - a short Array to flatten
Returns:
a flattened Collection
Since:
1.6.0


flatten

public static Collection flatten(boolean[] self)
Flatten an array. This array and any nested arrays or collections have their contents (recursively) added to the new collection.
Parameters:
self - an int Array to flatten
Returns:
a flattened Collection
Since:
1.6.0


flatten

public static Collection flatten(byte[] self)
Flatten an array. This array and any nested arrays or collections have their contents (recursively) added to the new collection.
Parameters:
self - a long Array to flatten
Returns:
a flattened Collection
Since:
1.6.0


flatten

public static Collection flatten(char[] self)
Flatten an array. This array and any nested arrays or collections have their contents (recursively) added to the new collection.
Parameters:
self - a float Array to flatten
Returns:
a flattened Collection
Since:
1.6.0


flatten

public static Collection flatten(short[] self)
Flatten an array. This array and any nested arrays or collections have their contents (recursively) added to the new collection.
Parameters:
self - a double Array to flatten
Returns:
a flattened Collection
Since:
1.6.0


flatten

public static Collection flatten(int[] self)


flatten

public static Collection flatten(long[] self)


flatten

public static Collection flatten(float[] self)


flatten

public static Collection flatten(double[] self)


flatten

public static Collection flatten(Collection self, Closure flattenUsing)
Overloads the left shift operator to provide an easy way to append objects to a Collection.
def list = [1,2]
 list << 3
 assert list == [1,2,3]
Parameters:
self - a Collection
value - an Object to be added to the collection.
Returns:
same collection, after the value was added to it.
Since:
1.0


get

public static Object get(Map map, Object key, Object defaultValue)
Support the range subscript operator for an Array
Parameters:
array - an Array of Objects
range - a Range
Returns:
a range of a list from the range's from index up to but not including the range's to value
Since:
1.0


getAt

public static Object getAt(Object self, String property)
Allows the subscript operator to be used to lookup dynamic property values. bean[somePropertyNameExpression]. The normal property notation of groovy is neater and more concise but only works with compile-time known property names.
Parameters:
self - the object to act upon
property - the property name of interest
Returns:
the property value
Since:
1.0


getAt

public static CharSequence getAt(CharSequence text, int index)


getAt

public static String getAt(String text, int index)


getAt

public static CharSequence getAt(CharSequence text, Range range)


getAt

public static CharSequence getAt(CharSequence text, IntRange range)
Support the range subscript operator for CharSequence or StringBuffer with EmptyRange
Parameters:
text - a CharSequence
range - an EmptyRange
Returns:
the subsequence CharSequence
Since:
1.5.0


getAt

public static CharSequence getAt(CharSequence text, EmptyRange range)


getAt

public static String getAt(String text, IntRange range)


getAt

public static String getAt(String text, EmptyRange range)


getAt

public static String getAt(String text, Range range)


getAt

public static Object getAt(Matcher matcher, int idx)
Set the position of the given Matcher to the given index.
Parameters:
matcher - a Matcher
idx - the index number
Since:
1.0


getAt

public static List getAt(List self, Range range)


getAt

public static List getAt(List self, EmptyRange range)


getAt

public static List getAt(List self, Collection indices)


getAt

public static List getAt(Object[] self, Collection indices)
Select a List of characters from a CharSequence using a Collection to identify the indices to be selected.
Parameters:
self - a CharSequence
indices - a Collection of indices
Returns:
a CharSequence consisting of the characters at the given indices
Since:
1.0


getAt

public 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.
Parameters:
self - a String
indices - a Collection of indices
Returns:
a String consisting of the characters at the given indices
Since:
1.0


getAt

public static String getAt(String self, Collection indices)


getAt

public static List getAt(Matcher self, Collection indices)


getAt

public static List getAt(Object[] array, Range range)


getAt

public static List getAt(Object[] array, IntRange range)
Parameters:
array - an Array of Objects
range - an ObjectRange
Returns:
a range of a list from the range's from index up to but not including the range's to value
Since:
1.0


getAt

public static List getAt(Object[] array, EmptyRange range)
Allows conversion of arrays into a mutable List.
Parameters:
array - an Array of Objects
Returns:
the array as a List
Since:
1.0


getAt

public static List getAt(Object[] array, ObjectRange range)
Support the subscript operator for a List.
def list = [2, "a", 5.3]
 assert list[1] == "a"
Parameters:
self - a List
idx - an index
Returns:
the value at the given index
Since:
1.0


getAt

public static Object getAt(List self, int idx)


getAt

public static Object getAt(Iterator self, int idx)


getAt

public static Object getAt(Map self, Object key)
Returns a new Map containing all entries from left and right, giving precedence to right. Any keys appearing in both Maps will appear in the resultant map with values from the right operand. If the left map is one of TreeMap, LinkedHashMap, Hashtable or Properties, the returned Map will preserve that type, otherwise a HashMap will be returned.

Roughly equivalent to Map m = new HashMap(); m.putAll(left); m.putAll(right); return m; but with some additional logic to preserve the left Map type for common cases as described above.

assert [a:10, b:20] + [a:5, c:7] == [a:5, b:20, c:7]
Parameters:
left - a Map
right - a Map
Returns:
a new Map containing all entries from left and right
Since:
1.5.0


getAt

public static List getAt(Collection coll, String property)


getAt

*/
public static List getAt(byte[] array, Range range)


getAt

*/
public static List getAt(char[] array, Range range)


getAt

*/
public static List getAt(short[] array, Range range)


getAt

*/
public static List getAt(int[] array, Range range)


getAt

*/
public static List getAt(long[] array, Range range)


getAt

*/
public static List getAt(float[] array, Range range)


getAt

*/
public static List getAt(double[] array, Range range)


getAt

*/
public static List getAt(boolean[] array, Range range)


getAt

*/
public static List getAt(byte[] array, IntRange range)


getAt

*/
public static List getAt(char[] array, IntRange range)


getAt

*/
public static List getAt(short[] array, IntRange range)


getAt

*/
public static List getAt(int[] array, IntRange range)


getAt

*/
public static List getAt(long[] array, IntRange range)


getAt

*/
public static List getAt(float[] array, IntRange range)


getAt

*/
public static List getAt(double[] array, IntRange range)


getAt

*/
public static List getAt(boolean[] array, IntRange range)


getAt

*/
public static List getAt(byte[] array, ObjectRange range)


getAt

*/
public static List getAt(char[] array, ObjectRange range)


getAt

*/
public static List getAt(short[] array, ObjectRange range)


getAt

*/
public static List getAt(int[] array, ObjectRange range)


getAt

*/
public static List getAt(long[] array, ObjectRange range)


getAt

*/
public static List getAt(float[] array, ObjectRange range)


getAt

*/
public static List getAt(double[] array, ObjectRange range)


getAt

*/
public static List getAt(boolean[] array, ObjectRange range)


getAt

*/
public static List getAt(byte[] array, Collection indices)


getAt

*/
public static List getAt(char[] array, Collection indices)


getAt

*/
public static List getAt(short[] array, Collection indices)


getAt

*/
public static List getAt(int[] array, Collection indices)


getAt

* @since 1.5.0
public static List getAt(long[] array, Collection indices)


getAt

* @see groovy.lang.IntRange
public static List getAt(float[] array, Collection indices)


getAt

if (range.isReverse()) {
public static List getAt(double[] array, Collection indices)


getAt

return (Boolean) primitiveArrayPut(array, idx, newValue);
//
public static List getAt(boolean[] array, Collection indices)


getAt

public static boolean getAt(BitSet self, int index)


getAt

public static BitSet getAt(BitSet self, IntRange range)


getBytes

public static byte[] getBytes(File file)
Write the text to the File.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
text - the text to write to the File
Returns:
the original file
Since:
1.0


getBytes

public static byte[] getBytes(URL url)


getBytes

public static byte[] getBytes(InputStream is)
Write the text to the File, using the specified encoding.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
text - the text to write to the File
charset - the charset used
Since:
1.0


getChars

public static char[] getChars(String self)
Iterates over the elements of an iterable collection of items and returns the index of the first item that matches the condition specified in the closure.
Parameters:
self - the iteration object over which to iterate
closure - the filter to perform a match on the collection
Returns:
an integer that is the index of the first matched object or -1 if no match was found
Since:
1.0


getChars

public static char[] getChars(CharSequence self)


getCount

public static int getCount(Matcher matcher)
Check whether a Matcher contains a group or not.
Parameters:
matcher - a Matcher
Returns:
boolean true if matcher contains at least one group.
Since:
1.0


getMetaClass

public static MetaClass getMetaClass(Class c)


getMetaClass

public static MetaClass getMetaClass(Object obj)
Attempts to create an Iterator for the given object by first converting it to a Collection.
Parameters:
a - an array
Returns:
an Iterator for the given Array.
See Also:
DefaultTypeTransformation.asCollection
Since:
1.6.4


getMetaClass

public static MetaClass getMetaClass(GroovyObject obj)
Attempts to create an Iterator for the given object by first converting it to a Collection.
Parameters:
o - an object
Returns:
an Iterator for the given Object.
See Also:
DefaultTypeTransformation.asCollection
Since:
1.0


getMetaPropertyValues

public 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'.
Parameters:
self - the receiver object
Returns:
list of PropertyValue objects
See Also:
Expando.getMetaPropertyValues
Since:
1.0


getProperties

public 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.&nsbp;without type() information.
Parameters:
self - the receiver object
Returns:
meta properties as Map of key/value pairs
Since:
1.0


getRootLoader

public 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.
Parameters:
obj - The object in question
Returns:
The MetaClass
Since:
1.5.0


getSubList

protected static List getSubList(List self, List splice)


getText

public static String getText(File file, String charset)
Read the content of this URL and returns it as a byte[].
throws:
IOException if an IOException occurs.
Parameters:
url - URL to read content from
Returns:
the byte[] from that URL
Since:
1.7.1


getText

public static String getText(File file)


getText

public static String getText(URL url)


getText

public static String getText(URL url, Map parameters)
Write the bytes from the byte array to the File.
throws:
IOException if an IOException occurs.
Parameters:
file - the file to write to
bytes - the byte[] to write to the file
Since:
1.7.1


getText

public static String getText(URL url, String charset)
Write the byte[] to the output stream. The stream is closed before this method returns.
throws:
IOException if an IOException occurs.
Parameters:
os - an output stream
bytes - the byte[] to write to the output stream
Since:
1.7.1


getText

public static String getText(URL url, Map parameters, String charset)
Write the text and append a newline (using the platform's line-ending).
throws:
IOException if an IOException occurs.
Parameters:
writer - a BufferedWriter
line - the line to write
Since:
1.0


getText

public static String getText(InputStream is)
Write the text to the File.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
text - the text to write to the File
Since:
1.0


getText

public static String getText(InputStream is, String charset)


getText

public static String getText(Reader reader)


getText

public static String getText(BufferedReader reader)


grep

public static Collection grep(Object self, Object filter)
Iterates over the collection of items which this Object represents and returns each item that matches the given filter - calling the 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', 3, 4.5]
 assert list.grep( ~/a+/ )  == ['a', 'aa']
 assert list.grep( ~/../ )  == ['aa', 'bc']
 assert list.grep( Number ) == [ 3, 4.5 ]
 assert list.grep{ it.toString().size() == 1 } == [ 'a', 'b', 3 ]
 
Parameters:
self - the object over which we iterate
filter - the filter to perform on the object (using the isCase(java.lang.Object, java.lang.Object) method)
Returns:
a collection of objects which match the filter
Since:
1.5.6


grep

public static Collection grep(Object self)
Iterates over the collection of items which this Object represents and returns each item that matches using the IDENTITY Closure as a filter - effectively returning all elements which satisfy Groovy truth.

Example:

 def items = [1, 2, 0, false, true, '', 'foo', [], [4, 5], null]
 assert items.grep() == [1, 2, true, 'foo', [4, 5]]
 
Parameters:
self - the object over which we iterate
Returns:
a collection of objects which match the filter
See Also:
Closure.IDENTITY
Since:
1.8.1


groupAnswer

protected static void groupAnswer(Map answer, Object element, Object value)


groupBy

public static Map groupBy(Collection self, Closure closure)


groupBy

public static Map groupBy(Collection self, Object... closures)


groupBy

public static Map groupBy(Collection self, List closures)
Sorts all collection members into (sub)groups determined by the supplied mapping closures. Each closure should return the key that this item should be grouped by. The returned LinkedHashMap will have an entry for each distinct 'key path' returned from the closures, with each value being a list of items for that 'group path'.

Example usage:

def result = [1,2,3,4,5,6].groupBy([{ it % 2 }, { it < 4 }])
 assert result == [1:[(true):[1, 3], (false):[5]], 0:[(true):[2], (false):[4, 6]]]
Another example:
def sql = groovy.sql.Sql.newInstance(/* ... */)
 def data = sql.rows("SELECT * FROM a_table").groupBy([{ it.column1 }, { it.column2 }, { it.column3 }])
 if (data.val1.val2.val3) {
     // there exists a record where:
     //   a_table.column1 == val1
     //   a_table.column2 == val2, and
     //   a_table.column3 == val3
 } else {
     // there is no such record
 }
If an empty list of closures is supplied the IDENTITY Closure will be used.
Parameters:
self - a collection to group
closures - a list of closures, each mapping entries on keys
Returns:
a new Map grouped by keys on each criterion
See Also:
Closure.IDENTITY
Since:
1.8.1


groupBy

public static Map groupBy(Map self, Closure closure)


groupBy

public static Map groupBy(Map self, Object... closures)


groupBy

public static Map groupBy(Map self, List closures)
Groups the members of a map into sub maps determined by the supplied mapping closures. Each closure will be passed a Map.Entry or key and value (depending on the number of parameters the closure accepts) and should return the key that each item should be grouped under. The resulting map will have an entry for each 'group path' returned by all closures, with values being the map members from the original map that belong to each such 'group path'.

If the self map is one of TreeMap, Hashtable, or Properties, the returned Map will preserve that type, otherwise a LinkedHashMap will be returned.

def result = [a:1,b:2,c:3,d:4,e:5,f:6].groupBy([{ it.value % 2 }, { it.key.next() }])
 assert result == [1:[b:[a:1], d:[c:3], f:[e:5]], 0:[c:[b:2], e:[d:4], g:[f:6]]]
If an empty list of closures is supplied the IDENTITY Closure will be used.
Parameters:
self - a map to group
closures - a list of closures that map entries on keys
Returns:
a new map grouped by keys on each criterion
See Also:
Closure.IDENTITY
Since:
1.8.1


groupEntriesBy

public static Map groupEntriesBy(Map self, Closure closure)


hasGroup

public static boolean hasGroup(Matcher matcher)


hasProperty

public static MetaProperty hasProperty(Object self, String name)


head

public static Object head(List self)
Returns the items from the List excluding the first item.
def list = [3, 4, 2]
 assert list.tail() == [4, 2]
 assert list == [3, 4, 2]
throws:
NoSuchElementException if the list is empty and you try to access the tail() item.
Parameters:
self - a List
Returns:
a list without its first element
Since:
1.5.6


head

public static Object head(Object[] self)


identity

public static Object identity(Object self, Closure closure)
Allows the closure to be called for the object reference self. Synonym for 'with()'.
Parameters:
self - the object to have a closure act upon
closure - the closure to call on the object
Returns:
result of calling the closure
Since:
1.0


implies

public static Boolean implies(Boolean left, Boolean right)


inject

public static Object inject(Collection self, Closure closure)


inject

public static Object inject(Collection self, Object initialValue, Closure closure)


inject

public static Object inject(Map self, Object initialValue, Closure closure)


inject

public static Object inject(Iterator self, Object initialValue, Closure closure)


inject

public static Object inject(Object self, Closure closure)


inject

public static Object inject(Object self, Object initialValue, Closure closure)
Iterates through the given array as with inject(Object[],initialValue,closure), but using the first element of the array as the initialValue, and then iterating the remaining elements of the array.
throws:
NoSuchElementException if the array is empty.
Parameters:
self - an Object[]
closure - a closure
Returns:
the result of the last closure call
See Also:
inject(Object[], Object, Closure)
Since:
1.8.7


inject

public static Object inject(Object[] self, Closure closure)
Iterates through the given array, passing in the initial value to the closure along with the first item. The result is passed back (injected) into the closure along with the second item. The new result is injected back into the closure along with the third item and so on until all elements of the array have been used. Also known as foldLeft in functional parlance.
Parameters:
self - an Object[]
initialValue - some initial value
closure - a closure
Returns:
the result of the last closure call
See Also:
inject(Collection, Object, Closure)
Since:
1.5.0


inject

public static Object inject(Object[] self, Object initialValue, Closure closure)


inspect

public static String inspect(Object self)
Inspects returns the String that matches what would be typed into a terminal to create this object.
Parameters:
self - any Object
Returns:
a String that matches what would be typed into a terminal to create this object. e.g. [1, 'hello'].inspect() -> [1, "hello"]
Since:
1.0


intdiv

public static Number intdiv(Character left, Number right)
Bitwise OR together two BitSets. Called when the '|' operator is used between two bit sets.
Parameters:
left - a BitSet
right - another BitSet to bitwise AND
Returns:
the bitwise OR of both BitSets
Since:
1.5.0


intdiv

public static Number intdiv(Number left, Character right)
Bitwise XOR together two Numbers. Called when the '|' operator is used.
Parameters:
left - a Number
right - another Number to bitwse XOR
Returns:
the bitwise XOR of both Numbers
Since:
1.0


intdiv

public static Number intdiv(Character left, Character right)
Performs a division modulus operation. Called by the '%' operator.
Parameters:
left - a Number
right - another Number to mod
Returns:
the modulus result
Since:
1.0


intdiv

public static Number intdiv(Number left, Number right)


intersect

public static Collection intersect(Collection left, Collection right)
Create a Map composed of the intersection of both maps. Any entries that exist in both maps are added to the resultant map.
assert [4:4,5:5] == [1:1,2:2,3:3,4:4,5:5].intersect([4:4,5:5,6:6,7:7,8:8])
assert [1: 1, 2: 2, 3: 3, 4: 4].intersect( [1: 1.0, 2: 2, 5: 5] ) == [1:1, 2:2]
Parameters:
left - a map
right - a map
Returns:
a Map as an intersection of both maps
Since:
1.7.4


intersect

public static Map intersect(Map left, Map right)
Returns 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
Parameters:
left - a Collection
right - a Collection
Returns:
boolean true if the intersection of two collections is empty, false otherwise.
Since:
1.0


invokeMethod

public 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.
Parameters:
object - any Object
method - the name of the method to call
arguments - the arguments to use
Returns:
the result of the method call
Since:
1.0


is

public static boolean is(Object self, Object other)
Identity check. Since == is overridden in Groovy with the meaning of equality we need some fallback to check for object identity. Invoke using the 'is' method, like so: def same = this.is(that)
Parameters:
self - an object
other - an object to compare identity with
Returns:
true if self and other are both references to the same instance, false otherwise
Since:
1.0


isAllWhitespace

public static boolean isAllWhitespace(String self)


isAllWhitespace

public static boolean isAllWhitespace(CharSequence self)

Strip numChar leading characters from every line in a String.

 assert 'DEF\n456' == '''ABCDEF\n123456'''.stripIndent(3)
 
Parameters:
self - The String to strip the characters from
numChars - The number of characters to strip
Returns:
the stripped String
Since:
1.7.3


isBigDecimal

public static boolean isBigDecimal(String self)
Determine if a CharSequence can be parsed as a Long.
Parameters:
self - a CharSequence
Returns:
true if the CharSequence can be parsed
See Also:
isLong(java.lang.String)
Since:
1.8.2


isBigDecimal

public static boolean isBigDecimal(CharSequence self)


isBigInteger

public static boolean isBigInteger(String self)


isBigInteger

public static boolean isBigInteger(CharSequence self)


isCase

public static boolean isCase(Object caseValue, Object switchValue)
Method for overloading the behavior of the 'case' method in switch statements. The default implementation handles arrays types but otherwise simply delegates to Object#equals, but this may be overridden for other types. In this example:
 switch( a ) {
   case b: //some code
 }
"some code" is called when b.isCase( a ) returns true.
Parameters:
caseValue - the case value
switchValue - the switch value
Returns:
true if the switchValue is deemed to be equal to the caseValue
Since:
1.0


isCase

public 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. For example:
switch( str ) {
   case 'one' :
   // etc...
 }
Note that this returns true for the case where both the 'switch' and 'case' operand is null.
Parameters:
caseValue - the case value
switchValue - the switch value
Returns:
true if the switchValue's toString() equals the caseValue
Since:
1.0


isCase

public static boolean isCase(CharSequence caseValue, Object switchValue)
'Case' implementation for a CharSequence, which simply calls the equivalent method for String.
Parameters:
caseValue - the case value
switchValue - the switch value
Returns:
true if the switchValue's toString() equals the caseValue
Since:
1.8.2


isCase

public static boolean isCase(GString caseValue, Object switchValue)


isCase

public static boolean isCase(Class caseValue, Object switchValue)


isCase

public 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. For example:
switch( 3 ) {
   case [1,3,5]:
     assert true
     break
   default:
     assert false
 }
Parameters:
caseValue - the case value
switchValue - the switch value
Returns:
true if the caseValue is deemed to contain the switchValue
See Also:
Collection.contains
Since:
1.0


isCase

public static boolean isCase(Map caseValue, Object switchValue)


isCase

public static boolean isCase(Pattern caseValue, Object switchValue)


isCase

public static boolean isCase(Number caseValue, Number switchValue)
Special 'case' implementation for all numbers, which delegates to the compareTo() method for comparing numbers of different types.
Parameters:
caseValue - the case value
switchValue - the switch value
Returns:
true if the numbers are deemed equal
Since:
1.5.0


isDigit

public static boolean isDigit(Character self)
Transform a Number into a BigDecimal
Parameters:
self - a Number
Returns:
an BigDecimal
Since:
1.0


isDouble

public static boolean isDouble(String self)
Parse a CharSequence into a BigInteger
Parameters:
self - a CharSequence
Returns:
a BigInteger
See Also:
toBigInteger(java.lang.String)
Since:
1.8.2


isDouble

public static boolean isDouble(CharSequence self)


isFloat

public static boolean isFloat(String self)
Parse a CharSequence into a Double
Parameters:
self - a CharSequence
Returns:
a Double
See Also:
toDouble(java.lang.String)
Since:
1.8.2


isFloat

public static boolean isFloat(CharSequence self)
Determines if a character is a whitespace character. Synonym for 'Character.isWhitespace(this)'.
Parameters:
self - a Character
Returns:
true if the character is a whitespace character
See Also:
Character.isWhitespace
Since:
1.5.7


isInteger

public static boolean isInteger(String self)


isInteger

public static boolean isInteger(CharSequence self)


isLetter

public static boolean isLetter(Character self)


isLetterOrDigit

public static boolean isLetterOrDigit(Character self)


isLong

public static boolean isLong(String self)


isLong

public static boolean isLong(CharSequence self)
Determines if a character is a letter or digit. Synonym for 'Character.isLetterOrDigit(this)'.
Parameters:
self - a Character
Returns:
true if the character is a letter or digit
See Also:
Character.isLetterOrDigit
Since:
1.5.7


isLowerCase

public static boolean isLowerCase(Character self)
Transform a Number into a Double
Parameters:
self - a Number
Returns:
an Double
Since:
1.0


isNumber

public static boolean isNumber(String self)
Determine if a CharSequence can be parsed as a Float.
Parameters:
self - a CharSequence
Returns:
true if the CharSequence can be parsed
See Also:
isFloat(java.lang.String)
Since:
1.8.2


isNumber

public static boolean isNumber(CharSequence self)


isUpperCase

public static boolean isUpperCase(Character self)
Transform a Number into a Float
Parameters:
self - a Number
Returns:
an Float
Since:
1.0


isWhitespace

public static boolean isWhitespace(Character self)


iterator

public static Iterator iterator(Object[] a)
Standard iterator for a input stream which iterates through the stream content in a byte-based fashion.
Parameters:
self - an InputStream object
Returns:
an Iterator for the InputStream
Since:
1.5.0


iterator

public static Iterator iterator(Object o)


iterator

public static Iterator iterator(Enumeration enumeration)


iterator

public static Iterator iterator(Matcher matcher)
An identity function for iterators, supporting 'duck-typing' when trying to get an iterator for each object within a collection, some of which may already be iterators.
Parameters:
self - an iterator object
Returns:
itself
Since:
1.5.0


iterator

public static Iterator iterator(Reader self)

Returns an object satisfying Groovy truth if the implementing MetaClass responds to a method with the given name regardless of the arguments.

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

Parameters:
self - The object to inspect
name - The name of the method of interest
Returns:
A List of MetaMethods matching the given name or an empty list if no matching methods exist
See Also:
MetaObjectProtocol.respondsTo
Since:
1.6.1


iterator

public static Iterator iterator(InputStream self)


iterator

public static Iterator iterator(DataInputStream self)


iterator

public static Iterator iterator(Iterator self)


join

public static String join(Iterator self, String separator)
Concatenates the toString() representation of each item in this collection, with the given String as a separator between each item.
assert "1, 2, 3" == [1,2,3].join(", ")
Parameters:
self - a Collection of objects
separator - a String separator
Returns:
the joined String
Since:
1.0


join

public static String join(Collection self, String separator)


join

public static String join(Object[] self, String separator)


last

public static Object last(List self)


last

public static Object last(Iterable self)
Returns the last item from the array.
 def array = [3, 4, 2].toArray()
 assert array.last() == 2
 
throws:
NoSuchElementException if the array is empty and you try to access the last() item.
Parameters:
self - an array
Returns:
the last item from the array
Since:
1.7.3


last

public static Object last(Object[] self)


leftShift

public static Collection leftShift(Collection self, Object value)
Overloads the left shift operator to provide an easy way to append Map.Entry values to a Map.
Parameters:
self - a Map
entry - a Map.Entry to be added to the Map.
Returns:
same map, after the value has been added to it.
Since:
1.6.0


leftShift

public static BlockingQueue leftShift(BlockingQueue self, Object value)
Overloads the left shift operator to provide an easy way to append multiple objects as string representations to a String.
Parameters:
self - a String
value - an Object
Returns:
a StringBuffer built from this string
Since:
1.0


leftShift

public static Map leftShift(Map self, Map.Entry entry)
Overloads the left shift operator to provide an easy way to append multiple objects as string representations to a CharSequence.
Parameters:
self - a CharSequence
value - an Object
Returns:
a StringBuilder built from this CharSequence
Since:
1.8.2


leftShift

public static Map leftShift(Map self, Map other)
Overloads the left shift operator to provide syntactic sugar for appending to a StringBuilder.
Parameters:
self - a StringBuilder
value - an Object
Returns:
the original StringBuilder
Since:
1.8.2


leftShift

public static StringBuffer leftShift(String self, Object value)
Overloads the left shift operator to provide an easy way to append multiple objects as string representations to a StringBuffer.
Parameters:
self - a StringBuffer
value - a value to append
Returns:
the StringBuffer on which this operation was invoked
Since:
1.0


leftShift

public static StringBuilder leftShift(CharSequence self, Object value)


leftShift

public static StringBuilder leftShift(StringBuilder self, Object value)


leftShift

public static StringBuffer leftShift(StringBuffer self, Object value)


leftShift

public static Writer leftShift(Writer self, Object value)


leftShift

public static Number leftShift(Number self, Number operand)


leftShift

public static Writer leftShift(OutputStream self, Object value)


leftShift

public static void leftShift(ObjectOutputStream self, Object value)


leftShift

public static OutputStream leftShift(OutputStream self, InputStream in)


leftShift

public static OutputStream leftShift(OutputStream self, byte[] value)
Support the subscript operator with a range for a short array
Parameters:
array - a short array
range - a range indicating the indices for the items to retrieve
Returns:
list of the retrieved shorts
Since:
1.0


leftShift

public static File leftShift(File file, Object text)
Invokes the closure for each 'child' file in this 'parent' folder/directory. Both regular files and subfolders/subdirectories can be processed depending on the fileType enum value.
throws:
FileNotFoundException if the given directory does not exist
throws:
IllegalArgumentException if the provided File object does not represent a directory
Parameters:
self - a file object
fileType - if normal files or directories or both should be processed
closure - the closure to invoke
Since:
1.7.1


leftShift

public static File leftShift(File file, byte[] bytes)


leftShift

public static File leftShift(File file, InputStream data)
Invokes the closure for each 'child' file in this 'parent' folder/directory. Both regular files and subfolders/subdirectories are processed.
throws:
FileNotFoundException if the given directory does not exist
throws:
IllegalArgumentException if the provided File object does not represent a directory
Parameters:
self - a File (that happens to be a folder/directory)
closure - a closure (first parameter is the 'child' file)
See Also:
File.listFiles
eachFile(java.io.File, groovy.io.FileType, groovy.lang.Closure)
Since:
1.5.0


leftShift

public static Writer leftShift(Socket self, Object value)
Converts the given String into a Set of unique strings of one character.

Example usage:

 assert 'groovy'.toSet() == ['v', 'g', 'r', 'o', 'y'] as Set
 assert "abc".toSet().iterator()[0] instanceof String
 
Parameters:
self - a String
Returns:
a Set of unique character Strings (each a 1-character String)
Since:
1.8.0


leftShift

public static OutputStream leftShift(Socket self, byte[] value)
Converts the given CharSequence into an array of characters.
Parameters:
self - a CharSequence
Returns:
an array of characters
See Also:
getChars(String)
Since:
1.8.2


matches

public static boolean matches(String self, Pattern pattern)


matches

public static boolean matches(CharSequence self, Pattern pattern)


max

public static Map.Entry max(Map self, Closure closure)


max

public static Object max(Collection self)


max

public static Object max(Iterator self)


max

public static Object max(Object[] self)


max

public static Object max(Collection self, Closure closure)


max

public static Object max(Iterator self, Closure closure)


max

public static Object max(Object[] self, Closure closure)
Selects the maximum value found in the collection using the given comparator.
assert "hello" == ["hello","hi","hey"].max( { a, b -> a.length() <=> b.length() } as Comparator )
Parameters:
self - a Collection
comparator - a Comparator
Returns:
the maximum value
Since:
1.0


max

public static Object max(Collection self, Comparator comparator)
Selects the maximum value found from the Iterator using the given comparator.
Parameters:
self - an Iterator
comparator - a Comparator
Returns:
the maximum value
Since:
1.5.5


max

public static Object max(Iterator self, Comparator comparator)
Selects the maximum value found from the Object array using the given comparator.
Parameters:
self - an Object array
comparator - a Comparator
Returns:
the maximum value
Since:
1.5.5


max

public static Object max(Object[] self, Comparator comparator)


metaClass

public static MetaClass metaClass(Class self, Closure closure)


metaClass

public static MetaClass metaClass(Object self, Closure closure)
Creates an iterator which will traverse through the reader a line at a time.
Parameters:
self - a Reader object
Returns:
an Iterator for the Reader
See Also:
BufferedReader.readLine
Since:
1.5.0


min

public static Object min(Collection self)
Adds min() method to Iterator objects. The iterator will become exhausted of elements after determining the minimum value.
Parameters:
self - an Iterator
Returns:
the minimum value
See Also:
min(java.util.Collection)
Since:
1.5.5


min

public static Object min(Iterator self)


min

public static Object min(Object[] self)


min

public static Object min(Collection self, Comparator comparator)
Selects the minimum value found from the Iterator using the given comparator.
Parameters:
self - an Iterator
comparator - a Comparator
Returns:
the minimum value
See Also:
min(java.util.Collection, java.util.Comparator)
Since:
1.5.5


min

public static Object min(Iterator self, Comparator comparator)
Selects the minimum value found from the Object array using the given comparator.
Parameters:
self - an Object array
comparator - a Comparator
Returns:
the minimum value
See Also:
min(java.util.Collection, java.util.Comparator)
Since:
1.5.5


min

public static Object min(Object[] self, Comparator comparator)


min

public static Object min(Collection self, Closure closure)


min

public static Map.Entry min(Map self, Closure closure)


min

public static Object min(Iterator self, Closure closure)


min

public static Object min(Object[] self, Closure closure)
Adds max() method to Collection objects.
assert 5 == [2,3,1,5,4].max()
Parameters:
self - a Collection
Returns:
the maximum value
See Also:
GroovyCollections.max
Since:
1.0


minus

public static Set minus(Set self, Collection removeMe)
Create a Set composed of the elements of the first Set minus the elements from the given Iterable.
Parameters:
self - a Set object
removeMe - the items to remove from the Set
Returns:
the resulting Set
Since:
1.8.7


minus

public static Set minus(Set self, Iterable removeMe)
Create an array composed of the elements of the first array minus the elements of the given Iterable.
Parameters:
self - an object array
removeMe - a Collection of elements to remove
Returns:
an array with the supplied elements removed
Since:
1.5.5


minus

public static Set minus(Set self, Object removeMe)


minus

public static Object[] minus(Object[] self, Iterable removeMe)


minus

}
public static Object[] minus(Object[] self, Object[] removeMe)


minus

public static List minus(List self, Collection removeMe)


minus

public static List minus(List self, Iterable removeMe)
Create a List composed of the elements of the first list minus every occurrence of elements of the given Iterable.
 class AbcIterable implements Iterable {
     Iterator iterator() { "abc".iterator() }
 }
 assert "backtrack".toList() - new AbcIterable() == ["k", "t", "r", "k"]
 
Parameters:
self - a List
removeMe - an Iterable of elements to remove
Returns:
a List with the supplied elements removed
Since:
1.8.7


minus

public static List minus(List self, Object removeMe)


minus

* @since 1.6.0
public static Object[] minus(Object[] self, Object removeMe)


minus

public static Map minus(Map self, Map removeMe)
Flatten an array. This array and any nested arrays or collections have their contents (recursively) added to the new collection.
Parameters:
self - a boolean Array to flatten
Returns:
a flattened Collection
Since:
1.6.0


minus

public static String minus(String self, Object target)


minus

public static CharSequence minus(CharSequence self, Object target)
Checks whether the array contains the given value.
Parameters:
self - the array we are searching
value - the value being searched for
Returns:
true if the array contains the value
Since:
1.8.6


minus

public static Number minus(Character left, Number right)
Power of a Number to a certain exponent. Called by the '**' operator.
Parameters:
self - a Number
exponent - a Number exponent
Returns:
a Number to the power of a certain exponent
Since:
1.0


minus

public static Number minus(Number left, Character right)


minus

public static Number minus(Character left, Character right)


mixin

public static void mixin(MetaClass self, List categoryClasses)
Extend object with category methods. All methods for given class and all super classes will be added to the object.
Parameters:
self - any Class
categoryClasses - a category classes to use
Since:
1.6.0


mixin

public static void mixin(Class self, List categoryClasses)
Extend class globally with category methods. All methods for given class and all super classes will be added to the class.
Parameters:
self - any Class
categoryClasses - a category classes to use
Since:
1.6.0


mixin

public static void mixin(Class self, Class categoryClass)
Extend class globally with category methods.
Parameters:
self - any Class
categoryClass - a category class to use
Since:
1.6.0


mixin

public static void mixin(Class self, Class[] categoryClass)
Extend class globally with category methods.
Parameters:
self - any Class
categoryClass - a category class to use
Since:
1.6.0


mixin

public static void mixin(MetaClass self, Class categoryClass)
Extend class globally with category methods.
Parameters:
self - any Class
categoryClass - a category class to use
Since:
1.6.0


mixin

public static void mixin(MetaClass self, Class[] categoryClass)
Extend class globally with category methods.
Parameters:
self - any Class
categoryClass - a category class to use
Since:
1.6.0


mod

public static Number mod(Number left, Number right)


multiply

public static List multiply(Collection self, Number factor)


multiply

public static String multiply(String self, Number factor)
Returns the string representation of the given array.
Parameters:
self - an array
Returns:
the string representation
Since:
1.6.0


multiply

public static CharSequence multiply(CharSequence self, Number factor)
Returns the string representation of this map. The string displays the contents of the map, i.e. [one:1, two:2, three:3].
Parameters:
self - a Map
Returns:
the string representation
Since:
1.0


multiply

public static Number multiply(Character left, Number right)
Power of a BigInteger to an integer certain exponent. If the exponent is positive, call the BigInteger.pow(int) method to maintain precision. Called by the '**' operator.
Parameters:
self - a BigInteger
exponent - an Integer exponent
Returns:
a Number to the power of a the exponent


multiply

public static Number multiply(Number left, Character right)
Power of an integer to an integer certain exponent. If the exponent is positive, convert to a BigInteger and call BigInteger.pow(int) method to maintain precision. Called by the '**' operator.
Parameters:
self - an Integer
exponent - an Integer exponent
Returns:
a Number to the power of a the exponent


multiply

public static Number multiply(Character left, Character right)


multiply

public static Number multiply(BigDecimal left, Double right)


multiply

public static Number multiply(BigDecimal left, BigInteger right)
Divide a Character by a Number. The ordinal value of the Character is used in the division (the ordinal value is the unicode value which for simple character sets is the ASCII value).
Parameters:
left - a Character
right - a Number
Returns:
the Number corresponding to the division of left by right
Since:
1.0


newDataInputStream

public static DataInputStream newDataInputStream(File file)


newDataOutputStream

public static DataOutputStream newDataOutputStream(File file)


newInputStream

public static BufferedInputStream newInputStream(File file)
Traverse through each byte of this Byte array. Alias for each.
Parameters:
self - a Byte array
closure - a closure
See Also:
each(java.lang.Object, groovy.lang.Closure)
Since:
1.5.5


newInputStream

public static BufferedInputStream newInputStream(URL url)
Traverse through each the specified stream reading bytes into a buffer and calling the 2 parameter closure with this buffer and the number of bytes.
throws:
IOException if an IOException occurs.
Parameters:
is - stream to iterate over, closed after the method call.
bufferLen - the length of the buffer to use.
closure - a 2 parameter closure which is passed the byte[] and a number of bytes successfully read.
Since:
1.8


newInputStream

public static BufferedInputStream newInputStream(URL url, Map parameters)


newInstance

return metaClass;
public static Object newInstance(Class c)
Sets/updates the metaclass for a given class to a closure.
throws:
GroovyRuntimeException if the metaclass can't be set for this class
Parameters:
self - the class whose metaclass we wish to update
closure - the closure representing the new metaclass
Returns:
the new metaclass value
Since:
1.6.0


newInstance

}
public static Object newInstance(Class c, Object[] args)


newObjectInputStream

public static ObjectInputStream newObjectInputStream(File file)


newObjectInputStream

public static ObjectInputStream newObjectInputStream(InputStream inputStream)


newObjectInputStream

public static ObjectInputStream newObjectInputStream(InputStream inputStream, ClassLoader classLoader)


newObjectInputStream

public static ObjectInputStream newObjectInputStream(File file, ClassLoader classLoader)


newObjectOutputStream

public static ObjectOutputStream newObjectOutputStream(File file)


newObjectOutputStream

public static ObjectOutputStream newObjectOutputStream(OutputStream outputStream)


newOutputStream

public static BufferedOutputStream newOutputStream(File file)


newPrintWriter

public static PrintWriter newPrintWriter(File file)


newPrintWriter

public static PrintWriter newPrintWriter(File file, String charset)
Helper method to create a new Reader for a stream and then passes it into the closure. The reader (and this stream) is closed after the closure returns.
throws:
IOException if an IOException occurs.
Parameters:
in - a stream
closure - the closure to invoke with the InputStream
Returns:
the value returned by the closure
See Also:
InputStreamReader
Since:
1.5.2


newPrintWriter

public static PrintWriter newPrintWriter(Writer writer)


newReader

public static BufferedReader newReader(File file)
Create a new DataInputStream for this file and passes it into the closure. This method ensures the stream is closed after the closure returns.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
closure - a closure
Returns:
the value returned by the closure
See Also:
withStream(java.io.InputStream, groovy.lang.Closure)
Since:
1.5.2


newReader

public static BufferedReader newReader(File file, String charset)


newReader

public static BufferedReader newReader(InputStream self)


newReader

public static BufferedReader newReader(InputStream self, String charset)


newReader

public static BufferedReader newReader(URL url)


newReader

public static BufferedReader newReader(URL url, Map parameters)
Reads the InputStream from this URL, passing a byte[] and a number of bytes to the given closure. The URL stream will be closed before this method returns.
throws:
IOException if an IOException occurs.
Parameters:
url - url to iterate over
bufferLen - the length of the buffer to use.
closure - a 2 parameter closure which is passed the byte[] and a number of bytes successfully read.
See Also:
eachByte(java.io.InputStream, int, groovy.lang.Closure)
Since:
1.8


newReader

public static BufferedReader newReader(URL url, String charset)
Transforms each character from this reader by passing it to the given closure. The Closure should return each transformed character, which will be passed to the Writer. The reader and writer will be both be closed before this method returns.
throws:
IOException if an IOException occurs.
Parameters:
self - a Reader object
writer - a Writer to receive the transformed characters
closure - a closure that performs the required transformation
Since:
1.5.0


newReader

public static BufferedReader newReader(URL url, Map parameters, String charset)


newWriter

public static BufferedWriter newWriter(File file)


newWriter

public static BufferedWriter newWriter(File file, boolean append)


newWriter

public static BufferedWriter newWriter(File file, String charset, boolean append)


newWriter

public static BufferedWriter newWriter(File file, String charset)
Allows this writer to be used within the closure, ensuring that it is flushed and closed before this method returns.
throws:
IOException if an IOException occurs.
Parameters:
writer - the writer which is used and then closed
closure - the closure that the writer is passed into
Returns:
the value returned by the closure
Since:
1.5.2


next

public static String next(String self)


next

public static CharSequence next(CharSequence self)
Executes the command specified by the given 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+).

throws:
IOException if an IOException occurs.
Parameters:
commandArray - an array of String containing the command name and parameters as separate items in the array.
Returns:
the Process which has just started for this command line representation.
Since:
1.0


next

public static Character next(Character self)


next

public static Number next(Number self)


normalize

public static String normalize(String self)


normalize

public static CharSequence normalize(CharSequence self)
Read the content of the File and returns it as a String.
throws:
IOException if an IOException occurs.
Parameters:
file - the file whose content we want to read
Returns:
a String containing the content of the file
Since:
1.0


numberAwareCompareTo

public static int numberAwareCompareTo(Comparable self, Comparable other)
Provides a method that compares two comparables using Groovy's default number aware comparator.
Parameters:
self - a Comparable
other - another Comparable
Returns:
a -ve number, 0 or a +ve number according to Groovy's compareTo contract
Since:
1.6.0


or

public static Number or(Number left, Number right)


or

public static BitSet or(BitSet left, BitSet right)


or

public static Boolean or(Boolean left, Boolean right)


padLeft

public static String padLeft(String self, Number numberOfChars, String padding)
Pad a CharSequence to a minimum length specified by numberOfChars, adding the supplied padding CharSequence as many times as needed to the left.
Parameters:
self - a CharSequence object
numberOfChars - the total minimum number of characters of the resulting CharSequence
padding - the characters used for padding
Returns:
the CharSequence padded to the left
See Also:
padLeft(String, Number, String)
Since:
1.8.2


padLeft

public static CharSequence padLeft(CharSequence self, Number numberOfChars, CharSequence padding)


padLeft

public static String padLeft(String self, Number numberOfChars)
Pad a CharSequence to a minimum length specified by numberOfChars by adding the space character to the left as many times as needed.
Parameters:
self - a CharSequence object
numberOfChars - the total minimum number of characters of the resulting CharSequence
Returns:
the CharSequence padded to the left
See Also:
padLeft(CharSequence, Number, CharSequence)
Since:
1.8.2


padLeft

public static CharSequence padLeft(CharSequence self, Number numberOfChars)


padRight

public static String padRight(String self, Number numberOfChars, String padding)
Pad a CharSequence to a minimum length specified by numberOfChars, adding the supplied padding CharSequence as many times as needed to the right.
Parameters:
self - a CharSequence object
numberOfChars - the total minimum number of characters of the resulting CharSequence
padding - the characters used for padding
Returns:
the CharSequence padded to the right
See Also:
padRight(String, Number, String)
Since:
1.8.2


padRight

public static CharSequence padRight(CharSequence self, Number numberOfChars, CharSequence padding)


padRight

public static String padRight(String self, Number numberOfChars)


padRight

public static CharSequence padRight(CharSequence self, Number numberOfChars)


permutations

public static Set permutations(List self)


plus

public static Map plus(Map left, Map right)
Support the subscript operator for Collection.
assert [String, Long, Integer] == ["a",5L,2]["class"]
Parameters:
coll - a Collection
property - a String
Returns:
a List
Since:
1.0


plus

*/
public static Object[] plus(Object[] left, Object[] right)


plus

* @param left  the array
public static Object[] plus(Object[] left, Object right)


plus

* @param right the right Collection
public static Object[] plus(Object[] left, Collection right)


plus

public static  Collection plus(Collection left, Iterable right) {
public static Object[] plus(Object[] left, Iterable right)
Create a Collection as a union of a Collection and an Iterable. If the left collection is a Set, then the returned collection will be a Set otherwise a List. This operation will always create a new object for the result, while the operands remain unchanged.
Parameters:
left - the left Collection
right - the right Iterable
Returns:
the merged Collection
See Also:
plus(Collection, Collection)
Since:
1.8.7


plus

public static Collection plus(Collection left, Collection right)


plus

public static Collection plus(Collection left, Iterable right)


plus

public static List plus(List self, int index, Object[] items)
Creates a new List by inserting all of the elements in the given additions List to the elements from the original List at the specified index. Shifts the element currently at that index (if any) and any subsequent elements to the right (increasing their indices). The new elements will appear in the resulting List in the order that they occur in the original lists. The behavior of this operation is undefined if the original lists are modified while the operation is in progress. The original lists remain unchanged.
 def items = [1, 2, 3]
 def newItems = items.plus(2, 'a'..'c')
 assert newItems == [1, 2, 'a', 'b', 'c', 3]
 assert items == [1, 2, 3]
 
See also addAll for similar functionality with modify semantics, i.e. which performs the changes on the original list itself.
Parameters:
self - an original List
additions - a List containing elements to be merged with elements from the original List
index - index at which to insert the first element from the given additions List
Returns:
the new list
Since:
1.8.1


plus

public static List plus(List self, int index, List additions)
Creates a new List by inserting all of the elements in the given Iterable to the elements from this List at the specified index.
Parameters:
self - an original list
additions - an Iterable containing elements to be merged with the elements from the original List
index - index at which to insert the first element from the given additions Iterable
Returns:
the new list
See Also:
plus(List, int, List)
Since:
1.8.7


plus

public static List plus(List self, int index, Iterable additions)
Synonym for toSpreadMap(java.util.Map).
Parameters:
self - a map
Returns:
a newly created SpreadMap
Since:
1.0


plus

public static Collection plus(Collection left, Object right)


plus

public static Map plus(Map self, Collection entries)


plus

public static String plus(String left, Object value)
Checks whether the array contains the given value.
Parameters:
self - the array we are searching
value - the value being searched for
Returns:
true if the array contains the value
Since:
1.8.6


plus

public static CharSequence plus(CharSequence left, Object value)
Checks whether the array contains the given value.
Parameters:
self - the array we are searching
value - the value being searched for
Returns:
true if the array contains the value
Since:
1.8.6


plus

public static String plus(Number value, String right)


plus

public static String plus(StringBuffer left, String value)


plus

public static Number plus(Character left, Number right)


plus

public static Number plus(Number left, Character right)


plus

public static Number plus(Character left, Character right)


pop

public static Object pop(List self)
Returns a new Map containing all entries from self and entries, giving precedence to entries. Any keys appearing in both Maps will appear in the resultant map with values from the entries operand. If self map is one of TreeMap, LinkedHashMap, Hashtable or Properties, the returned Map will preserve that type, otherwise a HashMap will be returned.

Parameters:
self - a Map
entries - a Collection of Map.Entry items to be added to the Map.
Returns:
a new Map containing all key, value pairs from self and entries
Since:
1.6.1


power

public static Number power(Number self, Number exponent)


power

public static Number power(BigDecimal self, Integer exponent)
Divide one Character by another. The ordinal values of the Characters are used in the division (the ordinal value is the unicode value which for simple character sets is the ASCII value).
Parameters:
left - a Character
right - another Character
Returns:
the Number corresponding to the division of left by right
Since:
1.0


power

public static Number power(BigInteger self, Integer exponent)
Integer Divide a Number by a Character. The ordinal value of the Character is used in the division (the ordinal value is the unicode value which for simple character sets is the ASCII value).
Parameters:
left - a Number
right - a Character
Returns:
a Number (an Integer) resulting from the integer division operation
Since:
1.0


power

public static Number power(Integer self, Integer exponent)
Integer Divide two Characters. The ordinal values of the Characters are used in the division (the ordinal value is the unicode value which for simple character sets is the ASCII value).
Parameters:
left - a Character
right - another Character
Returns:
a Number (an Integer) resulting from the integer division operation
Since:
1.0


power

public static Number power(Long self, Integer exponent)
Bitwise OR together two numbers.
Parameters:
left - a Number
right - another Number to bitwise OR
Returns:
the bitwise OR of both Numbers
Since:
1.0


previous

public static String previous(String self)


previous

public static CharSequence previous(CharSequence self)


previous

public static Character previous(Character self)
todo:
maybe a double dispatch thing to handle new large numbers?


previous

public static Number previous(Number self)


primitiveArrayGet

protected static Object primitiveArrayGet(Object self, int idx)
Convenience method to split a string (with whitespace as delimiter) Like tokenize, but returns an Array of Strings instead of a List
Parameters:
self - the string to split
Returns:
String[] result of split
Since:
1.5.0


primitiveArrayGet

protected static List primitiveArrayGet(Object self, Range range)


primitiveArrayGet

protected static List primitiveArrayGet(Object self, Collection indices)


primitiveArrayPut

protected static Object primitiveArrayPut(Object self, int idx, Object newValue)
Convenience method to capitalize the first letter of a CharSequence.
Parameters:
self - The CharSequence to capitalize
Returns:
The capitalized CharSequence
See Also:
capitalize(String)
Since:
1.8.2


print

public 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.
Parameters:
self - any Object
value - the value to print
Since:
1.0


print

public static void print(PrintWriter self, Object value)
Print a value formatted Groovy style to the print writer.
Parameters:
self - a PrintWriter
value - the value to print
Since:
1.0


print

public static void print(PrintStream self, Object value)
Print a value formatted Groovy style to the print stream.
Parameters:
self - a PrintStream
value - the value to print
Since:
1.6.0


print

public static void print(Closure self, Object value)
Print a value to the standard output stream. This method delegates to the owner to execute the method.
Parameters:
self - a generated closure
value - the value to print
Since:
1.0


print

public static void print(Object self, PrintWriter out)
Print to a console in interactive format.
Parameters:
self - any Object
out - the PrintWriter used for printing
Since:
1.0


printf

public static void printf(Object self, String format, Object[] values)
Printf to a console (Only works with JDK1.5 or later).
Parameters:
self - any Object
format - a format string
values - values referenced by the format specifiers in the format string.
Since:
1.0


printf

public static void printf(Object self, String format, Object arg)
Prints a formatted string using the specified format string and arguments.

For examples,

     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[] ) }

Parameters:
self - any Object
format - A format string
arg - 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[].
Since:
1.0


println

public static void println(Object self)
Print a linebreak to the standard output stream.
Parameters:
self - any Object
Since:
1.0


println

public static void println(Closure self)
Print a linebreak to the standard output stream. This method delegates to the owner to execute the method.
Parameters:
self - a closure
Since:
1.0


println

public 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.
Parameters:
self - any Object
value - the value to print
Since:
1.0


println

public static void println(PrintWriter self, Object value)
Print a value formatted Groovy style (followed by a newline) to the print writer.
Parameters:
self - a PrintWriter
value - the value to print
Since:
1.0


println

public static void println(PrintStream self, Object value)
Print a value formatted Groovy style (followed by a newline) to the print stream.
Parameters:
self - any Object
value - the value to print
Since:
1.6.0


println

public static void println(Closure self, Object value)
Print a value (followed by a newline) to the standard output stream. This method delegates to the owner to execute the method.
Parameters:
self - a closure
value - the value to print
Since:
1.0


println

public static void println(Object self, PrintWriter out)
Print to a console in interactive format.
Parameters:
self - any Object
out - the PrintWriter used for printing
Since:
1.0


push

public static boolean push(List self, Object value)


putAll

public static Map putAll(Map self, Collection entries)


putAt

public static void putAt(Object self, String property, Object newValue)
Allows the subscript operator to be used to set dynamically named property values. 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.
Parameters:
self - the object to act upon
property - the name of the property to set
newValue - the value to set
Since:
1.0


putAt

public static void putAt(List self, int idx, Object value)
Support the range subscript operator for StringBuffer. Index values are treated as characters within the buffer.
Parameters:
self - a StringBuffer
range - a Range
value - the object that's toString() will be inserted
Since:
1.0


putAt

public static void putAt(StringBuffer self, IntRange range, Object value)
A helper method to allow lists to work with subscript operators.
def list = ["a", true]
 list[1..<1] = 5
 assert list == ["a", 5, true]
Parameters:
self - a List
range - the (in this case empty) subset of the list to set
value - the values to put at the given sublist or a Collection of values
Since:
1.0


putAt

public static void putAt(StringBuffer self, EmptyRange range, Object value)


putAt

public static void putAt(List self, EmptyRange range, Object value)


putAt

public static void putAt(List self, EmptyRange range, Collection value)
List subscript assignment operator when given a range as the index and the assignment operand is a collection. Example:
def myList = [4, 3, 5, 1, 2, 8, 10]
 myList[3..5] = ["a", true]
 assert myList == [4, 3, 5, "a", true, 10]
Items in the given range are replaced with items from the collection.
Parameters:
self - a List
range - the subset of the list to set
col - the collection of values to put at the given sublist
Since:
1.5.0


putAt

public static void putAt(List self, IntRange range, Collection col)
List subscript assignment operator when given a range as the index. Example:
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 replaced with the operand. The value operand is always treated as a single value.
Parameters:
self - a List
range - the subset of the list to set
value - the value to put at the given sublist
Since:
1.0


putAt

public static void putAt(List self, IntRange range, Object value)


putAt

public static void putAt(List self, List splice, List values)
A helper method to allow lists to work with subscript operators.
def list = ["a", true, 42, 9.4]
 list[1, 3] = 5
 assert list == ["a", 5, 42, 5]
Parameters:
self - a List
splice - the subset of the list to set
value - the value to put at the given sublist
Since:
1.0


putAt

public static void putAt(List self, List splice, Object value)


putAt

public static Object putAt(Map self, Object key, Object value)


putAt

public static void putAt(BitSet self, IntRange range, boolean value)
Support assigning a range of values with a single assignment statement.
Parameters:
self - a BitSet
range - the range of values to set
value - value
See Also:
BitSet
Range
Since:
1.5.0


putAt

public 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.
Parameters:
array - a byte array
Returns:
a list containing the contents of this array.
Since:
1.0


readBytes

public static byte[] readBytes(File file)
Converts this File to a Writable.
Parameters:
file - a File
Returns:
a File which wraps the input file and which implements Writable
Since:
1.0


readLine

public static String readLine(Reader self)


readLines

public static List readLines(String self)


readLines

public static List readLines(CharSequence self)


readLines

public static List readLines(File file)
Read the data from this URL and return it as a String. The connection stream is closed before this method returns.
throws:
IOException if an IOException occurs.
Parameters:
url - URL to read content from
parameters - connection parameters
charset - opens the stream with a specified charset
Returns:
the text from that URL
See Also:
URLConnection.getInputStream
Since:
1.8.1


readLines

public static List readLines(File file, String charset)
Read the content of this InputStream and return it as a String. The stream is closed before this method returns.
throws:
IOException if an IOException occurs.
Parameters:
is - an input stream
Returns:
the text from that URL
Since:
1.0


readLines

public static List readLines(InputStream stream)


readLines

public static List readLines(InputStream stream, String charset)


readLines

public static List readLines(URL self)


readLines

public static List readLines(URL self, String charset)


readLines

public static List readLines(Reader reader)


removeAll

public static boolean removeAll(Collection self, Object[] items)


removeAll

public static boolean removeAll(Collection self, Closure condition)
Modifies this collection by removing the elements that are matched according to the specified closure condition. See also findAll and grep when wanting to produce a new list containing items which don't match some criteria while leaving the original collection unchanged.
Parameters:
self - a Collection to be modified
condition - a closure condition
Returns:
true if this collection changed as a result of the call
See Also:
Iterator.remove
Since:
1.7.2


renameTo

public static boolean renameTo(File self, String newPathName)
Create a new InputStream for this file and passes it into the closure. This method ensures the stream is closed after the closure returns.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
closure - a closure
Returns:
the value returned by the closure
See Also:
withStream(java.io.InputStream, groovy.lang.Closure)
Since:
1.5.2


replaceAll

public static String replaceAll(String self, Pattern pattern, String replacement)
Replaces all substrings of a CharSequence that match the given compiled regular expression with the given replacement.
Parameters:
self - the CharSequence that is to be matched
pattern - the regex Pattern to which the CharSequence of interest is to be matched
replacement - the CharSequence to be substituted for the first match
Returns:
The resulting CharSequence
See Also:
replaceAll(String, Pattern, String)
Since:
1.8.2


replaceAll

public static CharSequence replaceAll(CharSequence self, Pattern pattern, CharSequence replacement)


replaceAll

public static String replaceAll(String self, String regex, Closure closure)
Replaces all occurrences of a captured group by the result of a closure on that text.
throws:
java.util.regex.PatternSyntaxException if the regular expression's syntax is invalid
Parameters:
self - a CharSequence
regex - the capturing regex
closure - the closure to apply on each captured group
Returns:
a CharSequence with replaced content
See Also:
replaceAll(String, Pattern, Closure)
Since:
1.8.2


replaceAll

public static CharSequence replaceAll(CharSequence self, CharSequence regex, Closure closure)


replaceAll

public static CharSequence replaceAll(CharSequence self, CharSequence regex, CharSequence replacement)


replaceAll

public static String replaceAll(String self, Pattern pattern, Closure closure)
Replaces all occurrences of a captured group by the result of a closure call on that text.
Parameters:
self - a CharSequence
pattern - the capturing regex Pattern
closure - the closure to apply on each captured group
Returns:
a CharSequence with replaced content
See Also:
replaceAll(String, Pattern, Closure)
Since:
1.8.2


replaceAll

public static String replaceAll(CharSequence self, Pattern pattern, Closure closure)


replaceFirst

public static String replaceFirst(String self, Pattern pattern, String replacement)
Replaces the first substring of a CharSequence that matches the given compiled regular expression with the given replacement.
Parameters:
self - the CharSequence that is to be matched
pattern - the regex Pattern to which the CharSequence of interest is to be matched
replacement - the CharSequence to be substituted for the first match
Returns:
The resulting CharSequence
See Also:
replaceFirst(String, Pattern, String)
Since:
1.8.2


replaceFirst

public static CharSequence replaceFirst(CharSequence self, Pattern pattern, CharSequence replacement)


replaceFirst

public static String replaceFirst(String self, String regex, Closure closure)


replaceFirst

public static String replaceFirst(CharSequence self, CharSequence regex, CharSequence replacement)


replaceFirst

public static String replaceFirst(CharSequence self, CharSequence regex, Closure closure)


replaceFirst

public static String replaceFirst(String self, Pattern pattern, Closure closure)
Replaces the first occurrence of a captured group by the result of a closure call on that text.
Parameters:
self - a CharSequence
pattern - the capturing regex Pattern
closure - the closure to apply on the first captured group
Returns:
a CharSequence with replaced content
See Also:
replaceFirst(String, Pattern, Closure)
Since:
1.8.2


replaceFirst

public static String replaceFirst(CharSequence self, Pattern pattern, Closure closure)


respondsTo

public static List respondsTo(Object self, String name, Object[] argTypes)


respondsTo

public static List respondsTo(Object self, String name)


retainAll

public static boolean retainAll(Collection self, Object[] items)


retainAll

public static boolean retainAll(Collection self, Closure condition)


reverse

public static String reverse(String self)
Creates a new string which is the reverse (backwards) of this string
Parameters:
self - a String
Returns:
a new string with all the characters reversed.
See Also:
StringBuilder.reverse
Since:
1.0


reverse

public static CharSequence reverse(CharSequence self)


reverse

public static List reverse(List self)
Reverses the elements in a list. If mutate is true, the original list is modified in place and returned. Otherwise, a new list containing the reversed items is produced.
 def list = ["a", 4, false]
 assert list.reverse(false) == [false, 4, "a"]
 assert list == ["a", 4, false]
 assert list.reverse(true) == [false, 4, "a"]
 assert list == [false, 4, "a"]
 
Parameters:
self - a List
mutate - true if the list itself should be reversed in place and returned, false if a new list should be created
Returns:
a reversed List
Since:
1.8.1


reverse

public static List reverse(List self, boolean mutate)
Reverse the items in an array. If mutate is true, the original array is modified in place and returned. Otherwise, a new array containing the reversed items is produced.
Parameters:
self - an array
mutate - true if the array itself should be reversed in place and returned, false if a new array should be created
Returns:
an array containing the reversed items
Since:
1.8.1


reverse

/**
public static Object[] reverse(Object[] self)
Reverses the iterator. The original iterator will become exhausted of elements after determining the reversed values. A new iterator for iterating through the reversed values is returned.
Parameters:
self - an Iterator
Returns:
a reversed Iterator
Since:
1.5.5


reverse

for (int i = 0; i < size; i++) {
public static Object[] reverse(Object[] self, boolean mutate)
Create a List composed of the elements of this list, repeated a certain number of times. Note that for non-primitive elements, multiple references to the same instance will be added.
assert [1,2,3,1,2,3] == [1,2,3] * 2
Parameters:
self - a Collection
factor - the number of times to append
Returns:
the multiplied list
Since:
1.0


reverse

public static Iterator reverse(Iterator self)
Create a Collection composed of the intersection of both collections. Any elements that exist in both collections are added to the resultant collection.
assert [4,5] == [1,2,3,4,5].intersect([4,5,6,7,8])
Parameters:
left - a Collection
right - a Collection
Returns:
a Collection as an intersection of both collections
Since:
1.5.6


reverseEach

public static Map reverseEach(Map self, Closure closure)
Allows a Map to be iterated through in reverse order using a closure. 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 reverse of the natural ordering of the map.
Parameters:
self - the map over which we iterate
closure - the 1 or 2 arg closure applied on each entry of the map
Returns:
returns the self parameter
See Also:
each(Map, Closure)
Since:
1.7.2


reverseEach

public static List reverseEach(List self, Closure closure)
Iterate over each element of the list in the reverse order.
def result = []
 [1,2,3].reverseEach { result << it }
 assert result == [3,2,1]
Parameters:
self - a List
closure - a closure to which each item is passed.
Returns:
the original list
Since:
1.5.0


reverseEach

public static Object[] reverseEach(Object[] self, Closure closure)


rightShift

public static Number rightShift(Number self, Number operand)


rightShiftUnsigned

public static Number rightShiftUnsigned(Number self, Number operand)


round

public static int round(Float number)
Parse a String into a Float
Parameters:
self - a String
Returns:
a Float
Since:
1.0


round

public static float round(Float number, int precision)
Parse a String into a Double
Parameters:
self - a String
Returns:
a Double
Since:
1.0


round

public static long round(Double number)


round

public static double round(Double number, int precision)
Determine if a String can be parsed into a Long.
Parameters:
self - a String
Returns:
true if the string can be parsed
Since:
1.5.0


runAfter

public static TimerTask runAfter(Timer timer, int delay, Closure closure)


setBytes

public static void setBytes(File file, byte[] bytes)
Append the text at the end of the File.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
text - the text to append at the end of the File
Since:
1.0


setBytes

public static void setBytes(OutputStream os, byte[] bytes)


setIndex

public static void setIndex(Matcher matcher, int idx)
Find the number of Strings matched to the given Matcher.
Parameters:
matcher - a Matcher
Returns:
int the number of Strings matched to the given matcher.
Since:
1.0


setMetaClass

public static void setMetaClass(Class self, MetaClass metaClass)
Allows an Enumeration to behave like an Iterator. Note that the Iterator.remove method is unsupported since the underlying Enumeration does not provide a mechanism for removing items.
Parameters:
enumeration - an Enumeration object
Returns:
an Iterator for the given Enumeration
Since:
1.0


setMetaClass

public static void setMetaClass(Object self, MetaClass metaClass)


setText

public static void setText(File file, String text)
Append the text at the end of the File, using a specified encoding.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
text - the text to append at the end of the File
charset - the charset used
Since:
1.0


setText

public 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.
throws:
FileNotFoundException if the given directory does not exist
throws:
IllegalArgumentException if the provided File object does not represent a directory
Parameters:
dir - The directory to check
Since:
1.0


size

public static int size(Iterator self)
Provide the standard Groovy size() method for String.
Parameters:
text - a String
Returns:
the length of the String
Since:
1.0


size

public static int size(String text)
Provide the standard Groovy size() method for CharSequence.
Parameters:
text - a CharSequence
Returns:
the length of the CharSequence
Since:
1.8.2


size

public static int size(CharSequence text)


size

public static int size(StringBuffer buffer)


size

public static long size(File self)


size

public static long size(Matcher self)


size

public static int size(Object[] self)


size

public static int size(boolean[] array)


size

public static int size(byte[] array)


size

public static int size(char[] array)


size

public static int size(short[] array)


size

public static int size(int[] array)


size

public static int size(long[] array)
Converts this array to a List of the same size, with each element added to the list.
Parameters:
array - a float array
Returns:
a list containing the contents of this array.
Since:
1.0


size

public static int size(float[] array)
Converts this array to a List of the same size, with each element added to the list.
Parameters:
array - a double array
Returns:
a list containing the contents of this array.
Since:
1.0


size

public static int size(double[] array)


sort

public static List sort(Collection self)


sort

public static List sort(Collection self, boolean mutate)


sort

public static Map sort(Map self, Closure closure)


sort

public static Map sort(Map self, Comparator comparator)
Modifies this array so that its elements are in sorted order. The array items are assumed to be comparable.
Parameters:
self - the array to be sorted
Returns:
the sorted array
Since:
1.5.5


sort

public static Map sort(Map self)


sort

public static Object[] sort(Object[] self)


sort

public static Object[] sort(Object[] self, boolean mutate)
Sorts the given iterator items into a sorted iterator using the comparator. The original iterator will become exhausted of elements after completing this method call. A new iterator is produced that traverses the items in sorted order.
Parameters:
self - the Iterator to be sorted
comparator - a Comparator used for comparing items
Returns:
the sorted items as an Iterator
Since:
1.5.5


sort

public static Iterator sort(Iterator self)


sort

public static Iterator sort(Iterator self, Comparator comparator)


sort

public static List sort(Collection self, Comparator comparator)


sort

public static List sort(Collection self, boolean mutate, Comparator comparator)


sort

public static Object[] sort(Object[] self, Comparator comparator)


sort

public static Object[] sort(Object[] self, boolean mutate, Comparator comparator)


sort

public static Iterator sort(Iterator self, Closure closure)


sort

}
public static Object[] sort(Object[] self, Closure closure)


sort

/**
public static Object[] sort(Object[] self, boolean mutate, Closure closure)
Sorts this Collection using the given Closure to determine the correct ordering. If the Collection is a List, it is sorted in place and returned. Otherwise, the elements are first placed into a new list which is then sorted and returned - leaving the original Collection unchanged.

If the Closure has two parameters it is used like a traditional Comparator. I.e. it should compare its two parameters for order, returning a negative integer, zero, or a positive integer when the first parameter is less than, equal to, or greater than the second respectively. Otherwise, the Closure is assumed to take a single parameter and return a Comparable (typically an Integer) which is then used for further comparison.
assert ["hi","hey","hello"] == ["hello","hi","hey"].sort { it.length() }
assert ["hi","hey","hello"] == ["hello","hi","hey"].sort { a, b -> a.length() <=> b.length() }
Parameters:
self - a Collection to be sorted
closure - a 1 or 2 arg Closure used to determine the correct ordering
Returns:
a newly created sorted List
See Also:
sort(Collection, boolean, Closure)
Since:
1.0


sort

public static List sort(Collection self, Closure closure)
Sorts this Collection using the given Closure to determine the correct ordering. If the Collection is a List and mutate is true, it is sorted in place and returned. Otherwise, the elements are first placed into a new list which is then sorted and returned - leaving the original Collection unchanged.

If the closure has two parameters it is used like a traditional Comparator. I.e. it should compare its two parameters for order, returning a negative integer, zero, or a positive integer when the first parameter is less than, equal to, or greater than the second respectively. Otherwise, the Closure is assumed to take a single parameter and return a Comparable (typically an Integer) which is then used for further comparison.
assert ["hi","hey","hello"] == ["hello","hi","hey"].sort { it.length() }
assert ["hi","hey","hello"] == ["hello","hi","hey"].sort { a, b -> a.length() <=> b.length() }
 def orig = ["hello","hi","Hey"]
 def sorted = orig.sort(false) { it.toUpperCase() }
 assert orig == ["hello","hi","Hey"]
 assert sorted == ["hello","Hey","hi"]
 
Parameters:
self - a Collection to be sorted
mutate - false will always cause a new list to be created, true will mutate lists in place
closure - a 1 or 2 arg Closure used to determine the correct ordering
Returns:
a newly created sorted List
Since:
1.8.1


sort

public static List sort(Collection self, boolean mutate, Closure closure)
Avoids doing unnecessary work when sorting an already sorted set (i.e. an identity function for an already sorted set).
Parameters:
self - an already sorted set
Returns:
the set
Since:
1.0


sort

public static SortedSet sort(SortedSet self)


sort

public static SortedMap sort(SortedMap self)


split

public static Collection split(Object self, Closure closure)


split

public static Collection split(Collection self, Closure closure)


split

public static String[] split(String self)


split

public static CharSequence[] split(CharSequence self)
Expands all tabs into spaces. Assumes the String represents a single line of text.
Parameters:
self - A line to expand
tabStop - The number of spaces a tab represents
Returns:
The expanded String
Since:
1.7.3


split

public static String[] split(GString self)
Appends a String to the string representation of this number.
Parameters:
value - a Number
right - a String
Returns:
a String
Since:
1.0


splitEachLine

public 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. For each line, the given closure is called with a single parameter being the list of strings computed by splitting the line around matches of the given regular expression. Finally the resources used for processing the URL are closed.
throws:
IOException if an IOException occurs.
throws:
java.util.regex.PatternSyntaxException if the regular expression's syntax is invalid
Parameters:
self - a URL to open and read
regex - the delimiting regular expression
charset - opens the file with a specified charset
closure - a closure
Returns:
the last value returned by the closure
See Also:
splitEachLine(java.io.Reader, java.lang.String, groovy.lang.Closure)
Since:
1.6.8


splitEachLine

public static Object splitEachLine(File self, Pattern pattern, Closure closure)


splitEachLine

public static Object splitEachLine(File self, String regex, String charset, Closure closure)


splitEachLine

public static Object splitEachLine(File self, Pattern pattern, String charset, Closure closure)


splitEachLine

public static Object splitEachLine(URL self, String regex, Closure closure)


splitEachLine

public static Object splitEachLine(URL self, Pattern pattern, Closure closure)
Iterates through the given InputStream line by line using the specified encoding, splitting each line using the given separator. The list of tokens for each line is then passed to the given closure. Finally, the stream is closed.
throws:
IOException if an IOException occurs.
throws:
java.util.regex.PatternSyntaxException if the regular expression's syntax is invalid
Parameters:
stream - an InputStream
regex - the delimiting regular expression
charset - opens the stream with a specified charset
closure - a closure
Returns:
the last value returned by the closure
See Also:
splitEachLine(java.io.Reader, java.lang.String, groovy.lang.Closure)
Since:
1.5.5


splitEachLine

public static Object splitEachLine(URL self, String regex, String charset, Closure closure)
Iterates through the given InputStream line by line using the specified encoding, splitting each line using the given separator Pattern. The list of tokens for each line is then passed to the given closure. Finally, the stream is closed.
throws:
IOException if an IOException occurs.
Parameters:
stream - an InputStream
pattern - the regular expression Pattern for the delimiter
charset - opens the stream with a specified charset
closure - a closure
Returns:
the last value returned by the closure
See Also:
splitEachLine(java.io.Reader, java.util.regex.Pattern, groovy.lang.Closure)
Since:
1.6.8


splitEachLine

public static Object splitEachLine(URL self, Pattern pattern, String charset, Closure closure)
Iterates through the given InputStream line by line, splitting each line using the given separator. The list of tokens for each line is then passed to the given closure. The stream is closed before the method returns.
throws:
IOException if an IOException occurs.
throws:
java.util.regex.PatternSyntaxException if the regular expression's syntax is invalid
Parameters:
stream - an InputStream
regex - the delimiting regular expression
closure - a closure
Returns:
the last value returned by the closure
See Also:
splitEachLine(java.io.Reader, java.lang.String, groovy.lang.Closure)
Since:
1.5.6


splitEachLine

public static Object splitEachLine(Reader self, String regex, Closure closure)


splitEachLine

public static Object splitEachLine(Reader self, Pattern pattern, Closure closure)
Iterates through the given CharSequence line by line, splitting each line using the given separator. The list of tokens for each line is then passed to the given closure.
throws:
java.io.IOException if an error occurs
throws:
java.util.regex.PatternSyntaxException if the regular expression's syntax is invalid
Parameters:
self - a CharSequence
regex - the delimiting regular expression
closure - a closure
Returns:
the last value returned by the closure
See Also:
splitEachLine(String, String, Closure)
Since:
1.8.2


splitEachLine

public static Object splitEachLine(InputStream stream, String regex, String charset, Closure closure)
Iterates through the given CharSequence line by line, splitting each line using the given separator Pattern. The list of tokens for each line is then passed to the given closure.
throws:
java.io.IOException if an error occurs
Parameters:
self - a CharSequence
pattern - the regular expression Pattern for the delimiter
closure - a closure
Returns:
the last value returned by the closure
See Also:
splitEachLine(String, Pattern, Closure)
Since:
1.8.2


splitEachLine

public static Object splitEachLine(InputStream stream, Pattern pattern, String charset, Closure closure)


splitEachLine

public static Object splitEachLine(InputStream stream, String regex, Closure closure)


splitEachLine

public static Object splitEachLine(InputStream stream, Pattern pattern, Closure closure)


splitEachLine

public static Object splitEachLine(String self, String regex, Closure closure)


splitEachLine

public static Object splitEachLine(CharSequence self, CharSequence regex, Closure closure)


splitEachLine

public static Object splitEachLine(String self, Pattern pattern, Closure closure)


splitEachLine

public static Object splitEachLine(CharSequence self, Pattern pattern, Closure closure)
Return a String with lines (separated by LF, CR/LF, or CR) terminated by the platform specific line separator.
Parameters:
self - a String object
Returns:
the denormalized string
Since:
1.6.0


spread

public static SpreadMap spread(Map self)


sprintf

public static String sprintf(Object self, String format, Object[] values)
Sprintf to a string (Only works with JDK1.5 or later).
Parameters:
self - any Object
format - a format string
values - values referenced by the format specifiers in the format string.
Returns:
the resulting formatted string
Since:
1.5.0


sprintf

public static String sprintf(Object self, String format, Object arg)
Returns a formatted string using the specified format string and arguments.

Parameters:
self - any Object
format - A format string
arg - 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[].
Returns:
the resulting printf'd string
Since:
1.5.0


step

public static void step(Number self, Number to, Number stepNumber, Closure closure)
Get the absolute value
Parameters:
number - a Double
Returns:
the absolute value of that Double
Since:
1.0


stripIndent

public static String stripIndent(String self)


stripIndent

public static CharSequence stripIndent(CharSequence self)
True if a String only contains whitespace characters.
Parameters:
self - The String to check the characters in
Returns:
true If all characters are whitespace characters
See Also:
Character.isWhitespace
Since:
1.6


stripIndent

public static String stripIndent(String self, int numChars)


stripIndent

public static CharSequence stripIndent(CharSequence self, int numChars)
Transforms a String representing a URL into a URL object.
throws:
MalformedURLException is thrown if the URL is not well formed.
Parameters:
self - the String representing a URL
Returns:
a URL
Since:
1.0


stripMargin

public static String stripMargin(String self)

Strip leading whitespace/control characters followed by '|' from every line in a CharSequence.

Parameters:
self - The CharSequence to strip the margin from
Returns:
the stripped CharSequence
See Also:
stripMargin(CharSequence, char)
Since:
1.8.2


stripMargin

public static CharSequence stripMargin(CharSequence self)


stripMargin

public static String stripMargin(String self, String marginChar)


stripMargin

public static String stripMargin(CharSequence self, CharSequence marginChar)


stripMargin

public static String stripMargin(String self, char marginChar)


stripMargin

public static CharSequence stripMargin(CharSequence self, char marginChar)


subMap

public 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.
def map=[:]
 map.get("a", []) << 5
 assert map == [a:[5]]
Parameters:
map - a Map
key - the key to lookup the value of
defaultValue - the value to return and add to the map for this key if there is no entry for the given key
Returns:
the value of the given key or the default value, added to the map if the key did not exist
Since:
1.0


subsequences

public static Set subsequences(List self)


sum

public static Object sum(Collection self)
Sums the items in an array. This is equivalent to invoking the "plus" method on all items in the array.
Parameters:
self - The array of values to add together
Returns:
The sum of all of the items
See Also:
sum(java.util.Collection)
Since:
1.7.1


sum

public static Object sum(Object[] self)


sum

public static Object sum(Iterator self)


sum

public static Object sum(Collection self, Object initialValue)


sum

public static Object sum(Object[] self, Object initialValue)


sum

public static Object sum(Iterator self, Object initialValue)


sum

public static Object sum(Collection self, Closure closure)
Sums the result of apply a closure to each item of an array. array.sum(closure) is equivalent to: array.collect(closure).sum().
Parameters:
self - An array
closure - a single parameter closure that returns a numeric value.
Returns:
The sum of the values returned by applying the closure to each item of the array.
Since:
1.7.1


sum

public static Object sum(Object[] self, Closure closure)
Sums the result of apply a closure to each item returned from an iterator. iter.sum(closure) is equivalent to: iter.collect(closure).sum(). The iterator will become exhausted of elements after determining the sum value.
Parameters:
self - An Iterator
closure - a single parameter closure that returns a numeric value.
Returns:
The sum of the values returned by applying the closure to each item from the Iterator.
Since:
1.7.1


sum

public static Object sum(Iterator self, Closure closure)
Sums the result of applying a closure to each item of a collection to some initial value. coll.sum(initVal, closure) is equivalent to: coll.collect(closure).sum(initVal).
assert 50+4+6+10+12 == [2,3,5,6].sum(50) { it * 2 }
Parameters:
self - a Collection
closure - a single parameter closure that returns a numeric value.
initialValue - the closure results will be summed to this initial value
Returns:
The sum of the values returned by applying the closure to each item of the collection.
Since:
1.5.0


sum

public static Object sum(Collection self, Object initialValue, Closure closure)
Sums the result of applying a closure to each item of an array to some initial value. array.sum(initVal, closure) is equivalent to: array.collect(closure).sum(initVal).
Parameters:
self - an array
closure - a single parameter closure that returns a numeric value.
initialValue - the closure results will be summed to this initial value
Returns:
The sum of the values returned by applying the closure to each item of the array.
Since:
1.7.1


sum

public static Object sum(Object[] self, Object initialValue, Closure closure)
Sums the result of applying a closure to each item of an Iterator to some initial value. iter.sum(initVal, closure) is equivalent to: iter.collect(closure).sum(initVal). The iterator will become exhausted of elements after determining the sum value.
Parameters:
self - an Iterator
closure - a single parameter closure that returns a numeric value.
initialValue - the closure results will be summed to this initial value
Returns:
The sum of the values returned by applying the closure to each item from the Iterator.
Since:
1.7.1


sum

public static Object sum(Iterator self, Object initialValue, Closure closure)


tail

public static List tail(List self)


tail

public static Object[] tail(Object[] self)


take

public static List take(List self, int num)
Returns the first num elements from the head of this array.
 String[] strings = [ 'a', 'b', 'c' ]
 assert strings.take( 0 ) == [] as String[]
 assert strings.take( 2 ) == [ 'a', 'b' ] as String[]
 assert strings.take( 5 ) == [ 'a', 'b', 'c' ] as String[]
 
Parameters:
self - the original array
num - the number of elements to take from this array
Returns:
an array consisting of the first num elements of this array, or else the whole array if it has less then num elements.
Since:
1.8.1


take

public static Object[] take(Object[] self, int num)
Returns the first num elements from the head of this Iterable.
 class AbcIterable implements Iterable {
     Iterator iterator() { "abc".iterator() }
 }
 def abc = new AbcIterable()
 assert abc.take(0) == []
 assert abc.take(1) == ['a']
 assert abc.take(3) == ['a', 'b', 'c']
 assert abc.take(5) == ['a', 'b', 'c']
 
Parameters:
self - the original Iterable
num - the number of elements to take from this Iterable
Returns:
a List consisting of the first num elements from this Iterable, or else all the elements from the Iterable if it has less then num elements.
Since:
1.8.7


take

public static List take(Iterable self, int num)
Returns a new map containing the first num elements from the head of this map. If the map instance does not have ordered keys, then this function could return a random num entries. Groovy by default uses LinkedHashMap, so this shouldn't be an issue in the main.
 def strings = [ 'a':10, 'b':20, 'c':30 ]
 assert strings.take( 0 ) == [:]
 assert strings.take( 2 ) == [ 'a':10, 'b':20 ]
 assert strings.take( 5 ) == [ 'a':10, 'b':20, 'c':30 ]
 
Parameters:
self - the original map
num - the number of elements to take from this map
Returns:
a new map consisting of the first num elements of this map, or else the whole map if it has less then num elements.
Since:
1.8.1


take

public static Map take(Map self, int num)


take

* 
public static Iterator take(Iterator self, int num)


take

public static CharSequence take(CharSequence self, int num)


takeWhile

public static List takeWhile(List self, Closure condition)
Returns a List containing the longest prefix of the elements from this Iterable where each element passed to the given closure evaluates to true.
 class AbcIterable implements Iterable {
     Iterator iterator() { "abc".iterator() }
 }
 def abc = new AbcIterable()
 assert abc.takeWhile{ it < 'b' } == ['a']
 assert abc.takeWhile{ it <= 'b' } == ['a', 'b']
 
Parameters:
self - an Iterable
condition - the closure that must evaluate to true to continue taking elements
Returns:
a List containing a prefix of the elements from the given Iterable where each element passed to the given closure evaluates to true
Since:
1.8.7


takeWhile

public static List takeWhile(Iterable self, Closure condition)
Returns the longest prefix of this Map where each entry (or key/value pair) when passed to the given closure evaluates to true.
 def shopping = [milk:1, bread:2, chocolate:3]
 assert shopping.takeWhile{ it.key.size() < 6 } == [milk:1, bread:2]
 assert shopping.takeWhile{ it.value % 2 } == [milk:1]
 assert shopping.takeWhile{ k, v -> k.size() + v <= 7 } == [milk:1, bread:2]
 
If the map instance does not have ordered keys, then this function could appear to take random entries. Groovy by default uses LinkedHashMap, so this shouldn't be an issue in the main.
Parameters:
self - a Map
condition - a 1 (or 2) arg Closure that must evaluate to true for the entry (or key and value) to continue taking elements
Returns:
a prefix of the given Map where each entry (or key/value pair) passed to the given closure evaluates to true
Since:
1.8.7


takeWhile

public static Map takeWhile(Map self, Closure condition)
Returns the longest prefix of this array where each element passed to the given closure evaluates to true.
 def nums = [ 1, 3, 2 ] as Integer[]
 assert nums.takeWhile{ it < 1 } == [] as Integer[]
 assert nums.takeWhile{ it < 3 } == [ 1 ] as Integer[]
 assert nums.takeWhile{ it < 4 } == [ 1, 3, 2 ] as Integer[]
 
Parameters:
self - the original array
condition - the closure that must evaluate to true to continue taking elements
Returns:
a prefix of the given array where each element passed to the given closure evaluates to true
Since:
1.8.7


takeWhile

public static Object[] takeWhile(Object[] self, Closure condition)


takeWhile

public static Iterator takeWhile(Iterator self, Closure condition)


takeWhile

public static CharSequence takeWhile(CharSequence self, Closure closure)
Parameters:
array - an Array of Objects
range - an IntRange
Returns:
a range of a list from the range's from index up to but not including the range's to value
Since:
1.0


times

public static void times(Number self, Closure closure)
Iterates from this number up to the given number, inclusive, incrementing by one each time.
Parameters:
self - a double
to - the end number
closure - the code to execute for each number
Since:
1.0


toArrayString

public static String toArrayString(Object[] self)
Compare a Character and a Number. The ordinal value of the Character is used in the comparison (the ordinal value is the unicode value which for simple character sets is the ASCII value).
Parameters:
left - a Character
right - a Number
Returns:
the result of the comparison
Since:
1.0


toBigDecimal

public static BigDecimal toBigDecimal(String self)


toBigDecimal

public static BigDecimal toBigDecimal(CharSequence self)


toBigDecimal

public static BigDecimal toBigDecimal(Number self)
Exclusive disjunction of two boolean operators
Parameters:
left - left operator
right - right operator
Returns:
result of exclusive disjunction
Since:
1.0


toBigInteger

public static BigInteger toBigInteger(String self)


toBigInteger

public static BigInteger toBigInteger(CharSequence self)


toBigInteger

public static BigInteger toBigInteger(Number self)
Create an object input stream for this file.
throws:
IOException if an IOException occurs.
Parameters:
file - a file
Returns:
an object input stream
Since:
1.5.0


toBoolean

public static Boolean toBoolean(String self)


toBoolean

public static Boolean toBoolean(Boolean self)


toCharacter

public static Character toCharacter(String self)
Expands all tabs into spaces with tabStops of size 8.
Parameters:
self - A CharSequence to expand
Returns:
The expanded CharSequence
See Also:
expand(java.lang.String)
Since:
1.8.2


toDouble

public static Double toDouble(String self)


toDouble

public static Double toDouble(CharSequence self)


toDouble

public static Double toDouble(Number self)
Logical implication of two boolean operators
Parameters:
left - left operator
right - right operator
Returns:
result of logical implication
Since:
1.8.3


toFloat

public static Float toFloat(String self)


toFloat

public static Float toFloat(CharSequence self)


toFloat

public static Float toFloat(Number self)
Logical disjunction of two boolean operators
Parameters:
left - left operator
right - right operator
Returns:
result of logical disjunction
Since:
1.0


toInteger

public static Integer toInteger(String self)
Determine if a String can be parsed into a Double.
Parameters:
self - a String
Returns:
true if the string can be parsed
Since:
1.5.0


toInteger

public static Integer toInteger(CharSequence self)


toInteger

public static Integer toInteger(Number self)


toList

public static List toList(Collection self)


toList

public static List toList(Iterator self)


toList

public static List toList(Iterable self)


toList

public static List toList(Enumeration self)


toList

public static List toList(Object[] array)


toList

* @return a set containing the unique contents of this array.
public static List toList(byte[] array)


toList

* @return a set containing the unique contents of this array.
public static List toList(boolean[] array)


toList

* @return a set containing the unique contents of this array.
public static List toList(char[] array)


toList

* @return a set containing the unique contents of this array.
public static List toList(short[] array)


toList

* @return a set containing the unique contents of this array.
public static List toList(int[] array)


toList

* @return a set containing the unique contents of this array.
public static List toList(long[] array)


toList

* @return a set containing the unique contents of this array.
public static List toList(float[] array)


toList

* 
public static List toList(double[] array)


toList

public static List toList(String self)


toList

public static List toList(CharSequence self)


toListString

public static String toListString(Collection self)


toListString

public static String toListString(Collection self, int maxSize)


toLong

public static Long toLong(String self)


toLong

public static Long toLong(CharSequence self)


toLong

public static Long toLong(Number self)


toLowerCase

public static char toLowerCase(Character self)
Transform this Number into a BigInteger.
Parameters:
self - a Number
Returns:
an BigInteger
Since:
1.0


toMapString

public static String toMapString(Map self)


toMapString

public static String toMapString(Map self, int maxSize)


toSet

return answer;
public static Set toSet(byte[] array)


toSet

while (self.hasNext()) {
public static Set toSet(boolean[] array)
Convert an iterator to a Set. The iterator will become exhausted of elements after making this conversion.
Parameters:
self - an iterator
Returns:
a Set
Since:
1.8.0


toSet

public static  Set toSet(Enumeration self) {
public static Set toSet(char[] array)
Convert an enumeration to a Set.
Parameters:
self - an enumeration
Returns:
a Set
Since:
1.8.0


toSet

* @return the returned value from the array
public static Set toSet(short[] array)


toSet

* @since 1.5.0
public static Set toSet(int[] array)


toSet

* value in the collection argument is assumed to be a valid array index.
public static Set toSet(long[] array)


toSet

} else if (value instanceof List) {
public static Set toSet(float[] array)


toSet

* @param self     an object
public static Set toSet(double[] array)


toSet

public static Set toSet(Collection self)


toSet

public static Set toSet(Iterator self)


toSet

public static Set toSet(Enumeration self)


toSet

public static Set toSet(String self)


toSet

public static Set toSet(CharSequence self)


toShort

public static Short toShort(String self)


toShort

public static Short toShort(CharSequence self)


toSpreadMap

public static SpreadMap toSpreadMap(Map self)
Creates a spreadable map from this list.

Parameters:
self - a list
Returns:
a newly created SpreadMap
See Also:
SpreadMap.SpreadMap
toSpreadMap(java.util.Map)
Since:
1.8.0


toSpreadMap

public static SpreadMap toSpreadMap(Object[] self)


toSpreadMap

public static SpreadMap toSpreadMap(List self)


toString

public static String toString(boolean[] self)


toString

public static String toString(byte[] self)


toString

public static String toString(char[] self)
Returns the string representation of the given list. The string displays the contents of the list, similar to a list literal, i.e. [1, 2, a].
Parameters:
self - a Collection
Returns:
the string representation
Since:
1.0


toString

public static String toString(short[] self)


toString

public static String toString(int[] self)


toString

public static String toString(long[] self)


toString

public static String toString(float[] self)


toString

public static String toString(double[] self)


toString

public static String toString(AbstractMap self)


toString

public static String toString(AbstractCollection self)


toString

public static String toString(Object[] self)


toString

public static String toString(Object value)


toURI

public static URI toURI(String self)


toURI

public static URI toURI(CharSequence self)


toURL

public static URL toURL(String self)


toURL

public static URL toURL(CharSequence self)


toUpperCase

public static char toUpperCase(Character self)


tokenize

public static List tokenize(String self, String token)
Appends a String to this StringBuffer.
Parameters:
left - a StringBuffer
value - a String
Returns:
a String
Since:
1.0


tokenize

public static List tokenize(CharSequence self, CharSequence token)
Remove a part of a String. This replaces the first occurrence of target within self with '' and returns the result. If target is a regex Pattern, the first occurrence of that pattern will be removed (using regex matching), otherwise the first occurrence of target.toString() will be removed.
Parameters:
self - a String
target - an object representing the part to remove
Returns:
a String minus the part to be removed
Since:
1.0


tokenize

public static List tokenize(String self, Character token)


tokenize

public static List tokenize(CharSequence self, Character token)


tokenize

* Provide an implementation of contains() like
public static List tokenize(String self)


tokenize

public static List tokenize(CharSequence self)


tr

public static String tr(String self, String sourceSet, String replacementSet)
Translates a string by replacing characters from the sourceSet with characters from replacementSet.
Parameters:
self - the CharSequence that is to be translated
sourceSet - the set of characters to translate from
replacementSet - the set of replacement characters
Returns:
The resulting translated CharSequence
See Also:
tr(String, String, String)
Since:
1.8.2


tr

public static CharSequence tr(CharSequence self, CharSequence sourceSet, CharSequence replacementSet)
Tells whether or not a CharSequence matches the given compiled regular expression Pattern.
Parameters:
self - the CharSequence that is to be matched
pattern - the regex Pattern to which the string of interest is to be matched
Returns:
true if the CharSequence matches
See Also:
String.matches
Since:
1.8.2


transformChar

public static void transformChar(Reader self, Writer writer, Closure closure)
Filter the lines from this Reader, and return a Writable which can be used to stream the filtered lines to a destination. The closure should return true if the line should be passed to the writer.
Parameters:
reader - this reader
closure - a closure used for filtering
Returns:
a Writable which will use the closure to filter each line from the reader when the Writable#writeTo(Writer) is called.
Since:
1.0


transformLine

public static void transformLine(Reader reader, Writer writer, Closure closure)


transpose

public static List transpose(List self)


traverse

public static void traverse(File self, Map options, Closure closure)
Invokes the closure for each descendant file in this directory. Sub-directories are recursively searched in a depth-first fashion. Both regular files and subdirectories are passed to the closure.
throws:
FileNotFoundException if the given directory does not exist
throws:
IllegalArgumentException if the provided File object does not represent a directory
Parameters:
self - a File
closure - a closure
See Also:
eachFileRecurse(java.io.File, groovy.io.FileType, groovy.lang.Closure)
Since:
1.0


traverse

public static void traverse(File self, Closure closure)
Invokes the closure for each file whose name (file.name) matches the given nameFilter in the given directory - calling the isCase(java.lang.Object, java.lang.Object) method to determine if a match occurs. This method can be used with different kinds of filters like regular expressions, classes, ranges etc. Both regular files and subdirectories are matched.
throws:
FileNotFoundException if the given directory does not exist
throws:
IllegalArgumentException if the provided File object does not represent a directory
Parameters:
self - a file
nameFilter - the nameFilter to perform on the name of the file (using the isCase(java.lang.Object, java.lang.Object) method)
closure - the closure to invoke
See Also:
eachFileMatch(java.io.File, groovy.io.FileType, java.lang.Object, groovy.lang.Closure)
Since:
1.5.0


traverse

public static void traverse(File self, Map options)
Invokes the closure for each subdirectory whose name (dir.name) matches the given nameFilter in the given directory - calling the isCase(java.lang.Object, java.lang.Object) method to determine if a match occurs. This method can be used with different kinds of filters like regular expressions, classes, ranges etc. Only subdirectories are matched; regular files are ignored.
throws:
FileNotFoundException if the given directory does not exist
throws:
IllegalArgumentException if the provided File object does not represent a directory
Parameters:
self - a file
nameFilter - the nameFilter to perform on the name of the directory (using the isCase(java.lang.Object, java.lang.Object) method)
closure - the closure to invoke
See Also:
eachFileMatch(java.io.File, groovy.io.FileType, java.lang.Object, groovy.lang.Closure)
Since:
1.5.0


trunc

public static float trunc(Float number, int precision)


trunc

public static float trunc(Float number)


trunc

public static double trunc(Double number)


trunc

public static double trunc(Double number, int precision)


unaryMinus

public static Number unaryMinus(Number left)


unexpand

public static String unexpand(String self)


unexpand

public static CharSequence unexpand(CharSequence self)


unexpand

public static String unexpand(String self, int tabStop)


unexpand

public static CharSequence unexpand(CharSequence self, int tabStop)
Tokenize a CharSequence based on the given character delimiter.
Parameters:
self - a CharSequence
token - the delimiter
Returns:
a List of tokens
See Also:
tokenize(String, Character)
Since:
1.8.2


unexpandLine

public static String unexpandLine(String self, int tabStop)


unexpandLine

public static CharSequence unexpandLine(CharSequence self, int tabStop)
Appends the String representation of the given operand to this string.
Parameters:
left - a String
value - any Object
Returns:
the new string with the object appended
Since:
1.0


unique

public static Iterator unique(Iterator self)


unique

public static Collection unique(Collection self)


unique

public static Collection unique(Collection self, boolean mutate)


unique

public static Iterator unique(Iterator self, Closure closure)


unique

public static Collection unique(Collection self, Closure closure)


unique

public static Collection unique(Collection self, boolean mutate, Closure closure)


unique

public static Iterator unique(Iterator self, Comparator comparator)
Returns an iterator equivalent to this iterator with all duplicated items removed by using the supplied comparator.
Parameters:
self - an Iterator
comparator - a Comparator
Returns:
the modified Iterator
Since:
1.5.5


unique

public static Collection unique(Collection self, Comparator comparator)


unique

public static Collection unique(Collection self, boolean mutate, Comparator comparator)


upto

public static void upto(Number self, Number to, Closure closure)
Iterates from this number up to the given number, inclusive, incrementing by one each time.
Parameters:
self - a Double
to - the end number
closure - the code to execute for each number
Since:
1.0


upto

public static void upto(long self, Number to, Closure closure)
Iterates from this number up to the given number, inclusive, incrementing by one each time. Example:
0.upto( 10 ) {
   println it
 }
Prints numbers 0 to 10
Parameters:
self - a BigInteger
to - the end number
closure - the code to execute for each number
Since:
1.0


upto

public static void upto(Long self, Number to, Closure closure)


upto

public static void upto(float self, Number to, Closure closure)


upto

public static void upto(Float self, Number to, Closure closure)


upto

public static void upto(double self, Number to, Closure closure)


upto

public static void upto(Double self, Number to, Closure closure)


upto

public static void upto(BigInteger self, Number to, Closure closure)
Iterates from this number down to the given number, inclusive, decrementing by one each time.
Parameters:
self - a Long
to - the end number
closure - the code to execute for each number
Since:
1.0


upto

public static void upto(BigDecimal self, Number to, Closure closure)
Iterates from this number down to the given number, inclusive, decrementing by one each time.
Parameters:
self - a float
to - the end number
closure - the code to execute for each number
Since:
1.0


use

public static Object use(Object self, Class categoryClass, Closure closure)
Scoped use method
Parameters:
self - any Object
categoryClass - a category class to use
closure - the closure to invoke with the category in place
Returns:
the value returned from the closure
Since:
1.0


use

public static Object use(Object self, List categoryClassList, Closure closure)
Scoped use method with list of categories.
Parameters:
self - any Object
categoryClassList - a list of category classes
closure - the closure to invoke with the categories in place
Returns:
the value returned from the closure
Since:
1.0


use

public static Object use(Object self, Object[] array)
Allows you to use a list of categories, specifying the list as varargs. use(CategoryClass1, CategoryClass2) { ... } This method saves having to wrap the the category classes in a list.
Parameters:
self - any Object
array - a list of category classes and a Closure
Returns:
the value returned from the closure
Since:
1.0


with

public static Object with(Object self, Closure closure)
Allows the closure to be called for the object reference self.

Any method invoked inside the closure will first be invoked on the self reference. For instance, the following method calls to the append() method are invoked on the StringBuilder instance:
 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
 }
 
Parameters:
self - the object to have a closure act upon
closure - the closure to call on the object
Returns:
result of calling the closure
Since:
1.5.0


withDataInputStream

public static Object withDataInputStream(File file, Closure closure)


withDataOutputStream

public static Object withDataOutputStream(File file, Closure closure)
Create a new PrintWriter for this file.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
Returns:
the created PrintWriter
Since:
1.0


withDefault

public static Map withDefault(Map self, Closure init)


withDefault

public static List withDefault(List self, Closure init)


withEagerDefault

public static List withEagerDefault(List self, Closure init)
Sorts the Collection. Assumes that the collection items are comparable and uses their natural ordering to determine the resulting order. If the Collection is a List, it is sorted in place and returned. Otherwise, the elements are first placed into a new list which is then sorted and returned - leaving the original Collection unchanged.
assert [1,2,3] == [3,1,2].sort()
Parameters:
self - the collection to be sorted
Returns:
the sorted collection as a List
See Also:
sort(Collection, boolean)
Since:
1.0


withInputStream

public static Object withInputStream(File file, Closure closure)
Create a new BufferedWriter which will append to this file. The writer is passed to the closure and will be closed before this method returns.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
charset - the charset used
closure - a closure
Returns:
the value returned by the closure
Since:
1.5.2


withInputStream

public static Object withInputStream(URL url, Closure closure)
Create a new BufferedWriter for this file in append mode. The writer is passed to the closure and is closed after the closure returns.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
closure - a closure
Returns:
the value returned by the closure
Since:
1.5.2


withLazyDefault

public static List withLazyDefault(List self, Closure init)


withObjectInputStream

public static Object withObjectInputStream(File file, Closure closure)
Iterates through this file line by line. Each line is passed to the given 1 or 2 arg closure. The file is read using a reader which is closed before this method returns.
throws:
IOException if an IOException occurs.
Parameters:
self - a File
closure - a closure (arg 1 is line, optional arg 2 is line number starting at line 1)
Returns:
the last value returned by the closure
See Also:
eachLine(java.io.File, int, groovy.lang.Closure)
Since:
1.5.5


withObjectInputStream

public static Object withObjectInputStream(File file, ClassLoader classLoader, Closure closure)


withObjectInputStream

public static Object withObjectInputStream(InputStream inputStream, Closure closure)


withObjectInputStream

public static Object withObjectInputStream(InputStream inputStream, ClassLoader classLoader, Closure closure)


withObjectOutputStream

public static Object withObjectOutputStream(File file, Closure closure)


withObjectOutputStream

public static Object withObjectOutputStream(OutputStream outputStream, Closure closure)
Create a new ObjectInputStream for this file and pass it to the closure. This method ensures the stream is closed after the closure returns.
throws:
IOException if an IOException occurs.
Parameters:
inputStream - an input stream
closure - a closure
Returns:
the value returned by the closure
See Also:
withStream(java.io.InputStream, groovy.lang.Closure)
Since:
1.5.0


withObjectStreams

public static Object withObjectStreams(Socket socket, Closure closure)
Converts the given String into a List of strings of one character.
Parameters:
self - a String
Returns:
a List of characters (a 1-character String)
Since:
1.0


withOutputStream

public static Object withOutputStream(File file, Closure closure)


withPrintWriter

public static Object withPrintWriter(File file, Closure closure)


withPrintWriter

public static Object withPrintWriter(File file, String charset, Closure closure)


withPrintWriter

public static Object withPrintWriter(Writer writer, Closure closure)


withReader

public static Object withReader(File file, Closure closure)


withReader

public static Object withReader(File file, String charset, Closure closure)
Write a Byte Order Mark at the beginning of the file
throws:
IOException if an IOException occurs.
Parameters:
stream - the FileOutputStream to write the BOM to
bigEndian - true if UTF 16 Big Endian or false if Low Endian
Since:
1.0


withReader

public static Object withReader(Reader reader, Closure closure)
Creates a buffered input stream for this file.
throws:
FileNotFoundException if the file is not found.
Parameters:
file - a File
Returns:
a BufferedInputStream of the file
Since:
1.0


withReader

public static Object withReader(URL url, Closure closure)
Creates a buffered input stream for this URL.
throws:
MalformedURLException is thrown if the URL is not well formed
throws:
IOException if an I/O error occurs while creating the input stream
Parameters:
url - a URL
Returns:
a BufferedInputStream for the URL
Since:
1.5.2


withReader

public static Object withReader(URL url, String charset, Closure closure)


withReader

public static Object withReader(InputStream in, Closure closure)


withReader

public static Object withReader(InputStream in, String charset, Closure closure)
Creates a buffered reader for this URL using the given encoding.
throws:
MalformedURLException is thrown if the URL is not well formed
throws:
IOException if an I/O error occurs while creating the input stream
Parameters:
url - a URL
charset - opens the stream with a specified charset
Returns:
a BufferedReader for the URL
Since:
1.5.5


withStream

public static Object withStream(InputStream stream, Closure closure)


withStream

public static Object withStream(OutputStream os, Closure closure)


withStreams

public static Object withStreams(Socket socket, Closure closure)
Converts this File to a Writable or delegates to default asType(java.lang.Object, java.lang.Class).
Parameters:
f - a File
c - the desired class
Returns:
the converted object
Since:
1.0


withWriter

public 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.
throws:
IOException if an IOException occurs.
Parameters:
reader - the reader which is used and then closed
closure - the closure that the writer is passed into
Returns:
the value returned by the closure
Since:
1.5.2


withWriter

public static Object withWriter(File file, String charset, Closure closure)
Allows this input stream to be used within the closure, ensuring that it is flushed and closed before this method returns.
throws:
IOException if an IOException occurs.
Parameters:
stream - the stream which is used and then closed
closure - the closure that the stream is passed into
Returns:
the value returned by the closure
Since:
1.5.2


withWriter

public static Object withWriter(Writer writer, Closure closure)


withWriter

public static Object withWriter(OutputStream stream, Closure closure)
Creates a buffered reader for this URL using the given encoding.
throws:
MalformedURLException is thrown if the URL is not well formed
throws:
IOException if an I/O error occurs while creating the input stream
Parameters:
url - a URL
parameters - connection parameters
charset - opens the stream with a specified charset
Returns:
a BufferedReader for the URL
Since:
1.8.1


withWriter

public static Object withWriter(OutputStream stream, String charset, Closure closure)
Create a data input stream for this file
throws:
FileNotFoundException if the file is not found.
Parameters:
file - a File
Returns:
a DataInputStream of the file
Since:
1.5.0


withWriterAppend

public static Object withWriterAppend(File file, String charset, Closure closure)


withWriterAppend

public static Object withWriterAppend(File file, Closure closure)


write

public static void write(Writer self, Writable writable)


write

public static void write(File file, String text)
Append binary data to the file. It will not be interpreted as text.
throws:
IOException if an IOException occurs.
Parameters:
self - a File
stream - stream to read data from.
Since:
1.5.0


write

public static void write(File file, String text, String charset)


writeLine

public static void writeLine(BufferedWriter writer, String line)


xor

public static BitSet xor(BitSet left, BitSet right)
Iterates from this number up to the given number, inclusive, incrementing by one each time.
Parameters:
self - a long
to - the end number
closure - the code to execute for each number
Since:
1.0


xor

public static Number xor(Number left, Number right)
Iterates from this number up to the given number, inclusive, incrementing by one each time.
Parameters:
self - a float
to - the end number
closure - the code to execute for each number
Since:
1.0


xor

public static Boolean xor(Boolean left, Boolean right)


 

Copyright © 2003-2012 The Codehaus. All rights reserved.