| java.lang.Object org.codehaus.groovy.runtime.DefaultGroovyMethods
DefaultGroovyMethods | public class DefaultGroovyMethods (Code) | | This class defines all the new groovy methods which appear on normal JDK
classes inside the Groovy environment. Static methods are used with the
first parameter the destination class.
author: James Strachan author: Jeremy Rayner author: Sam Pullara author: Rod Cope author: Guillaume Laforge author: John Wilson author: Hein Meling author: Dierk Koenig author: Pilho Kim author: Marc Guillemot author: Russel Winder author: bing ran author: Jochen Theodorou version: $Revision: 4598 $ |
Inner Class :protected static class ProcessRunner implements Runnable | |
Inner Class :protected static class RangeInfo | |
Method Summary | |
public static int | abs(Number number) | public static long | abs(Long number) | public static float | abs(Float number) | public static double | abs(Double number) | public static Socket | accept(ServerSocket serverSocket, Closure closure) | public static Number | and(Number left, Number right) | public static Boolean | and(Boolean left, Boolean right) | public static boolean | any(Object self, Closure closure) | public static void | append(File file, Object text) | public static void | append(File file, Object text, String charset) | public static Map | asImmutable(Map self) | public static SortedMap | asImmutable(SortedMap self) | public static List | asImmutable(List self) | public static Set | asImmutable(Set self) | public static SortedSet | asImmutable(SortedSet self) | public static Collection | asImmutable(Collection self) | public static List | asList(Collection self) | public static Map | asSynchronized(Map self) | public static SortedMap | asSynchronized(SortedMap self) | public static Collection | asSynchronized(Collection self) | public static List | asSynchronized(List self) | public static Set | asSynchronized(Set self) | public static SortedSet | asSynchronized(SortedSet self) | public static Object | asType(Collection col, Class clazz) | public static Object | asType(Closure cl, Class clazz) | public static Object | asType(Map map, Class clazz) | public static Object | asType(Number self, Class c) | public static Object | asType(File f, Class c) | public static Object | asType(String self, Class c) | public static Object | asType(Object obj, Class type) Converts a given object to a type. | public static File | asWritable(File file) | public static File | asWritable(File file, String encoding) | protected static Object | callClosureForMapEntry(Closure closure, Map.Entry entry) | public static String | center(String self, Number numberOfChars, String padding) | public static String | center(String self, Number numberOfChars) | public static List | collect(Object self, Closure closure) Iterates through this object transforming each object into a new value using the closure
as a transformer, returning a list of transformed values. | public static Collection | collect(Object self, Collection collection, Closure closure) Iterates through this object transforming each object into a new value using the closure
as a transformer and adding it to the collection, returning the resulting collection. | public static List | collect(Collection self, Closure closure) Iterates through this collection transforming each entry into a new value using the closure
as a transformer, returning a list of transformed values. | public static Collection | collect(Collection self, Collection collection, Closure closure) Iterates through this collection transforming each entry into a new value using the closure
as a transformer, returning a list of transformed values. | 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. | public static List | collect(Map self, Closure closure) Iterates through this Map transforming each entry into a new value using the closure
as a transformer, returning a list of transformed values. | public static int | compareTo(Character left, Number right) | public static int | compareTo(Number left, Character right) | public static int | compareTo(Character left, Character right) | public static int | compareTo(Number left, Number right) | public static void | consumeProcessOutput(Process self) gets the input and error streams from a process and reads them
to avoid the process to block due to a full ouput buffer. | public static boolean | contains(String self, String text) | public static int | count(Collection self, Object value) | public static int | count(String self, String text) | protected static StringBufferWriter | createStringBufferWriter(StringBuffer self) | protected static StringWriter | createStringWriter(String self) | public static byte[] | decodeBase64(String value) | public static boolean | disjoint(Collection left, Collection right) Returns true if the intersection of two collenctions is empty. | public static Number | div(Character left, Number right) | public static Number | div(Number left, Character right) | public static Number | div(Character left, Character right) | public static Number | div(Number left, Number right) | public static void | downto(Number self, Number to, Closure closure) | public static void | downto(long self, Number to, Closure closure) | public static void | downto(Long self, Number to, Closure closure) | public static void | downto(float self, Number to, Closure closure) | public static void | downto(Float self, Number to, Closure closure) | public static void | downto(double self, Number to, Closure closure) | public static void | downto(Double self, Number to, Closure closure) | public static void | downto(BigInteger self, Number to, Closure closure) | public static void | downto(BigDecimal self, Number to, Closure closure) | public static String | dump(Object self) | public static void | each(Object self, Closure closure) | public static void | each(Collection self, Closure closure) | public static void | each(Map self, Closure closure) Allows a Map to be iterated through using a closure. | public static void | each(Matcher self, Closure closure) Process each matched substring of the given group matcher. | public static void | eachByte(File self, Closure closure) | public static void | eachByte(InputStream is, Closure closure) Traverse through each byte of the specified stream. | public static void | eachByte(URL url, Closure closure) | public static void | eachDir(File self, Closure closure) Invokes the closure for each directory in the given directory,
ignoring regular files. | public static void | eachFile(File self, Closure closure) | public static void | eachFileMatch(File self, Object filter, Closure closure) Invokes the closure for each file matching the given filter in the given directory
- calling the isCase() method used by switch statements. | public static void | eachFileRecurse(File self, Closure closure) Invokes the closure for each file in the given directory and recursively. | public static void | eachLine(File self, Closure closure) | public static void | eachLine(Reader self, Closure closure) Iterates through the given reader line by line. | public static void | eachLine(InputStream stream, Closure closure) | public static void | eachLine(URL url, Closure closure) | public static void | eachMatch(String self, String regex, Closure closure) Process each regex group matched substring of the given string. | public static void | eachObject(File self, Closure closure) | public static void | eachObject(ObjectInputStream ois, Closure closure) Iterates through the given object stream object by object. | public static void | eachWithIndex(Object self, Closure closure) | public static Writable | encodeBase64(Byte[] data) | public static Writable | encodeBase64(byte[] data) | public static boolean | equals(List left, List right) Compare two Lists. | public static boolean | every(Object self, Closure closure) Iterates over every element of a collection, and check whether a predicate is valid for all elements. | public static Process | execute(String self) Executes the given string as a command line process. | public static Process | execute(String[] commandArray) Executes the command specified by the String array that is the parameter.
The first item in the array is the command the others are the parameters. | public static Process | execute(String self, String[] envp, File dir) Executes the command specified by the self with environments envp
under the working directory dir .
For more control over the process mechanism in JDK 1.5 you can use java.lang.ProcessBuilder .
Parameters: self - a command line String to be executed. Parameters: envp - an array of Strings, each element of whichhas environment variable settings in the formatname=value, ornull if the subprocess should inheritthe environment of the current process. Parameters: dir - the working directory of the subprocess, ornull if the subprocess should inheritthe working directory of the current process. | public static Process | execute(List commandList) Executes the command specified by the String list that is the parameter.
The first item in the array is the command the others are the parameters. | public static Process | execute(String self, List envp, File dir) Executes the command specified by the self with environments envp
under the working directory dir .
For more control over the process mechanism in JDK 1.5 you can use java.lang.ProcessBuilder .
Parameters: self - a command line String to be executed. Parameters: envp - a List of Strings, each member of whichhas environment variable settings in the formatname=value, ornull if the subprocess should inheritthe environment of the current process. Parameters: dir - the working directory of the subprocess, ornull if the subprocess should inheritthe working directory of the current process. | public static void | filterLine(Reader reader, Writer writer, Closure closure) Filter the lines from a reader and write them on the writer,
according to a closure which returns true or false. | public static Writable | filterLine(File self, Closure closure) | public static void | filterLine(File self, Writer writer, Closure closure) | public static Writable | filterLine(Reader reader, Closure closure) Filter the lines of a Reader and create a Writable in return to stream
the filtered lines. | public static Writable | filterLine(InputStream self, Closure predicate) | public static void | filterLine(InputStream self, Writer writer, Closure predicate) Filters lines from an input stream, writing to a writer, using a closure which
returns boolean and takes a line. | public static Object | find(Object self, Closure closure) | public static Object | find(Collection self, Closure closure) | public static Object | find(Map self, Closure closure) | public static List | findAll(Object self, Closure closure) | public static List | findAll(Collection self, Closure closure) | public static Map | findAll(Map self, Closure closure) Finds all entries matching the closure condition. | public static int | findIndexOf(Object self, Closure closure) | public static List | flatten(List self) | public static Object | get(Map map, Object key, Object defaultValue) Looks up an item in a Map for the given key and returns the value - unless
there is no entry for the given key in which case add the default value
to the map and return that. | public static Object | getAt(Object self, String property) Allows the subscript operator to be used to lookup dynamic property values.
bean[somePropertyNameExpression] . | public static CharSequence | getAt(CharSequence text, int index) Support the subscript operator for String. | public static String | getAt(String text, int index) | public static CharSequence | getAt(CharSequence text, Range range) | public static CharSequence | getAt(CharSequence text, IntRange range) | public static String | getAt(String text, IntRange range) | public static String | getAt(String text, Range range) | public static Object | getAt(Matcher matcher, int idx) Support the subscript operator, e.g. | public static List | getAt(List self, IntRange range) | public static List | getAt(List self, Collection indices) | public static List | getAt(Object[] self, Collection indices) | public static CharSequence | getAt(CharSequence self, Collection indices) | public static String | getAt(String self, Collection indices) | public static String | getAt(Matcher self, Collection indices) | public static List | getAt(Object[] array, Range range) | public static List | getAt(Object[] array, IntRange range) | public static List | getAt(Object[] array, ObjectRange range) | public static Object | getAt(Object[] array, int idx) | public static Object | getAt(List self, int idx) | public static Object | getAt(Map self, Object key) | public static List | getAt(Collection coll, String property) | public static Object | getAt(byte[] array, int idx) | public static Object | getAt(char[] array, int idx) | public static Object | getAt(short[] array, int idx) | public static Object | getAt(int[] array, int idx) | public static Object | getAt(long[] array, int idx) | public static Object | getAt(float[] array, int idx) | public static Object | getAt(double[] array, int idx) | public static Object | getAt(boolean[] array, int idx) | public static Object | getAt(byte[] array, Range range) | public static Object | getAt(char[] array, Range range) | public static Object | getAt(short[] array, Range range) | public static Object | getAt(int[] array, Range range) | public static Object | getAt(long[] array, Range range) | public static Object | getAt(float[] array, Range range) | public static Object | getAt(double[] array, Range range) | public static Object | getAt(boolean[] array, Range range) | public static Object | getAt(byte[] array, IntRange range) | public static Object | getAt(char[] array, IntRange range) | public static Object | getAt(short[] array, IntRange range) | public static Object | getAt(int[] array, IntRange range) | public static Object | getAt(long[] array, IntRange range) | public static Object | getAt(float[] array, IntRange range) | public static Object | getAt(double[] array, IntRange range) | public static Object | getAt(boolean[] array, IntRange range) | public static Object | getAt(byte[] array, ObjectRange range) | public static Object | getAt(char[] array, ObjectRange range) | public static Object | getAt(short[] array, ObjectRange range) | public static Object | getAt(int[] array, ObjectRange range) | public static Object | getAt(long[] array, ObjectRange range) | public static Object | getAt(float[] array, ObjectRange range) | public static Object | getAt(double[] array, ObjectRange range) | public static Object | getAt(boolean[] array, ObjectRange range) | public static Object | getAt(byte[] array, Collection indices) | public static Object | getAt(char[] array, Collection indices) | public static Object | getAt(short[] array, Collection indices) | public static Object | getAt(int[] array, Collection indices) | public static Object | getAt(long[] array, Collection indices) | public static Object | getAt(float[] array, Collection indices) | public static Object | getAt(double[] array, Collection indices) | public static Object | getAt(boolean[] array, Collection indices) | public static int | getCount(Matcher matcher) Find the number of Strings matched to the given Matcher. | public static InputStream | getErr(Process self) | public static InputStream | getIn(Process self) | 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'. | public static OutputStream | getOut(Process self) | public static Map | getProperties(Object self) Convenience method that calls
DefaultGroovyMethods.getMetaPropertyValues(Object) (self)
and provides the data in form of simple key/value pairs, i.e. | public static ClassLoader | getRootLoader(ClassLoader cl) Iterates through the class loader parents until it finds a loader with a class
named equal to org.codehaus.groovy.tools.RootLoader. | protected static List | getSubList(List self, List splice) | public static String | getText(File file, String charset) | public static String | getText(File file) | public static String | getText(URL url) | public static String | getText(URL url, String charset) | public static String | getText(InputStream is) | public static String | getText(InputStream is, String charset) | public static String | getText(Reader reader) | public static String | getText(BufferedReader reader) Reads the content of the BufferedReader and returns it as a String. | public static String | getText(Process self) Read the text of the output stream of the Process. | public static List | grep(Object self, Object filter) Iterates over every element of the collection and return each object that matches
the given filter - calling the isCase() method used by switch statements. | public static Map | groupBy(Collection self, Closure closure) Groups all collection members into groups determined by the
supplied mapping closure. | public static boolean | hasGroup(Matcher matcher) Check whether a Matcher contains a group or not. | public static Object | identity(Object self, Closure closure) | public static Object | inject(Collection self, Object value, Closure closure) Iterates through the given collection, passing in the initial value to
the closure along with the current iterated item then passing into the
next iteration the value of the previous closure. | public static Object | inject(Object[] self, Object value, Closure closure) Iterates through the given array of objects, passing in the initial value to
the closure along with the current iterated item then passing into the
next iteration the value of the previous closure. | public static String | inspect(Object self) a String that matches what would be typed into a terminal tocreate this object. | public static Number | intdiv(Character left, Number right) | public static Number | intdiv(Number left, Character right) | public static Number | intdiv(Character left, Character right) | public static Number | intdiv(Number left, Number right) | public static List | intersect(Collection left, Collection right) | 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. | public static boolean | is(Object self, Object other) Identity check. | public static boolean | isCase(Object caseValue, Object switchValue) | public static boolean | isCase(String caseValue, Object switchValue) | public static boolean | isCase(Class caseValue, Object switchValue) | public static boolean | isCase(Collection caseValue, Object switchValue) | public static boolean | isCase(Pattern caseValue, Object switchValue) | public static Iterator | iterator(Object o) | public static Iterator | iterator(Enumeration enumeration) | public static Iterator | iterator(NodeList nodeList) | public static Iterator | iterator(Matcher matcher) | public static Iterator | iterator(Reader value) | public static Iterator | iterator(InputStream is) Standard iterator for a input stream which iterates through the stream content in a byte-based fashion. | public static Iterator | iterator(DataInputStream dis) Standard iterator for a data input stream which iterates through the stream content in a byte-based fashion. | public static Iterator | iterator(File f) Standard iterator for a file which iterates through the file content in a line-based fashion. | public static Iterator | iterator(Iterator it) | public static String | join(Collection self, String separator) | public static String | join(Object[] self, String separator) | public static Collection | leftShift(Collection self, Object value) Overloads the left shift operator to provide an easy way to append objects to a list
Parameters: self - a Collection Parameters: value - an Object to be added to the collection. | public static StringBuffer | leftShift(String self, Object value) | public static StringBuffer | leftShift(StringBuffer self, Object value) | public static Writer | leftShift(Writer self, Object value) | public static Number | leftShift(Number left, Number right) Implementation of the left shift operator for integral types. | public static Writer | leftShift(OutputStream self, Object value) | public static OutputStream | leftShift(OutputStream self, InputStream in) Pipe an inputstream into an outputstream for efficient stream copying. | public static OutputStream | leftShift(OutputStream self, byte[] value) | public static File | leftShift(File file, Object text) Write the text to the File. | public static Writer | leftShift(Socket self, Object value) | public static OutputStream | leftShift(Socket self, byte[] value) | public static Writer | leftShift(Process self, Object value) | public static OutputStream | leftShift(Process self, byte[] value) | public static Object | max(Collection self) | public static Object | max(Collection self, Comparator comparator) | public static Object | max(Collection self, Closure closure) | public static Object | min(Collection self) | public static Object | min(Collection self, Comparator comparator) | public static Object | min(Collection self, Closure closure) | public static List | minus(List self, Collection removeMe) | public static List | minus(List self, Object operand) | public static String | minus(String left, Object value) | public static Number | minus(Character left, Number right) | public static Number | minus(Number left, Character right) | public static Number | minus(Character left, Character right) | public static Number | minus(Number left, Number right) | public static Date | minus(Date self, int days) | public static java.sql.Date | minus(java.sql.Date self, int days) | public static Number | mod(Number left, Number right) | public static List | multiply(Collection self, Number factor) Create a List composed of the same elements repeated a certain number of times. | public static String | multiply(String self, Number factor) | public static Number | multiply(Character left, Number right) | public static Number | multiply(Number left, Character right) | public static Number | multiply(Character left, Character right) | public static Number | multiply(Number left, Number right) | public static Number | multiply(BigDecimal left, Double right) Multiply a BigDecimal and a Double.
Note: This method was added to enforce the Groovy rule of
BigDecimal*Double == Double. | public static Number | multiply(BigDecimal left, BigInteger right) Multiply a BigDecimal and a BigInteger.
Note: This method was added to enforce the Groovy rule of
BigDecimal*long == long. | public static Pattern | negate(String self) | public static Number | negate(Number left) | public static BufferedInputStream | newInputStream(File file) | public static Object | newInstance(Class c) | public static Object | newInstance(Class c, Object[] args) | public static ObjectInputStream | newObjectInputStream(File file) Helper method to create an object input stream from the given file. | public static BufferedOutputStream | newOutputStream(File file) | public static PrintWriter | newPrintWriter(File file) | public static PrintWriter | newPrintWriter(File file, String charset) | public static BufferedReader | newReader(File file) | public static BufferedReader | newReader(File file, String charset) | public static BufferedReader | newReader(InputStream self) | public static BufferedWriter | newWriter(File file) | public static BufferedWriter | newWriter(File file, boolean append) | public static BufferedWriter | newWriter(File file, String charset, boolean append) | public static BufferedWriter | newWriter(File file, String charset) | public static String | next(String self) This method is called by the ++ operator for the class String.
It increments the last character in the given string. | public static Number | next(Character self) | public static Number | next(Number self) | public static Date | next(Date self) | public static java.sql.Date | next(java.sql.Date self) | protected static int | normaliseIndex(int i, int size) This converts a possibly negative index to a real index into the array. | public static Number | or(Number left, Number right) | public static Boolean | or(Boolean left, Boolean right) | public static String | padLeft(String self, Number numberOfChars, String padding) | public static String | padLeft(String self, Number numberOfChars) | public static String | padRight(String self, Number numberOfChars, String padding) | public static String | padRight(String self, Number numberOfChars) | public static List | plus(Collection left, Collection right) | public static List | plus(Collection left, Object right) | public static String | plus(String left, Object value) | public static String | plus(Number value, String right) | public static String | plus(StringBuffer left, String value) | public static Number | plus(Character left, Number right) | public static Number | plus(Number left, Character right) | public static Number | plus(Character left, Character right) | public static Number | plus(Number left, Number right) Add two numbers and return the result. | public static Date | plus(Date self, int days) | public static java.sql.Date | plus(java.sql.Date self, int days) | public static Object | pop(List self) Removes the last item from the List. | public static Number | power(Number self, Number exponent) | public static String | previous(String self) This method is called by the -- operator for the class String.
It decrements the last character in the given string. | public static Number | previous(Character self) | public static Number | previous(Number self) | public static Date | previous(Date self) | public static java.sql.Date | previous(java.sql.Date self) | protected static Object | primitiveArrayGet(Object array, int idx) | protected static List | primitiveArrayGet(Object array, Range range) | protected static List | primitiveArrayGet(Object self, Collection indices) | protected static void | primitiveArrayPut(Object array, int idx, Object newValue) | public static void | print(Object self, Object value) | public static void | print(Object self, PrintWriter out) | public static void | printf(Object self, String format, Object[] values) Printf to a console. | public static void | printf(Object self, String format, Object arg) Returns 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: format - A format string Parameters: arg - Argument which is referenced by the format specifiers in the formatstring. | public static void | println(Object self) Print a linebreak to the standard out. | public static void | println(Object self, Object value) | public static void | println(Object self, PrintWriter out) | 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 . | public static void | putAt(Object[] array, int idx, Object value) | public static void | putAt(List self, int idx, Object value) | public static void | putAt(StringBuffer self, IntRange range, Object value) | public static void | putAt(StringBuffer self, EmptyRange range, Object value) | public static void | putAt(List self, EmptyRange range, Object value) | public static void | putAt(List self, IntRange range, Object value) | public static void | putAt(List self, List splice, List values) | public static void | putAt(List self, List splice, Object value) | public static Object | putAt(Map self, Object key, Object value) | public static void | putAt(boolean[] array, int idx, Boolean newValue) | public static void | putAt(byte[] array, int idx, Object newValue) | public static void | putAt(char[] array, int idx, Object newValue) | public static void | putAt(short[] array, int idx, Object newValue) | public static void | putAt(int[] array, int idx, Object newValue) | public static void | putAt(long[] array, int idx, Object newValue) | public static void | putAt(float[] array, int idx, Object newValue) | public static void | putAt(double[] array, int idx, Object newValue) | public static byte[] | readBytes(File file) | public static String | readLine(Reader self) | public static String | readLine(InputStream stream) | public static List | readLines(File file) | public static List | readLines(Reader reader) | public static List | readLines(InputStream stream) | public static String | replaceAll(String self, String regex, Closure closure) Replaces all occurrencies of a captured group by the result of a closure on that text. | public static String | reverse(String self) | public static List | reverse(List self) | public static void | reverseEach(List self, Closure closure) Iterate over each element of the list in the reverse order. | public static Number | rightShift(Number left, Number right) Implementation of the right shift operator for integral types. | public static Number | rightShiftUnsigned(Number left, Number right) Implementation of the right shift (unsigned) operator for integral types. | public static int | round(Float number) | public static long | round(Double number) | public static void | runAfter(Timer timer, int delay, Closure closure) Allow simple syntax for using timers. | public static void | setIndex(Matcher matcher, int idx) Set the position of the given Matcher to the given index. | public static int | size(String text) | public static int | size(StringBuffer buffer) | public static long | size(File file) | public static long | size(Matcher matcher) | public static int | size(Object[] self) | public static int | size(byte[] array) | public static int | size(char[] array) | public static int | size(short[] array) | public static int | size(int[] array) | public static int | size(long[] array) | public static int | size(float[] array) | public static int | size(double[] array) | public static List | sort(Collection self) Sorts the given collection into a sorted list. | public static SortedSet | sort(SortedSet self) | public static List | sort(Collection self, Comparator comparator) | public static List | sort(Collection self, Closure closure) | public static void | splitEachLine(File self, String sep, Closure closure) | public static void | splitEachLine(Reader self, String sep, Closure closure) Iterates through the given reader line by line, splitting on the separator. | public static SpreadMap | spread(Map self) | public static void | step(Number self, Number to, Number stepNumber, Closure closure) | protected static RangeInfo | subListBorders(int size, IntRange range) | protected static RangeInfo | subListBorders(int size, EmptyRange range) | public static Map | subMap(Map map, Collection keys) Creates a sub-Map containing the given keys. | public static Object | sum(Collection self) Sums a collection of numeric values. | 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() .
Parameters: self - a Collection Parameters: closure - a single parameter closure that returns a numeric value. | public static void | times(Number self, Closure closure) | public static String | toArrayString(Object[] self) Returns the string representation of the given array with the brace boundaries. | public static BigDecimal | toBigDecimal(String self) | public static BigDecimal | toBigDecimal(Number self) | public static BigInteger | toBigInteger(String self) | public static BigInteger | toBigInteger(Number self) | public static Boolean | toBoolean(String self) | public static Character | toCharacter(String self) | public static Double | toDouble(String self) | public static Double | toDouble(Number self) | public static Float | toFloat(String self) | public static Float | toFloat(Number self) | public static Integer | toInteger(String self) | public static Integer | toInteger(Number self) | public static List | toList(Collection self) Convert a collection to a List. | public static List | toList(Object[] array) | public static List | toList(byte[] array) | public static List | toList(char[] array) | public static List | toList(short[] array) | public static List | toList(int[] array) | public static List | toList(long[] array) | public static List | toList(float[] array) | public static List | toList(double[] array) | public static List | toList(String self) | public static String | toListString(Collection self) Returns the string representation of the given collection with the bracket boundaries. | public static Long | toLong(String self) | public static Long | toLong(Number self) | public static String | toMapString(Map self) Returns the string representation of the given map with bracket boundaries. | public static SpreadMap | toSpreadMap(Map self) Returns the converted SpreadLMap of the given self . | public static SpreadMap | toSpreadMap(Object[] self) | public static String | toString(Map self) Returns the string representation of the given map with bracket boundaries. | public static String | toString(Collection self) Returns the string representation of the given collection with the bracket boundaries. | public static String | toString(Object[] self) Returns the string representation of the given array with the brace boundaries. | protected static String | toString(Object value) | public static URI | toURI(String self) Transforms a String representing a URI into a URI object. | public static URL | toURL(String self) Transforms a String representing a URL into a URL object. | public static List | tokenize(String self, String token) | public static List | tokenize(String self) | public static void | transformChar(Reader reader, Writer writer, Closure closure) Transforms the characters from a reader with a Closure and
write them to a writer. | public static void | transformLine(Reader reader, Writer writer, Closure closure) Transforms the lines from a reader with a Closure and
write them to a writer. | public static Collection | unique(Collection self) | public static Collection | unique(Collection self, Closure closure) | public static Collection | unique(Collection self, Comparator comparator) Remove all duplicates from a given Collection.
Works on the receiver object and returns it.
The order of members in the Collection are compared by the given Comparator.
For each duplicate, the first member which is returned
by the given Collection's iterator is retained, but all other ones are removed.
The given Collection's original order is preserved.
class Person {
Parameters: self - a Collection Parameters: comparator - a Comparator.
| public static void | upto(Number self, Number to, Closure closure) | public static void | upto(long self, Number to, Closure closure) | public static void | upto(Long self, Number to, Closure closure) | public static void | upto(float self, Number to, Closure closure) | public static void | upto(Float self, Number to, Closure closure) | public static void | upto(Double self, Number to, Closure closure) | public static void | upto(BigInteger self, Number to, Closure closure) | public static void | upto(BigDecimal self, Number to, Closure closure) | public static void | use(Object self, Class categoryClass, Closure closure) | public static void | use(Object self, List categoryClassList, Closure closure) | public static void | use(Object self, Object[] array) use() a list of categories, specifying the list as varargs:
use(CategoryClass1, CategoryClass2) { ... | public static void | waitForOrKill(Process self, long numberOfMillis) Wait for the process to finish during a certain amount of time, otherwise stops the process. | public static void | withInputStream(File file, Closure closure) | public static void | withOutputStream(File file, Closure closure) | public static void | withPrintWriter(File file, Closure closure) | public static void | withReader(File file, Closure closure) | public static void | withReader(Reader reader, Closure closure) | public static void | withReader(URL url, Closure closure) | public static void | withReader(InputStream in, Closure closure) | public static void | withStream(InputStream stream, Closure closure) | public static void | withStream(OutputStream os, Closure closure) Allows a OutputStream to be used, calling the closure with the stream
and then ensuring that the stream is closed down again irrespective
of whether exceptions occur. | public static void | withStreams(Socket socket, Closure closure) Allows an InputStream and an OutputStream from a Socket to be used,
calling the closure with the streams and then ensuring that the streams
are closed down again irrespective of whether exceptions occur. | public static void | withWriter(File file, Closure closure) | public static void | withWriter(File file, String charset, Closure closure) | public static void | withWriter(Writer writer, Closure closure) | public static void | withWriter(OutputStream stream, Closure closure) | public static void | withWriter(OutputStream stream, String charset, Closure closure) Allows an output stream to be used, calling the closure with the output stream
and then ensuring that the output stream is closed down again irrespective
of whether exceptions occur. | public static void | withWriterAppend(File file, String charset, Closure closure) | public static void | write(Writer self, Writable writable) A helper method so that dynamic dispatch of the writer.write(object) method
will always use the more efficient Writable.writeTo(writer) mechanism if the
object implements the Writable interface. | public static void | write(File file, String text) Write the text to the File. | public static void | write(File file, String text, String charset) Write the text to the File with a specified encoding. | public static void | writeLine(BufferedWriter writer, String line) | public static Number | xor(Number left, Number right) | public static Boolean | xor(Boolean left, Boolean right) |
abs | public static int abs(Number number)(Code) | | Get the absolute value
Parameters: number - a Number the absolute value of that Number |
abs | public static long abs(Long number)(Code) | | Get the absolute value
Parameters: number - a Long the absolute value of that Long |
abs | public static float abs(Float number)(Code) | | Get the absolute value
Parameters: number - a Float the absolute value of that Float |
abs | public static double abs(Double number)(Code) | | Get the absolute value
Parameters: number - a Double the absolute value of that Double |
accept | public static Socket accept(ServerSocket serverSocket, Closure closure) throws IOException(Code) | | Allow to pass a Closure to the accept methods of ServerSocket
Parameters: serverSocket - a ServerSocket Parameters: closure - a Closure a Socket throws: IOException - |
and | public static Number and(Number left, Number right)(Code) | | Bitwise AND together two Numbers
Parameters: left - a Number Parameters: right - another Number to bitwse AND the bitwise AND of both Numbers |
any | public static boolean any(Object self, Closure closure)(Code) | | Iterates over every element of a collection, and check whether a predicate is valid for at least one element
Parameters: self - the object over which we iterate Parameters: closure - the closure predicate used for matching true if any item in the collection matches the closure predicate |
append | public static void append(File file, Object text) throws IOException(Code) | | Append the text at the end of the File
Parameters: file - a File Parameters: text - the text to append at the end of the File throws: IOException - |
append | public static void append(File file, Object text, String charset) throws IOException(Code) | | Append the text at the end of the File with a specified encoding
Parameters: file - a File Parameters: text - the text to append at the end of the File Parameters: charset - the charset used throws: IOException - |
asImmutable | public static Map asImmutable(Map self)(Code) | | A convenience method for creating an immutable map
Parameters: self - a Map an immutable Map |
asImmutable | public static SortedMap asImmutable(SortedMap self)(Code) | | A convenience method for creating an immutable sorted map
Parameters: self - a SortedMap an immutable SortedMap |
asImmutable | public static List asImmutable(List self)(Code) | | A convenience method for creating an immutable list
Parameters: self - a List an immutable List |
asImmutable | public static Set asImmutable(Set self)(Code) | | A convenience method for creating an immutable list
Parameters: self - a Set an immutable Set |
asImmutable | public static SortedSet asImmutable(SortedSet self)(Code) | | A convenience method for creating an immutable sorted set
Parameters: self - a SortedSet an immutable SortedSet |
asImmutable | public static Collection asImmutable(Collection self)(Code) | | A convenience method for creating an immutable Collection
Parameters: self - a Collection an immutable Collection |
asList | public static List asList(Collection self)(Code) | | Converts the given collection into a List
Parameters: self - a collection to be converted into a List a newly created List if this collection is not already a List |
asSynchronized | public static Map asSynchronized(Map self)(Code) | | A convenience method for creating a synchronized Map
Parameters: self - a Map a synchronized Map |
asSynchronized | public static SortedMap asSynchronized(SortedMap self)(Code) | | A convenience method for creating a synchronized SortedMap
Parameters: self - a SortedMap a synchronized SortedMap |
asSynchronized | public static Collection asSynchronized(Collection self)(Code) | | A convenience method for creating a synchronized Collection
Parameters: self - a Collection a synchronized Collection |
asSynchronized | public static List asSynchronized(List self)(Code) | | A convenience method for creating a synchronized List
Parameters: self - a List a synchronized List |
asSynchronized | public static Set asSynchronized(Set self)(Code) | | A convenience method for creating a synchronized Set
Parameters: self - a Set a synchronized Set |
asSynchronized | public static SortedSet asSynchronized(SortedSet self)(Code) | | A convenience method for creating a synchronized SortedSet
Parameters: self - a SortedSet a synchronized SortedSet |
asType | public static Object asType(Object obj, Class type)(Code) | | Converts a given object to a type. This method is used through
the "as" operator and is overloadable as any other operator.
Parameters: obj - the object to convert Parameters: type - the goal type the resulting object |
asWritable | public static File asWritable(File file)(Code) | | Parameters: file - a File a File which wraps the input file and which implements Writable |
asWritable | public static File asWritable(File file, String encoding)(Code) | | Parameters: file - a File Parameters: encoding - the encoding to be used when reading the file's contents File which wraps the input file and which implements Writable |
center | public static String center(String self, Number numberOfChars, String padding)(Code) | | Center a String and padd it with the characters appended around it
Parameters: numberOfChars - the total number of characters Parameters: padding - the charaters used for padding the String centered with padded character around |
center | public static String center(String self, Number numberOfChars)(Code) | | Center a String and padd it with spaces appended around it
Parameters: numberOfChars - the total number of characters the String centered with padded character around |
collect | public static List collect(Object self, Closure closure)(Code) | | Iterates through this object transforming each object into a new value using the closure
as a transformer, returning a list of transformed values.
Parameters: self - the values of the object to map Parameters: closure - the closure used to map each element of the collection a List of the mapped values |
collect | public static Collection collect(Object self, Collection collection, Closure closure)(Code) | | Iterates through this object transforming each object into a new value using the closure
as a transformer and adding it to the collection, returning the resulting collection.
Parameters: self - the values of the object to map Parameters: collection - the Collection to which the mapped values are added Parameters: closure - the closure used to map each element of the collection the resultant collection |
collect | public static List collect(Collection self, Closure closure)(Code) | | Iterates through this collection transforming each entry into a new value using the closure
as a transformer, returning a list of transformed values.
Parameters: self - a collection Parameters: closure - the closure used for mapping a List of the mapped values |
collect | public static Collection collect(Collection self, Collection collection, Closure closure)(Code) | | Iterates through this collection transforming each entry into a new value using the closure
as a transformer, returning a list of transformed values.
Parameters: self - a collection Parameters: collection - the Collection to which the mapped values are added Parameters: closure - the closure used to map each element of the collection the resultant collection |
collect | public static Collection collect(Map self, Collection collection, Closure closure)(Code) | | Iterates through this Map transforming each entry into a new value using the closure
as a transformer, returning a list of transformed values.
Parameters: self - a Map Parameters: collection - the Collection to which the mapped values are added Parameters: closure - the closure used for mapping, which can be with one(Map.Entry) or two(key, value) parameters a List of the mapped values |
collect | public static List collect(Map self, Closure closure)(Code) | | Iterates through this Map transforming each entry into a new value using the closure
as a transformer, returning a list of transformed values.
Parameters: self - a Map Parameters: closure - the closure used to map each element of the collection the resultant collection |
compareTo | public static int compareTo(Character left, Number right)(Code) | | Compare a Character and a Number
Parameters: left - a Character Parameters: right - a Number the result of the comparison |
compareTo | public static int compareTo(Number left, Character right)(Code) | | Compare a Number and a Character
Parameters: left - a Number Parameters: right - a Character the result of the comparison |
compareTo | public static int compareTo(Character left, Character right)(Code) | | Compare two Characters
Parameters: left - a Character Parameters: right - a Character the result of the comparison |
compareTo | public static int compareTo(Number left, Number right)(Code) | | Compare two Numbers
Parameters: left - a Number Parameters: right - another Number to compare to the comparision of both numbers |
consumeProcessOutput | public static void consumeProcessOutput(Process self)(Code) | | gets the input and error streams from a process and reads them
to avoid the process to block due to a full ouput buffer. For this
two Threads are started, so this method will return immediately
Parameters: self - a Process |
contains | public static boolean contains(String self, String text)(Code) | | Provide an implementation of contains() like Collection to make Strings more polymorphic
This method is not required on JDK 1.5 onwards
Parameters: self - a String Parameters: text - a String to look for true if this string contains the given text |
count | public static int count(Collection self, Object value)(Code) | | Counts the number of occurencies of the given value inside this collection
Parameters: self - the collection within which we count the number of occurencies Parameters: value - the value the number of occurrencies |
count | public static int count(String self, String text)(Code) | | Count the number of occurencies of a substring
Parameters: self - a String Parameters: text - a substring the number of occurrencies of the given string inside this String |
decodeBase64 | public static byte[] decodeBase64(String value)(Code) | | Decode the Sting from base64 into a byte array
Parameters: value - the string to be decoded the decoded bytes as an array |
disjoint | public static boolean disjoint(Collection left, Collection right)(Code) | | Returns true if the intersection of two collenctions is empty.
Parameters: left - a Collection Parameters: right - a Collection boolean true if the intersection of two collenctions is empty, false otherwise. |
div | public static Number div(Character left, Number right)(Code) | | Divide a Character by a Number
Parameters: left - a Character Parameters: right - a Number the multiplication of both |
div | public static Number div(Number left, Character right)(Code) | | Divide a Number by a Character
Parameters: left - a Number Parameters: right - a Character the multiplication of both |
div | public static Number div(Character left, Character right)(Code) | | Divide two Characters
Parameters: left - a Character Parameters: right - another Character the multiplication of both |
div | public static Number div(Number left, Number right)(Code) | | Divide two Numbers
Parameters: left - a Number Parameters: right - another Number a Number resulting of the divide operation |
downto | public static void downto(Number self, Number to, Closure closure)(Code) | | Iterates from this number down to the given number
Parameters: self - a Number Parameters: to - another Number to go down to Parameters: closure - the closure to call |
dump | public static String dump(Object self)(Code) | | Generates a detailed dump string of an object showing its class,
hashCode and fields
|
each | public static void each(Object self, Closure closure)(Code) | | Allows objects to be iterated through using a closure
Parameters: self - the object over which we iterate Parameters: closure - the closure applied on each element found |
each | public static void each(Collection self, Closure closure)(Code) | | Allows objects to be iterated through using a closure
Parameters: self - the collection over which we iterate Parameters: closure - the closure applied on each element of the collection |
each | public static void each(Map self, Closure closure)(Code) | | 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.
Parameters: self - the map over which we iterate Parameters: closure - the closure applied on each entry of the map |
each | public static void each(Matcher self, Closure closure)(Code) | | Process each matched substring of the given group matcher. The object
passed to the closure is an array of strings, matched per a successful match.
Parameters: self - the source matcher Parameters: closure - a closure |
eachByte | public static void eachByte(File self, Closure closure) throws IOException(Code) | | Traverse through each byte of the specified File
Parameters: self - a File Parameters: closure - a closure |
eachByte | public static void eachByte(InputStream is, Closure closure) throws IOException(Code) | | Traverse through each byte of the specified stream. The
stream is closed afterwards.
Parameters: is - stream to iterate over, closed after the method call Parameters: closure - closure to apply to each byte throws: IOException - |
eachByte | public static void eachByte(URL url, Closure closure) throws IOException(Code) | | Traverse through each byte of the specified URL
Parameters: url - url to iterate over Parameters: closure - closure to apply to each byte throws: IOException - |
eachFileMatch | public static void eachFileMatch(File self, Object filter, Closure closure) throws FileNotFoundException, IllegalArgumentException(Code) | | Invokes the closure for each file matching the given filter in the given directory
- calling the isCase() method used by switch statements. This method can be used
with different kinds of filters like regular expresions, classes, ranges etc.
Parameters: self - a file Parameters: filter - the filter to perform on the directory (using the isCase(object) method) Parameters: closure - throws: FileNotFoundException - Thrown if the given directory does not exist throws: IllegalArgumentException - Thrown if the provided File object does not represent a directory |
eachLine | public static void eachLine(File self, Closure closure) throws IOException(Code) | | Iterates through the given file line by line
Parameters: self - a File Parameters: closure - a closure throws: IOException - |
eachLine | public static void eachLine(Reader self, Closure closure) throws IOException(Code) | | Iterates through the given reader line by line. The
Reader is closed afterwards
Parameters: self - a Reader, closed after the method returns Parameters: closure - a closure throws: IOException - |
eachLine | public static void eachLine(URL url, Closure closure) throws IOException(Code) | | Iterates through the lines read from the URL's associated input stream
Parameters: url - a URL to open and read Parameters: closure - a closure to apply on each line throws: IOException - |
eachMatch | public static void eachMatch(String self, String regex, Closure closure)(Code) | | Process each regex group matched substring of the given string. If the closure
parameter takes one argument an array with all match groups is passed to it.
If the closure takes as many arguments as there are match groups, then each
parameter will be one match group.
Parameters: self - the source string Parameters: regex - a Regex string Parameters: closure - a closure with one parameter or as much parameters as groups |
eachWithIndex | public static void eachWithIndex(Object self, Closure closure)(Code) | | Allows object to be iterated through a closure with a counter
Parameters: self - an Object Parameters: closure - a Closure |
encodeBase64 | public static Writable encodeBase64(byte[] data)(Code) | | Produce a Writable object which writes the base64 encoding of the byte array
Calling toString() on the result rerurns the encoding as a String
Parameters: data - byte array to be encoded object which will write the base64 encoding of the byte array |
equals | public static boolean equals(List left, List right)(Code) | | Compare two Lists.
If numbers exits in the Lists, then they are compared as numbers,
for example 2 == 2L.
Parameters: left - a List Parameters: right - a List boolean true if two Lists equals, false otherwise. |
every | public static boolean every(Object self, Closure closure)(Code) | | Iterates over every element of a collection, and check whether a predicate is valid for all elements.
Parameters: self - the object over which we iterate Parameters: closure - the closure predicate used for matching true if every item in the collection matches the closurepredicate |
execute | public static Process execute(String self) throws IOException(Code) | | Executes the given string as a command line process. For more control
over the process mechanism in JDK 1.5 you can use java.lang.ProcessBuilder.
Parameters: self - a command line String the Process which has just started for this command line string |
execute | public static Process execute(String[] commandArray) throws IOException(Code) | | Executes the command specified by the String array that is the parameter.
The first item in the array is the command the others are the parameters. For more
control over the process mechanism in JDK 1.5 you can use
java.lang.ProcessBuilder .
Parameters: commandArray - an array of String containing the command name andparameters as separate items in the array. the Process which has just started for this command line string. |
execute | public static Process execute(String self, String[] envp, File dir) throws IOException(Code) | | Executes the command specified by the self with environments envp
under the working directory dir .
For more control over the process mechanism in JDK 1.5 you can use java.lang.ProcessBuilder .
Parameters: self - a command line String to be executed. Parameters: envp - an array of Strings, each element of whichhas environment variable settings in the formatname=value, ornull if the subprocess should inheritthe environment of the current process. Parameters: dir - the working directory of the subprocess, ornull if the subprocess should inheritthe working directory of the current process. the Process which has just started for this command line string. |
execute | public static Process execute(List commandList) throws IOException(Code) | | Executes the command specified by the String list that is the parameter.
The first item in the array is the command the others are the parameters. All entries
must be String s. For more control over the process mechanism in JDK 1.5 you
can use java.lang.ProcessBuilder .
Parameters: commandList - a list of String containing the command name andparameters as separate items in the list. the Process which has just started for this command line string. |
execute | public static Process execute(String self, List envp, File dir) throws IOException(Code) | | Executes the command specified by the self with environments envp
under the working directory dir .
For more control over the process mechanism in JDK 1.5 you can use java.lang.ProcessBuilder .
Parameters: self - a command line String to be executed. Parameters: envp - a List of Strings, each member of whichhas environment variable settings in the formatname=value, ornull if the subprocess should inheritthe environment of the current process. Parameters: dir - the working directory of the subprocess, ornull if the subprocess should inheritthe working directory of the current process. the Process which has just started for this command line string. |
filterLine | public static void filterLine(Reader reader, Writer writer, Closure closure) throws IOException(Code) | | Filter the lines from a reader and write them on the writer,
according to a closure which returns true or false.
Both Reader and Writer are closed after the operation.
Parameters: reader - a reader, closed after the call Parameters: writer - a writer, closed after the call Parameters: closure - the closure which returns booleans throws: IOException - |
filterLine | public static Writable filterLine(File self, Closure closure) throws IOException(Code) | | Filters the lines of a File and creates a Writeable in return to
stream the filtered lines
Parameters: self - a File Parameters: closure - a closure which returns a boolean indicating to filterthe line or not a Writable closure throws: IOException - if self is not readable |
filterLine | public static void filterLine(File self, Writer writer, Closure closure) throws IOException(Code) | | Filter the lines from a File and write them on a writer, according to a closure
which returns true or false
Parameters: self - a File Parameters: writer - a writer Parameters: closure - a closure which returns a boolean value and takes a line as input throws: IOException - if self is not readable |
filterLine | public static Writable filterLine(Reader reader, Closure closure)(Code) | | Filter the lines of a Reader and create a Writable in return to stream
the filtered lines.
Parameters: reader - a reader Parameters: closure - a closure returning a boolean indicating to filter or not a line a Writable closure |
filterLine | public static Writable filterLine(InputStream self, Closure predicate)(Code) | | Filter lines from an input stream using a closure predicate
Parameters: self - an input stream Parameters: predicate - a closure which returns boolean and takes a line a filtered writer |
filterLine | public static void filterLine(InputStream self, Writer writer, Closure predicate) throws IOException(Code) | | Filters lines from an input stream, writing to a writer, using a closure which
returns boolean and takes a line.
Parameters: self - an InputStream Parameters: writer - a writer to write output to Parameters: predicate - a closure which returns a boolean and takes a line as input |
find | public static Object find(Object self, Closure closure)(Code) | | Finds the first value matching the closure condition
Parameters: self - an Object with an iterator returning its values Parameters: closure - a closure condition the first Object found |
find | public static Object find(Collection self, Closure closure)(Code) | | Finds the first value matching the closure condition
Parameters: self - a Collection Parameters: closure - a closure condition the first Object found |
find | public static Object find(Map self, Closure closure)(Code) | | Finds the first value matching the closure condition
Parameters: self - a Map Parameters: closure - a closure condition the first Object found |
findAll | public static List findAll(Object self, Closure closure)(Code) | | Finds all values matching the closure condition
Parameters: self - an Object with an Iterator returning its values Parameters: closure - a closure condition a List of the values found |
findAll | public static List findAll(Collection self, Closure closure)(Code) | | Finds all values matching the closure condition
Parameters: self - a Collection Parameters: closure - a closure condition a List of the values found |
findAll | public static Map findAll(Map self, Closure closure)(Code) | | Finds all entries matching the closure condition. 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.
Parameters: self - a Map Parameters: closure - a closure condition applying on the entries a new subMap |
findIndexOf | public static int findIndexOf(Object self, Closure closure)(Code) | | Iterates over every element of the collection and return the index of the first object
that matches the condition specified in the closure
Parameters: self - the iteration object over which we iterate Parameters: closure - the filter to perform a match on the collection an integer that is the index of the first macthed object. |
flatten | public static List flatten(List self)(Code) | | Flatten a list
Parameters: self - a List a flattened List |
get | public static Object get(Map map, Object key, Object defaultValue)(Code) | | 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.
Parameters: map - a Map Parameters: key - the key to lookup the value of Parameters: defaultValue - the value to return and add to the map for this key ifthere is no entry for the given key the value of the given key or the default value, added to the map if thekey did not exist |
getAt | public static Object getAt(Object self, String property)(Code) | | 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 |
getAt | public static CharSequence getAt(CharSequence text, int index)(Code) | | Support the subscript operator for String.
Parameters: text - a String Parameters: index - the index of the Character to get the Character at the given index |
getAt | public static String getAt(String text, int index)(Code) | | Support the subscript operator for String
Parameters: text - a String the Character object at the given index |
getAt | public static CharSequence getAt(CharSequence text, Range range)(Code) | | Support the range subscript operator for CharSequence
Parameters: text - a CharSequence Parameters: range - a Range the subsequence CharSequence |
getAt | public static CharSequence getAt(CharSequence text, IntRange range)(Code) | | Support the range subscript operator for CharSequence or StringBuffer with IntRange
Parameters: text - a CharSequence Parameters: range - an IntRange the subsequence CharSequence |
getAt | public static String getAt(String text, IntRange range)(Code) | | Support the range subscript operator for String with IntRange
Parameters: text - a String Parameters: range - an IntRange the resulting String |
getAt | public static String getAt(String text, Range range)(Code) | | Support the range subscript operator for String
Parameters: text - a String Parameters: range - a Range a substring corresponding to the Range |
getAt | public static Object getAt(Matcher matcher, int idx)(Code) | | Support the subscript operator, e.g. matcher[index], for a regex Matcher.
For an example using no group match,
def p = /ab[d|f]/
def m = "abcabdabeabf" =~ p
for (i in 0..
For an example using group matches,
def p = /(?:ab([c|d|e|f]))/
def m = "abcabdabeabf" =~ p
for (i in 0..
For another example using group matches,
def m = "abcabdabeabfabxyzabx" =~ /(?:ab([d|x-z]+))/
m.count.times {
println( "m.groupCount() = " + m.groupCount())
println( " " + it + ": " + m[it] ) // m[it] is a List
}
Parameters: matcher - a Matcher Parameters: idx - an index object a matched String if no groups matched, list of matched groups otherwise. |
getAt | public static List getAt(List self, IntRange range)(Code) | | Support the range subscript operator for a List
Parameters: self - a List Parameters: range - a Range a sublist based on range borders or a new list if range is reversed See Also: java.util.List.subList(intint) |
getAt | public static List getAt(List self, Collection indices)(Code) | | Allows a List to be used as the indices to be used on a List
Parameters: self - a List Parameters: indices - a Collection of indices a new list of the values at the given indices |
getAt | public static List getAt(Object[] self, Collection indices)(Code) | | Allows a List to be used as the indices to be used on a List
Parameters: self - an Array of Objects Parameters: indices - a Collection of indices a new list of the values at the given indices |
getAt | public static CharSequence getAt(CharSequence self, Collection indices)(Code) | | Allows a List to be used as the indices to be used on a CharSequence
Parameters: self - a CharSequence Parameters: indices - a Collection of indices a String of the values at the given indices |
getAt | public static String getAt(String self, Collection indices)(Code) | | Allows a List to be used as the indices to be used on a String
Parameters: self - a String Parameters: indices - a Collection of indices a String of the values at the given indices |
getAt | public static String getAt(Matcher self, Collection indices)(Code) | | Allows a List to be used as the indices to be used on a Matcher
Parameters: self - a Matcher Parameters: indices - a Collection of indices a String of the values at the given indices |
getAt | public static List getAt(Object[] array, Range range)(Code) | | Support the range subscript operator for an Array
Parameters: array - an Array of Objects Parameters: range - a Range a range of a list from the range's from index up to but notincluding the ranges's to value |
getAt | public static Object getAt(Object[] array, int idx)(Code) | | Support the subscript operator for an Array
Parameters: array - an Array of Objects Parameters: idx - an index the value at the given index |
getAt | public static Object getAt(List self, int idx)(Code) | | Support the subscript operator for a List
Parameters: self - a List Parameters: idx - an index the value at the given index |
getAt | public static Object getAt(Map self, Object key)(Code) | | Support the subscript operator for a List
Parameters: self - a Map Parameters: key - an Object as a key for the map the value corresponding to the given key |
getAt | public static List getAt(Collection coll, String property)(Code) | | Support the subscript operator for List
Parameters: coll - a Collection Parameters: property - a String a List |
getAt | public static Object getAt(byte[] array, int idx)(Code) | | |
getAt | public static Object getAt(char[] array, int idx)(Code) | | |
getAt | public static Object getAt(short[] array, int idx)(Code) | | |
getAt | public static Object getAt(long[] array, int idx)(Code) | | |
getAt | public static Object getAt(float[] array, int idx)(Code) | | |
getAt | public static Object getAt(double[] array, int idx)(Code) | | |
getAt | public static Object getAt(boolean[] array, int idx)(Code) | | |
getCount | public static int getCount(Matcher matcher)(Code) | | Find the number of Strings matched to the given Matcher.
Parameters: matcher - a Matcher int the number of Strings matched to the given matcher. |
getErr | public static InputStream getErr(Process self)(Code) | | An alias method so that a process appears similar to System.out, System.in, System.err;
you can use process.in, process.out, process.err in a similar way
an InputStream |
getIn | public static InputStream getIn(Process self)(Code) | | An alias method so that a process appears similar to System.out, System.in, System.err;
you can use process.in, process.out, process.err in a similar way
an InputStream |
getOut | public static OutputStream getOut(Process self)(Code) | | An alias method so that a process appears similar to System.out, System.in, System.err;
you can use process.in, process.out, process.err in a similar way
an OutputStream |
getRootLoader | public static ClassLoader getRootLoader(ClassLoader cl)(Code) | | Iterates through the class loader parents until it finds a loader with a class
named equal to org.codehaus.groovy.tools.RootLoader. If there is no such class
null will be returned. The name has to be used because a direct compare with
== may fail as the class may be loaded through different classloaders.
See Also: org.codehaus.groovy.tools.RootLoader |
getText | public static String getText(File file, String charset) throws IOException(Code) | | Reads the content of the File opened with the specified encoding and returns it as a String
Parameters: file - the file whose content we want to read Parameters: charset - the charset used to read the content of the file a String containing the content of the file throws: IOException - |
getText | public static String getText(File file) throws IOException(Code) | | Reads the content of the File and returns it as a String
Parameters: file - the file whose content we want to read a String containing the content of the file throws: IOException - |
getText | public static String getText(URL url) throws IOException(Code) | | Reads the content of this URL and returns it as a String
Parameters: url - URL to read content from the text from that URL throws: IOException - |
getText | public static String getText(URL url, String charset) throws IOException(Code) | | Reads the content of this URL and returns it as a String
Parameters: url - URL to read content from Parameters: charset - opens the stream with a specified charset the text from that URL throws: IOException - |
getText | public static String getText(InputStream is, String charset) throws IOException(Code) | | Reads the content of this InputStream with a specified charset and returns it as a String
Parameters: is - an input stream Parameters: charset - opens the stream with a specified charset the text from that URL throws: IOException - |
getText | public static String getText(Reader reader) throws IOException(Code) | | Reads the content of the Reader and returns it as a String
Parameters: reader - a Reader whose content we want to read a String containing the content of the buffered reader throws: IOException - |
getText | public static String getText(BufferedReader reader) throws IOException(Code) | | Reads the content of the BufferedReader and returns it as a String.
The BufferedReader is closed afterwards.
Parameters: reader - a BufferedReader whose content we want to read a String containing the content of the buffered reader throws: IOException - |
grep | public static List grep(Object self, Object filter)(Code) | | Iterates over every element of the collection and return each object that matches
the given filter - calling the isCase() method used by switch statements.
This method can be used with different kinds of filters like regular expresions, classes, ranges etc.
Parameters: self - the object over which we iterate Parameters: filter - the filter to perform on the collection (using the isCase(object) method) a list of objects which match the filter |
groupBy | public static Map groupBy(Collection self, Closure closure)(Code) | | Groups all collection members into groups determined by the
supplied mapping closure.
Parameters: self - a collection to group (no map) Parameters: closure - a closure mapping entries on keys a new Map grouped by keys |
hasGroup | public static boolean hasGroup(Matcher matcher)(Code) | | Check whether a Matcher contains a group or not.
Parameters: matcher - a Matcher boolean true if matcher contains at least one group. |
identity | public static Object identity(Object self, Closure closure)(Code) | | Allows the closure to be called for the object reference self
Parameters: self - the object to have a closure act upon Parameters: closure - the closure to call on the object result of calling the closure |
inject | public static Object inject(Collection self, Object value, Closure closure)(Code) | | Iterates through the given collection, passing in the initial value to
the closure along with the current iterated item then passing into the
next iteration the value of the previous closure.
Parameters: self - a Collection Parameters: value - a value Parameters: closure - a closure the last value of the last iteration |
inject | public static Object inject(Object[] self, Object value, Closure closure)(Code) | | Iterates through the given array of objects, passing in the initial value to
the closure along with the current iterated item then passing into the
next iteration the value of the previous closure.
Parameters: self - an Object[] Parameters: value - a value Parameters: closure - a closure the last value of the last iteration |
inspect | public static String inspect(Object self)(Code) | | a String that matches what would be typed into a terminal tocreate this object. e.g. [1, 'hello'].inspect() -> [1, "hello"] |
intdiv | public static Number intdiv(Character left, Number right)(Code) | | Integer Divide a Character by a Number
Parameters: left - a Character Parameters: right - a Number the integer division of both |
intdiv | public static Number intdiv(Number left, Character right)(Code) | | Integer Divide a Number by a Character
Parameters: left - a Number Parameters: right - a Character the integer division of both |
intdiv | public static Number intdiv(Character left, Character right)(Code) | | Integer Divide two Characters
Parameters: left - a Character Parameters: right - another Character the integer division of both |
intdiv | public static Number intdiv(Number left, Number right)(Code) | | Integer Divide two Numbers
Parameters: left - a Number Parameters: right - another Number a Number (an Integer) resulting of the integer division operation |
intersect | public static List intersect(Collection left, Collection right)(Code) | | Create a List composed of the intersection of both collections
Parameters: left - a Collection Parameters: right - a Collection a List as an intersection of both collections |
invokeMethod | public static Object invokeMethod(Object object, String method, Object arguments)(Code) | | Provide a dynamic method invocation method which can be overloaded in
classes to implement dynamic proxies easily.
|
is | public static boolean is(Object self, Object other)(Code) | | Identity check. Since == is overridden in Groovy with the meaning of equality
we need some fallback to check for object identity.
Parameters: self - Parameters: other - true if self and other are identical, false otherwise |
iterator | public static Iterator iterator(InputStream is)(Code) | | Standard iterator for a input stream which iterates through the stream content in a byte-based fashion.
Parameters: is - |
iterator | public static Iterator iterator(DataInputStream dis)(Code) | | Standard iterator for a data input stream which iterates through the stream content in a byte-based fashion.
Parameters: dis - |
iterator | public static Iterator iterator(File f) throws IOException(Code) | | Standard iterator for a file which iterates through the file content in a line-based fashion.
Parameters: f - throws: IOException - |
join | public static String join(Collection self, String separator)(Code) | | Concatenates all of the items of the collection together with the given String as a separator
Parameters: self - a Collection of objects Parameters: separator - a String separator the joined String |
join | public static String join(Object[] self, String separator)(Code) | | Concatenates all of the elements of the array together with the given String as a separator
Parameters: self - an array of Object Parameters: separator - a String separator the joined String |
leftShift | public static Collection leftShift(Collection self, Object value)(Code) | | Overloads the left shift operator to provide an easy way to append objects to a list
Parameters: self - a Collection Parameters: value - an Object to be added to the collection. a Collection with an Object added to it. |
leftShift | public static StringBuffer leftShift(String self, Object value)(Code) | | Overloads the left shift operator to provide an easy way to append multiple
objects as string representations to a String
Parameters: self - a String Parameters: value - an Obect a StringBuffer |
leftShift | public static StringBuffer leftShift(StringBuffer self, Object value)(Code) | | Overloads the left shift operator to provide an easy way to append multiple
objects as string representations to a StringBuffer
Parameters: self - a StringBuffer Parameters: value - a value to append a StringBuffer |
leftShift | public static Writer leftShift(Writer self, Object value) throws IOException(Code) | | Overloads the left shift operator to provide an append mechanism to add things to a writer
Parameters: self - a Writer Parameters: value - a value to append a StringWriter |
leftShift | public static Number leftShift(Number left, Number right)(Code) | | Implementation of the left shift operator for integral types. Non integral
Number types throw UnsupportedOperationException.
|
leftShift | public static Writer leftShift(OutputStream self, Object value) throws IOException(Code) | | Overloads the left shift operator to provide an append mechanism to add things to a stream
Parameters: self - an OutputStream Parameters: value - a value to append a Writer |
leftShift | public static OutputStream leftShift(OutputStream self, byte[] value) throws IOException(Code) | | Overloads the left shift operator to provide an append mechanism to add bytes to a stream
Parameters: self - an OutputStream Parameters: value - a value to append an OutputStream |
leftShift | public static Writer leftShift(Socket self, Object value) throws IOException(Code) | | Overloads the left shift operator to provide an append mechanism to
add things to the output stream of a socket
Parameters: self - a Socket Parameters: value - a value to append a Writer |
leftShift | public static OutputStream leftShift(Socket self, byte[] value) throws IOException(Code) | | Overloads the left shift operator to provide an append mechanism
to add bytes to the output stream of a socket
Parameters: self - a Socket Parameters: value - a value to append an OutputStream |
leftShift | public static Writer leftShift(Process self, Object value) throws IOException(Code) | | Overloads the left shift operator to provide an append mechanism
to pipe into a Process
Parameters: self - a Process Parameters: value - a value to append a Writer |
leftShift | public static OutputStream leftShift(Process self, byte[] value) throws IOException(Code) | | Overloads the left shift operator to provide an append mechanism
to pipe into a Process
Parameters: self - a Process Parameters: value - a value to append an OutputStream |
max | public static Object max(Collection self)(Code) | | Selects the maximum value found in the collection
Parameters: self - a Collection the maximum value |
max | public static Object max(Collection self, Comparator comparator)(Code) | | Selects the maximum value found in the collection using the given comparator
Parameters: self - a Collection Parameters: comparator - a Comparator the maximum value |
max | public static Object max(Collection self, Closure closure)(Code) | | Selects the maximum value found in the collection using the given closure as a comparator
Parameters: self - a Collection Parameters: closure - a closure used as a comparator the maximum value |
min | public static Object min(Collection self)(Code) | | Selects the minimum value found in the collection
Parameters: self - a Collection the minimum value |
min | public static Object min(Collection self, Comparator comparator)(Code) | | Selects the minimum value found in the collection using the given comparator
Parameters: self - a Collection Parameters: comparator - a Comparator the minimum value |
min | public static Object min(Collection self, Closure closure)(Code) | | Selects the minimum value found in the collection using the given closure as a comparator
Parameters: self - a Collection Parameters: closure - a closure used as a comparator the minimum value |
minus | public static List minus(List self, Collection removeMe)(Code) | | Create a List composed of the elements of the first list minus the elements of the collection
Parameters: self - a List Parameters: removeMe - a Collection of elements to remove a List with the common elements removed |
minus | public static String minus(String left, Object value)(Code) | | Remove a part of a String
Parameters: left - a String Parameters: value - a String part to remove a String minus the part to be removed |
minus | public static Number minus(Character left, Number right)(Code) | | Subtract a Number from a Character
Parameters: left - a Character Parameters: right - a Number the addition of the Character and the Number |
minus | public static Number minus(Number left, Character right)(Code) | | Subtract a Character from a Number
Parameters: left - a Number Parameters: right - a Character the addition of the Character and the Number |
minus | public static Number minus(Character left, Character right)(Code) | | Subtraction two Characters
Parameters: left - a Character Parameters: right - a Character the addition of both Characters |
minus | public static Number minus(Number left, Number right)(Code) | | Substraction of two Numbers
Parameters: left - a Number Parameters: right - another Number to substract to the first one the substraction |
minus | public static Date minus(Date self, int days)(Code) | | Subtracts a number of days from this date and returns the new date
Parameters: self - a Date the new date |
minus | public static java.sql.Date minus(java.sql.Date self, int days)(Code) | | Subtracts a number of days from this date and returns the new date
Parameters: self - a java.sql.Date the new date |
mod | public static Number mod(Number left, Number right)(Code) | | Performs a division modulus operation
Parameters: left - a Number Parameters: right - another Number to mod the modulus result |
multiply | public static List multiply(Collection self, Number factor)(Code) | | Create a List composed of the same elements repeated a certain number of times.
Parameters: self - a Collection Parameters: factor - the number of times to append a List |
multiply | public static String multiply(String self, Number factor)(Code) | | Repeat a String a certain number of times
Parameters: self - a String to be repeated Parameters: factor - the number of times the String should be repeated a String composed of a repeatition throws: IllegalArgumentException - if the number of repeatition is < 0 |
multiply | public static Number multiply(Character left, Number right)(Code) | | Multiply a Character by a Number
Parameters: left - a Character Parameters: right - a Number the multiplication of both |
multiply | public static Number multiply(Number left, Character right)(Code) | | Multiply a Number by a Character
Parameters: left - a Number Parameters: right - a Character the multiplication of both |
multiply | public static Number multiply(Character left, Character right)(Code) | | Multiply two Characters
Parameters: left - a Character Parameters: right - another Character the multiplication of both |
multiply | public static Number multiply(Number left, Number right)(Code) | | Multiply two Numbers
Parameters: left - a Number Parameters: right - another Number the multiplication of both |
multiply | public static Number multiply(BigDecimal left, Double right)(Code) | | Multiply a BigDecimal and a Double.
Note: This method was added to enforce the Groovy rule of
BigDecimal*Double == Double. Without this method, the
multiply(BigDecimal) method in BigDecimal would respond
and return a BigDecimal instead. Since BigDecimal is prefered
over Number, the Number*Number method is not choosen as in older
versions of Groovy.
Parameters: left - a BigDecimal Parameters: right - a Double the multiplication of both |
multiply | public static Number multiply(BigDecimal left, BigInteger right)(Code) | | Multiply a BigDecimal and a BigInteger.
Note: This method was added to enforce the Groovy rule of
BigDecimal*long == long. Without this method, the
multiply(BigDecimal) method in BigDecimal would respond
and return a BigDecimal instead. Since BigDecimal is prefered
over Number, the Number*Number method is not choosen as in older
versions of Groovy. Biginteger is the fallback for all integer
types in Groovy
Parameters: left - a BigDecimal Parameters: right - a BigInteger the multiplication of both |
negate | public static Pattern negate(String self)(Code) | | Turns a String into a regular expression pattern
Parameters: self - a String to convert into a regular expression the regular expression pattern |
negate | public static Number negate(Number left)(Code) | | Negates the number
Parameters: left - a Number the negation of the number |
newReader | public static BufferedReader newReader(InputStream self)(Code) | | Provides a reader for an arbitrary input stream
Parameters: self - an input stream a reader |
newWriter | public static BufferedWriter newWriter(File file, boolean append) throws IOException(Code) | | Helper method to create a buffered writer for a file in append mode
Parameters: file - a File Parameters: append - true if in append mode a BufferedWriter throws: FileNotFoundException - |
newWriter | public static BufferedWriter newWriter(File file, String charset, boolean append) throws IOException(Code) | | Helper method to create a buffered writer for a file
Parameters: file - a File Parameters: charset - the name of the encoding used to write in this file Parameters: append - true if in append mode a BufferedWriter throws: FileNotFoundException - |
next | public static String next(String self)(Code) | | This method is called by the ++ operator for the class String.
It increments the last character in the given string. If the
character in the string is Character.MAX_VALUE a Character.MIN_VALUE
will be appended. The empty string is incremented to a string
consisting of the character Character.MIN_VALUE.
Parameters: self - a String an incremented String |
next | public static Number next(Character self)(Code) | | Increment a Character by one
Parameters: self - a Character an incremented Number |
next | public static Number next(Number self)(Code) | | Increment a Number by one
Parameters: self - a Number an incremented Number |
next | public static Date next(Date self)(Code) | | Increments a Date by a day
Parameters: self - a Date the next days date |
normaliseIndex | protected static int normaliseIndex(int i, int size)(Code) | | This converts a possibly negative index to a real index into the array.
Parameters: i - Parameters: size - |
or | public static Number or(Number left, Number right)(Code) | | Bitwise OR together two numbers
Parameters: left - a Number Parameters: right - another Number to bitwise OR the bitwise OR of both Numbers |
padLeft | public static String padLeft(String self, Number numberOfChars, String padding)(Code) | | Pad a String with the characters appended to the left
Parameters: numberOfChars - the total number of characters Parameters: padding - the charaters used for padding the String padded to the left |
padLeft | public static String padLeft(String self, Number numberOfChars)(Code) | | Pad a String with the spaces appended to the left
Parameters: numberOfChars - the total number of characters the String padded to the left |
padRight | public static String padRight(String self, Number numberOfChars, String padding)(Code) | | Pad a String with the characters appended to the right
Parameters: numberOfChars - the total number of characters Parameters: padding - the charaters used for padding the String padded to the right |
padRight | public static String padRight(String self, Number numberOfChars)(Code) | | Pad a String with the spaces appended to the right
Parameters: numberOfChars - the total number of characters the String padded to the right |
plus | public static List plus(Collection left, Collection right)(Code) | | Create a List as a union of both Collections
Parameters: left - the left Collection Parameters: right - the right Collection a List |
plus | public static List plus(Collection left, Object right)(Code) | | Create a List as a union of a Collection and an Object
Parameters: left - a Collection Parameters: right - an object to append a List |
plus | public static String plus(String left, Object value)(Code) | | Appends a String
Parameters: left - a String Parameters: value - any Object a String |
plus | public static String plus(Number value, String right)(Code) | | Appends a String
Parameters: value - a Number Parameters: right - a String a String |
plus | public static String plus(StringBuffer left, String value)(Code) | | Appends a String
Parameters: left - a StringBuffer Parameters: value - a String a String |
plus | public static Number plus(Character left, Number right)(Code) | | Add a Character and a Number
Parameters: left - a Character Parameters: right - a Number the addition of the Character and the Number |
plus | public static Number plus(Number left, Character right)(Code) | | Add a Number and a Character
Parameters: left - a Number Parameters: right - a Character the addition of the Character and the Number |
plus | public static Number plus(Character left, Character right)(Code) | | Add two Characters
Parameters: left - a Character Parameters: right - a Character the addition of both Characters |
plus | public static Number plus(Number left, Number right)(Code) | | Add two numbers and return the result.
Parameters: left - a Number Parameters: right - another Number to add the addition of both Numbers |
plus | public static Date plus(Date self, int days)(Code) | | Adds a number of days to this date and returns the new date
Parameters: self - a Date Parameters: days - the number of days to increase the new date |
plus | public static java.sql.Date plus(java.sql.Date self, int days)(Code) | | Adds a number of days to this date and returns the new date
Parameters: self - a java.sql.Date Parameters: days - the number of days to increase the new date |
pop | public static Object pop(List self)(Code) | | Removes the last item from the List. Using add() and pop()
is similar to push and pop on a Stack.
Parameters: self - a List the item removed from the List throws: NoSuchElementException - if the list is empty and you try to pop() it. |
power | public static Number power(Number self, Number exponent)(Code) | | Power of a Number to a certain exponent
Parameters: self - a Number Parameters: exponent - a Number exponent a Number to the power of a certain exponent |
previous | public static String previous(String self)(Code) | | This method is called by the -- operator for the class String.
It decrements the last character in the given string. If the
character in the string is Character.MIN_VALUE it will be deleted.
The empty string can't be decremented.
Parameters: self - a String a String with a decremented digit at the end |
previous | public static Number previous(Character self)(Code) | | Decrement a Character by one
Parameters: self - a Character a decremented Number |
previous | public static Number previous(Number self)(Code) | | Decrement a Number by one
Parameters: self - a Number a decremented Number |
previous | public static Date previous(Date self)(Code) | | Decrement a Date by a day
Parameters: self - a Date the previous days date |
previous | public static java.sql.Date previous(java.sql.Date self)(Code) | | Decrement a java.sql.Date by a day
Parameters: self - a java.sql.Date the previous days date |
primitiveArrayGet | protected static Object primitiveArrayGet(Object array, int idx)(Code) | | Implements the getAt(int) method for primitve type arrays
|
primitiveArrayGet | protected static List primitiveArrayGet(Object array, Range range)(Code) | | Implements the getAt(Range) method for primitve type arrays
|
primitiveArrayGet | protected static List primitiveArrayGet(Object self, Collection indices)(Code) | | Implements the getAt(Collection) method for primitve type arrays
|
primitiveArrayPut | protected static void primitiveArrayPut(Object array, int idx, Object newValue)(Code) | | Implements the set(int idx) method for primitve type arrays
|
print | public static void print(Object self, Object value)(Code) | | Print to a console in interactive format
|
printf | public static void printf(Object self, String format, Object[] values)(Code) | | Printf to a console. Only works with JDK1.5 or later.
|
printf | public static void printf(Object self, String format, Object arg)(Code) | | Returns 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: format - A format string Parameters: arg - Argument which is referenced by the format specifiers in the formatstring. The type of arg should be one of Object[], List,int[], short[], byte[], char[], boolean[], long[], float[], or double[]. since: JDK 1.5 |
println | public static void println(Object self)(Code) | | Print a linebreak to the standard out.
|
println | public static void println(Object self, Object value)(Code) | | Print to a console in interactive format along with a newline
|
println | public static void println(Object self, PrintWriter out)(Code) | | Print to a console in interactive format
Parameters: out - the PrintWriter used for printing |
putAt | public static void putAt(Object self, String property, Object newValue)(Code) | | 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 Parameters: property - the name of the property to set Parameters: newValue - the value to set |
putAt | public static void putAt(Object[] array, int idx, Object value)(Code) | | Support the subscript operator for an Array
Parameters: array - an Array of Objects Parameters: idx - an index Parameters: value - an Object to put at the given index |
putAt | public static void putAt(List self, int idx, Object value)(Code) | | A helper method to allow lists to work with subscript operators
Parameters: self - a List Parameters: idx - an index Parameters: value - the value to put at the given index |
putAt | public static void putAt(StringBuffer self, IntRange range, Object value)(Code) | | Support the range subscript operator for StringBuffer
Parameters: self - a StringBuffer Parameters: range - a Range Parameters: value - the object that's toString() will be inserted |
putAt | public static void putAt(StringBuffer self, EmptyRange range, Object value)(Code) | | Support the range subscript operator for StringBuffer
Parameters: self - a StringBuffer Parameters: range - a Range Parameters: value - the object that's toString() will be inserted |
putAt | public static void putAt(List self, EmptyRange range, Object value)(Code) | | A helper method to allow lists to work with subscript operators
Parameters: self - a List Parameters: range - the subset of the list to set Parameters: value - the values to put at the given sublist or a Collection of values |
putAt | public static void putAt(List self, IntRange range, Object value)(Code) | | A helper method to allow lists to work with subscript operators
Parameters: self - a List Parameters: range - the subset of the list to set Parameters: value - the value to put at the given sublist or a Collection of values |
putAt | public static void putAt(List self, List splice, List values)(Code) | | A helper method to allow lists to work with subscript operators
Parameters: self - a List Parameters: splice - the subset of the list to set Parameters: values - the value to put at the given sublist |
putAt | public static void putAt(List self, List splice, Object value)(Code) | | A helper method to allow lists to work with subscript operators
Parameters: self - a List Parameters: splice - the subset of the list to set Parameters: value - the value to put at the given sublist |
putAt | public static Object putAt(Map self, Object key, Object value)(Code) | | A helper method to allow lists to work with subscript operators
Parameters: self - a Map Parameters: key - an Object as a key for the map the value corresponding to the given key |
putAt | public static void putAt(boolean[] array, int idx, Boolean newValue)(Code) | | |
putAt | public static void putAt(byte[] array, int idx, Object newValue)(Code) | | |
putAt | public static void putAt(char[] array, int idx, Object newValue)(Code) | | |
putAt | public static void putAt(short[] array, int idx, Object newValue)(Code) | | |
putAt | public static void putAt(int[] array, int idx, Object newValue)(Code) | | |
putAt | public static void putAt(long[] array, int idx, Object newValue)(Code) | | |
putAt | public static void putAt(float[] array, int idx, Object newValue)(Code) | | |
putAt | public static void putAt(double[] array, int idx, Object newValue)(Code) | | |
readBytes | public static byte[] readBytes(File file) throws IOException(Code) | | Reads the content of the file into an array of byte
Parameters: file - a File a List of Bytes |
readLines | public static List readLines(File file) throws IOException(Code) | | Reads the file into a list of Strings for each line
Parameters: file - a File a List of lines throws: IOException - |
readLines | public static List readLines(Reader reader) throws IOException(Code) | | Reads the reader into a list of Strings for each line
Parameters: reader - a Reader a List of lines throws: IOException - |
replaceAll | public static String replaceAll(String self, String regex, Closure closure)(Code) | | Replaces all occurrencies of a captured group by the result of a closure on that text.
For examples,
assert "FOOBAR-FOOBAR-" == "foobar-FooBar-".replaceAll("(([fF][oO]{2})[bB]ar)", { Object[] it -> it[0].toUpperCase() })
Here,
it[0] is the global string of the matched group
it[1] is the first string in the matched group
it[2] is the second string in the matched group
assert "FOO-FOO-" == "foobar-FooBar-".replaceAll("(([fF][oO]{2})[bB]ar)", { x, y, z -> z.toUpperCase() })
Here,
x is the global string of the matched group
y is the first string in the matched group
z is the second string in the matched group
Parameters: self - a String Parameters: regex - the capturing regex Parameters: closure - the closure to apply on each captured group a String with replaced content |
reverse | public static String reverse(String self)(Code) | | Creates a new string which is the reverse (backwards) of this string
Parameters: self - a String a new string with all the characters reversed. |
reverse | public static List reverse(List self)(Code) | | Reverses the list
Parameters: self - a List a reversed List |
reverseEach | public static void reverseEach(List self, Closure closure)(Code) | | Iterate over each element of the list in the reverse order.
Parameters: self - a List Parameters: closure - a closure |
rightShift | public static Number rightShift(Number left, Number right)(Code) | | Implementation of the right shift operator for integral types. Non integral
Number types throw UnsupportedOperationException.
|
rightShiftUnsigned | public static Number rightShiftUnsigned(Number left, Number right)(Code) | | Implementation of the right shift (unsigned) operator for integral types. Non integral
Number types throw UnsupportedOperationException.
|
round | public static int round(Float number)(Code) | | Get the absolute value
Parameters: number - a Float the absolute value of that Float |
round | public static long round(Double number)(Code) | | Round the value
Parameters: number - a Double the absolute value of that Double |
runAfter | public static void runAfter(Timer timer, int delay, Closure closure)(Code) | | Allow simple syntax for using timers.
Parameters: timer - a timer object Parameters: delay - the delay in milliseconds before running the closure code Parameters: closure - |
setIndex | public static void setIndex(Matcher matcher, int idx)(Code) | | Set the position of the given Matcher to the given index.
Parameters: matcher - a Matcher Parameters: idx - the index number |
size | public static int size(String text)(Code) | | Makes a String look like a Collection by adding support for the size() method
Parameters: text - a String the length of the String |
size | public static int size(StringBuffer buffer)(Code) | | Provide standard Groovy size() method for StringBuffers
Parameters: buffer - a StringBuffer the length of the StringBuffer |
size | public static long size(File file)(Code) | | Provide the standard Groovy size method
|
size | public static long size(Matcher matcher)(Code) | | Provide the standard Groovy size method
|
size | public static int size(Object[] self)(Code) | | Makes an Array look like a Collection by adding support for the size() method
Parameters: self - an Array of Object the size of the Array |
size | public static int size(byte[] array)(Code) | | |
size | public static int size(char[] array)(Code) | | |
size | public static int size(short[] array)(Code) | | |
size | public static int size(int[] array)(Code) | | |
size | public static int size(long[] array)(Code) | | |
size | public static int size(float[] array)(Code) | | |
size | public static int size(double[] array)(Code) | | |
sort | public static List sort(Collection self)(Code) | | Sorts the given collection into a sorted list.
Parameters: self - the collection to be sorted the sorted collection as a List |
sort | public static SortedSet sort(SortedSet self)(Code) | | Avoids doing unnecessary work when sorting an already sorted set
Parameters: self - the sorted set |
sort | public static List sort(Collection self, Comparator comparator)(Code) | | A convenience method for sorting a Collection with a specific comparator
Parameters: self - a collection to be sorted Parameters: comparator - a Comparator used for the comparison a newly created sorted List |
sort | public static List sort(Collection self, Closure closure)(Code) | | A convenience method for sorting a Collection using a closure as a comparator
Parameters: self - a Collection to be sorted Parameters: closure - a Closure used as a comparator a newly created sorted List |
splitEachLine | public static void splitEachLine(File self, String sep, Closure closure) throws IOException(Code) | | Iterates through the given file line by line, splitting on the seperator
Parameters: self - a File Parameters: sep - a String separator Parameters: closure - a closure throws: IOException - |
splitEachLine | public static void splitEachLine(Reader self, String sep, Closure closure) throws IOException(Code) | | Iterates through the given reader line by line, splitting on the separator.
The Reader is closed afterwards.
Parameters: self - a Reader, closed after the method returns Parameters: sep - a String separator Parameters: closure - a closure throws: IOException - |
step | public static void step(Number self, Number to, Number stepNumber, Closure closure)(Code) | | Iterates from this number up to the given number using a step increment
Parameters: self - a Number to start with Parameters: to - a Number to go up to Parameters: stepNumber - a Number representing the step increment Parameters: closure - the closure to call |
subListBorders | protected static RangeInfo subListBorders(int size, IntRange range)(Code) | | |
subListBorders | protected static RangeInfo subListBorders(int size, EmptyRange range)(Code) | | |
subMap | public static Map subMap(Map map, Collection keys)(Code) | | Creates a sub-Map containing the given keys. This method is similar to
List.subList() but uses keys rather than index ranges.
Parameters: map - a Map Parameters: keys - a Collection of keys a new Map containing the given keys |
sum | public static Object sum(Collection self)(Code) | | Sums a collection of numeric values. coll.sum() is equivalent to:
coll.inject(0) {value, item -> value + item} .
Parameters: self - Collection of values to add together. The sum of all of the list itmems. |
sum | public static Object sum(Collection self, Closure closure)(Code) | | Sums the result of apply a closure to each item of a collection.
coll.sum(closure) is equivalent to:
coll.collect(closure).sum() .
Parameters: self - a Collection Parameters: closure - a single parameter closure that returns a numeric value. The sum of the values returned by applying the closure to eachitem of the list. |
times | public static void times(Number self, Closure closure)(Code) | | Iterates a number of times
Parameters: self - a Number Parameters: closure - the closure to call a number of times |
toArrayString | public static String toArrayString(Object[] self)(Code) | | Returns the string representation of the given array with the brace boundaries.
Parameters: self - an Object[] the string representation |
toBigDecimal | public static BigDecimal toBigDecimal(String self)(Code) | | Parse a String into a BigDecimal
Parameters: self - a String a BigDecimal |
toBigDecimal | public static BigDecimal toBigDecimal(Number self)(Code) | | Transform a Number into a BigDecimal
Parameters: self - a Number an BigDecimal |
toBigInteger | public static BigInteger toBigInteger(String self)(Code) | | Parse a String into a BigInteger
Parameters: self - a String a BigInteger |
toBigInteger | public static BigInteger toBigInteger(Number self)(Code) | | Transform a Number into a BigInteger
Parameters: self - a Number an BigInteger |
toBoolean | public static Boolean toBoolean(String self)(Code) | | Converts the given string into a Boolean object
If the trimmed string is "true", "y" or "1" (ignoring case)
then the result is true othewrwise it is false
Parameters: self - a String The Boolean value |
toCharacter | public static Character toCharacter(String self)(Code) | | Converts the given string into a Character object
using the first character in the string
Parameters: self - a String the first Character |
toDouble | public static Double toDouble(String self)(Code) | | Parse a String into a Double
Parameters: self - a String a Double |
toDouble | public static Double toDouble(Number self)(Code) | | Transform a Number into a Double
Parameters: self - a Number an Double |
toFloat | public static Float toFloat(String self)(Code) | | Parse a String into a Float
Parameters: self - a String a Float |
toFloat | public static Float toFloat(Number self)(Code) | | Transform a Number into a Float
Parameters: self - a Number an Float |
toInteger | public static Integer toInteger(String self)(Code) | | Parse a String into an Integer
Parameters: self - a String an Integer |
toInteger | public static Integer toInteger(Number self)(Code) | | Transform a Number into an Integer
Parameters: self - a Number an Integer |
toList | public static List toList(Collection self)(Code) | | Convert a collection to a List.
Parameters: self - a collection a List |
toList | public static List toList(Object[] array)(Code) | | Allows conversion of arrays into a mutable List
Parameters: array - an Array of Objects the array as a List |
toList | public static List toList(byte[] array)(Code) | | |
toList | public static List toList(char[] array)(Code) | | |
toList | public static List toList(short[] array)(Code) | | |
toList | public static List toList(int[] array)(Code) | | |
toList | public static List toList(long[] array)(Code) | | |
toList | public static List toList(float[] array)(Code) | | |
toList | public static List toList(double[] array)(Code) | | |
toList | public static List toList(String self)(Code) | | Converts the given String into a List of strings of one character
Parameters: self - a String a List of characters (a 1-character String) |
toListString | public static String toListString(Collection self)(Code) | | Returns the string representation of the given collection with the bracket boundaries.
Parameters: self - a Collection the string representation |
toLong | public static Long toLong(String self)(Code) | | Parse a String into a Long
Parameters: self - a String a Long |
toLong | public static Long toLong(Number self)(Code) | | Transform a Number into a Long
Parameters: self - a Number an Long |
toMapString | public static String toMapString(Map self)(Code) | | Returns the string representation of the given map with bracket boundaries.
Parameters: self - a Map the string representation |
toSpreadMap | public static SpreadMap toSpreadMap(Map self)(Code) | | Returns the converted SpreadLMap of the given self .
For examples, if there is defined a function like as
def fn(a, b, c, d) { return a + b + c + d }
, then all of the following three have the same meaning.
println fn(a:1, [b:2, c:3].toSpreadMap(), d:4)
println fn(a:1, *:[b:2, c:3], d:4)
println fn(a:1, b:2, c:3, d:4)
Parameters: self - a list to be converted into a spreadmap a newly created Spreadmap if this list is not null and its size is positive. |
toString | public static String toString(Map self)(Code) | | Returns the string representation of the given map with bracket boundaries.
Parameters: self - a Map the string representation |
toString | public static String toString(Collection self)(Code) | | Returns the string representation of the given collection with the bracket boundaries.
Parameters: self - a Collection the string representation |
toString | public static String toString(Object[] self)(Code) | | Returns the string representation of the given array with the brace boundaries.
Parameters: self - an Object[] the string representation |
toURI | public static URI toURI(String self) throws URISyntaxException(Code) | | Transforms a String representing a URI into a URI object.
Parameters: self - the String representing a URI a URI throws: URISyntaxException - is thrown if the URI is not well formed. |
tokenize | public static List tokenize(String self, String token)(Code) | | Tokenize a String
Parameters: self - a String Parameters: token - the delimiter a List of tokens |
tokenize | public static List tokenize(String self)(Code) | | Tokenize a String (with a whitespace as delimiter)
Parameters: self - a String a List of tokens |
transformChar | public static void transformChar(Reader reader, Writer writer, Closure closure) throws IOException(Code) | | Transforms the characters from a reader with a Closure and
write them to a writer.
Parameters: reader - Parameters: writer - Parameters: closure - |
transformLine | public static void transformLine(Reader reader, Writer writer, Closure closure) throws IOException(Code) | | Transforms the lines from a reader with a Closure and
write them to a writer. Both Reader and Writer are
closed after the operation
Parameters: reader - Lines of text to be transformed. Reader is closed afterwards. Parameters: writer - Where transformed lines are written. Writer is closed afterwards. Parameters: closure - Single parameter closure that is called to transform each line oftext from the reader, before writing it to the writer. |
unique | public static Collection unique(Collection self, Closure closure)(Code) | | A convenience method for making a collection unique using a closure as a comparator
(by Michael Baehr)
Parameters: self - a Collection Parameters: closure - a Closure used as a comparator self without any duplicates |
unique | public static Collection unique(Collection self, Comparator comparator)(Code) | | Remove all duplicates from a given Collection.
Works on the receiver object and returns it.
The order of members in the Collection are compared by the given Comparator.
For each duplicate, the first member which is returned
by the given Collection's iterator is retained, but all other ones are removed.
The given Collection's original order is preserved.
class Person {
Parameters: self - a Collection Parameters: comparator - a Comparator. self without duplicates
|
upto | public static void upto(Number self, Number to, Closure closure)(Code) | | Iterates from this number up to the given number
Parameters: self - a Number Parameters: to - another Number to go up to Parameters: closure - the closure to call |
use | public static void use(Object self, List categoryClassList, Closure closure)(Code) | | Scoped use method with list of categories
|
use | public static void use(Object self, Object[] array)(Code) | | use() a list of categories, specifying the list as varargs:
use(CategoryClass1, CategoryClass2) { ... }
This method prevents the error of forgetting to wrap the the category
classes in a list.
Parameters: self - Parameters: array - |
waitForOrKill | public static void waitForOrKill(Process self, long numberOfMillis)(Code) | | Wait for the process to finish during a certain amount of time, otherwise stops the process.
Parameters: self - a Process Parameters: numberOfMillis - the number of milliseconds to wait before stopping the process |
withInputStream | public static void withInputStream(File file, Closure closure) throws IOException(Code) | | Helper method to create a new InputStream for a file and then
passes it into the closure and ensures its closed again afterwords
Parameters: file - a File throws: FileNotFoundException - |
withOutputStream | public static void withOutputStream(File file, Closure closure) throws IOException(Code) | | Helper method to create a new OutputStream for a file and then
passes it into the closure and ensures its closed again afterwords
Parameters: file - a File throws: FileNotFoundException - |
withPrintWriter | public static void withPrintWriter(File file, Closure closure) throws IOException(Code) | | Helper method to create a new PrintWriter for a file and then
passes it into the closure and ensures its closed again afterwords
Parameters: file - a File throws: FileNotFoundException - |
withReader | public static void withReader(File file, Closure closure) throws IOException(Code) | | Helper method to create a new BufferedReader for a file and then
passes it into the closure and ensures its closed again afterwords
Parameters: file - throws: FileNotFoundException - |
withReader | public static void withReader(Reader reader, Closure closure) throws IOException(Code) | | Allows a Reader to be used, calling the closure with the reader
and then ensuring that the reader is closed down again irrespective
of whether exceptions occur or the
Parameters: reader - the reader which is used and then closed Parameters: closure - the closure that the writer is passed into throws: IOException - |
withReader | public static void withReader(URL url, Closure closure) throws IOException(Code) | | Helper method to create a new BufferedReader for a URL and then
passes it into the closure and ensures its closed again afterwords
Parameters: url - a URL throws: FileNotFoundException - |
withReader | public static void withReader(InputStream in, Closure closure) throws IOException(Code) | | Helper method to create a new BufferedReader for a stream and then
passes it into the closure and ensures its closed again afterwords
Parameters: in - a stream throws: FileNotFoundException - |
withStream | public static void withStream(InputStream stream, Closure closure) throws IOException(Code) | | Allows a InputStream to be used, calling the closure with the stream
and then ensuring that the stream is closed down again irrespective
of whether exceptions occur or the
Parameters: stream - the stream which is used and then closed Parameters: closure - the closure that the stream is passed into throws: IOException - |
withStream | public static void withStream(OutputStream os, Closure closure) throws IOException(Code) | | Allows a OutputStream to be used, calling the closure with the stream
and then ensuring that the stream is closed down again irrespective
of whether exceptions occur.
Parameters: os - the stream which is used and then closed Parameters: closure - the closure that the stream is passed into throws: IOException - |
withStreams | public static void withStreams(Socket socket, Closure closure) throws IOException(Code) | | Allows an InputStream and an OutputStream from a Socket to be used,
calling the closure with the streams and then ensuring that the streams
are closed down again irrespective of whether exceptions occur.
Parameters: socket - a Socket Parameters: closure - a Closure throws: IOException - |
withWriter | public static void withWriter(File file, Closure closure) throws IOException(Code) | | Helper method to create a new BufferedWriter for a file and then
passes it into the closure and ensures it is closed again afterwords
Parameters: file - a File Parameters: closure - a closure throws: FileNotFoundException - |
withWriter | public static void withWriter(File file, String charset, Closure closure) throws IOException(Code) | | Helper method to create a new BufferedWriter for a file in a specified encoding
and then passes it into the closure and ensures it is closed again afterwords
Parameters: file - a File Parameters: charset - the charset used Parameters: closure - a closure throws: FileNotFoundException - |
withWriter | public static void withWriter(Writer writer, Closure closure) throws IOException(Code) | | Allows a writer to be used, calling the closure with the writer
and then ensuring that the writer is closed down again irrespective
of whether exceptions occur or the
Parameters: writer - the writer which is used and then closed Parameters: closure - the closure that the writer is passed into throws: IOException - |
withWriter | public static void withWriter(OutputStream stream, Closure closure) throws IOException(Code) | | Allows an output stream to be used, calling the closure with the output stream
and then ensuring that the output stream is closed down again irrespective
of whether exceptions occur
Parameters: stream - the stream which is used and then closed Parameters: closure - the closure that the writer is passed into throws: IOException - |
withWriter | public static void withWriter(OutputStream stream, String charset, Closure closure) throws IOException(Code) | | Allows an output stream to be used, calling the closure with the output stream
and then ensuring that the output stream is closed down again irrespective
of whether exceptions occur.
Parameters: stream - the stream which is used and then closed Parameters: charset - the charset used Parameters: closure - the closure that the writer is passed into throws: IOException - |
withWriterAppend | public static void withWriterAppend(File file, String charset, Closure closure) throws IOException(Code) | | Helper method to create a new BufferedWriter for a file in a specified encoding
in append mode and then passes it into the closure and ensures it is closed again afterwords
Parameters: file - a File Parameters: charset - the charset used Parameters: closure - a closure throws: FileNotFoundException - |
write | public static void write(Writer self, Writable writable) throws IOException(Code) | | 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.
Parameters: self - a Writer Parameters: writable - an object implementing the Writable interface |
write | public static void write(File file, String text) throws IOException(Code) | | Write the text to the File.
Parameters: file - a File Parameters: text - the text to write to the File throws: IOException - |
write | public static void write(File file, String text, String charset) throws IOException(Code) | | Write the text to the File with a specified encoding.
Parameters: file - a File Parameters: text - the text to write to the File Parameters: charset - the charset used throws: IOException - |
writeLine | public static void writeLine(BufferedWriter writer, String line) throws IOException(Code) | | Write the text and append a new line (depending on the platform
line-ending)
Parameters: writer - a BufferedWriter Parameters: line - the line to write throws: IOException - |
xor | public static Number xor(Number left, Number right)(Code) | | Bitwise XOR together two Numbers
Parameters: left - a Number Parameters: right - another Number to bitwse XOR the bitwise XOR of both Numbers |
|
|