Groovy 1.7.11

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


Field Summary
static Class[] additionals

 
Method Summary
static int abs(Number number)

Truncate the value

static long abs(Long number)

static float abs(Float number)

static double abs(Double number)

static Socket accept(ServerSocket serverSocket, Closure closure)

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

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

Adds all of the elements in the specified array to this collection.

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

static void addShutdownHook(Object self, Closure closure)

Allows the usage of addShutdownHook without getting the runtime first.

static Number and(Number left, Number right)

static BitSet and(BitSet left, BitSet right)

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

static Boolean and(Boolean left, Boolean right)

Create an object input stream for this input stream using the given class loader.

static boolean any(Object self, Closure closure)

Iterates over the contents of an object or collection, and checks whether a predicate is valid for at least one element.

static boolean any(Map self, Closure closure)

Iterates over the entries of a map, and checks whether a predicate is valid for at least one entry.

static boolean any(Object self)

Iterates over the elements of a collection, and checks whether at least one element is true according to the Groovy Truth.

static void append(File file, Object text)

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

static void append(File self, InputStream stream)

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

static boolean asBoolean(Object object)

Coerce a Matcher instance to a boolean value.

static boolean asBoolean(Boolean bool)

static boolean asBoolean(Matcher matcher)

static boolean asBoolean(Collection collection)

Coerce an iterator instance to a boolean value.

static boolean asBoolean(Map map)

Coerce an enumeration instance to a boolean value.

static boolean asBoolean(Iterator iterator)

static boolean asBoolean(Enumeration enumeration)

static boolean asBoolean(CharSequence string)

static boolean asBoolean(Object[] array)

static boolean asBoolean(byte[] array)

static boolean asBoolean(short[] array)

static boolean asBoolean(int[] array)

static boolean asBoolean(long[] array)

static boolean asBoolean(float[] array)

static boolean asBoolean(double[] array)

static boolean asBoolean(boolean[] array)

static boolean asBoolean(char[] array)

Coerce a number to a boolean value.

static boolean asBoolean(Character character)

@deprecated use SqlGroovyMethods#asBoolean(GroovyResultSet)

static boolean asBoolean(Number number)

static boolean asBoolean(GroovyResultSet grs)

static Map asImmutable(Map self)

A convenience method for creating an immutable list

static SortedMap asImmutable(SortedMap self)

static List asImmutable(List self)

static Set asImmutable(Set self)

static SortedSet asImmutable(SortedSet self)

static Collection asImmutable(Collection self)

A convenience method for creating a synchronized SortedMap.

static List asList(Collection self)

Coerce an Boolean instance to a boolean value.

static Map asSynchronized(Map self)

static SortedMap asSynchronized(SortedMap self)

static Collection asSynchronized(Collection self)

static List asSynchronized(List self)

static Set asSynchronized(Set self)

static SortedSet asSynchronized(SortedSet self)

static Object asType(Collection col, Class clazz)

static Object asType(Object[] ary, Class clazz)

Converts the given array to either a List, Set, or SortedSet.

static Object asType(Closure cl, Class clazz)

Coerces this map to the given type, using the map's keys as the public method names, and values as the implementation.

static Object asType(Map map, Class clazz)

Reverses the list.

static Object asType(Number self, Class c)

Create a new ObjectOutputStream for this file and then pass it to the closure.

static Object asType(File f, Class c)

@deprecated use ProcessGroovyMethods#leftShift(Process, byte[])

static Object asType(GString self, Class c)

@deprecated use ProcessGroovyMethods#waitForProcessOutput(Process, OutputStream, OutputStream)

static Object asType(String self, Class c)

@deprecated use ProcessGroovyMethods#consumeProcessErrorStream(Process, Appendable)

static Object asType(Object obj, Class type)

Sets the metaclass for a given class.

static File asWritable(File file)

@deprecated use ProcessGroovyMethods#getOut(Process)

static File asWritable(File file, String encoding)

@deprecated use ProcessGroovyMethods#consumeProcessOutput(Process)

static Pattern bitwiseNegate(String self)

static BitSet bitwiseNegate(BitSet self)

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

protected static Object callClosureForMapEntry(Closure closure, def entry)

protected static Object callClosureForMapEntryAndCounter(Closure closure, def entry, int counter)

static String capitalize(String self)

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

static String center(String self, Number numberOfChars)

static void clearTime(Date self)

static void clearTime(def self)

static void clearTime(Calendar self)

static List collect(Object self, Closure closure)

Iterates through this object transforming each value into a new value using the closure as a transformer, returning a list of transformed values.

static Collection collect(Object self, Collection collection, Closure closure)

static List collect(Collection self, Closure closure)

static Collection collect(Collection self, Collection collection, Closure closure)

static Collection collect(Map self, Collection collection, Closure closure)

Iterates through this Map transforming each entry into a new value using the closure as a transformer, returning a list of transformed values.

static List collect(Map self, Closure closure)

static List collectAll(Collection self, Closure closure)

Recursively iterates through this collection transforming each non-Collection value into a new value using the closure as a transformer.

static Collection collectAll(Collection self, Collection collection, Closure closure)

static Map collectEntries(Map self, Map result, Closure closure)

static Map collectEntries(Map self, Closure closure)

static Map collectEntries(Collection self, Map result, Closure closure)

static Map collectEntries(Object[] self, Map result, Closure closure)

static Map collectEntries(Collection self, Closure closure)

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

static List combinations(Collection self)

Adds GroovyCollections#combinations(Collection) as a method on collections.

static int compareTo(Character left, Number right)

static int compareTo(Number left, Character right)

static int compareTo(Character left, Character right)

static int compareTo(Number left, Number right)

static Thread consumeProcessErrorStream(Process self, OutputStream err)

static Thread consumeProcessErrorStream(Process self, StringBuffer error)

static Thread consumeProcessErrorStream(Process self, Writer err)

static void consumeProcessOutput(Process self)

static void consumeProcessOutput(Process self, StringBuffer output, StringBuffer error)

static void consumeProcessOutput(Process self, OutputStream output, OutputStream error)

static Thread consumeProcessOutputStream(Process self, StringBuffer output)

static Thread consumeProcessOutputStream(Process self, Writer output)

static Thread consumeProcessOutputStream(Process self, OutputStream output)

static boolean contains(String self, String text)

Executes the command specified by self with environment defined by envp and under the working directory dir.

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

static Number count(Iterator self, Object value)

Counts the number of occurrences of the given value from the items within this Iterator.

static Number count(Collection self, Object value)

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

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

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

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

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

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

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

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

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

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

static int count(String self, String text)

protected static StringBufferWriter createStringBufferWriter(StringBuffer self)

protected static StringWriter createStringWriter(String self)

static byte[] decodeBase64(String value)

static boolean deleteDir(File self)

Creates a new data output stream for this file.

static String denormalize(String self)

static boolean disjoint(Collection left, Collection right)

Compare the contents of this array to the contents of the given array.

static Number div(Character left, Number right)

Bitwise AND together two Numbers.

static Number div(Number left, Character right)

static Number div(Character left, Character right)

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

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

static void downto(long self, Number to, Closure closure)

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

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

static void downto(float self, Number to, Closure closure)

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

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

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

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

static void downto(BigDecimal self, Number to, Closure closure)

Get the absolute value

static String dump(Object self)

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

static T each(T self, Closure closure)

Iterates through an aggregate type or data structure, passing each item to the given closure.

static Map each(Map self, Closure closure)

Allows a Map to be iterated through using a closure.

static void eachByte(File self, Closure closure)

Transforms the lines from a reader with a Closure and write them to a writer.

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

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

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

Filter the lines from a reader and write them on the writer, according to a closure which returns true if the line should be included.

static void eachByte(InputStream is, Closure closure)

static void eachByte(InputStream is, int bufferLen, Closure closure)

Filters the lines of a File and creates a Writeable in return to stream the filtered lines.

static void eachByte(URL url, Closure closure)

Filters the lines of a File and creates a Writeable in return to stream the filtered lines.

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

static void eachDir(File self, Closure closure)

Invokes the closure for each descendant file in this directory tree.

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

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

static void eachDirRecurse(File self, Closure closure)

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

static void eachFile(File self, Closure closure)

static void eachFileMatch(File self, FileType fileType, Object nameFilter, Closure closure)

Create a buffered reader for this file, using the specified charset as the encoding.

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

Creates a reader for this input stream, using the specified charset as the encoding.

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

Invokes the closure specified with key 'visit' in the options Map for each descendant file in this directory tree.

static void eachFileRecurse(File self, Closure closure)

Deletes a directory with all contained files and subdirectories.

static Object eachLine(String self, Closure closure)

Iterates through this stream, passing each line to the given 1 or 2 arg closure.

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

Iterates through this stream, passing each line to the given 1 or 2 arg closure.

static Object eachLine(File self, Closure closure)

Iterates through the lines read from the URL's associated input stream passing each line to the given 1 or 2 arg closure.

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

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

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

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

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

static Object eachLine(InputStream stream, Closure closure)

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

static Object eachLine(URL url, Closure closure)

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

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

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

Iterates through this file line by line, splitting each line using the given regex separator Pattern.

static Object eachLine(Reader self, Closure closure)

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

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

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

static void eachObject(File self, Closure closure)

static void eachObject(ObjectInputStream ois, Closure closure)

static Iterator eachPermutation(Collection self, Closure closure)

static Object eachWithIndex(Object self, Closure closure)

static Map eachWithIndex(Map self, Closure closure)

Allows a Map to be iterated through using a closure.

static Writable encodeBase64(Byte[] data, boolean chunked)

@deprecated moved to DateGroovyMethods.getAt

static Writable encodeBase64(Byte[] data)

static Writable encodeBase64(byte[] data, boolean chunked)

static Writable encodeBase64(byte[] data)

static boolean equals(int[] left, int[] right)

Determines if the contents of this array are equal to the contents of the given list, in the same order.

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

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

static boolean equals(List left, List right)

static boolean every(Object self, Closure closure)

static boolean every(Map self, Closure closure)

Iterates over the entries of a map, and checks whether a predicate is valid for all entries.

static boolean every(Object self)

Iterates over every element of a collection, and checks whether all elements are true according to the Groovy Truth.

static Process execute(String self)

Executes the command specified by the String array given in the first parameter, with the environment defined by envp and under the working directory dir.

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

Executes the command specified by the given list.

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

static Process execute(String[] commandArray)

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

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

Returns the string representation of the given array.

static Process execute(List commands)

Returns the string representation of the given array.

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

Returns the string representation of the given array.

static Process execute(List commands, List envp, File dir)

Returns the string representation of the given array.

static String expand(String self)

static String expand(String self, int tabStop)

static String expandLine(String self, int tabStop)

Tokenize a String based on the given string delimiter.

static void filterLine(Reader reader, Writer writer, Closure closure)

Filter lines from an input stream using a closure predicate.

static Writable filterLine(File self, Closure closure)

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

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

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

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

static Writable filterLine(Reader reader, Closure closure)

static Writable filterLine(InputStream self, Closure predicate)

Passes the Socket's InputStream and OutputStream to the closure.

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

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

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

static Writable filterLine(URL self, Closure predicate)

Overloads the left shift operator to provide an append mechanism to add things to the output stream of a socket

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

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

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

static Object find(Object self, Closure closure)

Finds the first value matching the closure condition

static T find(Collection self, Closure closure)

Finds the first value matching the closure condition.

static def find(Map self, Closure closure)

static String find(String self, String regex)

static String find(String self, Pattern pattern)

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

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

static Collection findAll(Collection self, Closure closure)

static Collection findAll(Object self, Closure closure)

static Map findAll(Map self, Closure closure)

static List findAll(String self, String regex)

Finds all occurrences of a regular expression Pattern within a String.

static List findAll(String self, Pattern pattern)

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

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

static int findIndexOf(Object self, Closure closure)

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

static List findIndexValues(Object self, Closure closure)

Convenience method to dynamically create a new instance of this class.

static List findIndexValues(Object self, Number startIndex, Closure closure)

static int findLastIndexOf(Object self, Closure closure)

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

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

static Object findResult(Object self, Closure closure)

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

static Object findResult(Collection self, Closure closure)

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

static Object findResult(Map self, Closure closure)

static T first(List self)

static T first(T[] self)

static Collection flatten(Collection self)

Flatten an array.

static Collection flatten(Object[] self)

static Collection flatten(boolean[] self)

static Collection flatten(byte[] self)

static Collection flatten(char[] self)

static Collection flatten(short[] self)

static Collection flatten(int[] self)

static Collection flatten(long[] self)

static Collection flatten(float[] self)

Flatten a collection.

static Collection flatten(double[] self)

static Collection flatten(Collection self, Closure flattenUsing)

Overloads the left shift operator to provide an easy way to append objects to a Collection.

static String format(Date self, String format)

static String format(Calendar self, String pattern)

static V get(Map map, K key, V defaultValue)

Support the range subscript operator for an Array

static Object getAt(Object self, String property)

Allows the subscript operator to be used to lookup dynamic property values.

static CharSequence getAt(CharSequence text, int index)

Support the subscript operator for String.

static String getAt(String text, int index)

Support the range subscript operator for CharSequence

static CharSequence getAt(CharSequence text, Range range)

static CharSequence getAt(CharSequence text, IntRange range)

Support the range subscript operator for CharSequence or StringBuffer with IntRange

static CharSequence getAt(CharSequence text, EmptyRange range)

Support the range subscript operator for String with IntRange

static String getAt(String text, IntRange range)

Support the range subscript operator for String with EmptyRange

static String getAt(String text, EmptyRange range)

Support the range subscript operator for String

static String getAt(String text, Range range)

static Object getAt(Matcher matcher, int idx)

static List getAt(List self, Range range)

static List getAt(List self, EmptyRange range)

static List getAt(List self, Collection indices)

Select a List of items from an Object array using a Collection to identify the indices to be selected.

static List getAt(T[] self, Collection indices)

Select a List of characters from a CharSequence using a Collection to identify the indices to be selected.

static CharSequence getAt(CharSequence self, Collection indices)

Select a List of characters from a String using a Collection to identify the indices to be selected.

static String getAt(String self, Collection indices)

Select a List of values from a Matcher using a Collection to identify the indices to be selected.

static List getAt(Matcher self, Collection indices)

Creates a sub-Map containing the given keys.

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

@param array an Array of Objects

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

@param array an Array of Objects

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

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

static T getAt(List self, int idx)

static T getAt(Iterator self, int idx)

static V getAt(Map self, K key)

Support the subscript operator for a Map.

static List getAt(Collection coll, String property)

A convenience method for creating an immutable map.

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

Support the subscript operator with a range for an int array

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

static List getAt(long[] array, Collection indices)

static List getAt(float[] array, Collection indices)

static List getAt(double[] array, Collection indices)

static List getAt(boolean[] array, Collection indices)

static boolean getAt(BitSet self, int index)

static BitSet getAt(BitSet self, IntRange range)

static int getAt(Date self, int field)

static byte[] getBytes(File file)

Write the text to the File.

static byte[] getBytes(URL url)

static byte[] getBytes(InputStream is)

static char[] getChars(String self)

@deprecated use ProcessGroovyMethods#waitForProcessOutput(Process)

static int getCount(Matcher matcher)

Check whether a Matcher contains a group or not.

static String getDateString(Date self)

static String getDateTimeString(Date self)

static InputStream getErr(Process self)

static InputStream getIn(Process self)

@deprecated use ProcessGroovyMethods#withWriter(Process, Closure)

static MetaClass getMetaClass(Class c)

static MetaClass getMetaClass(Object obj)

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

static MetaClass getMetaClass(GroovyObject obj)

static List getMetaPropertyValues(Object self)

Retrieves the list of MetaProperty objects for 'self' and wraps it in a list of PropertyValue objects that additionally provide the value for each property of 'self'.

static OutputStream getOut(Process self)

static Map getProperties(Object self)

Convenience method that calls getMetaPropertyValues(java.lang.Object)(self) and provides the data in form of simple key/value pairs, i.e.

static ClassLoader getRootLoader(ClassLoader self)

Obtains a MetaClass for an object either from the registry or in the case of a GroovyObject from the object itself.

protected static List getSubList(List self, List splice)

static String getText(File file, String charset)

static String getText(File file)

static String getText(URL url)

static String getText(URL url, String charset)

static String getText(InputStream is)

static String getText(InputStream is, String charset)

static String getText(Reader reader)

Synonym for write(text) allowing file.text = 'foo'.

static String getText(BufferedReader reader)

static String getText(Process self)

static String getTimeString(Date self)

static Collection grep(Object self, Object filter)

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

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

Groups the current element according to the value

static Map groupBy(Collection self, Closure closure)

static Map groupBy(Map self, Closure closure)

static Map groupEntriesBy(Map self, Closure closure)

static boolean hasGroup(Matcher matcher)

static MetaProperty hasProperty(Object self, String name)

@deprecated moved to DateGroovyMethods.clearTime

static T head(List self)

Returns the items from the List excluding the first item.

static T head(T[] self)

static Object identity(Object self, Closure closure)

Allows the closure to be called for the object reference self synonym for 'with()'.

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

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

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

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

static String inspect(Object self)

Inspects returns the String that matches what would be typed into a terminal to create this object.

static Number intdiv(Character left, Number right)

static Number intdiv(Number left, Character right)

static Number intdiv(Character left, Character right)

Performs a division modulus operation.

static Number intdiv(Number left, Number right)

Negates the number.

static Collection intersect(Collection left, Collection right)

static Map intersect(Map left, Map right)

Returns 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 isBigDecimal(String self)

static boolean isBigInteger(String self)

static boolean isCase(Object caseValue, Object switchValue)

Method for overloading the behavior of the 'case' method in switch statements.

static boolean isCase(String caseValue, Object switchValue)

'Case' implementation for a String, which uses String#equals(Object) in order to allow Strings to be used in switch statements.

static boolean isCase(GString caseValue, Object switchValue)

'Case' implementation for a GString, which simply calls the equivalet method for String.

static boolean isCase(Class caseValue, Object switchValue)

static boolean isCase(Collection caseValue, Object switchValue)

'Case' implementation for collections which tests if the 'switch' operand is contained in any of the 'case' values.

static boolean isCase(Map caseValue, Object switchValue)

static boolean isCase(Pattern caseValue, Object switchValue)

static boolean isCase(Number caseValue, Number switchValue)

Special 'case' implementation for all numbers, which delegates to the compareTo() method for comparing numbers of different types.

static boolean isDigit(Character self)

static boolean isDouble(String self)

static boolean isFloat(String self)

Determines if a character is a digit.

static boolean isInteger(String self)

static boolean isLetter(Character self)

static boolean isLetterOrDigit(Character self)

static boolean isLong(String self)

Determines if a character is a letter.

static boolean isLowerCase(Character self)

static boolean isNumber(String self)

Transform a Number into an Integer

static boolean isUpperCase(Character self)

Transform a Number into a Long

static boolean isWhitespace(Character self)

static Iterator iterator(T[] a)

Standard iterator for a input stream which iterates through the stream content in a byte-based fashion.

static Iterator iterator(Object o)

static Iterator iterator(Enumeration enumeration)

static Iterator iterator(Matcher matcher)

Just throws a DeprecationException.

static Iterator iterator(Reader self)

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

static Iterator iterator(InputStream self)

@deprecated moved to XmlGroovyMethods.iterator

static Iterator iterator(DataInputStream self)

@deprecated moved to DateGroovyMethods.next

static Iterator iterator(File self)

@deprecated moved to DateGroovyMethods.next

static Iterator iterator(Iterator self)

@deprecated moved to DateGroovyMethods.minus

static Iterator iterator(def nodeList)

@deprecated moved to DateGroovyMethods.clearTime

static String join(Iterator self, String separator)

Concatenates the toString() representation of each item from the iterator, with the given String as a separator between each item.

static String join(Collection self, String separator)

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

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

static T last(List self)

static T last(T[] self)

static Collection leftShift(Collection self, T value)

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

static BlockingQueue leftShift(BlockingQueue self, T value)

static Map leftShift(Map self, def entry)

static Map leftShift(Map self, Map other)

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

static StringBuffer leftShift(String self, Object value)

static StringBuffer leftShift(StringBuffer self, Object value)

Implementation of the right shift operator for integral types.

static Writer leftShift(Writer self, Object value)

Implementation of the right shift (unsigned) operator for integral types.

static Number leftShift(Number self, Number operand)

A helper method so that dynamic dispatch of the writer.write(object) method will always use the more efficient Writable.writeTo(writer) mechanism if the object implements the Writable interface.

static Writer leftShift(OutputStream self, Object value)

static void leftShift(ObjectOutputStream self, Object value)

static OutputStream leftShift(OutputStream self, InputStream in)

Support the subscript operator with a range for a byte array

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

Support the subscript operator with a range for a char array

static File leftShift(File file, Object text)

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

static File leftShift(File file, InputStream data)

static Writer leftShift(Socket self, Object value)

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

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

static Writer leftShift(Process self, Object value)

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

static boolean matches(String self, Pattern pattern)

static def max(Map self, Closure closure)

static T max(Collection self)

Adds max() method to Iterator objects.

static T max(Iterator self)

Adds max() method to Object arrays.

static T max(T[] self)

static T max(Collection self, Closure closure)

static T max(Iterator self, Closure closure)

Selects the maximum value found from the Iterator using the closure to determine the correct ordering.

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

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

static T max(Collection self, Comparator comparator)

static T max(Iterator self, Comparator comparator)

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

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

Provide the standard Groovy size() method for Iterator.

static MetaClass metaClass(Class self, Closure closure)

static MetaClass metaClass(Object self, Closure closure)

Creates an iterator which will traverse through the reader a line at a time.

static T min(Collection self)

Adds min() method to Collection objects.

static T min(Iterator self)

Adds min() method to Object arrays.

static T min(T[] self)

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

static T min(Collection self, Comparator comparator)

static T min(Iterator self, Comparator comparator)

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

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

static T min(Collection self, Closure closure)

static def min(Map self, Closure closure)

Selects an entry in the map having the minimum calculated value as determined by the supplied closure.

static T min(Iterator self, Closure closure)

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

Adds max() method to Collection objects.

static Set minus(Set self, Collection operands)

Create a Set composed of the elements of the first set minus the elements of the given collection.

static Set minus(Set self, Object operand)

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

static T[] minus(T[] self, Collection removeMe)

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

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

static List minus(List self, Collection removeMe)

static List minus(List self, Object operand)

Create a new List composed of the elements of the first list minus every occurrence of the operand.

static T[] minus(T[] self, Object operand)

Flatten a collection.

static Map minus(Map self, Map operands)

Flatten an array.

static String minus(String self, Object target)

Executes the command specified by self as a command-line process.

static Number minus(Character left, Number right)

static Number minus(Number left, Character right)

static Number minus(Character left, Character right)

Power of a BigDecimal to an integer certain exponent.

static Date minus(Date self, int days)

static def minus(def self, int days)

static int minus(Calendar self, Calendar then)

static int minus(Date self, Date then)

static void mixin(MetaClass self, List categoryClasses)

Extend object with category methods.

static void mixin(Class self, List categoryClasses)

Extend class globally with category methods.

static void mixin(Class self, Class categoryClass)

Extend class globally with category methods.

static void mixin(Class self, Class[] categoryClass)

Extend class globally with category methods.

static void mixin(MetaClass self, Class categoryClass)

Extend class globally with category methods.

static void mixin(MetaClass self, Class[] categoryClass)

Extend class globally with category methods.

static Number mod(Number left, Number right)

static List multiply(Collection self, Number factor)

static String multiply(String self, Number factor)

Returns the string representation of the given map.

static Number multiply(Character left, Number right)

static Number multiply(Number left, Character right)

static Number multiply(Character left, Character right)

static Number multiply(BigDecimal left, Double right)

Power of a long to an integer certain exponent.

static Number multiply(BigDecimal left, BigInteger right)

Divide a Character by a Number.

static DataInputStream newDataInputStream(File file)

static DataOutputStream newDataOutputStream(File file)

static BufferedInputStream newInputStream(File file)

Reads the InputStream from this URL, passing each byte to the given closure.

static BufferedInputStream newInputStream(URL url)

static T newInstance(Class c)

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

static T newInstance(Class c, Object[] args)

static ObjectInputStream newObjectInputStream(File file)

static ObjectInputStream newObjectInputStream(InputStream inputStream)

static ObjectInputStream newObjectInputStream(InputStream inputStream, ClassLoader classLoader)

static ObjectInputStream newObjectInputStream(File file, ClassLoader classLoader)

Iterates through this String line by line.

static ObjectOutputStream newObjectOutputStream(File file)

Iterates through the given object stream object by object.

static ObjectOutputStream newObjectOutputStream(OutputStream outputStream)

static BufferedOutputStream newOutputStream(File file)

static PrintWriter newPrintWriter(File file)

static PrintWriter newPrintWriter(File file, String charset)

static PrintWriter newPrintWriter(Writer writer)

static BufferedReader newReader(File file)

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

static BufferedReader newReader(File file, String charset)

Create a buffered writer for this file.

static BufferedReader newReader(InputStream self)

static BufferedReader newReader(InputStream self, String charset)

Helper method to create a buffered writer for a file.

static BufferedReader newReader(URL url)

static BufferedReader newReader(URL url, String charset)

static BufferedWriter newWriter(File file)

Create a new PrintWriter for this file, using specified charset.

static BufferedWriter newWriter(File file, boolean append)

Create a new PrintWriter for this file which is then passed it into the given closure.

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

Create a new PrintWriter with a specified charset for this file.

static BufferedWriter newWriter(File file, String charset)

Create a new PrintWriter with a specified charset for this file.

static String next(String self)

Executes the command specified by the given String array.

static Character next(Character self)

static Number next(Number self)

static Date next(Date self)

static def next(def self)

static String normalize(String self)

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

static int numberAwareCompareTo(Comparable self, Comparable other)

Provides a method that compares two comparables using Groovy's default number aware comparator.

static Number or(Number left, Number right)

static BitSet or(BitSet left, BitSet right)

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

static Boolean or(Boolean left, Boolean right)

Create an object input stream for this file using the given class loader.

static Process or(Process left, Process right)

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

static String padLeft(String self, Number numberOfChars)

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

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

static String padRight(String self, Number numberOfChars)

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

static Set permutations(List self)

static Process pipeTo(Process left, Process right)

static Map plus(Map left, Map right)

A helper method to allow maps to work with subscript operators

static Map plus(Map self, Collection entries)

static Collection plus(Collection left, Collection right)

static Collection plus(Collection left, T right)

static String plus(String left, Object value)

static String plus(Number value, String right)

static String plus(StringBuffer left, String value)

static Number plus(Character left, Number right)

Subtract a Character from a Number.

static Number plus(Number left, Character right)

Subtract one Character from another.

static Number plus(Character left, Character right)

Multiply a Character by a Number.

static Date plus(Date self, int days)

static def plus(def self, int days)

static T pop(List self)

static Number power(Number self, Number exponent)

static Number power(BigDecimal self, Integer exponent)

Divide one Character by another.

static Number power(BigInteger self, Integer exponent)

static Number power(Integer self, Integer exponent)

Integer Divide two Characters.

static Number power(Long self, Integer exponent)

Integer Divide two Numbers.

static String previous(String self)

Executes the command specified by the String array given in the first parameter, with the environment defined by envp and under the working directory dir.

static Character previous(Character self)

Compare two Numbers.

static Number previous(Number self)

static Date previous(Date self)

static def previous(def self)

protected static Object primitiveArrayGet(Object self, int idx)

protected static List primitiveArrayGet(Object self, Range range)

protected static List primitiveArrayGet(Object self, Collection indices)

Convenience method to capitalize the first letter of a string (typically the first letter of a word).

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

Expands all tabs into spaces with tabStops of size 8.

static void print(Object self, Object value)

Print a value formatted Groovy style to self if it is a Writer, otherwise to the standard output stream.

static void print(PrintWriter self, Object value)

Print a value formatted Groovy style to the print writer.

static void print(PrintStream self, Object value)

Print a value formatted Groovy style to the print stream.

static void print(Closure self, Object value)

Print a value to the standard output stream.

static void print(Object self, PrintWriter out)

Print to a console in interactive format.

static void printf(Object self, String format, Object[] values)

Printf to a console (Only works with JDK1.5 or later).

static void printf(Object self, String format, Object arg)

Prints a formatted string using the specified format string and arguments.

static void println(Object self)

Print a linebreak to the standard output stream.

static void println(Closure self)

Print a linebreak to the standard output stream.

static void println(Object self, Object value)

Print a value formatted Groovy style (followed by a newline) to self if it is a Writer, otherwise to the standard output stream.

static void println(PrintWriter self, Object value)

Print a value formatted Groovy style (followed by a newline) to the print writer.

static void println(PrintStream self, Object value)

Print a value formatted Groovy style (followed by a newline) to the print stream.

static void println(Closure self, Object value)

Print a value (followed by a newline) to the standard output stream.

static void println(Object self, PrintWriter out)

Print to a console in interactive format.

static boolean push(List self, T value)

static Map putAll(Map self, Collection entries)

static void putAt(Object self, String property, Object newValue)

Allows the subscript operator to be used to set dynamically named property values.

static void putAt(List self, int idx, T value)

Support the range subscript operator for StringBuffer.

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

Support the range subscript operator for StringBuffer.

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

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

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

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

static void putAt(List self, IntRange range, Collection col)

List subscript assignment operator when given a range as the index.

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

static void putAt(List self, List splice, List values)

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

static V putAt(Map self, K key, V value)

static void putAt(BitSet self, IntRange range, boolean value)

Support assigning a range of values with a single assignment statement.

static void putAt(BitSet self, int index, boolean value)

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

static byte[] readBytes(File file)

static String readLine(Reader self)

static List readLines(String self)

Read the content of this URL and returns it as a String.

static List readLines(File file)

static List readLines(File file, String charset)

static List readLines(InputStream stream)

static List readLines(InputStream stream, String charset)

static List readLines(URL self)

static List readLines(URL self, String charset)

static List readLines(Reader reader)

static boolean removeAll(Collection self, T[] items)

static boolean removeAll(Collection self, Closure closure)

Removes the elements in this collection that are matched according to the specified closure condition.

static boolean renameTo(File self, String newPathName)

Creates a new OutputStream for this file and passes it into the closure.

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

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

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

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

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

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

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

Get a replacement corresponding to the matched pattern for DefaultGroovyMethods.replaceAll.

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

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

@deprecated moved to DateGroovyMethods.minus

static List respondsTo(Object self, String name)

@deprecated moved to DateGroovyMethods.getTimeString

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

static boolean retainAll(Collection self, Closure closure)

static T[] reverse(T[] self)

static String reverse(String self)

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

static List reverse(List self)

Reverses the iterator.

static Iterator reverse(Iterator self)

static Map reverseEach(Map self, Closure closure)

Allows a Map to be iterated through in reverse order using a closure.

static List reverseEach(List self, Closure closure)

Iterate over each element of the list in the reverse order.

static T[] reverseEach(T[] self, Closure closure)

static Number rightShift(Number self, Number operand)

Overloads the leftShift operator to provide an append mechanism to add values to a stream.

static Number rightShiftUnsigned(Number self, Number operand)

Overloads the leftShift operator to add objects to an ObjectOutputStream.

static int round(Float number)

static float round(Float number, int precision)

static long round(Double number)

Determine if a String can be parsed into an Integer.

static double round(Double number, int precision)

static TimerTask runAfter(Timer timer, int delay, Closure closure)

static void setBytes(File file, byte[] bytes)

Append the text at the end of the File.

static void setBytes(OutputStream os, byte[] bytes)

static void setIndex(Matcher matcher, int idx)

static void setMetaClass(Class self, MetaClass metaClass)

static void setMetaClass(Object self, MetaClass metaClass)

Returns an Iterator which traverses each match.

static void setText(File file, String text)

Append the text at the end of the File, using a specified encoding.

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

This method is used to throw useful exceptions when the eachFile* and eachDir closure methods are used incorrectly.

static int size(Iterator self)

static int size(String text)

Provide the standard Groovy size() method for StringBuffer.

static int size(StringBuffer buffer)

Provide the standard Groovy size() method for File.

static long size(File self)

Provide the standard Groovy size() method for Matcher.

static long size(Matcher self)

Provide the standard Groovy size() method for an array.

static int size(Object[] self)

Support the subscript operator for CharSequence.

static int size(boolean[] array)

static int size(byte[] array)

static int size(char[] array)

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

static int size(short[] array)

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

static int size(int[] array)

static int size(long[] array)

static int size(float[] array)

static int size(double[] array)

static List sort(Collection self)

static Map sort(Map self, Closure closure)

static Map sort(Map self, Comparator comparator)

Sorts the given Object array into sorted order.

static Map sort(Map self)

Sorts the given iterator items into a sorted iterator.

static T[] sort(T[] self)

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

static Iterator sort(Iterator self)

Sorts the Collection using the given comparator.

static Iterator sort(Iterator self, Comparator comparator)

Sorts the given Object array into sorted order using the given comparator.

static List sort(Collection self, Comparator comparator)

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

static Iterator sort(Iterator self, Closure closure)

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

static List sort(Collection self, Closure closure)

Avoids doing unnecessary work when sorting an already sorted set.

static SortedSet sort(SortedSet self)

Provides an easy way to append multiple Map.Entry values to a Map.

static Collection split(Object self, Closure closure)

static Collection split(Collection self, Closure closure)

static String[] split(String self)

Replaces sequences of whitespaces with tabs.

static String[] split(GString self)

Remove a part of a String.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Read a single, whole line from the given Reader.

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

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

static Object splitEachLine(InputStream stream, Pattern pattern, Closure closure)

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

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

static SpreadMap spread(Map self)

static String sprintf(Object self, String format, Object[] values)

Sprintf to a string (Only works with JDK1.5 or later).

static String sprintf(Object self, String format, Object arg)

Returns a formatted string using the specified format string and arguments.

static void step(Number self, Number to, Number stepNumber, Closure closure)

Get the absolute value

static String stripIndent(String self)

static String stripIndent(String self, int numChars)

static String stripMargin(String self)

Strip leading whitespace/control characters followed by marginChar from every line in a String.

static String stripMargin(String self, String marginChar)

static String stripMargin(String self, char marginChar)

static Map subMap(Map map, Collection keys)

Looks up an item in a Map for the given key and returns the value - unless there is no entry for the given key in which case add the default value to the map and return that.

static Set subsequences(List self)

static Object sum(Collection self)

Sums the items in an array.

static Object sum(Object[] self)

Sums the items from an Iterator.

static Object sum(Iterator self)

Sums the items in a collection, adding the result to some initial value.

static Object sum(Collection self, Object initialValue)

Sums the items in an array, adding the result to some initial value.

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

Sums the items from an Iterator, adding the result to some initial value.

static Object sum(Iterator self, Object initialValue)

static Object sum(Collection self, Closure closure)

Sums the result of apply a closure to each item of a collection.

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

static Object sum(Iterator self, Closure closure)

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

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

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

static List tail(List self)

static T[] tail(T[] self)

Converts this Collection to a List.

static void times(Number self, Closure closure)

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

static String toArrayString(Object[] self)

static BigDecimal toBigDecimal(String self)

Determine if a Character is uppercase.

static BigDecimal toBigDecimal(Number self)

Create an object output stream for this file.

static BigInteger toBigInteger(String self)

static BigInteger toBigInteger(Number self)

Create an object input stream for this file.

static Boolean toBoolean(String self)

Expands all tabs into spaces.

static Boolean toBoolean(Boolean self)

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

static Character toCharacter(String self)

static Double toDouble(String self)

static Double toDouble(Number self)

static Float toFloat(String self)

static Float toFloat(Number self)

static Integer toInteger(String self)

static Integer toInteger(Number self)

static List toList(Collection self)

static List toList(Iterator self)

static List toList(Enumeration self)

Convert an enumeration to a List.

static List toList(T[] array)

static List toList(byte[] array)

Implements the getAt(int) method for primitve type arrays.

static List toList(boolean[] array)

Implements the getAt(Range) method for primitve type arrays.

static List toList(char[] array)

static List toList(short[] array)

static List toList(int[] array)

Implements the setAt(int idx) method for primitve type arrays.

static List toList(long[] array)

static List toList(float[] array)

static List toList(double[] array)

static List toList(String self)

@deprecated use ProcessGroovyMethods#consumeProcessOutput(Process, OutputStream, OutputStream)

static String toListString(Collection self)

static String toListString(Collection self, int maxSize)

Add a Number and a Character.

static Long toLong(String self)

static Long toLong(Number self)

static char toLowerCase(Character self)

Transform this Number into a BigInteger.

static String toMapString(Map self)

Increment a Number by one.

static String toMapString(Map self, int maxSize)

Decrement a Character by one.

static def toRowResult(def rs)

@deprecated moved to DateGroovyMethods.format

static Short toShort(String self)

Determine if a String can be parsed into a BigInteger.

static SpreadMap toSpreadMap(Map self)

Creates a spreadable map from this array.

static SpreadMap toSpreadMap(Object[] self)

static String toString(boolean[] self)

Returns the string representation of this map.

static String toString(byte[] self)

static String toString(char[] self)

static String toString(short[] self)

static String toString(int[] self)

static String toString(long[] self)

Returns the string representation of this array's contents.

static String toString(float[] self)

Returns the string representation of the given array.

static String toString(double[] self)

Create a String representation of this object.

static String toString(AbstractMap self)

Increment a Character by one.

static String toString(AbstractCollection self)

Decrement a Number by one.

static String toString(Object[] self)

static String toString(Object value)

static URI toURI(String self)

static URL toURL(String self)

Turns a String into a regular expression Pattern

static char toUpperCase(Character self)

static List tokenize(String self, String token)

static List tokenize(String self, Character token)

static List tokenize(String self)

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

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

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

static void transformLine(Reader reader, Writer writer, Closure closure)

static List transpose(List self)

static void traverse(File self, Map options, Closure closure)

Invokes the closure for each descendant file in this directory.

static void traverse(File self, Closure closure)

static void traverse(File self, Map options)

static float trunc(Float number, int precision)

Parse a String into a BigInteger

static float trunc(Float number)

Parse a String into a BigDecimal

static double trunc(Double number)

static double trunc(Double number, int precision)

Determine if a String can be parsed into a Float.

static Number unaryMinus(Number left)

static String unexpand(String self)

Tokenize a String (with a whitespace as the delimiter).

static String unexpand(String self, int tabStop)

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

static String unexpandLine(String self, int tabStop)

Appends a String to the string representation of this number.

static Iterator unique(Iterator self)

static Collection unique(Collection self)

static Iterator unique(Iterator self, Closure closure)

static Collection unique(Collection self, Closure closure)

static Iterator unique(Iterator self, Comparator comparator)

Returns an iterator equivalent to this iterator with all duplicated items removed by using the supplied comparator.

static Collection unique(Collection self, Comparator comparator)

static void upto(Number self, Number to, Closure closure)

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

static void upto(long self, Number to, Closure closure)

static void upto(Long self, Number to, Closure closure)

static void upto(float self, Number to, Closure closure)

static void upto(Float self, Number to, Closure closure)

static void upto(double self, Number to, Closure closure)

static void upto(Double self, Number to, Closure closure)

static void upto(BigInteger self, Number to, Closure closure)

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

static void upto(BigDecimal self, Number to, Closure closure)

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

static Object use(Object self, Class categoryClass, Closure closure)

Scoped use method

static Object use(Object self, List categoryClassList, Closure closure)

Scoped use method with list of categories.

static Object use(Object self, Object[] array)

Allows you to use a list of categories, specifying the list as varargs.

static void waitForOrKill(Process self, long numberOfMillis)

static void waitForProcessOutput(Process self)

static void waitForProcessOutput(Process self, StringBuffer output, StringBuffer error)

static void waitForProcessOutput(Process self, OutputStream output, OutputStream error)

static Object with(Object self, Closure closure)

Allows the closure to be called for the object reference self

Any method invoked inside the closure will first be invoked on the self reference.

static Object withDataInputStream(File file, Closure closure)

Create a new PrintWriter for this file, using specified charset.

static Object withDataOutputStream(File file, Closure closure)

Create a new PrintWriter for this file.

static Map withDefault(Map self, Closure init)

Sorts the given collection into a sorted list.

static Object withInputStream(File file, Closure closure)

static Object withInputStream(URL url, Closure closure)

static Object withObjectInputStream(File file, Closure closure)

Iterates through this file line by line.

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

Iterates through this file line by line.

static Object withObjectInputStream(InputStream inputStream, Closure closure)

Iterates through this stream reading with the provided charset, passing each line to the given 1 or 2 arg closure.

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

Iterates through this stream reading with the provided charset, passing each line to the given 1 or 2 arg closure.

static Object withObjectOutputStream(File file, Closure closure)

static Object withObjectOutputStream(OutputStream outputStream, Closure closure)

static Object withObjectStreams(Socket socket, Closure closure)

Converts the given String into a List of strings of one character.

static Object withOutputStream(File file, Closure closure)

static void withOutputStream(Process self, Closure closure)

static Object withPrintWriter(File file, Closure closure)

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

static Object withPrintWriter(Writer writer, Closure closure)

static Object withReader(File file, Closure closure)

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

static Object withReader(Reader reader, Closure closure)

Creates a buffered input stream for this file.

static Object withReader(URL url, Closure closure)

Create a data input stream for this file

static Object withReader(URL url, String charset, Closure closure)

static Object withReader(InputStream in, Closure closure)

static Object withReader(InputStream in, String charset, Closure closure)

Traverse through each byte of this byte array.

static Object withStream(InputStream stream, Closure closure)

Creates a buffered reader for this URL.

static Object withStream(OutputStream os, Closure closure)

static Object withStreams(Socket socket, Closure closure)

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

static Object withWriter(File file, Closure closure)

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

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

static Object withWriter(Writer writer, Closure closure)

static Object withWriter(OutputStream stream, Closure closure)

Traverse through each byte of the specified stream.

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

static void withWriter(Process self, Closure closure)

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

static Object withWriterAppend(File file, Closure closure)

Helper method to create a new BufferedReader for a URL and then passes it to the closure.

static void write(Writer self, Writable writable)

Pipe an InputStream into an OutputStream for efficient stream copying.

static void write(File file, String text)

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

static void writeLine(BufferedWriter writer, String line)

Append bytes to the end of a File.

static BitSet xor(BitSet left, BitSet right)

static Number xor(Number left, Number right)

static Boolean xor(Boolean left, Boolean right)

Iterates through the given file object by object.

 
Methods inherited from class DefaultGroovyMethodsSupport
cloneSimilarCollection, cloneSimilarMap, closeQuietly, closeWithWarning, 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)


abs

public static float abs(Float number)


abs

public static double abs(Double number)


accept

public static Socket accept(ServerSocket serverSocket, Closure closure)


accept

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


addAll

public static boolean addAll(Collection self, T[] items)
Adds all of the elements in the specified array to this collection. The behavior of this operation is undefined if the specified array is modified while the operation is in progress.
Parameters:
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, T[] 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)
Iterates from this number up to the given number, inclusive, incrementing by one each time.
Parameters:
self - a Number
to - another Number to go up to
closure - the closure to call
Since:
1.0


and

public static Boolean and(Boolean left, Boolean right)
Create an object input stream for this input stream using the given class loader.
throws:
IOException if an IOException occurs.
Parameters:
inputStream - an input stream
classLoader - the class loader to use when loading the class
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)


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)
Coerce a Matcher instance to a boolean value.
Parameters:
matcher - the matcher
Returns:
the boolean value
Since:
1.7.0


asBoolean

public static boolean asBoolean(Boolean bool)


asBoolean

public static boolean asBoolean(Matcher matcher)


asBoolean

public static boolean asBoolean(Collection collection)
Coerce an iterator instance to a boolean value. An iterator is coerced to false if there are no more elements to iterate over, and to true otherwise.
Parameters:
iterator - the iterator
Returns:
the boolean value
Since:
1.7.0


asBoolean

public static boolean asBoolean(Map map)
Coerce an enumeration instance to a boolean value. An enumeration is coerced to false if there are no more elements to enumerate, and to true otherwise.
Parameters:
enumeration - the enumeration
Returns:
the boolean value
Since:
1.7.0


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)
Coerce a number to a boolean value. A number is coerced to false if its double value is equal to 0, and to true otherwise, and to true otherwise.
Parameters:
number - the number
Returns:
the boolean value
Since:
1.7.0


asBoolean

public static boolean asBoolean(Character character)
deprecated:
use SqlGroovyMethods#asBoolean(GroovyResultSet)


asBoolean

public static boolean asBoolean(Number number)


asBoolean

if (col instanceof SortedSet) return col;
public static boolean asBoolean(GroovyResultSet grs)


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)


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

public static Object asType(Collection col, Class clazz)


asType

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

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)
Reverses the list. The result is a new List with the identical contents 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
Since:
1.0


asType

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

public static Object asType(File f, Class c)
deprecated:
use ProcessGroovyMethods#leftShift(Process, byte[])


asType

public static Object asType(GString self, Class c)
deprecated:
use ProcessGroovyMethods#waitForProcessOutput(Process, OutputStream, OutputStream)


asType

public static Object asType(String self, Class c)
deprecated:
use ProcessGroovyMethods#consumeProcessErrorStream(Process, Appendable)


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)
deprecated:
use ProcessGroovyMethods#getOut(Process)


asWritable

public static File asWritable(File file, String encoding)
deprecated:
use ProcessGroovyMethods#consumeProcessOutput(Process)


bitwiseNegate

public static Pattern bitwiseNegate(String 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, def entry)


callClosureForMapEntryAndCounter

protected static Object callClosureForMapEntryAndCounter(Closure closure, def entry, int counter)


capitalize

public static String capitalize(String self)


center

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


center

public static String center(String self, Number numberOfChars)


clearTime

public static void clearTime(Date self)


clearTime

public static void clearTime(def self)


clearTime

public static void clearTime(Calendar self)


collect

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


collect

public static Collection collect(Object self, Collection collection, Closure closure)


collect

public static List collect(Collection self, Closure closure)


collect

public static Collection collect(Collection self, Collection collection, Closure closure)


collect

public static Collection collect(Map self, Collection collection, Closure closure)
Iterates through this Map transforming each entry into a new value using the closure as a transformer, returning a list of transformed values.
assert [a:1, b:2].collect( [] as HashSet ) { key, value -> key*value } == ["a", "bb"] as Set
 assert [3:20, 2:30].collect( [] as HashSet ) { entry -> entry.key * entry.value } == [60] as Set
Parameters:
self - a Map
collection - the Collection to which the mapped values are added
closure - the closure used for mapping, which can take one (Map.Entry) or two (key, value) parameters
Returns:
a List of the mapped values
Since:
1.0


collect

public static List collect(Map self, Closure closure)


collectAll

public static List collectAll(Collection self, Closure closure)
Recursively iterates through this collection transforming each non-Collection value into a new value using the closure as a transformer. Returns a potentially nested list of transformed values.
assert [2,[4,6],[8],[]] == [1,[2,3],[4],[]].collectAll { it * 2 }
Parameters:
self - a collection
closure - the closure used to transform each element of the collection
Returns:
the resultant collection
Since:
1.5.2


collectAll

public static Collection collectAll(Collection self, Collection collection, Closure closure)


collectEntries

public static Map collectEntries(Map self, Map result, Closure closure)


collectEntries

public static Map collectEntries(Map self, Closure closure)


collectEntries

public static Map collectEntries(Collection self, Map result, Closure closure)


collectEntries

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


collectEntries

public static Map collectEntries(Collection self, Closure closure)


collectEntries

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


combinations

public static List combinations(Collection self)
Adds GroovyCollections#combinations(Collection) as a method on collections.
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)


consumeProcessErrorStream

Object value = iter.next();
public static Thread consumeProcessErrorStream(Process self, OutputStream err)


consumeProcessErrorStream

return result;
public static Thread consumeProcessErrorStream(Process self, StringBuffer error)


consumeProcessErrorStream

* @param closure the filter to perform a match on the collection
public static Thread consumeProcessErrorStream(Process self, Writer err)


consumeProcessOutput

* @param closure    the filter to perform a match on the collection
public static void consumeProcessOutput(Process self)


consumeProcessOutput

Object value = iter.next();
public static void consumeProcessOutput(Process self, StringBuffer output, StringBuffer error)


consumeProcessOutput

}
public static void consumeProcessOutput(Process self, OutputStream output, OutputStream error)


consumeProcessOutputStream

/**
public static Thread consumeProcessOutputStream(Process self, StringBuffer output)


consumeProcessOutputStream

* @return a list of numbers corresponding to the index values of all matched objects
public static Thread consumeProcessOutputStream(Process self, Writer output)


consumeProcessOutputStream

Object value = iter.next();
public static Thread consumeProcessOutputStream(Process self, OutputStream output)


contains

public static boolean contains(String self, String text)
Executes the command specified by self with environment defined by envp and under the working directory dir.

For more control over Process construction you can use java.lang.ProcessBuilder (JDK 1.5+).

throws:
IOException if an IOException occurs.
Parameters:
self - a command line String to be executed.
envp - an array of Strings, each element of which has environment variable settings in the format name=value, or null if the subprocess should inherit the environment of the current process.
dir - the working directory of the subprocess, or null if the subprocess should inherit the working directory of the current process.
Returns:
the Process which has just started for this command line representation.
Since:
1.0


containsAll

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


count

public static Number count(Iterator self, Object value)
Counts the number of occurrences of the given value from the items within this Iterator. Comparison is done using Groovy's == operator (using compareTo(value) == 0 or equals(value) ). The iterator will become exhausted of elements after determining the count value.
Parameters:
self - the Iterator from which we count the number of matching occurrences
value - the value being searched for
Returns:
the number of occurrences
Since:
1.5.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) ).
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(Object[] self, Object value)


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)


createStringBufferWriter

protected static StringBufferWriter createStringBufferWriter(StringBuffer self)


createStringWriter

protected static StringWriter createStringWriter(String self)


decodeBase64

public static byte[] decodeBase64(String value)


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)


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 operand array.
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 Numbers.
Parameters:
left - a Number
right - another Number to bitwise AND
Returns:
the bitwise AND of both Numbers
Since:
1.0


div

public static Number div(Number left, Character right)


div

public static Number div(Character left, Character right)


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)


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


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 T each(T 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)
Transforms the lines from a reader with a Closure and write them to a writer. Both Reader and Writer are closed after the operation.
throws:
IOException if an IOException occurs.
Parameters:
reader - Lines of text to be transformed. Reader is closed afterwards.
writer - Where transformed lines are written. Writer is closed afterwards.
closure - Single parameter closure that is called to transform each line of text from the reader, before writing it to the writer.
Since:
1.0


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)
Filter the lines from a reader and write them on the writer, according to a closure which returns true if the line should be included. Both Reader and Writer are closed after the operation.
throws:
IOException if an IOException occurs.
Parameters:
reader - a reader, closed after the call
writer - a writer, closed after the call
closure - the closure which returns booleans
Since:
1.0


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 Writeable 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)
Filters the lines of a File and creates a Writeable in return to stream the filtered lines.
throws:
IOException if an IOException occurs
Parameters:
self - a File
charset - opens the file with a specified charset
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.6.8


eachByte

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


eachDir

public static void eachDir(File self, Closure closure)
Invokes the closure for each descendant file in this directory tree. Sub-directories are recursively traversed in a depth-first fashion. Convenience method for traverse(java.io.File, java.util.Map, groovy.lang.Closure) when no options to alter the traversal behavior are required.
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 - the Closure to invoke on each file/directory and optionally returning a FileVisitResult value which can be used to control subsequent processing
See Also:
traverse(java.io.File, java.util.Map, groovy.lang.Closure)
Since:
1.7.1


eachDirMatch

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


eachDirRecurse

public static void eachDirRecurse(File self, Closure closure)


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)
Creates a reader for this input stream, using the specified charset as the encoding.
throws:
UnsupportedEncodingException if the encoding specified is not supported
Parameters:
self - an input stream
charset - the charset for this input stream
Returns:
a reader
Since:
1.6.0


eachFileRecurse

public static void eachFileRecurse(File self, FileType fileType, Closure closure)
Invokes the closure specified with key 'visit' in the options Map for each descendant file in this directory tree. Convenience method for traverse(java.io.File, java.util.Map, groovy.lang.Closure) allowing the 'visit' closure to be included in the options Map rather than as a parameter.
throws:
FileNotFoundException if the given directory does not exist
throws:
IllegalArgumentException if the provided File object does not represent a directory or illegal filter combinations are supplied
Parameters:
self - a File
options - a Map of options to alter the traversal behavior
See Also:
traverse(java.io.File, java.util.Map, groovy.lang.Closure)
Since:
1.7.1


eachFileRecurse

public static void eachFileRecurse(File self, Closure closure)
Deletes a directory with all contained files and subdirectories.

The method returns

Parameters:
self - a File
Returns:
true if the file doesn't exist or deletion was successful
Since:
1.6.0


eachLine

public static Object eachLine(String self, Closure closure)
Iterates through this stream, passing each line to the given 1 or 2 arg closure. The stream is closed before this method returns.
throws:
IOException if an IOException occurs.
Parameters:
stream - a stream
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.InputStream, int, groovy.lang.Closure)
Since:
1.5.6


eachLine

public static Object eachLine(String self, int firstLine, Closure closure)
Iterates through this stream, passing each line to the given 1 or 2 arg closure. The stream is closed before this method returns.
throws:
IOException if an IOException occurs.
Parameters:
stream - a stream
firstLine - the line number value used for the first line (default is 1, set to 0 to start counting from 0)
closure - a closure (arg 1 is line, optional arg 2 is line number)
Returns:
the last value returned by the closure
See Also:
eachLine(java.io.Reader, int, groovy.lang.Closure)
Since:
1.5.7


eachLine

public static Object eachLine(File self, Closure closure)
Iterates through the lines read from the URL's associated input stream passing each line to the given 1 or 2 arg closure. The stream is closed before this method returns.
throws:
IOException if an IOException occurs.
Parameters:
url - a URL to open and read
closure - a closure to apply on each line (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.net.URL, int, groovy.lang.Closure)
Since:
1.5.6


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)


eachLine

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


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)
Iterates through this file 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 file are closed.
throws:
IOException if an IOException occurs.
Parameters:
self - a File
pattern - the regular expression Pattern for the delimiter
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.util.regex.Pattern, groovy.lang.Closure)
Since:
1.6.8


eachLine

public static Object eachLine(Reader self, Closure closure)


eachLine

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


eachMatch

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


eachMatch

public static String eachMatch(String 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


encodeBase64

@Deprecated
public static Writable encodeBase64(Byte[] data, boolean chunked)
deprecated:
moved to DateGroovyMethods.getAt


encodeBase64

public static Writable encodeBase64(Byte[] data)


encodeBase64

public static Writable encodeBase64(byte[] data, boolean chunked)


encodeBase64

public static Writable encodeBase64(byte[] data)


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


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)
Executes the command specified by the String array given in the first parameter, with the environment defined by envp and under the working directory dir. The first item in the array is the command; the others are the parameters.

For more control over Process construction you can use java.lang.ProcessBuilder (JDK 1.5+).

throws:
IOException if an IOException occurs.
Parameters:
commandArray - an array of String containing the command name and parameters as separate items in the array.
envp - a List of Objects (converted to Strings using toString), each member of which has environment variable settings in the format name=value, or null if the subprocess should inherit the environment of the current process.
dir - the working directory of the subprocess, or null if the subprocess should inherit the working directory of the current process.
Returns:
the Process which has just started for this command line representation.
Since:
1.7.1


execute

public static Process execute(String self, String[] envp, File dir)
Executes the command specified by the given list. The toString() method is called for each item in the list to convert into a resulting String. The first item in the list 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:
commands - a list containing the command name and parameters as separate items in the list.
Returns:
the Process which has just started for this command line representation.
Since:
1.0


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)


execute

public static Process execute(String[] commandArray, List 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)
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)


expand

public static String expand(String self, int tabStop)


expandLine

public static String expandLine(String self, int tabStop)
Tokenize a String based on the given string delimiter.
Parameters:
self - a String
token - the delimiter
Returns:
a List of tokens
See Also:
StringTokenizer.StringTokenizer
Since:
1.0


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)


filterLine

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


filterLine

public static Writable filterLine(Reader reader, Closure closure)


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)
Overloads the left shift operator to provide an append mechanism to add things to the output stream of a socket
throws:
IOException if an IOException occurs.
Parameters:
self - a Socket
value - a value to append
Returns:
a Writer
Since:
1.0


filterLine

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


filterLine

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


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
Since:
1.0


find

public static T find(Collection self, Closure closure)
Finds the first value matching the closure condition. Example:
def list = [1,2,3]
 assert 2 == list.find { it > 1 }
 
Parameters:
self - a Collection
closure - a closure condition
Returns:
the first Object found
Since:
1.0


find

public static def find(Map self, Closure closure)


find

public static String find(String self, String regex)


find

public static String find(String self, Pattern pattern)


find

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


find

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


findAll

public static Collection findAll(Collection self, Closure closure)


findAll

public static Collection findAll(Object self, Closure closure)


findAll

public static Map findAll(Map self, Closure closure)


findAll

public static List findAll(String self, String regex)
Finds all occurrences of a regular expression Pattern within a String. A List is returned containing all full matches or an empty list if there are no matches within the string.

For example, if the pattern doesn't match, it returns an empty list:

 assert [] == "foo".findAll(~/(\w*) Fish/)
 

Any regular expression matches are returned in a list, and all regex capture groupings are ignored, only the full match is returned:

 def expected = ["One Fish", "Two Fish", "Red Fish", "Blue Fish"]
 assert expected == "One Fish, Two Fish, Red Fish, Blue Fish".findAll(~/(\w*) Fish/)
 
Parameters:
self - a String
pattern - the compiled regex Pattern
Returns:
a List containing all full matches of the Pattern within the string, an empty list will be returned if there are no matches
Since:
1.6.1


findAll

public static List findAll(String self, Pattern pattern)


findAll

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


findAll

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


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)


first

public static T first(List self)


first

public static T first(T[] self)


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 boolean Array to flatten
Returns:
a flattened Collection
Since:
1.6.0


flatten

public static Collection flatten(Object[] self)


flatten

public static Collection flatten(boolean[] self)


flatten

public static Collection flatten(byte[] self)


flatten

public static Collection flatten(char[] self)


flatten

public static Collection flatten(short[] self)


flatten

public static Collection flatten(int[] self)


flatten

public static Collection flatten(long[] self)


flatten

public static Collection flatten(float[] self)
Flatten a collection. This collection and any nested arrays or collections have their contents (recursively) added to the new collection. For any non-Array, non-Collection object which represents some sort of collective type, the supplied closure should yield the contained items; otherwise, the closure should just return any element which corresponds to a leaf.
Parameters:
self - a Collection
flattenUsing - a closure to determine how to flatten non-Array, non-Collection elements
Returns:
a flattened Collection
Since:
1.6.0


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


format

public static String format(Date self, String format)


format

public static String format(Calendar self, String pattern)


get

public static V get(Map map, K key, V 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)
Support the subscript operator for String.
Parameters:
text - a String
index - the index of the Character to get
Returns:
the Character at the given index
Since:
1.0


getAt

public static String getAt(String text, int index)
Support the range subscript operator for CharSequence
Parameters:
text - a CharSequence
range - a Range
Returns:
the subsequence CharSequence
Since:
1.0


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 IntRange
Parameters:
text - a CharSequence
range - an IntRange
Returns:
the subsequence CharSequence
Since:
1.0


getAt

public static CharSequence getAt(CharSequence text, EmptyRange range)
Support the range subscript operator for String with IntRange
Parameters:
text - a String
range - an IntRange
Returns:
the resulting String
Since:
1.0


getAt

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


getAt

public static String getAt(String text, EmptyRange range)
Support the range subscript operator for String
Parameters:
text - a String
range - a Range
Returns:
a substring corresponding to the Range
Since:
1.0


getAt

public static String getAt(String text, Range range)


getAt

public static Object getAt(Matcher matcher, int idx)


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)
Select a List of items from an Object array using a Collection to identify the indices to be selected.
Parameters:
self - an Array of Objects
indices - a Collection of indices
Returns:
a new list of the values at the given indices
Since:
1.0


getAt

public static List getAt(T[] self, Collection indices)
Select a List of characters from a CharSequence using a Collection to identify the indices to be selected.
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)
Select a List of values from a Matcher using a Collection to identify the indices to be selected.
Parameters:
self - a Matcher
indices - a Collection of indices
Returns:
a String of the values at the given indices
Since:
1.6.0


getAt

public static List getAt(Matcher self, Collection indices)
Creates a sub-Map containing the given keys. This method is similar to List.subList() but uses keys rather than index ranges.
assert [1:10, 2:20, 4:40].subMap( [2, 4] ) == [2:20, 4:40]
Parameters:
map - a Map
keys - a Collection of keys
Returns:
a new Map containing the given keys
Since:
1.0


getAt

public static List getAt(T[] array, Range range)
Parameters:
array - an Array of Objects
range - an EmptyRange
Returns:
an empty Range
Since:
1.5.0


getAt

public static List getAt(T[] 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(T[] array, EmptyRange range)


getAt

public static List getAt(T[] array, ObjectRange range)


getAt

public static T getAt(List self, int idx)


getAt

public static T getAt(Iterator self, int idx)


getAt

public static V getAt(Map self, K key)
Support the subscript operator for a Map.
def map = [a:10]
 assert map["a"] == 10
Parameters:
self - a Map
key - an Object as a key for the map
Returns:
the value corresponding to the given key
Since:
1.0


getAt

public static List getAt(Collection coll, String property)
A convenience method for creating an immutable map.
Parameters:
self - a Map
Returns:
an immutable Map
See Also:
Collections.unmodifiableMap
Since:
1.0


getAt

* Support the subscript operator with a range for a long array
public static List getAt(byte[] array, Range range)
Support the subscript operator with a range for an int array
Parameters:
array - an int array
range - a range indicating the indices for the items to retrieve
Returns:
list of the ints at the given indices
Since:
1.0


getAt

* Support the subscript operator with a range for a float array
public static List getAt(char[] array, Range range)


getAt

* Support the subscript operator with a range for a double array
public static List getAt(short[] array, Range range)


getAt

* Support the subscript operator with a range for a boolean array
public static List getAt(int[] array, Range range)


getAt

* Support the subscript operator with an IntRange for a byte array
public static List getAt(long[] array, Range range)


getAt

* Support the subscript operator with an IntRange for a char array
public static List getAt(float[] array, Range range)


getAt

* Support the subscript operator with an IntRange for a short array
public static List getAt(double[] array, Range range)


getAt

* Support the subscript operator with an IntRange for an int array
public static List getAt(boolean[] array, Range range)


getAt

* Support the subscript operator with an IntRange for a long array
public static List getAt(byte[] array, IntRange range)


getAt

* Support the subscript operator with an IntRange for a float array
public static List getAt(char[] array, IntRange range)


getAt

* Support the subscript operator with an IntRange for a double array
public static List getAt(short[] array, IntRange range)


getAt

* Support the subscript operator with an IntRange for a boolean array
public static List getAt(int[] array, IntRange range)


getAt

* Support the subscript operator with an ObjectRange for a byte array
public static List getAt(long[] array, IntRange range)


getAt

* Support the subscript operator with an ObjectRange for a char array
public static List getAt(float[] array, IntRange range)


getAt

* Support the subscript operator with an ObjectRange for a short array
public static List getAt(double[] array, IntRange range)


getAt

* Support the subscript operator with an ObjectRange for an int array
public static List getAt(boolean[] array, IntRange range)


getAt

* Support the subscript operator with an ObjectRange for a long array
public static List getAt(byte[] array, ObjectRange range)


getAt

* Support the subscript operator with an ObjectRange for a float array
public static List getAt(char[] array, ObjectRange range)


getAt

* Support the subscript operator with an ObjectRange for a double array
public static List getAt(short[] array, ObjectRange range)


getAt

* Support the subscript operator with an ObjectRange for a byte array
public static List getAt(int[] array, ObjectRange range)


getAt

* Support the subscript operator with a collection for a byte array
public static List getAt(long[] array, ObjectRange range)


getAt

* Support the subscript operator with a collection for a char array
public static List getAt(float[] array, ObjectRange range)


getAt

* Support the subscript operator with a collection for a short array
public static List getAt(double[] array, ObjectRange range)


getAt

* Support the subscript operator with a collection for an int array
public static List getAt(boolean[] array, ObjectRange range)


getAt

* Support the subscript operator with a collection for a long array
public static List getAt(byte[] array, Collection indices)


getAt

* Support the subscript operator with a collection for a float array
public static List getAt(char[] array, Collection indices)


getAt

* Support the subscript operator with a collection for a double array
public static List getAt(short[] array, Collection indices)


getAt

* Support the subscript operator with a collection for a boolean array
public static List getAt(int[] array, Collection indices)


getAt

* Support the subscript operator for a Bitset
public static List getAt(long[] array, Collection indices)


getAt

* Support retrieving a subset of a BitSet using a Range
public static List getAt(float[] array, Collection indices)


getAt

BitSet result = new BitSet();
public static List getAt(double[] array, Collection indices)


getAt

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


getAt

public static int getAt(Date self, int field)


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)


getChars

public static char[] getChars(String self)
deprecated:
use ProcessGroovyMethods#waitForProcessOutput(Process)


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


getDateString

public static String getDateString(Date self)


getDateTimeString

public static String getDateTimeString(Date self)


getErr

}
public static InputStream getErr(Process self)


getIn

}
public static InputStream getIn(Process self)
deprecated:
use ProcessGroovyMethods#withWriter(Process, Closure)


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)


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


getOut

* @param self    the source string
public static OutputStream getOut(Process self)


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)


getText

public static String getText(File file)


getText

public static String getText(URL url)


getText

public static String getText(URL url, String charset)


getText

public static String getText(InputStream is)


getText

public static String getText(InputStream is, String charset)


getText

public static String getText(Reader reader)
Synonym for write(text) allowing file.text = 'foo'.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
text - the text to write to the File
See Also:
write(java.io.File, java.lang.String)
Since:
1.5.1


getText

public static String getText(BufferedReader reader)


getText

* @param self    the source string
public static String getText(Process self)


getTimeString

public static String getTimeString(Date self)


grep

public static Collection grep(Object self, Object filter)
Iterates over every element of the collection and returns each item that matches the given filter - calling the isCase(java.lang.Object, java.lang.Object) method used by switch statements. This method can be used with different kinds of filters like regular expressions, classes, ranges etc. Example:
def list = ['a', 'b', 'aa', 'bc' ]
 def filtered = list.grep( ~/a+/ ) //contains 'a' and 'aa'
 
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


groupAnswer

protected static void groupAnswer(Map answer, T element, Object value)
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


groupBy

public static Map groupBy(Collection self, Closure closure)


groupBy

public static Map groupBy(Map self, Closure closure)


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)
deprecated:
moved to DateGroovyMethods.clearTime


head

public static T 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 T head(T[] 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


inject

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


inject

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


inject

public static Object inject(Object self, Object value, Closure closure)


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)


intdiv

public static Number intdiv(Number left, Character right)


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)
Negates the number. Equivalent to the '-' operator when it preceeds a single operand, i.e. -10
Parameters:
left - a Number
Returns:
the negation of the number
Since:
1.5.0


intersect

public static Collection intersect(Collection left, Collection right)


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)


isBigDecimal

public static boolean isBigDecimal(String self)


isBigInteger

public static boolean isBigInteger(String 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(GString caseValue, Object switchValue)
'Case' implementation for a GString, which simply calls the equivalet method for String.
Parameters:
caseValue - the case value
switchValue - the switch value
Returns:
true if the switchValue's toString() equals the caseValue
Since:
1.6.0


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)


isDouble

public static boolean isDouble(String self)


isFloat

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


isInteger

public static boolean isInteger(String self)


isLetter

public static boolean isLetter(Character self)


isLetterOrDigit

public static boolean isLetterOrDigit(Character self)


isLong

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


isLowerCase

public static boolean isLowerCase(Character self)


isNumber

public static boolean isNumber(String self)
Transform a Number into an Integer
Parameters:
self - a Number
Returns:
an Integer
Since:
1.0


isUpperCase

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


isWhitespace

public static boolean isWhitespace(Character self)


iterator

public static Iterator iterator(T[] 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)
Just throws a DeprecationException. DO NOT USE. It used to provide an iterator for text file content one line at a time.
throws:
IOException if there is a problem processing the file (e.g. file is not found)
deprecated:
use File#eachLine instead please
Parameters:
self - a file object
Returns:
a line-based iterator
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 and arguments types.

Note that this method's return value is based on realised methods and does not take into account objects or classes that implement invokeMethod or methodMissing

This method is "safe" in that it will always return a value and never throw an exception

Parameters:
self - The object to inspect
name - The name of the method of interest
argTypes - The argument types to match against
Returns:
A List of MetaMethods matching the argument types which will be empty if no matching methods exist
See Also:
MetaObjectProtocol.respondsTo
Since:
1.6.0


iterator

public static Iterator iterator(InputStream self)
deprecated:
moved to XmlGroovyMethods.iterator


iterator

public static Iterator iterator(DataInputStream self)
deprecated:
moved to DateGroovyMethods.next


iterator

public static Iterator iterator(File self)
deprecated:
moved to DateGroovyMethods.next


iterator

public static Iterator iterator(Iterator self)
deprecated:
moved to DateGroovyMethods.minus


iterator

@Deprecated
public static Iterator iterator(def nodeList)
deprecated:
moved to DateGroovyMethods.clearTime


join

public static String join(Iterator self, String separator)
Concatenates the toString() representation of each item from the iterator, with the given String as a separator between each item. The iterator will become exhausted of elements after determining the resulting conjoined value.
Parameters:
self - an Iterator of items
separator - a String separator
Returns:
the joined String
Since:
1.5.5


join

public static String join(Collection self, String separator)


join

public static String join(Object[] self, String separator)
Concatenates the toString() representation of each items in this array, with the given String as a separator between each item.
Parameters:
self - an array of Object
separator - a String separator
Returns:
the joined String
Since:
1.0


last

public static T last(List self)


last

public static T last(T[] self)


leftShift

public static Collection leftShift(Collection self, T value)
Overloads the left shift operator to provide an easy way to append Map.Entry values to a Map.
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, T value)


leftShift

public static Map leftShift(Map self, def entry)


leftShift

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


leftShift

public static StringBuffer leftShift(String self, Object value)


leftShift

public static StringBuffer leftShift(StringBuffer self, Object value)
Implementation of the right shift operator for integral types. Non integral Number types throw UnsupportedOperationException.
Parameters:
self - a Number object
operand - the shift distance by which to right shift the number
Returns:
the resulting number
Since:
1.5.0


leftShift

public static Writer leftShift(Writer self, Object value)
Implementation of the right shift (unsigned) operator for integral types. Non integral Number types throw UnsupportedOperationException.
Parameters:
self - a Number object
operand - the shift distance by which to right shift (unsigned) the number
Returns:
the resulting number
Since:
1.5.0


leftShift

public static Number leftShift(Number self, Number operand)
A helper method so that dynamic dispatch of the writer.write(object) method will always use the more efficient Writable.writeTo(writer) mechanism if the object implements the Writable interface.
throws:
IOException if an I/O error occurs.
Parameters:
self - a Writer
writable - an object implementing the Writable interface
Since:
1.0


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)
Support the subscript operator with a range for a byte array
Parameters:
array - a byte array
range - a range indicating the indices for the items to retrieve
Returns:
list of the retrieved bytes
Since:
1.0


leftShift

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


leftShift

public static File leftShift(File file, Object text)


leftShift

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


leftShift

public static File leftShift(File file, InputStream data)


leftShift

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


leftShift

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


leftShift

each(m, closure);
public static Writer leftShift(Process self, Object value)


leftShift

* @param self    the iteration object over which to iterate
public static OutputStream leftShift(Process self, byte[] value)


matches

public static boolean matches(String self, Pattern pattern)


max

public static def max(Map self, Closure closure)


max

public static T max(Collection self)
Adds max() method to Iterator objects. The iterator will become exhausted of elements after determining the maximum value.
Parameters:
self - an Iterator
Returns:
the maximum value
See Also:
GroovyCollections.max
Since:
1.5.5


max

public static T max(Iterator self)
Adds max() method to Object arrays.
Parameters:
self - an Object array
Returns:
the maximum value
See Also:
max(java.util.Collection)
Since:
1.5.5


max

public static T max(T[] self)


max

public static T max(Collection self, Closure closure)


max

public static T max(Iterator self, Closure closure)
Selects the maximum value found from the Iterator using the closure to determine the correct ordering. The iterator will become exhausted of elements after this operation.

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.
Parameters:
self - an Iterator
closure - a Closure used to determine the correct ordering
Returns:
the maximum value
See Also:
max(java.util.Collection, groovy.lang.Closure)
Since:
1.5.5


max

public static T max(T[] 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 T max(Collection self, Comparator comparator)


max

public static T 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 T max(T[] self, Comparator comparator)
Provide the standard Groovy size() method for Iterator. The iterator will become exhausted of elements after determining the size value.
Parameters:
self - an Iterator
Returns:
the length of the Iterator
Since:
1.5.5


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 T min(Collection self)
Adds min() method to Collection objects.
assert 2 == [4,2,5].min()
Parameters:
self - a Collection
Returns:
the minimum value
See Also:
GroovyCollections.min
Since:
1.0


min

public static T min(Iterator self)
Adds min() method to Object arrays.
Parameters:
self - an Object array
Returns:
the minimum value
See Also:
min(java.util.Collection)
Since:
1.5.5


min

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


min

public static T min(Collection self, Comparator comparator)


min

public static T 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 T min(T[] self, Comparator comparator)


min

public static T min(Collection self, Closure closure)


min

public static def min(Map self, Closure closure)
Selects an entry in the map having the minimum calculated value as determined by the supplied closure. If more than one entry has the minimum value, an arbitrary choice is made between the entries having the minimum value.

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.
 def zoo = [monkeys:6, lions:5, tigers:7]
 def leastCommonEntry = zoo.min{ it.value }
 assert leastCommonEntry.value == 5
 def mostCommonEntry = zoo.min{ a, b -> b.value <=> a.value } // double negative!
 assert mostCommonEntry.value == 7
 
Edge case for multiple min values:
 def zoo = [monkeys:6, lions:5, tigers:7]
 def lastCharOfName = { e -> e.key[-1] }
 def ans = zoo.min(lastCharOfName) // some random entry
 assert lastCharOfName(ans) == 's'
 
Parameters:
self - a Map
closure - a 1 or 2 arg Closure used to determine the correct ordering
Returns:
the Map.Entry having the minimum value as determined by the closure
Since:
1.7.6


min

public static T min(Iterator self, Closure closure)


min

public static T min(T[] 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 operands)
Create a Set composed of the elements of the first set minus the elements of the given collection.

TODO: remove using number comparator?

Parameters:
self - a set object
operands - the items to remove from the set
Returns:
the resulting set
Since:
1.5.0


minus

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


minus

public static T[] minus(T[] self, Collection removeMe)
Create a List composed of the elements of the first list minus every occurrence of elements of the given collection.
assert [1, "a", true, true, false, 5.3] - [true, 5.3] == [1, "a", false]
Parameters:
self - a List
removeMe - a Collection of elements to remove
Returns:
a List with the supplied elements removed
Since:
1.0


minus

if (Number.class.isInstance(t)) {
public static T[] minus(T[] self, T[] removeMe)


minus

public static List minus(List self, Collection removeMe)


minus

public static List minus(List self, Object operand)
Create a new List composed of the elements of the first list minus every occurrence of the operand.
assert ["a", 5, 5, true] - 5 == ["a", true]
Parameters:
self - a List object
operand - an element to remove from the list
Returns:
the resulting List with the operand removed
Since:
1.0


minus

public static T[] minus(T[] self, Object operand)
Flatten a collection. This collection and any nested arrays or collections have their contents (recursively) added to the new collection.
assert [1,2,3,4,5] == [1,[2,3],[[4]],[],5].flatten()
Parameters:
self - a Collection to flatten
Returns:
a flattened Collection
Since:
1.6.0


minus

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


minus

public static String minus(String self, Object target)
Executes the command specified by self as a command-line process.

For more control over Process construction you can use java.lang.ProcessBuilder (JDK 1.5+).

throws:
IOException if an IOException occurs.
Parameters:
self - a command line String
Returns:
the Process which has just started for this command line representation
Since:
1.0


minus

public static Number minus(Character left, Number right)


minus

public static Number minus(Number left, Character right)


minus

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


minus

public static Date minus(Date self, int days)


minus

public static def minus(def self, int days)


minus

public static int minus(Calendar self, Calendar then)


minus

public static int minus(Date self, Date then)


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 map.
Parameters:
self - a Map
Returns:
the string representation
See Also:
toMapString(java.util.Map)
Since:
1.0


multiply

public static Number multiply(Character left, Number right)


multiply

public static Number multiply(Number left, Character right)


multiply

public static Number multiply(Character left, Character right)


multiply

public static Number multiply(BigDecimal left, Double right)
Power of a long 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 - a Long
exponent - an Integer exponent
Returns:
a Number to the power of a the exponent


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)
Reads the InputStream from this URL, passing each byte 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
closure - closure to apply to each byte
See Also:
eachByte(java.io.InputStream, groovy.lang.Closure)
Since:
1.0


newInputStream

public static BufferedInputStream newInputStream(URL url)


newInstance

public static T newInstance(Class c)
Sets/updates the metaclass for a given object to a closure.
throws:
GroovyRuntimeException if the metaclass can't be set for this object
Parameters:
self - the object 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 T 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)
Iterates through this String line by line. Each line is passed to the given 1 or 2 arg closure. If a 2 arg closure is found the line count is passed as the second argument.
throws:
java.io.IOException if an error occurs
Parameters:
self - a String
firstLine - the line number value used for the first line (default is 1, set to 0 to start counting from 0)
closure - a closure (arg 1 is line, optional arg 2 is line number)
Returns:
the last value returned by the closure
Since:
1.5.7


newObjectOutputStream

public static ObjectOutputStream newObjectOutputStream(File file)
Iterates through the given object stream object by object. The ObjectInputStream is closed afterwards.
throws:
IOException if an IOException occurs.
throws:
ClassNotFoundException if the class is not found.
Parameters:
ois - an ObjectInputStream, closed after the operation
closure - a closure
Since:
1.0


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)


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)
Create a buffered writer for this file.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
Returns:
a BufferedWriter
Since:
1.0


newReader

public static BufferedReader newReader(InputStream self)


newReader

public static BufferedReader newReader(InputStream self, String charset)
Helper method to create a buffered writer for a file. If the given charset is "UTF-16BE" or "UTF-16LE", the requisite byte order mark is written to the stream before the writer is returned.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
charset - the name of the encoding used to write in this file
append - true if in append mode
Returns:
a BufferedWriter
Since:
1.0


newReader

public static BufferedReader newReader(URL url)


newReader

public static BufferedReader newReader(URL url, String charset)


newWriter

public static BufferedWriter newWriter(File file)
Create a new PrintWriter for this file, using specified charset.
Parameters:
writer - a writer
Returns:
a PrintWriter
Since:
1.6.0


newWriter

public static BufferedWriter newWriter(File file, boolean append)
Create a new PrintWriter for this file which is then passed it into the given closure. This method ensures its the writer is closed after the closure returns.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
closure - the closure to invoke with the PrintWriter
Returns:
the value returned by the closure
Since:
1.5.2


newWriter

public static BufferedWriter newWriter(File file, String charset, boolean append)
Create a new PrintWriter with a specified charset for 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
closure - the closure to invoke with the PrintWriter
Returns:
the value returned by the closure
Since:
1.5.2


newWriter

public static BufferedWriter newWriter(File file, String charset)
Create a new PrintWriter with a specified charset for this file. The writer is passed to the closure, and will be closed before this method returns.
throws:
IOException if an IOException occurs.
Parameters:
writer - a writer
closure - the closure to invoke with the PrintWriter
Returns:
the value returned by the closure
Since:
1.6.0


next

public static String next(String 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)


next

public static Date next(Date self)


next

public static def next(def self)


normalize

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


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


or

public static Boolean or(Boolean left, Boolean right)
Create an object input stream for this file using the given class loader.
throws:
IOException if an IOException occurs.
Parameters:
file - a file
classLoader - the class loader to use when loading the class
Returns:
an object input stream
Since:
1.5.0


or

Class current = self.getClass();
public static Process or(Process left, Process right)


padLeft

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


padLeft

public static String padLeft(String self, Number numberOfChars)
Pad a String to a minimum length specified by numberOfChars, adding the supplied padding String as many times as needed to the right. 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.padRight(5, '#') + it.size() }
 
will produce output like:
 A####1
 BB###2
 CCC##3
 DDDD#4
 
Parameters:
self - a String object
numberOfChars - the total minimum number of characters of the resulting string
padding - the charaters used for padding
Returns:
the String padded to the right
Since:
1.0


padRight

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


padRight

public static String padRight(String self, Number numberOfChars)
Pad a String to a minimum length specified by numberOfChars, appending the supplied padding String around the original as many times as needed keeping it centered. 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
padding - the charaters used for padding
Returns:
the String centered with padded characters around it
Since:
1.0


permutations

public static Set permutations(List self)


pipeTo

while (true) {
public static Process pipeTo(Process left, Process right)


plus

public static Map plus(Map left, Map right)
A helper method to allow maps to work with subscript operators
Parameters:
self - a Map
key - an Object as a key for the map
value - the value to put into the map
Returns:
the value corresponding to the given key
Since:
1.0


plus

public static Map plus(Map self, Collection entries)


plus

public static Collection plus(Collection left, Collection right)


plus

public static Collection plus(Collection left, T right)


plus

public static String plus(String left, Object value)


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)
Subtract a Character from a Number. The ordinal value of the Character is used in the subtraction (the ordinal value is the unicode value which for simple character sets is the ASCII value).
Parameters:
left - a Number
right - a Character
Returns:
the Number corresponding to the subtraction of right from left
Since:
1.0


plus

public static Number plus(Number left, Character right)
Subtract one Character from another. The ordinal values of the Characters 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 Character
Returns:
the Number corresponding to the subtraction of right from left
Since:
1.0


plus

public static Number plus(Character left, Character right)
Multiply a Character by a Number. The ordinal value of the Character is used in the multiplcation (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 multiplication of left by right
Since:
1.0


plus

public static Date plus(Date self, int days)


plus

public static def plus(def self, int days)


pop

public static T pop(List self)


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)


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)
Integer Divide two Numbers.
Parameters:
left - a Number
right - another Number
Returns:
a Number (an Integer) resulting from the integer division operation
Since:
1.0


previous

public static String previous(String self)
Executes the command specified by the String array given in the first parameter, with the environment defined by envp and under the working directory dir. The first item in the array is the command; the others are the parameters.

For more control over Process construction you can use java.lang.ProcessBuilder (JDK 1.5+).

throws:
IOException if an IOException occurs.
Parameters:
commandArray - an array of String containing the command name and parameters as separate items in the array.
envp - an array of Strings, each member of which has environment variable settings in the format name=value, or null if the subprocess should inherit the environment of the current process.
dir - the working directory of the subprocess, or null if the subprocess should inherit the working directory of the current process.
Returns:
the Process which has just started for this command line representation.
Since:
1.7.1


previous

public static Character previous(Character self)
Compare two Numbers. Equality (==) for numbers dispatches to this.
Parameters:
left - a Number
right - another Number to compare to
Returns:
the comparision of both numbers
Since:
1.0


previous

public static Number previous(Number self)


previous

public static Date previous(Date self)


previous

public static def previous(def self)


primitiveArrayGet

protected static Object primitiveArrayGet(Object self, int idx)


primitiveArrayGet

protected static List primitiveArrayGet(Object self, Range range)


primitiveArrayGet

protected static List primitiveArrayGet(Object self, Collection indices)
Convenience method to capitalize the first letter of a string (typically the first letter of a word). Example usage:
 assert 'h'.capitalize() == 'H'
 assert 'hello'.capitalize() == 'Hello'
 assert 'hello world'.capitalize() == 'Hello world'
 assert 'Hello World' ==
     'hello world'.split(' ').collect{ it.capitalize() }.join(' ')
 
Parameters:
self - The string to capitalize
Returns:
String The capitalized String result of split
Since:
1.7.3


primitiveArrayPut

protected static Object primitiveArrayPut(Object self, int idx, Object newValue)
Expands all tabs into spaces with tabStops of size 8.
Parameters:
self - A String to expand
Returns:
The expanded String
See Also:
expand(java.lang.String, int)
Since:
1.7.3


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, T 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, T 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)
Support the range subscript operator for StringBuffer.
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, EmptyRange range, Object value)


putAt

public static void putAt(List self, EmptyRange range, Object value)
A helper method to allow lists to work with subscript operators.
def list = ["a", true]
 list[1..<1] = [4, 3, 2]
 assert list == ["a", 4, 3, 2, true]
Parameters:
self - a List
range - the (in this case empty) subset of the list to set
value - the Collection of values
See Also:
putAt(java.util.List, groovy.lang.EmptyRange, java.lang.Object)
Since:
1.0


putAt

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


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


putAt

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


putAt

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


readLine

public static String readLine(Reader self)


readLines

public static List readLines(String self)
Read the content of this URL and returns it as a String.
throws:
IOException if an IOException occurs.
Parameters:
url - URL to read content from
Returns:
the text from that URL
Since:
1.0


readLines

public static List readLines(File file)


readLines

public static List readLines(File file, String charset)


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


removeAll

public static boolean removeAll(Collection self, Closure closure)
Removes the elements in this collection that are matched according to the specified closure condition.
Parameters:
self - a Collection to be modified
closure - 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)
Creates a new OutputStream 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.OutputStream, groovy.lang.Closure)
Since:
1.5.2


replaceAll

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


replaceAll

public static String replaceAll(String self, String regex, Closure closure)
Replaces the first occurrence of a captured group by the result of a closure call on that text.

For example (with some replaceAll variants thrown in for comparison purposes),

 assert "hellO world" == "hello world".replaceFirst("(o)") { it[0].toUpperCase() } // first match
 assert "hellO wOrld" == "hello world".replaceAll("(o)") { it[0].toUpperCase() }   // all matches
 

assert '1-FISH, two fish' == "one fish, two fish".replaceFirst(/([a-z]{3})\s([a-z]{4})/) { [one:1, two:2][it[1]] + '-' + it[2].toUpperCase() } assert '1-FISH, 2-FISH' == "one fish, two fish".replaceAll(/([a-z]{3})\s([a-z]{4})/) { [one:1, two:2][it[1]] + '-' + it[2].toUpperCase() }

throws:
java.util.regex.PatternSyntaxException if the regular expression's syntax is invalid
Parameters:
self - a String
regex - the capturing regex
closure - the closure to apply on the first captured group
Returns:
a String with replaced content
See Also:
Matcher.quoteReplacement
replaceFirst(String, Pattern, Closure)
Since:
1.7.7


replaceAll

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


replaceFirst

public static String replaceFirst(String self, Pattern pattern, String replacement)
Replaces all substrings of a String that match the given compiled regular expression with the given replacement.

Note that backslashes (\) and dollar signs ($) in the replacement string may cause the results to be different than if it were being treated as a literal replacement string; see Matcher.replaceAll. Use Matcher.quoteReplacement to suppress the special meaning of these characters, if desired.

Parameters:
self - the string that is to be matched
pattern - the regex Pattern to which the string of interest is to be matched
replacement - the string to be substituted for the first match
Returns:
The resulting String
See Also:
String.replaceAll
Since:
1.6.1


replaceFirst

public static String replaceFirst(String self, String regex, Closure closure)
Get a replacement corresponding to the matched pattern for DefaultGroovyMethods.replaceAll. The closure take parameter:
  • Whole of match if the pattern include no capturing group
  • Object[] of capturing groups if the closure takes Object[] as parameter
  • List of capturing groups
Parameters:
matcher - the matcher object used for matching
closure - specified with replaceAll() to get replacement
Returns:
replacement correspond replacement for a match


replaceFirst

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


respondsTo

public static List respondsTo(Object self, String name, Object[] argTypes)
deprecated:
moved to DateGroovyMethods.minus


respondsTo

public static List respondsTo(Object self, String name)
deprecated:
moved to DateGroovyMethods.getTimeString


retainAll

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


retainAll

public static boolean retainAll(Collection self, Closure closure)


reverse

* true for all items in this data structure).
public static T[] reverse(T[] self)


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 List reverse(List 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

public static Iterator reverse(Iterator self)


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


rightShift

public static Number rightShift(Number self, Number operand)
Overloads the leftShift operator to provide an append mechanism to add values to a stream.
throws:
IOException if an I/O error occurs.
Parameters:
self - an OutputStream
value - a value to append
Returns:
a Writer
Since:
1.0


rightShiftUnsigned

public static Number rightShiftUnsigned(Number self, Number operand)
Overloads the leftShift operator to add objects to an ObjectOutputStream.
throws:
IOException if an I/O error occurs.
Parameters:
self - an ObjectOutputStream
value - an object to write to the stream
Since:
1.5.0


round

public static int round(Float number)


round

public static float round(Float number, int precision)


round

public static long round(Double number)
Determine if a String can be parsed into an Integer.
Parameters:
self - a String
Returns:
true if the string can be parsed
Since:
1.5.0


round

public static double round(Double number, int precision)


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)


setMetaClass

public static void setMetaClass(Class self, MetaClass metaClass)


setMetaClass

public static void setMetaClass(Object self, MetaClass metaClass)
Returns an Iterator which traverses each match.
Parameters:
matcher - a Matcher object
Returns:
an Iterator for a Matcher
See Also:
Matcher.group
Since:
1.0


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)


size

public static int size(String text)
Provide the standard Groovy size() method for StringBuffer.
Parameters:
buffer - a StringBuffer
Returns:
the length of the StringBuffer
Since:
1.0


size

public static int size(StringBuffer buffer)
Provide the standard Groovy size() method for File.
Parameters:
self - a file object
Returns:
the file's size (length)
Since:
1.5.0


size

public static long size(File self)
Provide the standard Groovy size() method for Matcher.
Parameters:
self - a matcher object
Returns:
the matcher's size (count)
Since:
1.5.0


size

public static long size(Matcher self)
Provide the standard Groovy size() method for an array.
Parameters:
self - an Array of objects
Returns:
the size (length) of the Array
Since:
1.0


size

public static int size(Object[] self)
Support the subscript operator for CharSequence.
Parameters:
text - a CharSequence
index - the index of the Character to get
Returns:
the Character at the given index
Since:
1.0


size

public static int size(boolean[] array)


size

public static int size(byte[] array)


size

public static int size(char[] array)
Converts this array to a List of the same size, with each element added to the list.
Parameters:
array - a short array
Returns:
a list containing the contents of this array.
Since:
1.0


size

public static int size(short[] array)
Converts this array to a List of the same size, with each element added to the list.
Parameters:
array - an int array
Returns:
a list containing the contents of this array.
Since:
1.0


size

public static int size(int[] array)


size

public static int size(long[] array)


size

public static int size(float[] array)


size

public static int size(double[] array)


sort

public static List sort(Collection self)


sort

public static Map sort(Map self, Closure closure)


sort

public static Map sort(Map self, Comparator comparator)
Sorts the given Object array into 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)
Sorts the given iterator items into a sorted iterator. The items are assumed to be comparable. 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
Returns:
the sorted items as an Iterator
Since:
1.5.5


sort

public static T[] sort(T[] self)
Sorts the given iterator items into a sorted iterator using the comparator.
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)
Sorts the Collection using the given comparator. The elements are sorted into a new list, and the existing collection is unchanged.
assert ["hi","hey","hello"] == ["hello","hi","hey"].sort( { a, b -> a.length() <=> b.length() } as Comparator )
assert ["hello","Hey","hi"] == ["hello","hi","Hey"].sort(String.CASE_INSENSITIVE_ORDER)
Parameters:
self - a collection to be sorted
comparator - a Comparator used for the comparison
Returns:
a newly created sorted List
Since:
1.0


sort

public static Iterator sort(Iterator self, Comparator comparator)
Sorts the given Object array into sorted order using the given comparator.
Parameters:
self - the array to be sorted
comparator - a Comparator used for the comparison
Returns:
the sorted array
Since:
1.5.5


sort

public static List sort(Collection self, Comparator comparator)


sort

public static T[] sort(T[] self, Comparator comparator)


sort

public static Iterator sort(Iterator self, Closure closure)


sort

Collections.sort(list, new OrderBy(closure));
public static T[] sort(T[] self, Closure closure)


sort

public static List sort(Collection self, Closure closure)
Avoids doing unnecessary work when sorting an already sorted set.
Parameters:
self - an identity function for an already sorted set
Returns:
the sorted set
Since:
1.0


sort

public static SortedSet sort(SortedSet self)
Provides an easy way to append multiple Map.Entry values to a Map.
Parameters:
self - a Map
entries - a Collection of Map.Entry items to be added to the Map.
Returns:
the same map, after the items have been added to it.
Since:
1.6.1


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


split

public static String[] split(GString self)
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


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)


splitEachLine

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


splitEachLine

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


splitEachLine

public static Object splitEachLine(Reader self, String regex, Closure closure)
Iterates through the given InputStream line by line, splitting each line using the given separator Pattern. 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.
Parameters:
stream - an InputStream
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


splitEachLine

public static Object splitEachLine(Reader self, Pattern pattern, Closure closure)
Iterates through the given String line by line, splitting each line using the given separator Pattern. 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 String
pattern - the regular expression Pattern for the delimiter
closure - a closure
Returns:
the last value returned by the closure
See Also:
Pattern.split
Since:
1.6.8


splitEachLine

public static Object splitEachLine(InputStream stream, String regex, String charset, Closure closure)
Read a single, whole line from the given Reader.
throws:
IOException if an IOException occurs.
Parameters:
self - a Reader
Returns:
a line
Since:
1.0


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(String self, Pattern pattern, Closure closure)


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 String stripIndent(String self, int numChars)


stripMargin

public static String stripMargin(String self)

Strip leading whitespace/control characters followed by marginChar from every line in a String.

Parameters:
self - The String to strip the margin from
marginChar - Any character that serves as margin delimiter
See Also:
stripMargin(String, char)
Since:
1.7.3


stripMargin

public static String stripMargin(String self, String marginChar)


stripMargin

public static String stripMargin(String 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)
Sums the items from an Iterator. This is equivalent to invoking the "plus" method on all items from the Iterator. The iterator will become exhausted of elements after determining the sum value.
Parameters:
self - an Iterator for the values to add together
Returns:
The sum of all of the items
Since:
1.5.5


sum

public static Object sum(Iterator self)
Sums the items in a collection, adding the result to some initial value.
assert 5+1+2+3+4 == [1,2,3,4].sum(5)
Parameters:
self - a collection of values to sum
initialValue - the items in the collection will be summed to this initial value
Returns:
The sum of all of the items.
Since:
1.5.0


sum

public static Object sum(Collection self, Object initialValue)
Sums the items in an array, adding the result to some initial value.
Parameters:
self - an array of values to sum
initialValue - the items in the array will be summed to this initial value
Returns:
The sum of all of the items.
Since:
1.7.1


sum

public static Object sum(Object[] self, Object initialValue)
Sums the items from an Iterator, adding the result to some initial value. This is equivalent to invoking the "plus" method on all items from the Iterator. The iterator will become exhausted of elements after determining the sum value.
Parameters:
self - an Iterator for the values to add together
initialValue - the items in the collection will be summed to this initial value
Returns:
The sum of all of the items
Since:
1.5.5


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 a collection. coll.sum(closure) is equivalent to: coll.collect(closure).sum().
assert 4+6+10+12 == [2,3,5,6].sum() { it * 2 }
Parameters:
self - a Collection
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 collection.
Since:
1.0


sum

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


sum

public static Object sum(Iterator self, Closure closure)


sum

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


sum

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


sum

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


tail

public static List tail(List self)


tail

public static T[] tail(T[] self)
Converts this Collection to a List. Returns the original Collection if it is already a List.

Example usage:

assert new HashSet().asList() instanceof List
Parameters:
self - a collection to be converted into a List
Returns:
a newly created List if this collection is not already a List
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)


toBigDecimal

public static BigDecimal toBigDecimal(String self)
Determine if a Character is uppercase. Synonym for 'Character.isUpperCase(this)'.
Parameters:
self - a Character
Returns:
true if the character is uppercase
See Also:
Character.isUpperCase
Since:
1.5.7


toBigDecimal

public static BigDecimal toBigDecimal(Number self)
Create an object output stream for this file.
throws:
IOException if an IOException occurs.
Parameters:
file - a file
Returns:
an object output stream
Since:
1.5.0


toBigInteger

public static BigInteger toBigInteger(String 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)
Expands all tabs into spaces.
Parameters:
self - A line to expand
tabStop - The number of spaces a tab represents
Returns:
The expanded String
Since:
1.7.3


toBoolean

public static Boolean toBoolean(Boolean 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


toCharacter

public static Character toCharacter(String self)


toDouble

public static Double toDouble(String self)


toDouble

public static Double toDouble(Number self)


toFloat

public static Float toFloat(String self)


toFloat

public static Float toFloat(Number self)


toInteger

public static Integer toInteger(String 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(Enumeration self)
Convert an enumeration to a List.
Parameters:
self - an enumeration
Returns:
a List
Since:
1.5.0


toList

public static List toList(T[] array)


toList

/**
public static List toList(byte[] array)
Implements the getAt(int) method for primitve type arrays.
Parameters:
self - an array object
idx - the index of interest
Returns:
the returned value from the array
Since:
1.5.0


toList

}
public static List toList(boolean[] array)
Implements the getAt(Range) method for primitve type arrays.
Parameters:
self - an array object
range - the range of indices of interest
Returns:
the returned values from the array corresponding to the range
Since:
1.5.0


toList

*/
public static List toList(char[] array)


toList

return answer;
public static List toList(short[] array)


toList

Array.set(self, normaliseIndex(idx, Array.getLength(self)), newValue);
public static List toList(int[] array)
Implements the setAt(int idx) method for primitve type arrays.
Parameters:
self - an object
idx - the index of interest
newValue - the new value to be put into the index of interest
Returns:
the added value
Since:
1.5.0


toList

* @since 1.0
public static List toList(long[] array)


toList

* @since 1.0
public static List toList(float[] array)


toList

* Identity conversion which returns Boolean.TRUE for a true Boolean and Boolean.FALSE for a false Boolean.
public static List toList(double[] array)


toList

public static List toList(String self)
deprecated:
use ProcessGroovyMethods#consumeProcessOutput(Process, OutputStream, OutputStream)


toListString

public static String toListString(Collection self)


toListString

public static String toListString(Collection self, int maxSize)
Add a Number and a Character. The ordinal value of the Character is used in the addition (the ordinal value is the unicode value which for simple character sets is the ASCII value).
Parameters:
left - a Number
right - a Character
Returns:
The Number corresponding to the addition of left and right
See Also:
Integer.valueOf
Since:
1.0


toLong

public static Long toLong(String 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)
Increment a Number by one.
Parameters:
self - a Number
Returns:
an incremented Number
Since:
1.0


toMapString

public static String toMapString(Map self, int maxSize)
Decrement a Character by one.
Parameters:
self - a Character
Returns:
a decremented Character
Since:
1.5.7


toRowResult

@Deprecated
public static def toRowResult(def rs)
deprecated:
moved to DateGroovyMethods.format


toShort

public static Short toShort(String self)
Determine if a String can be parsed into a BigInteger.
Parameters:
self - a String
Returns:
true if the string can be parsed
Since:
1.5.0


toSpreadMap

public static SpreadMap toSpreadMap(Map self)
Creates a spreadable map from this array.
Parameters:
self - an object array
Returns:
a newly created Spreadmap
See Also:
SpreadMap.SpreadMap
Since:
1.0


toSpreadMap

public static SpreadMap toSpreadMap(Object[] self)


toString

public static String toString(boolean[] self)
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
maxSize - stop after approximately this many characters and append '...'
Returns:
the string representation
Since:
1.0


toString

public static String toString(byte[] self)


toString

public static String toString(char[] self)


toString

public static String toString(short[] self)


toString

public static String toString(int[] self)


toString

public static String toString(long[] self)
Returns the string representation of this array's contents.
Parameters:
self - an Object[]
Returns:
the string representation
See Also:
toArrayString(java.lang.Object[])
Since:
1.0


toString

public static String toString(float[] self)
Returns the string representation of the given array. The string displays the contents of the array, similar to an array literal, i.e. {1, 2, "a"}.
Parameters:
self - an Object[]
Returns:
the string representation
Since:
1.0


toString

public static String toString(double[] self)
Create a String representation of this object.
Parameters:
value - an object
Returns:
a string.
Since:
1.0


toString

public static String toString(AbstractMap self)
Increment a Character by one.
Parameters:
self - a Character
Returns:
an incremented Character
Since:
1.5.7


toString

public static String toString(AbstractCollection self)
Decrement a Number by one.
Parameters:
self - a Number
Returns:
a decremented Number
Since:
1.0


toString

public static String toString(Object[] self)


toString

public static String toString(Object value)


toURI

public static URI toURI(String self)


toURL

public static URL toURL(String self)
Turns a String into a regular expression Pattern
Parameters:
self - a String to convert into a regular expression
Returns:
the regular expression pattern
Since:
1.5.0


toUpperCase

public static char toUpperCase(Character self)


tokenize

public static List tokenize(String self, String token)


tokenize

public static List tokenize(String self, Character token)


tokenize

public static List tokenize(String self)


tr

public static String tr(String self, String sourceSet, String replacementSet)
Tells whether or not self matches the given compiled regular expression Pattern.
Parameters:
self - the string that is to be matched
pattern - the regex Pattern to which the string of interest is to be matched
Returns:
The resulting String
See Also:
String.matches
Since:
1.6.1


transformChar

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


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)


traverse

public static void traverse(File self, Map options)


trunc

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


trunc

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


trunc

public static double trunc(Double number)


trunc

public static double trunc(Double number, int precision)
Determine if a String can be parsed into a Float.
Parameters:
self - a String
Returns:
true if the string can be parsed
Since:
1.5.0


unaryMinus

public static Number unaryMinus(Number left)


unexpand

public static String unexpand(String self)
Tokenize a String (with a whitespace as the delimiter).
Parameters:
self - a String
Returns:
a List of tokens
See Also:
StringTokenizer.StringTokenizer
Since:
1.0


unexpand

public static String unexpand(String 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


unexpandLine

public static String unexpandLine(String self, int tabStop)
Appends a String to the string representation of this number.
Parameters:
value - a Number
right - a String
Returns:
a String
Since:
1.0


unique

public static Iterator unique(Iterator self)


unique

public static Collection unique(Collection self)


unique

public static Iterator unique(Iterator self, Closure closure)


unique

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


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)


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


waitForOrKill

public static void waitForOrKill(Process self, long numberOfMillis)


waitForProcessOutput

* @param self    the iteration object over which to iterate
public static void waitForProcessOutput(Process self)


waitForProcessOutput

public static void waitForProcessOutput(Process self, StringBuffer output, StringBuffer error)


waitForProcessOutput

* @param closure    the filter to perform a match on the collection
public static void waitForProcessOutput(Process self, OutputStream output, OutputStream error)


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)
Create a new PrintWriter for this file, using specified charset.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
charset - the charset
Returns:
a PrintWriter
Since:
1.0


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)
Sorts the given collection into a sorted list. The collection items are assumed to be comparable.
assert [1,2,3] == [3,1,2].sort()
Parameters:
self - the collection to be sorted
Returns:
the sorted collection as a List
Since:
1.0


withInputStream

public static Object withInputStream(File file, Closure closure)


withInputStream

public static Object withInputStream(URL url, Closure closure)


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
firstLine - the line number value used for the first line (default is 1, set to 0 to start counting from 0)
closure - a closure (arg 1 is line, optional arg 2 is line number)
Returns:
the last value returned by the closure
See Also:
eachLine(java.io.Reader, int, groovy.lang.Closure)
Since:
1.5.7


withObjectInputStream

public static Object withObjectInputStream(File file, ClassLoader classLoader, 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
charset - opens the file with a specified charset
firstLine - the line number value used for the first line (default is 1, set to 0 to start counting from 0)
closure - a closure (arg 1 is line, optional arg 2 is line number)
Returns:
the last value returned by the closure
See Also:
eachLine(java.io.Reader, int, groovy.lang.Closure)
Since:
1.6.8


withObjectInputStream

public static Object withObjectInputStream(InputStream inputStream, Closure closure)
Iterates through this stream reading with the provided charset, passing each line to the given 1 or 2 arg closure. The stream is closed before this method returns.
throws:
IOException if an IOException occurs.
Parameters:
stream - a stream
charset - opens the stream with a specified charset
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.InputStream, java.lang.String, int, groovy.lang.Closure)
Since:
1.5.5


withObjectInputStream

public static Object withObjectInputStream(InputStream inputStream, ClassLoader classLoader, Closure closure)
Iterates through this stream reading with the provided charset, passing each line to the given 1 or 2 arg closure. The stream is closed after this method returns.
throws:
IOException if an IOException occurs.
Parameters:
stream - a stream
charset - opens the stream with a specified charset
firstLine - the line number value used for the first line (default is 1, set to 0 to start counting from 0)
closure - a closure (arg 1 is line, optional arg 2 is line number)
Returns:
the last value returned by the closure
See Also:
eachLine(java.io.Reader, int, groovy.lang.Closure)
Since:
1.5.7


withObjectOutputStream

public static Object withObjectOutputStream(File file, Closure closure)


withObjectOutputStream

public static Object withObjectOutputStream(OutputStream outputStream, Closure closure)


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)


withOutputStream

* different classloaders.
public static void withOutputStream(Process self, 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)


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


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


withStream

public static Object withStream(InputStream stream, Closure closure)
Creates a buffered reader 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 BufferedReader for the URL
Since:
1.5.5


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)


withWriter

public static Object withWriter(Writer writer, Closure closure)


withWriter

public static Object withWriter(OutputStream stream, Closure closure)
Traverse through each byte of the specified stream. The stream is closed after the closure returns.
throws:
IOException if an IOException occurs.
Parameters:
is - stream to iterate over, closed after the method call
closure - closure to apply to each byte
Since:
1.0


withWriter

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


withWriter

return result;
public static void withWriter(Process self, Closure closure)


withWriterAppend

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


withWriterAppend

public static Object withWriterAppend(File file, Closure closure)
Helper method to create a new BufferedReader for a URL and then passes it to the closure. The reader is closed after the closure returns.
throws:
IOException if an IOException occurs.
Parameters:
url - a URL
closure - the closure to invoke with the reader
Returns:
the value returned by the closure
Since:
1.5.2


write

public static void write(Writer self, Writable writable)
Pipe an InputStream into an OutputStream for efficient stream copying.
throws:
IOException if an I/O error occurs.
Parameters:
self - stream on which to write
in - stream to read from
Returns:
the outputstream itself
Since:
1.0


write

public static void write(File file, String text)


write

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


writeLine

public static void writeLine(BufferedWriter writer, String line)
Append bytes to the end of a File.
throws:
IOException if an IOException occurs.
Parameters:
file - a File
bytes - the byte array to append to the end of the File
Since:
1.5.1


xor

public static BitSet xor(BitSet left, BitSet right)


xor

public static Number xor(Number left, Number right)


xor

public static Boolean xor(Boolean left, Boolean right)
Iterates through the given file object by object.
throws:
IOException if an IOException occurs.
throws:
ClassNotFoundException if the class is not found.
Parameters:
self - a File
closure - a closure
See Also:
eachObject(java.io.ObjectInputStream, groovy.lang.Closure)
Since:
1.0


 

Copyright © 2003-2010 The Codehaus. All rights reserved.