id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
156,500
groovy/groovy-core
src/main/org/codehaus/groovy/ast/MethodNode.java
MethodNode.getText
@Override public String getText() { String retType = AstToTextHelper.getClassText(returnType); String exceptionTypes = AstToTextHelper.getThrowsClauseText(exceptions); String parms = AstToTextHelper.getParametersText(parameters); return AstToTextHelper.getModifiersText(modifiers) + " " + retType + " " + name + "(" + parms + ") " + exceptionTypes + " { ... }"; }
java
@Override public String getText() { String retType = AstToTextHelper.getClassText(returnType); String exceptionTypes = AstToTextHelper.getThrowsClauseText(exceptions); String parms = AstToTextHelper.getParametersText(parameters); return AstToTextHelper.getModifiersText(modifiers) + " " + retType + " " + name + "(" + parms + ") " + exceptionTypes + " { ... }"; }
[ "@", "Override", "public", "String", "getText", "(", ")", "{", "String", "retType", "=", "AstToTextHelper", ".", "getClassText", "(", "returnType", ")", ";", "String", "exceptionTypes", "=", "AstToTextHelper", ".", "getThrowsClauseText", "(", "exceptions", ")", ";", "String", "parms", "=", "AstToTextHelper", ".", "getParametersText", "(", "parameters", ")", ";", "return", "AstToTextHelper", ".", "getModifiersText", "(", "modifiers", ")", "+", "\" \"", "+", "retType", "+", "\" \"", "+", "name", "+", "\"(\"", "+", "parms", "+", "\") \"", "+", "exceptionTypes", "+", "\" { ... }\"", ";", "}" ]
Provides a nicely formatted string of the method definition. For simplicity, generic types on some of the elements are not displayed. @return string form of node with some generic elements suppressed
[ "Provides", "a", "nicely", "formatted", "string", "of", "the", "method", "definition", ".", "For", "simplicity", "generic", "types", "on", "some", "of", "the", "elements", "are", "not", "displayed", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/ast/MethodNode.java#L300-L306
156,501
groovy/groovy-core
subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
SimpleGroovyClassDoc.constructors
public GroovyConstructorDoc[] constructors() { Collections.sort(constructors); return constructors.toArray(new GroovyConstructorDoc[constructors.size()]); }
java
public GroovyConstructorDoc[] constructors() { Collections.sort(constructors); return constructors.toArray(new GroovyConstructorDoc[constructors.size()]); }
[ "public", "GroovyConstructorDoc", "[", "]", "constructors", "(", ")", "{", "Collections", ".", "sort", "(", "constructors", ")", ";", "return", "constructors", ".", "toArray", "(", "new", "GroovyConstructorDoc", "[", "constructors", ".", "size", "(", ")", "]", ")", ";", "}" ]
returns a sorted array of constructors
[ "returns", "a", "sorted", "array", "of", "constructors" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java#L100-L103
156,502
groovy/groovy-core
subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
SimpleGroovyClassDoc.innerClasses
public GroovyClassDoc[] innerClasses() { Collections.sort(nested); return nested.toArray(new GroovyClassDoc[nested.size()]); }
java
public GroovyClassDoc[] innerClasses() { Collections.sort(nested); return nested.toArray(new GroovyClassDoc[nested.size()]); }
[ "public", "GroovyClassDoc", "[", "]", "innerClasses", "(", ")", "{", "Collections", ".", "sort", "(", "nested", ")", ";", "return", "nested", ".", "toArray", "(", "new", "GroovyClassDoc", "[", "nested", ".", "size", "(", ")", "]", ")", ";", "}" ]
returns a sorted array of nested classes and interfaces
[ "returns", "a", "sorted", "array", "of", "nested", "classes", "and", "interfaces" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java#L129-L132
156,503
groovy/groovy-core
subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
SimpleGroovyClassDoc.fields
public GroovyFieldDoc[] fields() { Collections.sort(fields); return fields.toArray(new GroovyFieldDoc[fields.size()]); }
java
public GroovyFieldDoc[] fields() { Collections.sort(fields); return fields.toArray(new GroovyFieldDoc[fields.size()]); }
[ "public", "GroovyFieldDoc", "[", "]", "fields", "(", ")", "{", "Collections", ".", "sort", "(", "fields", ")", ";", "return", "fields", ".", "toArray", "(", "new", "GroovyFieldDoc", "[", "fields", ".", "size", "(", ")", "]", ")", ";", "}" ]
returns a sorted array of fields
[ "returns", "a", "sorted", "array", "of", "fields" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java#L141-L144
156,504
groovy/groovy-core
subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
SimpleGroovyClassDoc.properties
public GroovyFieldDoc[] properties() { Collections.sort(properties); return properties.toArray(new GroovyFieldDoc[properties.size()]); }
java
public GroovyFieldDoc[] properties() { Collections.sort(properties); return properties.toArray(new GroovyFieldDoc[properties.size()]); }
[ "public", "GroovyFieldDoc", "[", "]", "properties", "(", ")", "{", "Collections", ".", "sort", "(", "properties", ")", ";", "return", "properties", ".", "toArray", "(", "new", "GroovyFieldDoc", "[", "properties", ".", "size", "(", ")", "]", ")", ";", "}" ]
returns a sorted array of properties
[ "returns", "a", "sorted", "array", "of", "properties" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java#L153-L156
156,505
groovy/groovy-core
subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
SimpleGroovyClassDoc.enumConstants
public GroovyFieldDoc[] enumConstants() { Collections.sort(enumConstants); return enumConstants.toArray(new GroovyFieldDoc[enumConstants.size()]); }
java
public GroovyFieldDoc[] enumConstants() { Collections.sort(enumConstants); return enumConstants.toArray(new GroovyFieldDoc[enumConstants.size()]); }
[ "public", "GroovyFieldDoc", "[", "]", "enumConstants", "(", ")", "{", "Collections", ".", "sort", "(", "enumConstants", ")", ";", "return", "enumConstants", ".", "toArray", "(", "new", "GroovyFieldDoc", "[", "enumConstants", ".", "size", "(", ")", "]", ")", ";", "}" ]
returns a sorted array of enum constants
[ "returns", "a", "sorted", "array", "of", "enum", "constants" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java#L165-L168
156,506
groovy/groovy-core
subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
SimpleGroovyClassDoc.methods
public GroovyMethodDoc[] methods() { Collections.sort(methods); return methods.toArray(new GroovyMethodDoc[methods.size()]); }
java
public GroovyMethodDoc[] methods() { Collections.sort(methods); return methods.toArray(new GroovyMethodDoc[methods.size()]); }
[ "public", "GroovyMethodDoc", "[", "]", "methods", "(", ")", "{", "Collections", ".", "sort", "(", "methods", ")", ";", "return", "methods", ".", "toArray", "(", "new", "GroovyMethodDoc", "[", "methods", ".", "size", "(", ")", "]", ")", ";", "}" ]
returns a sorted array of methods
[ "returns", "a", "sorted", "array", "of", "methods" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java#L177-L180
156,507
groovy/groovy-core
subprojects/groovy-sql/src/main/java/groovy/sql/DataSet.java
DataSet.add
public void add(Map<String, Object> map) throws SQLException { if (withinDataSetBatch) { if (batchData.size() == 0) { batchKeys = map.keySet(); } else { if (!map.keySet().equals(batchKeys)) { throw new IllegalArgumentException("Inconsistent keys found for batch add!"); } } batchData.add(map); return; } int answer = executeUpdate(buildListQuery(map), new ArrayList<Object>(map.values())); if (answer != 1) { LOG.warning("Should have updated 1 row not " + answer + " when trying to add: " + map); } }
java
public void add(Map<String, Object> map) throws SQLException { if (withinDataSetBatch) { if (batchData.size() == 0) { batchKeys = map.keySet(); } else { if (!map.keySet().equals(batchKeys)) { throw new IllegalArgumentException("Inconsistent keys found for batch add!"); } } batchData.add(map); return; } int answer = executeUpdate(buildListQuery(map), new ArrayList<Object>(map.values())); if (answer != 1) { LOG.warning("Should have updated 1 row not " + answer + " when trying to add: " + map); } }
[ "public", "void", "add", "(", "Map", "<", "String", ",", "Object", ">", "map", ")", "throws", "SQLException", "{", "if", "(", "withinDataSetBatch", ")", "{", "if", "(", "batchData", ".", "size", "(", ")", "==", "0", ")", "{", "batchKeys", "=", "map", ".", "keySet", "(", ")", ";", "}", "else", "{", "if", "(", "!", "map", ".", "keySet", "(", ")", ".", "equals", "(", "batchKeys", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Inconsistent keys found for batch add!\"", ")", ";", "}", "}", "batchData", ".", "add", "(", "map", ")", ";", "return", ";", "}", "int", "answer", "=", "executeUpdate", "(", "buildListQuery", "(", "map", ")", ",", "new", "ArrayList", "<", "Object", ">", "(", "map", ".", "values", "(", ")", ")", ")", ";", "if", "(", "answer", "!=", "1", ")", "{", "LOG", ".", "warning", "(", "\"Should have updated 1 row not \"", "+", "answer", "+", "\" when trying to add: \"", "+", "map", ")", ";", "}", "}" ]
Adds the provided map of key-value pairs as a new row in the table represented by this DataSet. @param map the key (column-name), value pairs to add as a new row @throws SQLException if a database error occurs
[ "Adds", "the", "provided", "map", "of", "key", "-", "value", "pairs", "as", "a", "new", "row", "in", "the", "table", "represented", "by", "this", "DataSet", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/subprojects/groovy-sql/src/main/java/groovy/sql/DataSet.java#L233-L249
156,508
groovy/groovy-core
subprojects/groovy-sql/src/main/java/groovy/sql/DataSet.java
DataSet.each
public void each(int offset, int maxRows, Closure closure) throws SQLException { eachRow(getSql(), getParameters(), offset, maxRows, closure); }
java
public void each(int offset, int maxRows, Closure closure) throws SQLException { eachRow(getSql(), getParameters(), offset, maxRows, closure); }
[ "public", "void", "each", "(", "int", "offset", ",", "int", "maxRows", ",", "Closure", "closure", ")", "throws", "SQLException", "{", "eachRow", "(", "getSql", "(", ")", ",", "getParameters", "(", ")", ",", "offset", ",", "maxRows", ",", "closure", ")", ";", "}" ]
Calls the provided closure for a "page" of rows from the table represented by this DataSet. A page is defined as starting at a 1-based offset, and containing a maximum number of rows. @param offset the 1-based offset for the first row to be processed @param maxRows the maximum number of rows to be processed @param closure called for each row with a GroovyResultSet @throws SQLException if a database access error occurs @see groovy.sql.Sql#eachRow(String, java.util.List, int, int, groovy.lang.Closure)
[ "Calls", "the", "provided", "closure", "for", "a", "page", "of", "rows", "from", "the", "table", "represented", "by", "this", "DataSet", ".", "A", "page", "is", "defined", "as", "starting", "at", "a", "1", "-", "based", "offset", "and", "containing", "a", "maximum", "number", "of", "rows", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/subprojects/groovy-sql/src/main/java/groovy/sql/DataSet.java#L349-L351
156,509
groovy/groovy-core
src/main/groovy/beans/VetoableASTTransformation.java
VetoableASTTransformation.wrapSetterMethod
private void wrapSetterMethod(ClassNode classNode, boolean bindable, String propertyName) { String getterName = "get" + MetaClassHelper.capitalize(propertyName); MethodNode setter = classNode.getSetterMethod("set" + MetaClassHelper.capitalize(propertyName)); if (setter != null) { // Get the existing code block Statement code = setter.getCode(); Expression oldValue = varX("$oldValue"); Expression newValue = varX("$newValue"); Expression proposedValue = varX(setter.getParameters()[0].getName()); BlockStatement block = new BlockStatement(); // create a local variable to hold the old value from the getter block.addStatement(declS(oldValue, callThisX(getterName))); // add the fireVetoableChange method call block.addStatement(stmt(callThisX("fireVetoableChange", args( constX(propertyName), oldValue, proposedValue)))); // call the existing block, which will presumably set the value properly block.addStatement(code); if (bindable) { // get the new value to emit in the event block.addStatement(declS(newValue, callThisX(getterName))); // add the firePropertyChange method call block.addStatement(stmt(callThisX("firePropertyChange", args(constX(propertyName), oldValue, newValue)))); } // replace the existing code block with our new one setter.setCode(block); } }
java
private void wrapSetterMethod(ClassNode classNode, boolean bindable, String propertyName) { String getterName = "get" + MetaClassHelper.capitalize(propertyName); MethodNode setter = classNode.getSetterMethod("set" + MetaClassHelper.capitalize(propertyName)); if (setter != null) { // Get the existing code block Statement code = setter.getCode(); Expression oldValue = varX("$oldValue"); Expression newValue = varX("$newValue"); Expression proposedValue = varX(setter.getParameters()[0].getName()); BlockStatement block = new BlockStatement(); // create a local variable to hold the old value from the getter block.addStatement(declS(oldValue, callThisX(getterName))); // add the fireVetoableChange method call block.addStatement(stmt(callThisX("fireVetoableChange", args( constX(propertyName), oldValue, proposedValue)))); // call the existing block, which will presumably set the value properly block.addStatement(code); if (bindable) { // get the new value to emit in the event block.addStatement(declS(newValue, callThisX(getterName))); // add the firePropertyChange method call block.addStatement(stmt(callThisX("firePropertyChange", args(constX(propertyName), oldValue, newValue)))); } // replace the existing code block with our new one setter.setCode(block); } }
[ "private", "void", "wrapSetterMethod", "(", "ClassNode", "classNode", ",", "boolean", "bindable", ",", "String", "propertyName", ")", "{", "String", "getterName", "=", "\"get\"", "+", "MetaClassHelper", ".", "capitalize", "(", "propertyName", ")", ";", "MethodNode", "setter", "=", "classNode", ".", "getSetterMethod", "(", "\"set\"", "+", "MetaClassHelper", ".", "capitalize", "(", "propertyName", ")", ")", ";", "if", "(", "setter", "!=", "null", ")", "{", "// Get the existing code block\r", "Statement", "code", "=", "setter", ".", "getCode", "(", ")", ";", "Expression", "oldValue", "=", "varX", "(", "\"$oldValue\"", ")", ";", "Expression", "newValue", "=", "varX", "(", "\"$newValue\"", ")", ";", "Expression", "proposedValue", "=", "varX", "(", "setter", ".", "getParameters", "(", ")", "[", "0", "]", ".", "getName", "(", ")", ")", ";", "BlockStatement", "block", "=", "new", "BlockStatement", "(", ")", ";", "// create a local variable to hold the old value from the getter\r", "block", ".", "addStatement", "(", "declS", "(", "oldValue", ",", "callThisX", "(", "getterName", ")", ")", ")", ";", "// add the fireVetoableChange method call\r", "block", ".", "addStatement", "(", "stmt", "(", "callThisX", "(", "\"fireVetoableChange\"", ",", "args", "(", "constX", "(", "propertyName", ")", ",", "oldValue", ",", "proposedValue", ")", ")", ")", ")", ";", "// call the existing block, which will presumably set the value properly\r", "block", ".", "addStatement", "(", "code", ")", ";", "if", "(", "bindable", ")", "{", "// get the new value to emit in the event\r", "block", ".", "addStatement", "(", "declS", "(", "newValue", ",", "callThisX", "(", "getterName", ")", ")", ")", ";", "// add the firePropertyChange method call\r", "block", ".", "addStatement", "(", "stmt", "(", "callThisX", "(", "\"firePropertyChange\"", ",", "args", "(", "constX", "(", "propertyName", ")", ",", "oldValue", ",", "newValue", ")", ")", ")", ")", ";", "}", "// replace the existing code block with our new one\r", "setter", ".", "setCode", "(", "block", ")", ";", "}", "}" ]
Wrap an existing setter.
[ "Wrap", "an", "existing", "setter", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/groovy/beans/VetoableASTTransformation.java#L169-L203
156,510
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
ResourceGroovyMethods.directorySize
public static long directorySize(File self) throws IOException, IllegalArgumentException { final long[] size = {0L}; eachFileRecurse(self, FileType.FILES, new Closure<Void>(null) { public void doCall(Object[] args) { size[0] += ((File) args[0]).length(); } }); return size[0]; }
java
public static long directorySize(File self) throws IOException, IllegalArgumentException { final long[] size = {0L}; eachFileRecurse(self, FileType.FILES, new Closure<Void>(null) { public void doCall(Object[] args) { size[0] += ((File) args[0]).length(); } }); return size[0]; }
[ "public", "static", "long", "directorySize", "(", "File", "self", ")", "throws", "IOException", ",", "IllegalArgumentException", "{", "final", "long", "[", "]", "size", "=", "{", "0L", "}", ";", "eachFileRecurse", "(", "self", ",", "FileType", ".", "FILES", ",", "new", "Closure", "<", "Void", ">", "(", "null", ")", "{", "public", "void", "doCall", "(", "Object", "[", "]", "args", ")", "{", "size", "[", "0", "]", "+=", "(", "(", "File", ")", "args", "[", "0", "]", ")", ".", "length", "(", ")", ";", "}", "}", ")", ";", "return", "size", "[", "0", "]", ";", "}" ]
Calculates directory size as total size of all its files, recursively. @param self a file object @return directory size (length) @since 2.1 @throws IOException if File object specified does not exist @throws IllegalArgumentException if the provided File object does not represent a directory
[ "Calculates", "directory", "size", "as", "total", "size", "of", "all", "its", "files", "recursively", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java#L118-L129
156,511
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
ResourceGroovyMethods.splitEachLine
public static <T> T splitEachLine(File self, String regex, @ClosureParams(value=SimpleType.class, options="java.lang.String[]") Closure<T> closure) throws IOException { return IOGroovyMethods.splitEachLine(newReader(self), regex, closure); }
java
public static <T> T splitEachLine(File self, String regex, @ClosureParams(value=SimpleType.class, options="java.lang.String[]") Closure<T> closure) throws IOException { return IOGroovyMethods.splitEachLine(newReader(self), regex, closure); }
[ "public", "static", "<", "T", ">", "T", "splitEachLine", "(", "File", "self", ",", "String", "regex", ",", "@", "ClosureParams", "(", "value", "=", "SimpleType", ".", "class", ",", "options", "=", "\"java.lang.String[]\"", ")", "Closure", "<", "T", ">", "closure", ")", "throws", "IOException", "{", "return", "IOGroovyMethods", ".", "splitEachLine", "(", "newReader", "(", "self", ")", ",", "regex", ",", "closure", ")", ";", "}" ]
Iterates through this file line by line, splitting each line using the given regex separator. For each line, the given closure is called with a single parameter being the list of strings computed by splitting the line around matches of the given regular expression. Finally the resources used for processing the file are closed. @param self a File @param regex the delimiting regular expression @param closure a closure @return the last value returned by the closure @throws IOException if an IOException occurs. @throws java.util.regex.PatternSyntaxException if the regular expression's syntax is invalid @see IOGroovyMethods#splitEachLine(java.io.Reader, java.lang.String, groovy.lang.Closure) @since 1.5.5
[ "Iterates", "through", "this", "file", "line", "by", "line", "splitting", "each", "line", "using", "the", "given", "regex", "separator", ".", "For", "each", "line", "the", "given", "closure", "is", "called", "with", "a", "single", "parameter", "being", "the", "list", "of", "strings", "computed", "by", "splitting", "the", "line", "around", "matches", "of", "the", "given", "regular", "expression", ".", "Finally", "the", "resources", "used", "for", "processing", "the", "file", "are", "closed", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java#L378-L380
156,512
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
ResourceGroovyMethods.write
public static void write(File file, String text, String charset) throws IOException { Writer writer = null; try { FileOutputStream out = new FileOutputStream(file); writeUTF16BomIfRequired(charset, out); writer = new OutputStreamWriter(out, charset); writer.write(text); writer.flush(); Writer temp = writer; writer = null; temp.close(); } finally { closeWithWarning(writer); } }
java
public static void write(File file, String text, String charset) throws IOException { Writer writer = null; try { FileOutputStream out = new FileOutputStream(file); writeUTF16BomIfRequired(charset, out); writer = new OutputStreamWriter(out, charset); writer.write(text); writer.flush(); Writer temp = writer; writer = null; temp.close(); } finally { closeWithWarning(writer); } }
[ "public", "static", "void", "write", "(", "File", "file", ",", "String", "text", ",", "String", "charset", ")", "throws", "IOException", "{", "Writer", "writer", "=", "null", ";", "try", "{", "FileOutputStream", "out", "=", "new", "FileOutputStream", "(", "file", ")", ";", "writeUTF16BomIfRequired", "(", "charset", ",", "out", ")", ";", "writer", "=", "new", "OutputStreamWriter", "(", "out", ",", "charset", ")", ";", "writer", ".", "write", "(", "text", ")", ";", "writer", ".", "flush", "(", ")", ";", "Writer", "temp", "=", "writer", ";", "writer", "=", "null", ";", "temp", ".", "close", "(", ")", ";", "}", "finally", "{", "closeWithWarning", "(", "writer", ")", ";", "}", "}" ]
Write the text to the File, using the specified encoding. @param file a File @param text the text to write to the File @param charset the charset used @throws IOException if an IOException occurs. @since 1.0
[ "Write", "the", "text", "to", "the", "File", "using", "the", "specified", "encoding", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java#L817-L832
156,513
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
ResourceGroovyMethods.append
public static void append(File file, Object text) throws IOException { Writer writer = null; try { writer = new FileWriter(file, true); InvokerHelper.write(writer, text); writer.flush(); Writer temp = writer; writer = null; temp.close(); } finally { closeWithWarning(writer); } }
java
public static void append(File file, Object text) throws IOException { Writer writer = null; try { writer = new FileWriter(file, true); InvokerHelper.write(writer, text); writer.flush(); Writer temp = writer; writer = null; temp.close(); } finally { closeWithWarning(writer); } }
[ "public", "static", "void", "append", "(", "File", "file", ",", "Object", "text", ")", "throws", "IOException", "{", "Writer", "writer", "=", "null", ";", "try", "{", "writer", "=", "new", "FileWriter", "(", "file", ",", "true", ")", ";", "InvokerHelper", ".", "write", "(", "writer", ",", "text", ")", ";", "writer", ".", "flush", "(", ")", ";", "Writer", "temp", "=", "writer", ";", "writer", "=", "null", ";", "temp", ".", "close", "(", ")", ";", "}", "finally", "{", "closeWithWarning", "(", "writer", ")", ";", "}", "}" ]
Append the text at the end of the File. @param file a File @param text the text to append at the end of the File @throws IOException if an IOException occurs. @since 1.0
[ "Append", "the", "text", "at", "the", "end", "of", "the", "File", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java#L842-L855
156,514
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
ResourceGroovyMethods.append
public static void append(File file, Object text, String charset) throws IOException { Writer writer = null; try { FileOutputStream out = new FileOutputStream(file, true); if (!file.exists()) { writeUTF16BomIfRequired(charset, out); } writer = new OutputStreamWriter(out, charset); InvokerHelper.write(writer, text); writer.flush(); Writer temp = writer; writer = null; temp.close(); } finally { closeWithWarning(writer); } }
java
public static void append(File file, Object text, String charset) throws IOException { Writer writer = null; try { FileOutputStream out = new FileOutputStream(file, true); if (!file.exists()) { writeUTF16BomIfRequired(charset, out); } writer = new OutputStreamWriter(out, charset); InvokerHelper.write(writer, text); writer.flush(); Writer temp = writer; writer = null; temp.close(); } finally { closeWithWarning(writer); } }
[ "public", "static", "void", "append", "(", "File", "file", ",", "Object", "text", ",", "String", "charset", ")", "throws", "IOException", "{", "Writer", "writer", "=", "null", ";", "try", "{", "FileOutputStream", "out", "=", "new", "FileOutputStream", "(", "file", ",", "true", ")", ";", "if", "(", "!", "file", ".", "exists", "(", ")", ")", "{", "writeUTF16BomIfRequired", "(", "charset", ",", "out", ")", ";", "}", "writer", "=", "new", "OutputStreamWriter", "(", "out", ",", "charset", ")", ";", "InvokerHelper", ".", "write", "(", "writer", ",", "text", ")", ";", "writer", ".", "flush", "(", ")", ";", "Writer", "temp", "=", "writer", ";", "writer", "=", "null", ";", "temp", ".", "close", "(", ")", ";", "}", "finally", "{", "closeWithWarning", "(", "writer", ")", ";", "}", "}" ]
Append the text at the end of the File, using a specified encoding. @param file a File @param text the text to append at the end of the File @param charset the charset used @throws IOException if an IOException occurs. @since 1.0
[ "Append", "the", "text", "at", "the", "end", "of", "the", "File", "using", "a", "specified", "encoding", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java#L946-L963
156,515
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
ResourceGroovyMethods.append
public static void append(File file, Writer writer, String charset) throws IOException { appendBuffered(file, writer, charset); }
java
public static void append(File file, Writer writer, String charset) throws IOException { appendBuffered(file, writer, charset); }
[ "public", "static", "void", "append", "(", "File", "file", ",", "Writer", "writer", ",", "String", "charset", ")", "throws", "IOException", "{", "appendBuffered", "(", "file", ",", "writer", ",", "charset", ")", ";", "}" ]
Append the text supplied by the Writer at the end of the File, using a specified encoding. @param file a File @param writer the Writer supplying the text to append at the end of the File @param charset the charset used @throws IOException if an IOException occurs. @since 2.3
[ "Append", "the", "text", "supplied", "by", "the", "Writer", "at", "the", "end", "of", "the", "File", "using", "a", "specified", "encoding", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java#L974-L976
156,516
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
ResourceGroovyMethods.writeUtf16Bom
private static void writeUtf16Bom(OutputStream stream, boolean bigEndian) throws IOException { if (bigEndian) { stream.write(-2); stream.write(-1); } else { stream.write(-1); stream.write(-2); } }
java
private static void writeUtf16Bom(OutputStream stream, boolean bigEndian) throws IOException { if (bigEndian) { stream.write(-2); stream.write(-1); } else { stream.write(-1); stream.write(-2); } }
[ "private", "static", "void", "writeUtf16Bom", "(", "OutputStream", "stream", ",", "boolean", "bigEndian", ")", "throws", "IOException", "{", "if", "(", "bigEndian", ")", "{", "stream", ".", "write", "(", "-", "2", ")", ";", "stream", ".", "write", "(", "-", "1", ")", ";", "}", "else", "{", "stream", ".", "write", "(", "-", "1", ")", ";", "stream", ".", "write", "(", "-", "2", ")", ";", "}", "}" ]
Write a Byte Order Mark at the beginning of the file @param stream the FileOutputStream to write the BOM to @param bigEndian true if UTF 16 Big Endian or false if Low Endian @throws IOException if an IOException occurs. @since 1.0
[ "Write", "a", "Byte", "Order", "Mark", "at", "the", "beginning", "of", "the", "file" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/ResourceGroovyMethods.java#L1825-L1833
156,517
groovy/groovy-core
src/main/groovy/lang/GroovyClassLoader.java
GroovyClassLoader.getClassCacheEntry
protected Class getClassCacheEntry(String name) { if (name == null) return null; synchronized (classCache) { return classCache.get(name); } }
java
protected Class getClassCacheEntry(String name) { if (name == null) return null; synchronized (classCache) { return classCache.get(name); } }
[ "protected", "Class", "getClassCacheEntry", "(", "String", "name", ")", "{", "if", "(", "name", "==", "null", ")", "return", "null", ";", "synchronized", "(", "classCache", ")", "{", "return", "classCache", ".", "get", "(", "name", ")", ";", "}", "}" ]
gets a class from the class cache. This cache contains only classes loaded through this class loader or an InnerLoader instance. If no class is stored for a specific name, then the method should return null. @param name of the class @return the class stored for the given name @see #removeClassCacheEntry(String) @see #setClassCacheEntry(Class) @see #clearCache()
[ "gets", "a", "class", "from", "the", "class", "cache", ".", "This", "cache", "contains", "only", "classes", "loaded", "through", "this", "class", "loader", "or", "an", "InnerLoader", "instance", ".", "If", "no", "class", "is", "stored", "for", "a", "specific", "name", "then", "the", "method", "should", "return", "null", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/groovy/lang/GroovyClassLoader.java#L560-L565
156,518
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
MetaClassRegistryImpl.getMetaClassRegistryChangeEventListeners
public MetaClassRegistryChangeEventListener[] getMetaClassRegistryChangeEventListeners() { synchronized (changeListenerList) { ArrayList<MetaClassRegistryChangeEventListener> ret = new ArrayList<MetaClassRegistryChangeEventListener>(changeListenerList.size()+nonRemoveableChangeListenerList.size()); ret.addAll(nonRemoveableChangeListenerList); ret.addAll(changeListenerList); return ret.toArray(new MetaClassRegistryChangeEventListener[ret.size()]); } }
java
public MetaClassRegistryChangeEventListener[] getMetaClassRegistryChangeEventListeners() { synchronized (changeListenerList) { ArrayList<MetaClassRegistryChangeEventListener> ret = new ArrayList<MetaClassRegistryChangeEventListener>(changeListenerList.size()+nonRemoveableChangeListenerList.size()); ret.addAll(nonRemoveableChangeListenerList); ret.addAll(changeListenerList); return ret.toArray(new MetaClassRegistryChangeEventListener[ret.size()]); } }
[ "public", "MetaClassRegistryChangeEventListener", "[", "]", "getMetaClassRegistryChangeEventListeners", "(", ")", "{", "synchronized", "(", "changeListenerList", ")", "{", "ArrayList", "<", "MetaClassRegistryChangeEventListener", ">", "ret", "=", "new", "ArrayList", "<", "MetaClassRegistryChangeEventListener", ">", "(", "changeListenerList", ".", "size", "(", ")", "+", "nonRemoveableChangeListenerList", ".", "size", "(", ")", ")", ";", "ret", ".", "addAll", "(", "nonRemoveableChangeListenerList", ")", ";", "ret", ".", "addAll", "(", "changeListenerList", ")", ";", "return", "ret", ".", "toArray", "(", "new", "MetaClassRegistryChangeEventListener", "[", "ret", ".", "size", "(", ")", "]", ")", ";", "}", "}" ]
Gets an array of of all registered ConstantMetaClassListener instances.
[ "Gets", "an", "array", "of", "of", "all", "registered", "ConstantMetaClassListener", "instances", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java#L400-L408
156,519
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java
MetaClassRegistryImpl.getInstance
public static MetaClassRegistry getInstance(int includeExtension) { if (includeExtension != DONT_LOAD_DEFAULT) { if (instanceInclude == null) { instanceInclude = new MetaClassRegistryImpl(); } return instanceInclude; } else { if (instanceExclude == null) { instanceExclude = new MetaClassRegistryImpl(DONT_LOAD_DEFAULT); } return instanceExclude; } }
java
public static MetaClassRegistry getInstance(int includeExtension) { if (includeExtension != DONT_LOAD_DEFAULT) { if (instanceInclude == null) { instanceInclude = new MetaClassRegistryImpl(); } return instanceInclude; } else { if (instanceExclude == null) { instanceExclude = new MetaClassRegistryImpl(DONT_LOAD_DEFAULT); } return instanceExclude; } }
[ "public", "static", "MetaClassRegistry", "getInstance", "(", "int", "includeExtension", ")", "{", "if", "(", "includeExtension", "!=", "DONT_LOAD_DEFAULT", ")", "{", "if", "(", "instanceInclude", "==", "null", ")", "{", "instanceInclude", "=", "new", "MetaClassRegistryImpl", "(", ")", ";", "}", "return", "instanceInclude", ";", "}", "else", "{", "if", "(", "instanceExclude", "==", "null", ")", "{", "instanceExclude", "=", "new", "MetaClassRegistryImpl", "(", "DONT_LOAD_DEFAULT", ")", ";", "}", "return", "instanceExclude", ";", "}", "}" ]
Singleton of MetaClassRegistry. @param includeExtension @return the registry
[ "Singleton", "of", "MetaClassRegistry", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.java#L416-L428
156,520
groovy/groovy-core
src/main/org/codehaus/groovy/syntax/Reduction.java
Reduction.get
public CSTNode get( int index ) { CSTNode element = null; if( index < size() ) { element = (CSTNode)elements.get( index ); } return element; }
java
public CSTNode get( int index ) { CSTNode element = null; if( index < size() ) { element = (CSTNode)elements.get( index ); } return element; }
[ "public", "CSTNode", "get", "(", "int", "index", ")", "{", "CSTNode", "element", "=", "null", ";", "if", "(", "index", "<", "size", "(", ")", ")", "{", "element", "=", "(", "CSTNode", ")", "elements", ".", "get", "(", "index", ")", ";", "}", "return", "element", ";", "}" ]
Returns the specified element, or null.
[ "Returns", "the", "specified", "element", "or", "null", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/syntax/Reduction.java#L118-L128
156,521
groovy/groovy-core
src/main/org/codehaus/groovy/syntax/Reduction.java
Reduction.set
public CSTNode set( int index, CSTNode element ) { if( elements == null ) { throw new GroovyBugError( "attempt to set() on a EMPTY Reduction" ); } if( index == 0 && !(element instanceof Token) ) { // // It's not the greatest of design that the interface allows this, but it // is a tradeoff with convenience, and the convenience is more important. throw new GroovyBugError( "attempt to set() a non-Token as root of a Reduction" ); } // // Fill slots with nulls, if necessary. int count = elements.size(); if( index >= count ) { for( int i = count; i <= index; i++ ) { elements.add( null ); } } // // Then set in the element. elements.set( index, element ); return element; }
java
public CSTNode set( int index, CSTNode element ) { if( elements == null ) { throw new GroovyBugError( "attempt to set() on a EMPTY Reduction" ); } if( index == 0 && !(element instanceof Token) ) { // // It's not the greatest of design that the interface allows this, but it // is a tradeoff with convenience, and the convenience is more important. throw new GroovyBugError( "attempt to set() a non-Token as root of a Reduction" ); } // // Fill slots with nulls, if necessary. int count = elements.size(); if( index >= count ) { for( int i = count; i <= index; i++ ) { elements.add( null ); } } // // Then set in the element. elements.set( index, element ); return element; }
[ "public", "CSTNode", "set", "(", "int", "index", ",", "CSTNode", "element", ")", "{", "if", "(", "elements", "==", "null", ")", "{", "throw", "new", "GroovyBugError", "(", "\"attempt to set() on a EMPTY Reduction\"", ")", ";", "}", "if", "(", "index", "==", "0", "&&", "!", "(", "element", "instanceof", "Token", ")", ")", "{", "//", "// It's not the greatest of design that the interface allows this, but it", "// is a tradeoff with convenience, and the convenience is more important.", "throw", "new", "GroovyBugError", "(", "\"attempt to set() a non-Token as root of a Reduction\"", ")", ";", "}", "//", "// Fill slots with nulls, if necessary.", "int", "count", "=", "elements", ".", "size", "(", ")", ";", "if", "(", "index", ">=", "count", ")", "{", "for", "(", "int", "i", "=", "count", ";", "i", "<=", "index", ";", "i", "++", ")", "{", "elements", ".", "add", "(", "null", ")", ";", "}", "}", "//", "// Then set in the element.", "elements", ".", "set", "(", "index", ",", "element", ")", ";", "return", "element", ";", "}" ]
Sets an element in at the specified index.
[ "Sets", "an", "element", "in", "at", "the", "specified", "index", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/syntax/Reduction.java#L199-L236
156,522
groovy/groovy-core
src/main/org/codehaus/groovy/util/ManagedLinkedList.java
ManagedLinkedList.add
public void add(T value) { Element<T> element = new Element<T>(bundle, value); element.previous = tail; if (tail != null) tail.next = element; tail = element; if (head == null) head = element; }
java
public void add(T value) { Element<T> element = new Element<T>(bundle, value); element.previous = tail; if (tail != null) tail.next = element; tail = element; if (head == null) head = element; }
[ "public", "void", "add", "(", "T", "value", ")", "{", "Element", "<", "T", ">", "element", "=", "new", "Element", "<", "T", ">", "(", "bundle", ",", "value", ")", ";", "element", ".", "previous", "=", "tail", ";", "if", "(", "tail", "!=", "null", ")", "tail", ".", "next", "=", "element", ";", "tail", "=", "element", ";", "if", "(", "head", "==", "null", ")", "head", "=", "element", ";", "}" ]
adds a value to the list @param value the value
[ "adds", "a", "value", "to", "the", "list" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/util/ManagedLinkedList.java#L100-L106
156,523
groovy/groovy-core
src/main/org/codehaus/groovy/util/ManagedLinkedList.java
ManagedLinkedList.toArray
public T[] toArray(T[] tArray) { List<T> array = new ArrayList<T>(100); for (Iterator<T> it = iterator(); it.hasNext();) { T val = it.next(); if (val != null) array.add(val); } return array.toArray(tArray); }
java
public T[] toArray(T[] tArray) { List<T> array = new ArrayList<T>(100); for (Iterator<T> it = iterator(); it.hasNext();) { T val = it.next(); if (val != null) array.add(val); } return array.toArray(tArray); }
[ "public", "T", "[", "]", "toArray", "(", "T", "[", "]", "tArray", ")", "{", "List", "<", "T", ">", "array", "=", "new", "ArrayList", "<", "T", ">", "(", "100", ")", ";", "for", "(", "Iterator", "<", "T", ">", "it", "=", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "T", "val", "=", "it", ".", "next", "(", ")", ";", "if", "(", "val", "!=", "null", ")", "array", ".", "add", "(", "val", ")", ";", "}", "return", "array", ".", "toArray", "(", "tArray", ")", ";", "}" ]
Returns an array of non null elements from the source array. @param tArray the source array @return the array
[ "Returns", "an", "array", "of", "non", "null", "elements", "from", "the", "source", "array", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/util/ManagedLinkedList.java#L125-L132
156,524
groovy/groovy-core
subprojects/groovy-json/src/main/java/groovy/json/internal/ValueMapImpl.java
ValueMapImpl.get
public Value get(Object key) { /* If the length is under and we are asking for the key, then just look for the key. Don't build the map. */ if (map == null && items.length < 20) { for (Object item : items) { MapItemValue miv = (MapItemValue) item; if (key.equals(miv.name.toValue())) { return miv.value; } } return null; } else { if (map == null) buildIfNeededMap(); return map.get(key); } }
java
public Value get(Object key) { /* If the length is under and we are asking for the key, then just look for the key. Don't build the map. */ if (map == null && items.length < 20) { for (Object item : items) { MapItemValue miv = (MapItemValue) item; if (key.equals(miv.name.toValue())) { return miv.value; } } return null; } else { if (map == null) buildIfNeededMap(); return map.get(key); } }
[ "public", "Value", "get", "(", "Object", "key", ")", "{", "/* If the length is under and we are asking for the key, then just look for the key. Don't build the map. */", "if", "(", "map", "==", "null", "&&", "items", ".", "length", "<", "20", ")", "{", "for", "(", "Object", "item", ":", "items", ")", "{", "MapItemValue", "miv", "=", "(", "MapItemValue", ")", "item", ";", "if", "(", "key", ".", "equals", "(", "miv", ".", "name", ".", "toValue", "(", ")", ")", ")", "{", "return", "miv", ".", "value", ";", "}", "}", "return", "null", ";", "}", "else", "{", "if", "(", "map", "==", "null", ")", "buildIfNeededMap", "(", ")", ";", "return", "map", ".", "get", "(", "key", ")", ";", "}", "}" ]
Get the items for the key. @param key @return the items for the given key
[ "Get", "the", "items", "for", "the", "key", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/subprojects/groovy-json/src/main/java/groovy/json/internal/ValueMapImpl.java#L80-L94
156,525
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.unique
public static <T> Iterator<T> unique(Iterator<T> self) { return toList((Iterable<T>) unique(toList(self))).listIterator(); }
java
public static <T> Iterator<T> unique(Iterator<T> self) { return toList((Iterable<T>) unique(toList(self))).listIterator(); }
[ "public", "static", "<", "T", ">", "Iterator", "<", "T", ">", "unique", "(", "Iterator", "<", "T", ">", "self", ")", "{", "return", "toList", "(", "(", "Iterable", "<", "T", ">", ")", "unique", "(", "toList", "(", "self", ")", ")", ")", ".", "listIterator", "(", ")", ";", "}" ]
Returns an iterator equivalent to this iterator with all duplicated items removed by using the default comparator. The original iterator will become exhausted of elements after determining the unique values. A new iterator for the unique values will be returned. @param self an Iterator @return the modified Iterator @since 1.5.5
[ "Returns", "an", "iterator", "equivalent", "to", "this", "iterator", "with", "all", "duplicated", "items", "removed", "by", "using", "the", "default", "comparator", ".", "The", "original", "iterator", "will", "become", "exhausted", "of", "elements", "after", "determining", "the", "unique", "values", ".", "A", "new", "iterator", "for", "the", "unique", "values", "will", "be", "returned", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L1014-L1016
156,526
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.numberAwareCompareTo
public static int numberAwareCompareTo(Comparable self, Comparable other) { NumberAwareComparator<Comparable> numberAwareComparator = new NumberAwareComparator<Comparable>(); return numberAwareComparator.compare(self, other); }
java
public static int numberAwareCompareTo(Comparable self, Comparable other) { NumberAwareComparator<Comparable> numberAwareComparator = new NumberAwareComparator<Comparable>(); return numberAwareComparator.compare(self, other); }
[ "public", "static", "int", "numberAwareCompareTo", "(", "Comparable", "self", ",", "Comparable", "other", ")", "{", "NumberAwareComparator", "<", "Comparable", ">", "numberAwareComparator", "=", "new", "NumberAwareComparator", "<", "Comparable", ">", "(", ")", ";", "return", "numberAwareComparator", ".", "compare", "(", "self", ",", "other", ")", ";", "}" ]
Provides a method that compares two comparables using Groovy's default number aware comparator. @param self a Comparable @param other another Comparable @return a -ve number, 0 or a +ve number according to Groovy's compareTo contract @since 1.6.0
[ "Provides", "a", "method", "that", "compares", "two", "comparables", "using", "Groovy", "s", "default", "number", "aware", "comparator", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L1117-L1120
156,527
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.any
public static boolean any(Object self, Closure closure) { BooleanClosureWrapper bcw = new BooleanClosureWrapper(closure); for (Iterator iter = InvokerHelper.asIterator(self); iter.hasNext();) { if (bcw.call(iter.next())) return true; } return false; }
java
public static boolean any(Object self, Closure closure) { BooleanClosureWrapper bcw = new BooleanClosureWrapper(closure); for (Iterator iter = InvokerHelper.asIterator(self); iter.hasNext();) { if (bcw.call(iter.next())) return true; } return false; }
[ "public", "static", "boolean", "any", "(", "Object", "self", ",", "Closure", "closure", ")", "{", "BooleanClosureWrapper", "bcw", "=", "new", "BooleanClosureWrapper", "(", "closure", ")", ";", "for", "(", "Iterator", "iter", "=", "InvokerHelper", ".", "asIterator", "(", "self", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "if", "(", "bcw", ".", "call", "(", "iter", ".", "next", "(", ")", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}" ]
Iterates over the contents of an object or collection, and checks whether a predicate is valid for at least one element. @param self the object over which we iterate @param closure the closure predicate used for matching @return true if any iteration for the object matches the closure predicate @since 1.0
[ "Iterates", "over", "the", "contents", "of", "an", "object", "or", "collection", "and", "checks", "whether", "a", "predicate", "is", "valid", "for", "at", "least", "one", "element", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L2306-L2312
156,528
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.findResult
public static Object findResult(Object self, Object defaultResult, Closure closure) { Object result = findResult(self, closure); if (result == null) return defaultResult; return result; }
java
public static Object findResult(Object self, Object defaultResult, Closure closure) { Object result = findResult(self, closure); if (result == null) return defaultResult; return result; }
[ "public", "static", "Object", "findResult", "(", "Object", "self", ",", "Object", "defaultResult", ",", "Closure", "closure", ")", "{", "Object", "result", "=", "findResult", "(", "self", ",", "closure", ")", ";", "if", "(", "result", "==", "null", ")", "return", "defaultResult", ";", "return", "result", ";", "}" ]
Treats the object as iterable, iterating through the values it represents and returns the first non-null result obtained from calling the closure, otherwise returns the defaultResult. @param self an Object with an iterator returning its values @param defaultResult an Object that should be returned if all closure results are null @param closure a closure that returns a non-null value when processing should stop @return the first non-null result of the closure, otherwise the default value @since 1.7.5
[ "Treats", "the", "object", "as", "iterable", "iterating", "through", "the", "values", "it", "represents", "and", "returns", "the", "first", "non", "-", "null", "result", "obtained", "from", "calling", "the", "closure", "otherwise", "returns", "the", "defaultResult", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L3845-L3849
156,529
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.groupAnswer
protected static <K, T> void groupAnswer(final Map<K, List<T>> answer, T element, K value) { if (answer.containsKey(value)) { answer.get(value).add(element); } else { List<T> groupedElements = new ArrayList<T>(); groupedElements.add(element); answer.put(value, groupedElements); } }
java
protected static <K, T> void groupAnswer(final Map<K, List<T>> answer, T element, K value) { if (answer.containsKey(value)) { answer.get(value).add(element); } else { List<T> groupedElements = new ArrayList<T>(); groupedElements.add(element); answer.put(value, groupedElements); } }
[ "protected", "static", "<", "K", ",", "T", ">", "void", "groupAnswer", "(", "final", "Map", "<", "K", ",", "List", "<", "T", ">", ">", "answer", ",", "T", "element", ",", "K", "value", ")", "{", "if", "(", "answer", ".", "containsKey", "(", "value", ")", ")", "{", "answer", ".", "get", "(", "value", ")", ".", "add", "(", "element", ")", ";", "}", "else", "{", "List", "<", "T", ">", "groupedElements", "=", "new", "ArrayList", "<", "T", ">", "(", ")", ";", "groupedElements", ".", "add", "(", "element", ")", ";", "answer", ".", "put", "(", "value", ",", "groupedElements", ")", ";", "}", "}" ]
Groups the current element according to the value @param answer the map containing the results @param element the element to be placed @param value the value according to which the element will be placed @since 1.5.0
[ "Groups", "the", "current", "element", "according", "to", "the", "value" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L5205-L5213
156,530
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asImmutable
public static <K,V> Map<K,V> asImmutable(Map<? extends K, ? extends V> self) { return Collections.unmodifiableMap(self); }
java
public static <K,V> Map<K,V> asImmutable(Map<? extends K, ? extends V> self) { return Collections.unmodifiableMap(self); }
[ "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "asImmutable", "(", "Map", "<", "?", "extends", "K", ",", "?", "extends", "V", ">", "self", ")", "{", "return", "Collections", ".", "unmodifiableMap", "(", "self", ")", ";", "}" ]
A convenience method for creating an immutable map. @param self a Map @return an immutable Map @see java.util.Collections#unmodifiableMap(java.util.Map) @since 1.0
[ "A", "convenience", "method", "for", "creating", "an", "immutable", "map", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L7493-L7495
156,531
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asImmutable
public static <K,V> SortedMap<K,V> asImmutable(SortedMap<K, ? extends V> self) { return Collections.unmodifiableSortedMap(self); }
java
public static <K,V> SortedMap<K,V> asImmutable(SortedMap<K, ? extends V> self) { return Collections.unmodifiableSortedMap(self); }
[ "public", "static", "<", "K", ",", "V", ">", "SortedMap", "<", "K", ",", "V", ">", "asImmutable", "(", "SortedMap", "<", "K", ",", "?", "extends", "V", ">", "self", ")", "{", "return", "Collections", ".", "unmodifiableSortedMap", "(", "self", ")", ";", "}" ]
A convenience method for creating an immutable sorted map. @param self a SortedMap @return an immutable SortedMap @see java.util.Collections#unmodifiableSortedMap(java.util.SortedMap) @since 1.0
[ "A", "convenience", "method", "for", "creating", "an", "immutable", "sorted", "map", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L7505-L7507
156,532
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asImmutable
public static <T> List<T> asImmutable(List<? extends T> self) { return Collections.unmodifiableList(self); }
java
public static <T> List<T> asImmutable(List<? extends T> self) { return Collections.unmodifiableList(self); }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "asImmutable", "(", "List", "<", "?", "extends", "T", ">", "self", ")", "{", "return", "Collections", ".", "unmodifiableList", "(", "self", ")", ";", "}" ]
A convenience method for creating an immutable list @param self a List @return an immutable List @see java.util.Collections#unmodifiableList(java.util.List) @since 1.0
[ "A", "convenience", "method", "for", "creating", "an", "immutable", "list" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L7517-L7519
156,533
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asImmutable
public static <T> Set<T> asImmutable(Set<? extends T> self) { return Collections.unmodifiableSet(self); }
java
public static <T> Set<T> asImmutable(Set<? extends T> self) { return Collections.unmodifiableSet(self); }
[ "public", "static", "<", "T", ">", "Set", "<", "T", ">", "asImmutable", "(", "Set", "<", "?", "extends", "T", ">", "self", ")", "{", "return", "Collections", ".", "unmodifiableSet", "(", "self", ")", ";", "}" ]
A convenience method for creating an immutable list. @param self a Set @return an immutable Set @see java.util.Collections#unmodifiableSet(java.util.Set) @since 1.0
[ "A", "convenience", "method", "for", "creating", "an", "immutable", "list", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L7529-L7531
156,534
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.asImmutable
public static <T> SortedSet<T> asImmutable(SortedSet<T> self) { return Collections.unmodifiableSortedSet(self); }
java
public static <T> SortedSet<T> asImmutable(SortedSet<T> self) { return Collections.unmodifiableSortedSet(self); }
[ "public", "static", "<", "T", ">", "SortedSet", "<", "T", ">", "asImmutable", "(", "SortedSet", "<", "T", ">", "self", ")", "{", "return", "Collections", ".", "unmodifiableSortedSet", "(", "self", ")", ";", "}" ]
A convenience method for creating an immutable sorted set. @param self a SortedSet @return an immutable SortedSet @see java.util.Collections#unmodifiableSortedSet(java.util.SortedSet) @since 1.0
[ "A", "convenience", "method", "for", "creating", "an", "immutable", "sorted", "set", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L7541-L7543
156,535
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.sort
public static <T> T[] sort(T[] self, Comparator<T> comparator) { return sort(self, true, comparator); }
java
public static <T> T[] sort(T[] self, Comparator<T> comparator) { return sort(self, true, comparator); }
[ "public", "static", "<", "T", ">", "T", "[", "]", "sort", "(", "T", "[", "]", "self", ",", "Comparator", "<", "T", ">", "comparator", ")", "{", "return", "sort", "(", "self", ",", "true", ",", "comparator", ")", ";", "}" ]
Sorts the given array into sorted order using the given comparator. @param self the array to be sorted @param comparator a Comparator used for the comparison @return the sorted array @since 1.5.5
[ "Sorts", "the", "given", "array", "into", "sorted", "order", "using", "the", "given", "comparator", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L8292-L8294
156,536
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.addAll
public static <T> boolean addAll(Collection<T> self, Iterator<T> items) { boolean changed = false; while (items.hasNext()) { T next = items.next(); if (self.add(next)) changed = true; } return changed; }
java
public static <T> boolean addAll(Collection<T> self, Iterator<T> items) { boolean changed = false; while (items.hasNext()) { T next = items.next(); if (self.add(next)) changed = true; } return changed; }
[ "public", "static", "<", "T", ">", "boolean", "addAll", "(", "Collection", "<", "T", ">", "self", ",", "Iterator", "<", "T", ">", "items", ")", "{", "boolean", "changed", "=", "false", ";", "while", "(", "items", ".", "hasNext", "(", ")", ")", "{", "T", "next", "=", "items", ".", "next", "(", ")", ";", "if", "(", "self", ".", "add", "(", "next", ")", ")", "changed", "=", "true", ";", "}", "return", "changed", ";", "}" ]
Adds all items from the iterator to the Collection. @param self the collection @param items the items to add @return true if the collection changed
[ "Adds", "all", "items", "from", "the", "iterator", "to", "the", "Collection", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L9371-L9378
156,537
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.addAll
public static <T> boolean addAll(Collection<T> self, Iterable<T> items) { boolean changed = false; for (T next : items) { if (self.add(next)) changed = true; } return changed; }
java
public static <T> boolean addAll(Collection<T> self, Iterable<T> items) { boolean changed = false; for (T next : items) { if (self.add(next)) changed = true; } return changed; }
[ "public", "static", "<", "T", ">", "boolean", "addAll", "(", "Collection", "<", "T", ">", "self", ",", "Iterable", "<", "T", ">", "items", ")", "{", "boolean", "changed", "=", "false", ";", "for", "(", "T", "next", ":", "items", ")", "{", "if", "(", "self", ".", "add", "(", "next", ")", ")", "changed", "=", "true", ";", "}", "return", "changed", ";", "}" ]
Adds all items from the iterable to the Collection. @param self the collection @param items the items to add @return true if the collection changed
[ "Adds", "all", "items", "from", "the", "iterable", "to", "the", "Collection", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L9387-L9393
156,538
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.minus
public static <K,V> Map<K,V> minus(Map<K,V> self, Map removeMe) { final Map<K,V> ansMap = createSimilarMap(self); ansMap.putAll(self); if (removeMe != null && removeMe.size() > 0) { for (Map.Entry<K, V> e1 : self.entrySet()) { for (Object e2 : removeMe.entrySet()) { if (DefaultTypeTransformation.compareEqual(e1, e2)) { ansMap.remove(e1.getKey()); } } } } return ansMap; }
java
public static <K,V> Map<K,V> minus(Map<K,V> self, Map removeMe) { final Map<K,V> ansMap = createSimilarMap(self); ansMap.putAll(self); if (removeMe != null && removeMe.size() > 0) { for (Map.Entry<K, V> e1 : self.entrySet()) { for (Object e2 : removeMe.entrySet()) { if (DefaultTypeTransformation.compareEqual(e1, e2)) { ansMap.remove(e1.getKey()); } } } } return ansMap; }
[ "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "minus", "(", "Map", "<", "K", ",", "V", ">", "self", ",", "Map", "removeMe", ")", "{", "final", "Map", "<", "K", ",", "V", ">", "ansMap", "=", "createSimilarMap", "(", "self", ")", ";", "ansMap", ".", "putAll", "(", "self", ")", ";", "if", "(", "removeMe", "!=", "null", "&&", "removeMe", ".", "size", "(", ")", ">", "0", ")", "{", "for", "(", "Map", ".", "Entry", "<", "K", ",", "V", ">", "e1", ":", "self", ".", "entrySet", "(", ")", ")", "{", "for", "(", "Object", "e2", ":", "removeMe", ".", "entrySet", "(", ")", ")", "{", "if", "(", "DefaultTypeTransformation", ".", "compareEqual", "(", "e1", ",", "e2", ")", ")", "{", "ansMap", ".", "remove", "(", "e1", ".", "getKey", "(", ")", ")", ";", "}", "}", "}", "}", "return", "ansMap", ";", "}" ]
Create a Map composed of the entries of the first map minus the entries of the given map. @param self a map object @param removeMe the entries to remove from the map @return the resulting map @since 1.7.4
[ "Create", "a", "Map", "composed", "of", "the", "entries", "of", "the", "first", "map", "minus", "the", "entries", "of", "the", "given", "map", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L11931-L11944
156,539
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.findLastIndexOf
public static int findLastIndexOf(Object self, int startIndex, Closure closure) { int result = -1; int i = 0; BooleanClosureWrapper bcw = new BooleanClosureWrapper(closure); for (Iterator iter = InvokerHelper.asIterator(self); iter.hasNext(); i++) { Object value = iter.next(); if (i < startIndex) { continue; } if (bcw.call(value)) { result = i; } } return result; }
java
public static int findLastIndexOf(Object self, int startIndex, Closure closure) { int result = -1; int i = 0; BooleanClosureWrapper bcw = new BooleanClosureWrapper(closure); for (Iterator iter = InvokerHelper.asIterator(self); iter.hasNext(); i++) { Object value = iter.next(); if (i < startIndex) { continue; } if (bcw.call(value)) { result = i; } } return result; }
[ "public", "static", "int", "findLastIndexOf", "(", "Object", "self", ",", "int", "startIndex", ",", "Closure", "closure", ")", "{", "int", "result", "=", "-", "1", ";", "int", "i", "=", "0", ";", "BooleanClosureWrapper", "bcw", "=", "new", "BooleanClosureWrapper", "(", "closure", ")", ";", "for", "(", "Iterator", "iter", "=", "InvokerHelper", ".", "asIterator", "(", "self", ")", ";", "iter", ".", "hasNext", "(", ")", ";", "i", "++", ")", "{", "Object", "value", "=", "iter", ".", "next", "(", ")", ";", "if", "(", "i", "<", "startIndex", ")", "{", "continue", ";", "}", "if", "(", "bcw", ".", "call", "(", "value", ")", ")", "{", "result", "=", "i", ";", "}", "}", "return", "result", ";", "}" ]
Iterates over the elements of an iterable collection of items, starting from a specified startIndex, and returns the index of the last item that matches the condition specified in the closure. @param self the iteration object over which to iterate @param startIndex start matching from this index @param closure the filter to perform a match on the collection @return an integer that is the index of the last matched object or -1 if no match was found @since 1.5.2
[ "Iterates", "over", "the", "elements", "of", "an", "iterable", "collection", "of", "items", "starting", "from", "a", "specified", "startIndex", "and", "returns", "the", "index", "of", "the", "last", "item", "that", "matches", "the", "condition", "specified", "in", "the", "closure", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L15414-L15428
156,540
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.findIndexValues
public static List<Number> findIndexValues(Object self, Closure closure) { return findIndexValues(self, 0, closure); }
java
public static List<Number> findIndexValues(Object self, Closure closure) { return findIndexValues(self, 0, closure); }
[ "public", "static", "List", "<", "Number", ">", "findIndexValues", "(", "Object", "self", ",", "Closure", "closure", ")", "{", "return", "findIndexValues", "(", "self", ",", "0", ",", "closure", ")", ";", "}" ]
Iterates over the elements of an iterable collection of items and returns the index values of the items that match the condition specified in the closure. @param self the iteration object over which to iterate @param closure the filter to perform a match on the collection @return a list of numbers corresponding to the index values of all matched objects @since 1.5.2
[ "Iterates", "over", "the", "elements", "of", "an", "iterable", "collection", "of", "items", "and", "returns", "the", "index", "values", "of", "the", "items", "that", "match", "the", "condition", "specified", "in", "the", "closure", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L15439-L15441
156,541
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
DefaultGroovyMethods.findIndexValues
public static List<Number> findIndexValues(Object self, Number startIndex, Closure closure) { List<Number> result = new ArrayList<Number>(); long count = 0; long startCount = startIndex.longValue(); BooleanClosureWrapper bcw = new BooleanClosureWrapper(closure); for (Iterator iter = InvokerHelper.asIterator(self); iter.hasNext(); count++) { Object value = iter.next(); if (count < startCount) { continue; } if (bcw.call(value)) { result.add(count); } } return result; }
java
public static List<Number> findIndexValues(Object self, Number startIndex, Closure closure) { List<Number> result = new ArrayList<Number>(); long count = 0; long startCount = startIndex.longValue(); BooleanClosureWrapper bcw = new BooleanClosureWrapper(closure); for (Iterator iter = InvokerHelper.asIterator(self); iter.hasNext(); count++) { Object value = iter.next(); if (count < startCount) { continue; } if (bcw.call(value)) { result.add(count); } } return result; }
[ "public", "static", "List", "<", "Number", ">", "findIndexValues", "(", "Object", "self", ",", "Number", "startIndex", ",", "Closure", "closure", ")", "{", "List", "<", "Number", ">", "result", "=", "new", "ArrayList", "<", "Number", ">", "(", ")", ";", "long", "count", "=", "0", ";", "long", "startCount", "=", "startIndex", ".", "longValue", "(", ")", ";", "BooleanClosureWrapper", "bcw", "=", "new", "BooleanClosureWrapper", "(", "closure", ")", ";", "for", "(", "Iterator", "iter", "=", "InvokerHelper", ".", "asIterator", "(", "self", ")", ";", "iter", ".", "hasNext", "(", ")", ";", "count", "++", ")", "{", "Object", "value", "=", "iter", ".", "next", "(", ")", ";", "if", "(", "count", "<", "startCount", ")", "{", "continue", ";", "}", "if", "(", "bcw", ".", "call", "(", "value", ")", ")", "{", "result", ".", "add", "(", "count", ")", ";", "}", "}", "return", "result", ";", "}" ]
Iterates over the elements of an iterable collection of items, starting from a specified startIndex, and returns the index values of the items that match the condition specified in the closure. @param self the iteration object over which to iterate @param startIndex start matching from this index @param closure the filter to perform a match on the collection @return a list of numbers corresponding to the index values of all matched objects @since 1.5.2
[ "Iterates", "over", "the", "elements", "of", "an", "iterable", "collection", "of", "items", "starting", "from", "a", "specified", "startIndex", "and", "returns", "the", "index", "values", "of", "the", "items", "that", "match", "the", "condition", "specified", "in", "the", "closure", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java#L15454-L15469
156,542
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/HandleMetaClass.java
HandleMetaClass.getProperty
public Object getProperty(String property) { if(ExpandoMetaClass.isValidExpandoProperty(property)) { if(property.equals(ExpandoMetaClass.STATIC_QUALIFIER) || property.equals(ExpandoMetaClass.CONSTRUCTOR) || myMetaClass.hasProperty(this, property) == null) { return replaceDelegate().getProperty(property); } } return myMetaClass.getProperty(this, property); }
java
public Object getProperty(String property) { if(ExpandoMetaClass.isValidExpandoProperty(property)) { if(property.equals(ExpandoMetaClass.STATIC_QUALIFIER) || property.equals(ExpandoMetaClass.CONSTRUCTOR) || myMetaClass.hasProperty(this, property) == null) { return replaceDelegate().getProperty(property); } } return myMetaClass.getProperty(this, property); }
[ "public", "Object", "getProperty", "(", "String", "property", ")", "{", "if", "(", "ExpandoMetaClass", ".", "isValidExpandoProperty", "(", "property", ")", ")", "{", "if", "(", "property", ".", "equals", "(", "ExpandoMetaClass", ".", "STATIC_QUALIFIER", ")", "||", "property", ".", "equals", "(", "ExpandoMetaClass", ".", "CONSTRUCTOR", ")", "||", "myMetaClass", ".", "hasProperty", "(", "this", ",", "property", ")", "==", "null", ")", "{", "return", "replaceDelegate", "(", ")", ".", "getProperty", "(", "property", ")", ";", "}", "}", "return", "myMetaClass", ".", "getProperty", "(", "this", ",", "property", ")", ";", "}" ]
this method mimics EMC behavior
[ "this", "method", "mimics", "EMC", "behavior" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/HandleMetaClass.java#L82-L91
156,543
groovy/groovy-core
src/main/org/codehaus/groovy/control/messages/Message.java
Message.create
public static Message create( String text, Object data, ProcessingUnit owner ) { return new SimpleMessage( text, data, owner); }
java
public static Message create( String text, Object data, ProcessingUnit owner ) { return new SimpleMessage( text, data, owner); }
[ "public", "static", "Message", "create", "(", "String", "text", ",", "Object", "data", ",", "ProcessingUnit", "owner", ")", "{", "return", "new", "SimpleMessage", "(", "text", ",", "data", ",", "owner", ")", ";", "}" ]
Creates a new Message from the specified text.
[ "Creates", "a", "new", "Message", "from", "the", "specified", "text", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/control/messages/Message.java#L80-L83
156,544
groovy/groovy-core
subprojects/groovy-json/src/main/java/groovy/json/JsonDelegate.java
JsonDelegate.invokeMethod
public Object invokeMethod(String name, Object args) { Object val = null; if (args != null && Object[].class.isAssignableFrom(args.getClass())) { Object[] arr = (Object[]) args; if (arr.length == 1) { val = arr[0]; } else if (arr.length == 2 && arr[0] instanceof Collection && arr[1] instanceof Closure) { Closure<?> closure = (Closure<?>) arr[1]; Iterator<?> iterator = ((Collection) arr[0]).iterator(); List<Object> list = new ArrayList<Object>(); while (iterator.hasNext()) { list.add(curryDelegateAndGetContent(closure, iterator.next())); } val = list; } else { val = Arrays.asList(arr); } } content.put(name, val); return val; }
java
public Object invokeMethod(String name, Object args) { Object val = null; if (args != null && Object[].class.isAssignableFrom(args.getClass())) { Object[] arr = (Object[]) args; if (arr.length == 1) { val = arr[0]; } else if (arr.length == 2 && arr[0] instanceof Collection && arr[1] instanceof Closure) { Closure<?> closure = (Closure<?>) arr[1]; Iterator<?> iterator = ((Collection) arr[0]).iterator(); List<Object> list = new ArrayList<Object>(); while (iterator.hasNext()) { list.add(curryDelegateAndGetContent(closure, iterator.next())); } val = list; } else { val = Arrays.asList(arr); } } content.put(name, val); return val; }
[ "public", "Object", "invokeMethod", "(", "String", "name", ",", "Object", "args", ")", "{", "Object", "val", "=", "null", ";", "if", "(", "args", "!=", "null", "&&", "Object", "[", "]", ".", "class", ".", "isAssignableFrom", "(", "args", ".", "getClass", "(", ")", ")", ")", "{", "Object", "[", "]", "arr", "=", "(", "Object", "[", "]", ")", "args", ";", "if", "(", "arr", ".", "length", "==", "1", ")", "{", "val", "=", "arr", "[", "0", "]", ";", "}", "else", "if", "(", "arr", ".", "length", "==", "2", "&&", "arr", "[", "0", "]", "instanceof", "Collection", "&&", "arr", "[", "1", "]", "instanceof", "Closure", ")", "{", "Closure", "<", "?", ">", "closure", "=", "(", "Closure", "<", "?", ">", ")", "arr", "[", "1", "]", ";", "Iterator", "<", "?", ">", "iterator", "=", "(", "(", "Collection", ")", "arr", "[", "0", "]", ")", ".", "iterator", "(", ")", ";", "List", "<", "Object", ">", "list", "=", "new", "ArrayList", "<", "Object", ">", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "list", ".", "add", "(", "curryDelegateAndGetContent", "(", "closure", ",", "iterator", ".", "next", "(", ")", ")", ")", ";", "}", "val", "=", "list", ";", "}", "else", "{", "val", "=", "Arrays", ".", "asList", "(", "arr", ")", ";", "}", "}", "content", ".", "put", "(", "name", ",", "val", ")", ";", "return", "val", ";", "}" ]
Intercepts calls for setting a key and value for a JSON object @param name the key name @param args the value associated with the key
[ "Intercepts", "calls", "for", "setting", "a", "key", "and", "value", "for", "a", "JSON", "object" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/subprojects/groovy-json/src/main/java/groovy/json/JsonDelegate.java#L43-L65
156,545
groovy/groovy-core
src/main/groovy/lang/Binding.java
Binding.setVariable
public void setVariable(String name, Object value) { if (variables == null) variables = new LinkedHashMap(); variables.put(name, value); }
java
public void setVariable(String name, Object value) { if (variables == null) variables = new LinkedHashMap(); variables.put(name, value); }
[ "public", "void", "setVariable", "(", "String", "name", ",", "Object", "value", ")", "{", "if", "(", "variables", "==", "null", ")", "variables", "=", "new", "LinkedHashMap", "(", ")", ";", "variables", ".", "put", "(", "name", ",", "value", ")", ";", "}" ]
Sets the value of the given variable @param name the name of the variable to set @param value the new value for the given variable
[ "Sets", "the", "value", "of", "the", "given", "variable" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/groovy/lang/Binding.java#L76-L80
156,546
groovy/groovy-core
src/main/groovy/lang/MetaBeanProperty.java
MetaBeanProperty.getProperty
public Object getProperty(Object object) { MetaMethod getter = getGetter(); if (getter == null) { if (field != null) return field.getProperty(object); //TODO: create a WriteOnlyException class? throw new GroovyRuntimeException("Cannot read write-only property: " + name); } return getter.invoke(object, MetaClassHelper.EMPTY_ARRAY); }
java
public Object getProperty(Object object) { MetaMethod getter = getGetter(); if (getter == null) { if (field != null) return field.getProperty(object); //TODO: create a WriteOnlyException class? throw new GroovyRuntimeException("Cannot read write-only property: " + name); } return getter.invoke(object, MetaClassHelper.EMPTY_ARRAY); }
[ "public", "Object", "getProperty", "(", "Object", "object", ")", "{", "MetaMethod", "getter", "=", "getGetter", "(", ")", ";", "if", "(", "getter", "==", "null", ")", "{", "if", "(", "field", "!=", "null", ")", "return", "field", ".", "getProperty", "(", "object", ")", ";", "//TODO: create a WriteOnlyException class?", "throw", "new", "GroovyRuntimeException", "(", "\"Cannot read write-only property: \"", "+", "name", ")", ";", "}", "return", "getter", ".", "invoke", "(", "object", ",", "MetaClassHelper", ".", "EMPTY_ARRAY", ")", ";", "}" ]
Get the property of the given object. @param object which to be got @return the property of the given object @throws RuntimeException if the property could not be evaluated
[ "Get", "the", "property", "of", "the", "given", "object", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/groovy/lang/MetaBeanProperty.java#L56-L64
156,547
groovy/groovy-core
src/main/groovy/lang/MetaBeanProperty.java
MetaBeanProperty.setProperty
public void setProperty(Object object, Object newValue) { MetaMethod setter = getSetter(); if (setter == null) { if (field != null && !Modifier.isFinal(field.getModifiers())) { field.setProperty(object, newValue); return; } throw new GroovyRuntimeException("Cannot set read-only property: " + name); } newValue = DefaultTypeTransformation.castToType(newValue, getType()); setter.invoke(object, new Object[]{newValue}); }
java
public void setProperty(Object object, Object newValue) { MetaMethod setter = getSetter(); if (setter == null) { if (field != null && !Modifier.isFinal(field.getModifiers())) { field.setProperty(object, newValue); return; } throw new GroovyRuntimeException("Cannot set read-only property: " + name); } newValue = DefaultTypeTransformation.castToType(newValue, getType()); setter.invoke(object, new Object[]{newValue}); }
[ "public", "void", "setProperty", "(", "Object", "object", ",", "Object", "newValue", ")", "{", "MetaMethod", "setter", "=", "getSetter", "(", ")", ";", "if", "(", "setter", "==", "null", ")", "{", "if", "(", "field", "!=", "null", "&&", "!", "Modifier", ".", "isFinal", "(", "field", ".", "getModifiers", "(", ")", ")", ")", "{", "field", ".", "setProperty", "(", "object", ",", "newValue", ")", ";", "return", ";", "}", "throw", "new", "GroovyRuntimeException", "(", "\"Cannot set read-only property: \"", "+", "name", ")", ";", "}", "newValue", "=", "DefaultTypeTransformation", ".", "castToType", "(", "newValue", ",", "getType", "(", ")", ")", ";", "setter", ".", "invoke", "(", "object", ",", "new", "Object", "[", "]", "{", "newValue", "}", ")", ";", "}" ]
Set the property on the given object to the new value. @param object on which to set the property @param newValue the new value of the property @throws RuntimeException if the property could not be set
[ "Set", "the", "property", "on", "the", "given", "object", "to", "the", "new", "value", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/groovy/lang/MetaBeanProperty.java#L73-L84
156,548
groovy/groovy-core
src/main/groovy/lang/MetaBeanProperty.java
MetaBeanProperty.getModifiers
public int getModifiers() { MetaMethod getter = getGetter(); MetaMethod setter = getSetter(); if (setter != null && getter == null) return setter.getModifiers(); if (getter != null && setter == null) return getter.getModifiers(); int modifiers = getter.getModifiers() | setter.getModifiers(); int visibility = 0; if (Modifier.isPublic(modifiers)) visibility = Modifier.PUBLIC; if (Modifier.isProtected(modifiers)) visibility = Modifier.PROTECTED; if (Modifier.isPrivate(modifiers)) visibility = Modifier.PRIVATE; int states = getter.getModifiers() & setter.getModifiers(); states &= ~(Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE); states |= visibility; return states; }
java
public int getModifiers() { MetaMethod getter = getGetter(); MetaMethod setter = getSetter(); if (setter != null && getter == null) return setter.getModifiers(); if (getter != null && setter == null) return getter.getModifiers(); int modifiers = getter.getModifiers() | setter.getModifiers(); int visibility = 0; if (Modifier.isPublic(modifiers)) visibility = Modifier.PUBLIC; if (Modifier.isProtected(modifiers)) visibility = Modifier.PROTECTED; if (Modifier.isPrivate(modifiers)) visibility = Modifier.PRIVATE; int states = getter.getModifiers() & setter.getModifiers(); states &= ~(Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE); states |= visibility; return states; }
[ "public", "int", "getModifiers", "(", ")", "{", "MetaMethod", "getter", "=", "getGetter", "(", ")", ";", "MetaMethod", "setter", "=", "getSetter", "(", ")", ";", "if", "(", "setter", "!=", "null", "&&", "getter", "==", "null", ")", "return", "setter", ".", "getModifiers", "(", ")", ";", "if", "(", "getter", "!=", "null", "&&", "setter", "==", "null", ")", "return", "getter", ".", "getModifiers", "(", ")", ";", "int", "modifiers", "=", "getter", ".", "getModifiers", "(", ")", "|", "setter", ".", "getModifiers", "(", ")", ";", "int", "visibility", "=", "0", ";", "if", "(", "Modifier", ".", "isPublic", "(", "modifiers", ")", ")", "visibility", "=", "Modifier", ".", "PUBLIC", ";", "if", "(", "Modifier", ".", "isProtected", "(", "modifiers", ")", ")", "visibility", "=", "Modifier", ".", "PROTECTED", ";", "if", "(", "Modifier", ".", "isPrivate", "(", "modifiers", ")", ")", "visibility", "=", "Modifier", ".", "PRIVATE", ";", "int", "states", "=", "getter", ".", "getModifiers", "(", ")", "&", "setter", ".", "getModifiers", "(", ")", ";", "states", "&=", "~", "(", "Modifier", ".", "PUBLIC", "|", "Modifier", ".", "PROTECTED", "|", "Modifier", ".", "PRIVATE", ")", ";", "states", "|=", "visibility", ";", "return", "states", ";", "}" ]
Gets the visibility modifiers for the property as defined by the getter and setter methods. @return the visibility modifer of the getter, the setter, or both depending on which exist
[ "Gets", "the", "visibility", "modifiers", "for", "the", "property", "as", "defined", "by", "the", "getter", "and", "setter", "methods", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/groovy/lang/MetaBeanProperty.java#L127-L141
156,549
groovy/groovy-core
src/main/org/codehaus/groovy/transform/trait/Traits.java
Traits.isTrait
public static boolean isTrait(final ClassNode cNode) { return cNode!=null && ((cNode.isInterface() && !cNode.getAnnotations(TRAIT_CLASSNODE).isEmpty()) || isAnnotatedWithTrait(cNode)); }
java
public static boolean isTrait(final ClassNode cNode) { return cNode!=null && ((cNode.isInterface() && !cNode.getAnnotations(TRAIT_CLASSNODE).isEmpty()) || isAnnotatedWithTrait(cNode)); }
[ "public", "static", "boolean", "isTrait", "(", "final", "ClassNode", "cNode", ")", "{", "return", "cNode", "!=", "null", "&&", "(", "(", "cNode", ".", "isInterface", "(", ")", "&&", "!", "cNode", ".", "getAnnotations", "(", "TRAIT_CLASSNODE", ")", ".", "isEmpty", "(", ")", ")", "||", "isAnnotatedWithTrait", "(", "cNode", ")", ")", ";", "}" ]
Returns true if the specified class node is a trait. @param cNode a class node to test @return true if the classnode represents a trait
[ "Returns", "true", "if", "the", "specified", "class", "node", "is", "a", "trait", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/transform/trait/Traits.java#L149-L153
156,550
groovy/groovy-core
src/main/org/codehaus/groovy/transform/trait/Traits.java
Traits.getBridgeMethodTarget
public static Method getBridgeMethodTarget(Method someMethod) { TraitBridge annotation = someMethod.getAnnotation(TraitBridge.class); if (annotation==null) { return null; } Class aClass = annotation.traitClass(); String desc = annotation.desc(); for (Method method : aClass.getDeclaredMethods()) { String methodDescriptor = BytecodeHelper.getMethodDescriptor(method.getReturnType(), method.getParameterTypes()); if (desc.equals(methodDescriptor)) { return method; } } return null; }
java
public static Method getBridgeMethodTarget(Method someMethod) { TraitBridge annotation = someMethod.getAnnotation(TraitBridge.class); if (annotation==null) { return null; } Class aClass = annotation.traitClass(); String desc = annotation.desc(); for (Method method : aClass.getDeclaredMethods()) { String methodDescriptor = BytecodeHelper.getMethodDescriptor(method.getReturnType(), method.getParameterTypes()); if (desc.equals(methodDescriptor)) { return method; } } return null; }
[ "public", "static", "Method", "getBridgeMethodTarget", "(", "Method", "someMethod", ")", "{", "TraitBridge", "annotation", "=", "someMethod", ".", "getAnnotation", "(", "TraitBridge", ".", "class", ")", ";", "if", "(", "annotation", "==", "null", ")", "{", "return", "null", ";", "}", "Class", "aClass", "=", "annotation", ".", "traitClass", "(", ")", ";", "String", "desc", "=", "annotation", ".", "desc", "(", ")", ";", "for", "(", "Method", "method", ":", "aClass", ".", "getDeclaredMethods", "(", ")", ")", "{", "String", "methodDescriptor", "=", "BytecodeHelper", ".", "getMethodDescriptor", "(", "method", ".", "getReturnType", "(", ")", ",", "method", ".", "getParameterTypes", "(", ")", ")", ";", "if", "(", "desc", ".", "equals", "(", "methodDescriptor", ")", ")", "{", "return", "method", ";", "}", "}", "return", "null", ";", "}" ]
Reflection API to find the method corresponding to the default implementation of a trait, given a bridge method. @param someMethod a method node @return null if it is not a method implemented in a trait. If it is, returns the method from the trait class.
[ "Reflection", "API", "to", "find", "the", "method", "corresponding", "to", "the", "default", "implementation", "of", "a", "trait", "given", "a", "bridge", "method", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/transform/trait/Traits.java#L209-L223
156,551
groovy/groovy-core
subprojects/groovy-console/src/main/groovy/groovy/ui/text/FindReplaceUtility.java
FindReplaceUtility.findNext
private static int findNext(boolean reverse, int pos) { boolean backwards = IS_BACKWARDS_CHECKBOX.isSelected(); backwards = backwards ? !reverse : reverse; String pattern = (String) FIND_FIELD.getSelectedItem(); if (pattern != null && pattern.length() > 0) { try { Document doc = textComponent.getDocument(); doc.getText(0, doc.getLength(), SEGMENT); } catch (Exception e) { // should NEVER reach here e.printStackTrace(); } pos += textComponent.getSelectedText() == null ? (backwards ? -1 : 1) : 0; char first = backwards ? pattern.charAt(pattern.length() - 1) : pattern.charAt(0); char oppFirst = Character.isUpperCase(first) ? Character.toLowerCase(first) : Character.toUpperCase(first); int start = pos; boolean wrapped = WRAP_SEARCH_CHECKBOX.isSelected(); int end = backwards ? 0 : SEGMENT.getEndIndex(); pos += backwards ? -1 : 1; int length = textComponent.getDocument().getLength(); if (pos > length) { pos = wrapped ? 0 : length; } boolean found = false; while (!found && (backwards ? pos > end : pos < end)) { found = !MATCH_CASE_CHECKBOX.isSelected() && SEGMENT.array[pos] == oppFirst; found = found ? found : SEGMENT.array[pos] == first; if (found) { pos += backwards ? -(pattern.length() - 1) : 0; for (int i = 0; found && i < pattern.length(); i++) { char c = pattern.charAt(i); found = SEGMENT.array[pos + i] == c; if (!MATCH_CASE_CHECKBOX.isSelected() && !found) { c = Character.isUpperCase(c) ? Character.toLowerCase(c) : Character.toUpperCase(c); found = SEGMENT.array[pos + i] == c; } } } if (!found) { pos += backwards ? -1 : 1; if (pos == end && wrapped) { pos = backwards ? SEGMENT.getEndIndex() : 0; end = start; wrapped = false; } } } pos = found ? pos : -1; } return pos; }
java
private static int findNext(boolean reverse, int pos) { boolean backwards = IS_BACKWARDS_CHECKBOX.isSelected(); backwards = backwards ? !reverse : reverse; String pattern = (String) FIND_FIELD.getSelectedItem(); if (pattern != null && pattern.length() > 0) { try { Document doc = textComponent.getDocument(); doc.getText(0, doc.getLength(), SEGMENT); } catch (Exception e) { // should NEVER reach here e.printStackTrace(); } pos += textComponent.getSelectedText() == null ? (backwards ? -1 : 1) : 0; char first = backwards ? pattern.charAt(pattern.length() - 1) : pattern.charAt(0); char oppFirst = Character.isUpperCase(first) ? Character.toLowerCase(first) : Character.toUpperCase(first); int start = pos; boolean wrapped = WRAP_SEARCH_CHECKBOX.isSelected(); int end = backwards ? 0 : SEGMENT.getEndIndex(); pos += backwards ? -1 : 1; int length = textComponent.getDocument().getLength(); if (pos > length) { pos = wrapped ? 0 : length; } boolean found = false; while (!found && (backwards ? pos > end : pos < end)) { found = !MATCH_CASE_CHECKBOX.isSelected() && SEGMENT.array[pos] == oppFirst; found = found ? found : SEGMENT.array[pos] == first; if (found) { pos += backwards ? -(pattern.length() - 1) : 0; for (int i = 0; found && i < pattern.length(); i++) { char c = pattern.charAt(i); found = SEGMENT.array[pos + i] == c; if (!MATCH_CASE_CHECKBOX.isSelected() && !found) { c = Character.isUpperCase(c) ? Character.toLowerCase(c) : Character.toUpperCase(c); found = SEGMENT.array[pos + i] == c; } } } if (!found) { pos += backwards ? -1 : 1; if (pos == end && wrapped) { pos = backwards ? SEGMENT.getEndIndex() : 0; end = start; wrapped = false; } } } pos = found ? pos : -1; } return pos; }
[ "private", "static", "int", "findNext", "(", "boolean", "reverse", ",", "int", "pos", ")", "{", "boolean", "backwards", "=", "IS_BACKWARDS_CHECKBOX", ".", "isSelected", "(", ")", ";", "backwards", "=", "backwards", "?", "!", "reverse", ":", "reverse", ";", "String", "pattern", "=", "(", "String", ")", "FIND_FIELD", ".", "getSelectedItem", "(", ")", ";", "if", "(", "pattern", "!=", "null", "&&", "pattern", ".", "length", "(", ")", ">", "0", ")", "{", "try", "{", "Document", "doc", "=", "textComponent", ".", "getDocument", "(", ")", ";", "doc", ".", "getText", "(", "0", ",", "doc", ".", "getLength", "(", ")", ",", "SEGMENT", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// should NEVER reach here", "e", ".", "printStackTrace", "(", ")", ";", "}", "pos", "+=", "textComponent", ".", "getSelectedText", "(", ")", "==", "null", "?", "(", "backwards", "?", "-", "1", ":", "1", ")", ":", "0", ";", "char", "first", "=", "backwards", "?", "pattern", ".", "charAt", "(", "pattern", ".", "length", "(", ")", "-", "1", ")", ":", "pattern", ".", "charAt", "(", "0", ")", ";", "char", "oppFirst", "=", "Character", ".", "isUpperCase", "(", "first", ")", "?", "Character", ".", "toLowerCase", "(", "first", ")", ":", "Character", ".", "toUpperCase", "(", "first", ")", ";", "int", "start", "=", "pos", ";", "boolean", "wrapped", "=", "WRAP_SEARCH_CHECKBOX", ".", "isSelected", "(", ")", ";", "int", "end", "=", "backwards", "?", "0", ":", "SEGMENT", ".", "getEndIndex", "(", ")", ";", "pos", "+=", "backwards", "?", "-", "1", ":", "1", ";", "int", "length", "=", "textComponent", ".", "getDocument", "(", ")", ".", "getLength", "(", ")", ";", "if", "(", "pos", ">", "length", ")", "{", "pos", "=", "wrapped", "?", "0", ":", "length", ";", "}", "boolean", "found", "=", "false", ";", "while", "(", "!", "found", "&&", "(", "backwards", "?", "pos", ">", "end", ":", "pos", "<", "end", ")", ")", "{", "found", "=", "!", "MATCH_CASE_CHECKBOX", ".", "isSelected", "(", ")", "&&", "SEGMENT", ".", "array", "[", "pos", "]", "==", "oppFirst", ";", "found", "=", "found", "?", "found", ":", "SEGMENT", ".", "array", "[", "pos", "]", "==", "first", ";", "if", "(", "found", ")", "{", "pos", "+=", "backwards", "?", "-", "(", "pattern", ".", "length", "(", ")", "-", "1", ")", ":", "0", ";", "for", "(", "int", "i", "=", "0", ";", "found", "&&", "i", "<", "pattern", ".", "length", "(", ")", ";", "i", "++", ")", "{", "char", "c", "=", "pattern", ".", "charAt", "(", "i", ")", ";", "found", "=", "SEGMENT", ".", "array", "[", "pos", "+", "i", "]", "==", "c", ";", "if", "(", "!", "MATCH_CASE_CHECKBOX", ".", "isSelected", "(", ")", "&&", "!", "found", ")", "{", "c", "=", "Character", ".", "isUpperCase", "(", "c", ")", "?", "Character", ".", "toLowerCase", "(", "c", ")", ":", "Character", ".", "toUpperCase", "(", "c", ")", ";", "found", "=", "SEGMENT", ".", "array", "[", "pos", "+", "i", "]", "==", "c", ";", "}", "}", "}", "if", "(", "!", "found", ")", "{", "pos", "+=", "backwards", "?", "-", "1", ":", "1", ";", "if", "(", "pos", "==", "end", "&&", "wrapped", ")", "{", "pos", "=", "backwards", "?", "SEGMENT", ".", "getEndIndex", "(", ")", ":", "0", ";", "end", "=", "start", ";", "wrapped", "=", "false", ";", "}", "}", "}", "pos", "=", "found", "?", "pos", ":", "-", "1", ";", "}", "return", "pos", ";", "}" ]
Find and select the next searchable matching text. @param reverse look forwards or backwards @param pos the starting index to start finding from @return the location of the next selected, or -1 if not found
[ "Find", "and", "select", "the", "next", "searchable", "matching", "text", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/subprojects/groovy-console/src/main/groovy/groovy/ui/text/FindReplaceUtility.java#L261-L326
156,552
groovy/groovy-core
src/main/org/codehaus/groovy/vmplugin/v7/IndyInterface.java
IndyInterface.invalidateSwitchPoints
protected static void invalidateSwitchPoints() { if (LOG_ENABLED) { LOG.info("invalidating switch point"); } SwitchPoint old = switchPoint; switchPoint = new SwitchPoint(); synchronized(IndyInterface.class) { SwitchPoint.invalidateAll(new SwitchPoint[]{old}); } }
java
protected static void invalidateSwitchPoints() { if (LOG_ENABLED) { LOG.info("invalidating switch point"); } SwitchPoint old = switchPoint; switchPoint = new SwitchPoint(); synchronized(IndyInterface.class) { SwitchPoint.invalidateAll(new SwitchPoint[]{old}); } }
[ "protected", "static", "void", "invalidateSwitchPoints", "(", ")", "{", "if", "(", "LOG_ENABLED", ")", "{", "LOG", ".", "info", "(", "\"invalidating switch point\"", ")", ";", "}", "SwitchPoint", "old", "=", "switchPoint", ";", "switchPoint", "=", "new", "SwitchPoint", "(", ")", ";", "synchronized", "(", "IndyInterface", ".", "class", ")", "{", "SwitchPoint", ".", "invalidateAll", "(", "new", "SwitchPoint", "[", "]", "{", "old", "}", ")", ";", "}", "}" ]
Callback for constant meta class update change
[ "Callback", "for", "constant", "meta", "class", "update", "change" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/vmplugin/v7/IndyInterface.java#L108-L115
156,553
groovy/groovy-core
src/main/org/codehaus/groovy/vmplugin/v7/IndyInterface.java
IndyInterface.bootstrapCurrent
public static CallSite bootstrapCurrent(Lookup caller, String name, MethodType type) { return realBootstrap(caller, name, CALL_TYPES.METHOD.ordinal(), type, false, true, false); }
java
public static CallSite bootstrapCurrent(Lookup caller, String name, MethodType type) { return realBootstrap(caller, name, CALL_TYPES.METHOD.ordinal(), type, false, true, false); }
[ "public", "static", "CallSite", "bootstrapCurrent", "(", "Lookup", "caller", ",", "String", "name", ",", "MethodType", "type", ")", "{", "return", "realBootstrap", "(", "caller", ",", "name", ",", "CALL_TYPES", ".", "METHOD", ".", "ordinal", "(", ")", ",", "type", ",", "false", ",", "true", ",", "false", ")", ";", "}" ]
bootstrap method for method calls with "this" as receiver @deprecated since Groovy 2.1.0
[ "bootstrap", "method", "for", "method", "calls", "with", "this", "as", "receiver" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/vmplugin/v7/IndyInterface.java#L157-L159
156,554
groovy/groovy-core
src/main/org/codehaus/groovy/vmplugin/v7/IndyInterface.java
IndyInterface.realBootstrap
private static CallSite realBootstrap(Lookup caller, String name, int callID, MethodType type, boolean safe, boolean thisCall, boolean spreadCall) { // since indy does not give us the runtime types // we produce first a dummy call site, which then changes the target to one, // that does the method selection including the the direct call to the // real method. MutableCallSite mc = new MutableCallSite(type); MethodHandle mh = makeFallBack(mc,caller.lookupClass(),name,callID,type,safe,thisCall,spreadCall); mc.setTarget(mh); return mc; }
java
private static CallSite realBootstrap(Lookup caller, String name, int callID, MethodType type, boolean safe, boolean thisCall, boolean spreadCall) { // since indy does not give us the runtime types // we produce first a dummy call site, which then changes the target to one, // that does the method selection including the the direct call to the // real method. MutableCallSite mc = new MutableCallSite(type); MethodHandle mh = makeFallBack(mc,caller.lookupClass(),name,callID,type,safe,thisCall,spreadCall); mc.setTarget(mh); return mc; }
[ "private", "static", "CallSite", "realBootstrap", "(", "Lookup", "caller", ",", "String", "name", ",", "int", "callID", ",", "MethodType", "type", ",", "boolean", "safe", ",", "boolean", "thisCall", ",", "boolean", "spreadCall", ")", "{", "// since indy does not give us the runtime types", "// we produce first a dummy call site, which then changes the target to one,", "// that does the method selection including the the direct call to the ", "// real method.", "MutableCallSite", "mc", "=", "new", "MutableCallSite", "(", "type", ")", ";", "MethodHandle", "mh", "=", "makeFallBack", "(", "mc", ",", "caller", ".", "lookupClass", "(", ")", ",", "name", ",", "callID", ",", "type", ",", "safe", ",", "thisCall", ",", "spreadCall", ")", ";", "mc", ".", "setTarget", "(", "mh", ")", ";", "return", "mc", ";", "}" ]
backing bootstrap method with all parameters
[ "backing", "bootstrap", "method", "with", "all", "parameters" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/vmplugin/v7/IndyInterface.java#L188-L197
156,555
groovy/groovy-core
subprojects/groovy-swing/src/main/groovy/groovy/swing/impl/TableLayout.java
TableLayout.addCell
public void addCell(TableLayoutCell cell) { GridBagConstraints constraints = cell.getConstraints(); constraints.insets = new Insets(cellpadding, cellpadding, cellpadding, cellpadding); add(cell.getComponent(), constraints); }
java
public void addCell(TableLayoutCell cell) { GridBagConstraints constraints = cell.getConstraints(); constraints.insets = new Insets(cellpadding, cellpadding, cellpadding, cellpadding); add(cell.getComponent(), constraints); }
[ "public", "void", "addCell", "(", "TableLayoutCell", "cell", ")", "{", "GridBagConstraints", "constraints", "=", "cell", ".", "getConstraints", "(", ")", ";", "constraints", ".", "insets", "=", "new", "Insets", "(", "cellpadding", ",", "cellpadding", ",", "cellpadding", ",", "cellpadding", ")", ";", "add", "(", "cell", ".", "getComponent", "(", ")", ",", "constraints", ")", ";", "}" ]
Adds a new cell to the current grid @param cell the td component
[ "Adds", "a", "new", "cell", "to", "the", "current", "grid" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/subprojects/groovy-swing/src/main/groovy/groovy/swing/impl/TableLayout.java#L54-L58
156,556
groovy/groovy-core
src/main/org/codehaus/groovy/ast/CompileUnit.java
CompileUnit.addClass
public void addClass(ClassNode node) { node = node.redirect(); String name = node.getName(); ClassNode stored = classes.get(name); if (stored != null && stored != node) { // we have a duplicate class! // One possibility for this is, that we declared a script and a // class in the same file and named the class like the file SourceUnit nodeSource = node.getModule().getContext(); SourceUnit storedSource = stored.getModule().getContext(); String txt = "Invalid duplicate class definition of class " + node.getName() + " : "; if (nodeSource == storedSource) { // same class in same source txt += "The source " + nodeSource.getName() + " contains at least two definitions of the class " + node.getName() + ".\n"; if (node.isScriptBody() || stored.isScriptBody()) { txt += "One of the classes is an explicit generated class using the class statement, the other is a class generated from" + " the script body based on the file name. Solutions are to change the file name or to change the class name.\n"; } } else { txt += "The sources " + nodeSource.getName() + " and " + storedSource.getName() + " each contain a class with the name " + node.getName() + ".\n"; } nodeSource.getErrorCollector().addErrorAndContinue( new SyntaxErrorMessage(new SyntaxException(txt, node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()), nodeSource) ); } classes.put(name, node); if (classesToCompile.containsKey(name)) { ClassNode cn = classesToCompile.get(name); cn.setRedirect(node); classesToCompile.remove(name); } }
java
public void addClass(ClassNode node) { node = node.redirect(); String name = node.getName(); ClassNode stored = classes.get(name); if (stored != null && stored != node) { // we have a duplicate class! // One possibility for this is, that we declared a script and a // class in the same file and named the class like the file SourceUnit nodeSource = node.getModule().getContext(); SourceUnit storedSource = stored.getModule().getContext(); String txt = "Invalid duplicate class definition of class " + node.getName() + " : "; if (nodeSource == storedSource) { // same class in same source txt += "The source " + nodeSource.getName() + " contains at least two definitions of the class " + node.getName() + ".\n"; if (node.isScriptBody() || stored.isScriptBody()) { txt += "One of the classes is an explicit generated class using the class statement, the other is a class generated from" + " the script body based on the file name. Solutions are to change the file name or to change the class name.\n"; } } else { txt += "The sources " + nodeSource.getName() + " and " + storedSource.getName() + " each contain a class with the name " + node.getName() + ".\n"; } nodeSource.getErrorCollector().addErrorAndContinue( new SyntaxErrorMessage(new SyntaxException(txt, node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()), nodeSource) ); } classes.put(name, node); if (classesToCompile.containsKey(name)) { ClassNode cn = classesToCompile.get(name); cn.setRedirect(node); classesToCompile.remove(name); } }
[ "public", "void", "addClass", "(", "ClassNode", "node", ")", "{", "node", "=", "node", ".", "redirect", "(", ")", ";", "String", "name", "=", "node", ".", "getName", "(", ")", ";", "ClassNode", "stored", "=", "classes", ".", "get", "(", "name", ")", ";", "if", "(", "stored", "!=", "null", "&&", "stored", "!=", "node", ")", "{", "// we have a duplicate class!", "// One possibility for this is, that we declared a script and a", "// class in the same file and named the class like the file", "SourceUnit", "nodeSource", "=", "node", ".", "getModule", "(", ")", ".", "getContext", "(", ")", ";", "SourceUnit", "storedSource", "=", "stored", ".", "getModule", "(", ")", ".", "getContext", "(", ")", ";", "String", "txt", "=", "\"Invalid duplicate class definition of class \"", "+", "node", ".", "getName", "(", ")", "+", "\" : \"", ";", "if", "(", "nodeSource", "==", "storedSource", ")", "{", "// same class in same source", "txt", "+=", "\"The source \"", "+", "nodeSource", ".", "getName", "(", ")", "+", "\" contains at least two definitions of the class \"", "+", "node", ".", "getName", "(", ")", "+", "\".\\n\"", ";", "if", "(", "node", ".", "isScriptBody", "(", ")", "||", "stored", ".", "isScriptBody", "(", ")", ")", "{", "txt", "+=", "\"One of the classes is an explicit generated class using the class statement, the other is a class generated from\"", "+", "\" the script body based on the file name. Solutions are to change the file name or to change the class name.\\n\"", ";", "}", "}", "else", "{", "txt", "+=", "\"The sources \"", "+", "nodeSource", ".", "getName", "(", ")", "+", "\" and \"", "+", "storedSource", ".", "getName", "(", ")", "+", "\" each contain a class with the name \"", "+", "node", ".", "getName", "(", ")", "+", "\".\\n\"", ";", "}", "nodeSource", ".", "getErrorCollector", "(", ")", ".", "addErrorAndContinue", "(", "new", "SyntaxErrorMessage", "(", "new", "SyntaxException", "(", "txt", ",", "node", ".", "getLineNumber", "(", ")", ",", "node", ".", "getColumnNumber", "(", ")", ",", "node", ".", "getLastLineNumber", "(", ")", ",", "node", ".", "getLastColumnNumber", "(", ")", ")", ",", "nodeSource", ")", ")", ";", "}", "classes", ".", "put", "(", "name", ",", "node", ")", ";", "if", "(", "classesToCompile", ".", "containsKey", "(", "name", ")", ")", "{", "ClassNode", "cn", "=", "classesToCompile", ".", "get", "(", "name", ")", ";", "cn", ".", "setRedirect", "(", "node", ")", ";", "classesToCompile", ".", "remove", "(", "name", ")", ";", "}", "}" ]
Adds a class to the unit.
[ "Adds", "a", "class", "to", "the", "unit", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/ast/CompileUnit.java#L127-L159
156,557
groovy/groovy-core
src/main/org/codehaus/groovy/tools/LoaderConfiguration.java
LoaderConfiguration.getSlashyPath
private String getSlashyPath(final String path) { String changedPath = path; if (File.separatorChar != '/') changedPath = changedPath.replace(File.separatorChar, '/'); return changedPath; }
java
private String getSlashyPath(final String path) { String changedPath = path; if (File.separatorChar != '/') changedPath = changedPath.replace(File.separatorChar, '/'); return changedPath; }
[ "private", "String", "getSlashyPath", "(", "final", "String", "path", ")", "{", "String", "changedPath", "=", "path", ";", "if", "(", "File", ".", "separatorChar", "!=", "'", "'", ")", "changedPath", "=", "changedPath", ".", "replace", "(", "File", ".", "separatorChar", ",", "'", "'", ")", ";", "return", "changedPath", ";", "}" ]
This solution is based on an absolute path
[ "This", "solution", "is", "based", "on", "an", "absolute", "path" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/tools/LoaderConfiguration.java#L259-L265
156,558
groovy/groovy-core
subprojects/groovy-nio/src/main/java/org/codehaus/groovy/runtime/NioGroovyMethods.java
NioGroovyMethods.write
public static void write(Path self, String text, String charset) throws IOException { Writer writer = null; try { writer = new OutputStreamWriter(Files.newOutputStream(self, CREATE, APPEND), Charset.forName(charset)); writer.write(text); writer.flush(); Writer temp = writer; writer = null; temp.close(); } finally { closeWithWarning(writer); } }
java
public static void write(Path self, String text, String charset) throws IOException { Writer writer = null; try { writer = new OutputStreamWriter(Files.newOutputStream(self, CREATE, APPEND), Charset.forName(charset)); writer.write(text); writer.flush(); Writer temp = writer; writer = null; temp.close(); } finally { closeWithWarning(writer); } }
[ "public", "static", "void", "write", "(", "Path", "self", ",", "String", "text", ",", "String", "charset", ")", "throws", "IOException", "{", "Writer", "writer", "=", "null", ";", "try", "{", "writer", "=", "new", "OutputStreamWriter", "(", "Files", ".", "newOutputStream", "(", "self", ",", "CREATE", ",", "APPEND", ")", ",", "Charset", ".", "forName", "(", "charset", ")", ")", ";", "writer", ".", "write", "(", "text", ")", ";", "writer", ".", "flush", "(", ")", ";", "Writer", "temp", "=", "writer", ";", "writer", "=", "null", ";", "temp", ".", "close", "(", ")", ";", "}", "finally", "{", "closeWithWarning", "(", "writer", ")", ";", "}", "}" ]
Write the text to the Path, using the specified encoding. @param self a Path @param text the text to write to the Path @param charset the charset used @throws java.io.IOException if an IOException occurs. @since 2.3.0
[ "Write", "the", "text", "to", "the", "Path", "using", "the", "specified", "encoding", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/subprojects/groovy-nio/src/main/java/org/codehaus/groovy/runtime/NioGroovyMethods.java#L558-L571
156,559
groovy/groovy-core
subprojects/groovy-nio/src/main/java/org/codehaus/groovy/runtime/NioGroovyMethods.java
NioGroovyMethods.append
public static void append(Path self, Object text) throws IOException { Writer writer = null; try { writer = new OutputStreamWriter(Files.newOutputStream(self, CREATE, APPEND), Charset.defaultCharset()); InvokerHelper.write(writer, text); writer.flush(); Writer temp = writer; writer = null; temp.close(); } finally { closeWithWarning(writer); } }
java
public static void append(Path self, Object text) throws IOException { Writer writer = null; try { writer = new OutputStreamWriter(Files.newOutputStream(self, CREATE, APPEND), Charset.defaultCharset()); InvokerHelper.write(writer, text); writer.flush(); Writer temp = writer; writer = null; temp.close(); } finally { closeWithWarning(writer); } }
[ "public", "static", "void", "append", "(", "Path", "self", ",", "Object", "text", ")", "throws", "IOException", "{", "Writer", "writer", "=", "null", ";", "try", "{", "writer", "=", "new", "OutputStreamWriter", "(", "Files", ".", "newOutputStream", "(", "self", ",", "CREATE", ",", "APPEND", ")", ",", "Charset", ".", "defaultCharset", "(", ")", ")", ";", "InvokerHelper", ".", "write", "(", "writer", ",", "text", ")", ";", "writer", ".", "flush", "(", ")", ";", "Writer", "temp", "=", "writer", ";", "writer", "=", "null", ";", "temp", ".", "close", "(", ")", ";", "}", "finally", "{", "closeWithWarning", "(", "writer", ")", ";", "}", "}" ]
Append the text at the end of the Path. @param self a Path @param text the text to append at the end of the Path @throws java.io.IOException if an IOException occurs. @since 2.3.0
[ "Append", "the", "text", "at", "the", "end", "of", "the", "Path", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/subprojects/groovy-nio/src/main/java/org/codehaus/groovy/runtime/NioGroovyMethods.java#L581-L594
156,560
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.count
public static int count(CharSequence self, CharSequence text) { int answer = 0; for (int idx = 0; true; idx++) { idx = self.toString().indexOf(text.toString(), idx); // break once idx goes to -1 or for case of empty string once // we get to the end to avoid JDK library bug (see GROOVY-5858) if (idx < answer) break; ++answer; } return answer; }
java
public static int count(CharSequence self, CharSequence text) { int answer = 0; for (int idx = 0; true; idx++) { idx = self.toString().indexOf(text.toString(), idx); // break once idx goes to -1 or for case of empty string once // we get to the end to avoid JDK library bug (see GROOVY-5858) if (idx < answer) break; ++answer; } return answer; }
[ "public", "static", "int", "count", "(", "CharSequence", "self", ",", "CharSequence", "text", ")", "{", "int", "answer", "=", "0", ";", "for", "(", "int", "idx", "=", "0", ";", "true", ";", "idx", "++", ")", "{", "idx", "=", "self", ".", "toString", "(", ")", ".", "indexOf", "(", "text", ".", "toString", "(", ")", ",", "idx", ")", ";", "// break once idx goes to -1 or for case of empty string once", "// we get to the end to avoid JDK library bug (see GROOVY-5858)", "if", "(", "idx", "<", "answer", ")", "break", ";", "++", "answer", ";", "}", "return", "answer", ";", "}" ]
Count the number of occurrences of a sub CharSequence. @param self a CharSequence @param text a sub CharSequence @return the number of occurrences of the given CharSequence inside this CharSequence @see #count(String, String) @since 1.8.2
[ "Count", "the", "number", "of", "occurrences", "of", "a", "sub", "CharSequence", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L387-L397
156,561
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.eachMatch
public static <T extends CharSequence> T eachMatch(T self, CharSequence regex, @ClosureParams(value=FromString.class, options={"List<String>","String[]"}) Closure closure) { eachMatch(self.toString(), regex.toString(), closure); return self; }
java
public static <T extends CharSequence> T eachMatch(T self, CharSequence regex, @ClosureParams(value=FromString.class, options={"List<String>","String[]"}) Closure closure) { eachMatch(self.toString(), regex.toString(), closure); return self; }
[ "public", "static", "<", "T", "extends", "CharSequence", ">", "T", "eachMatch", "(", "T", "self", ",", "CharSequence", "regex", ",", "@", "ClosureParams", "(", "value", "=", "FromString", ".", "class", ",", "options", "=", "{", "\"List<String>\"", ",", "\"String[]\"", "}", ")", "Closure", "closure", ")", "{", "eachMatch", "(", "self", ".", "toString", "(", ")", ",", "regex", ".", "toString", "(", ")", ",", "closure", ")", ";", "return", "self", ";", "}" ]
Process each regex group matched substring of the given CharSequence. 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. @param self the source CharSequence @param regex a Regex CharSequence @param closure a closure with one parameter or as much parameters as groups @return the source CharSequence @see #eachMatch(String, String, groovy.lang.Closure) @since 1.8.2
[ "Process", "each", "regex", "group", "matched", "substring", "of", "the", "given", "CharSequence", ".", "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", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L692-L695
156,562
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.eachMatch
public static String eachMatch(String self, String regex, @ClosureParams(value=FromString.class, options={"List<String>","String[]"}) Closure closure) { return eachMatch(self, Pattern.compile(regex), closure); }
java
public static String eachMatch(String self, String regex, @ClosureParams(value=FromString.class, options={"List<String>","String[]"}) Closure closure) { return eachMatch(self, Pattern.compile(regex), closure); }
[ "public", "static", "String", "eachMatch", "(", "String", "self", ",", "String", "regex", ",", "@", "ClosureParams", "(", "value", "=", "FromString", ".", "class", ",", "options", "=", "{", "\"List<String>\"", ",", "\"String[]\"", "}", ")", "Closure", "closure", ")", "{", "return", "eachMatch", "(", "self", ",", "Pattern", ".", "compile", "(", "regex", ")", ",", "closure", ")", ";", "}" ]
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. @param self the source string @param regex a Regex string @param closure a closure with one parameter or as much parameters as groups @return the source string @since 1.6.0
[ "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", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L745-L747
156,563
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.expandLine
public static String expandLine(CharSequence self, int tabStop) { String s = self.toString(); int index; while ((index = s.indexOf('\t')) != -1) { StringBuilder builder = new StringBuilder(s); int count = tabStop - index % tabStop; builder.deleteCharAt(index); for (int i = 0; i < count; i++) builder.insert(index, " "); s = builder.toString(); } return s; }
java
public static String expandLine(CharSequence self, int tabStop) { String s = self.toString(); int index; while ((index = s.indexOf('\t')) != -1) { StringBuilder builder = new StringBuilder(s); int count = tabStop - index % tabStop; builder.deleteCharAt(index); for (int i = 0; i < count; i++) builder.insert(index, " "); s = builder.toString(); } return s; }
[ "public", "static", "String", "expandLine", "(", "CharSequence", "self", ",", "int", "tabStop", ")", "{", "String", "s", "=", "self", ".", "toString", "(", ")", ";", "int", "index", ";", "while", "(", "(", "index", "=", "s", ".", "indexOf", "(", "'", "'", ")", ")", "!=", "-", "1", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", "s", ")", ";", "int", "count", "=", "tabStop", "-", "index", "%", "tabStop", ";", "builder", ".", "deleteCharAt", "(", "index", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "builder", ".", "insert", "(", "index", ",", "\"", "\"", ")", ";", "s", "=", "builder", ".", "toString", "(", ")", ";", "}", "return", "s", ";", "}" ]
Expands all tabs into spaces. Assumes the CharSequence represents a single line of text. @param self A line to expand @param tabStop The number of spaces a tab represents @return The expanded toString() of this CharSequence @see #expandLine(String, int) @since 1.8.2
[ "Expands", "all", "tabs", "into", "spaces", ".", "Assumes", "the", "CharSequence", "represents", "a", "single", "line", "of", "text", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L819-L830
156,564
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.find
public static String find(CharSequence self, CharSequence regex, @ClosureParams(value=SimpleType.class, options="java.lang.String[]") Closure closure) { return find(self.toString(), Pattern.compile(regex.toString()), closure); }
java
public static String find(CharSequence self, CharSequence regex, @ClosureParams(value=SimpleType.class, options="java.lang.String[]") Closure closure) { return find(self.toString(), Pattern.compile(regex.toString()), closure); }
[ "public", "static", "String", "find", "(", "CharSequence", "self", ",", "CharSequence", "regex", ",", "@", "ClosureParams", "(", "value", "=", "SimpleType", ".", "class", ",", "options", "=", "\"java.lang.String[]\"", ")", "Closure", "closure", ")", "{", "return", "find", "(", "self", ".", "toString", "(", ")", ",", "Pattern", ".", "compile", "(", "regex", ".", "toString", "(", ")", ")", ",", "closure", ")", ";", "}" ]
Returns the result of calling a closure with the first occurrence of a regular expression found within a CharSequence. If the regex doesn't match, the closure will not be called and find will return null. @param self a CharSequence @param regex the capturing regex CharSequence @param closure the closure that will be passed the full match, plus each of the capturing groups (if any) @return a String containing the result of calling the closure (calling toString() if needed), or null if the regex pattern doesn't match @see #find(String, java.util.regex.Pattern, groovy.lang.Closure) @since 1.8.2
[ "Returns", "the", "result", "of", "calling", "a", "closure", "with", "the", "first", "occurrence", "of", "a", "regular", "expression", "found", "within", "a", "CharSequence", ".", "If", "the", "regex", "doesn", "t", "match", "the", "closure", "will", "not", "be", "called", "and", "find", "will", "return", "null", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L881-L883
156,565
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.getAt
public static String getAt(CharSequence self, Collection indices) { StringBuilder answer = new StringBuilder(); for (Object value : indices) { if (value instanceof Range) { answer.append(getAt(self, (Range) value)); } else if (value instanceof Collection) { answer.append(getAt(self, (Collection) value)); } else { int idx = DefaultTypeTransformation.intUnbox(value); answer.append(getAt(self, idx)); } } return answer.toString(); }
java
public static String getAt(CharSequence self, Collection indices) { StringBuilder answer = new StringBuilder(); for (Object value : indices) { if (value instanceof Range) { answer.append(getAt(self, (Range) value)); } else if (value instanceof Collection) { answer.append(getAt(self, (Collection) value)); } else { int idx = DefaultTypeTransformation.intUnbox(value); answer.append(getAt(self, idx)); } } return answer.toString(); }
[ "public", "static", "String", "getAt", "(", "CharSequence", "self", ",", "Collection", "indices", ")", "{", "StringBuilder", "answer", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Object", "value", ":", "indices", ")", "{", "if", "(", "value", "instanceof", "Range", ")", "{", "answer", ".", "append", "(", "getAt", "(", "self", ",", "(", "Range", ")", "value", ")", ")", ";", "}", "else", "if", "(", "value", "instanceof", "Collection", ")", "{", "answer", ".", "append", "(", "getAt", "(", "self", ",", "(", "Collection", ")", "value", ")", ")", ";", "}", "else", "{", "int", "idx", "=", "DefaultTypeTransformation", ".", "intUnbox", "(", "value", ")", ";", "answer", ".", "append", "(", "getAt", "(", "self", ",", "idx", ")", ")", ";", "}", "}", "return", "answer", ".", "toString", "(", ")", ";", "}" ]
Select a List of characters from a CharSequence using a Collection to identify the indices to be selected. @param self a CharSequence @param indices a Collection of indices @return a String consisting of the characters at the given indices @since 1.0
[ "Select", "a", "List", "of", "characters", "from", "a", "CharSequence", "using", "a", "Collection", "to", "identify", "the", "indices", "to", "be", "selected", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1205-L1218
156,566
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.getAt
public static CharSequence getAt(CharSequence text, int index) { index = normaliseIndex(index, text.length()); return text.subSequence(index, index + 1); }
java
public static CharSequence getAt(CharSequence text, int index) { index = normaliseIndex(index, text.length()); return text.subSequence(index, index + 1); }
[ "public", "static", "CharSequence", "getAt", "(", "CharSequence", "text", ",", "int", "index", ")", "{", "index", "=", "normaliseIndex", "(", "index", ",", "text", ".", "length", "(", ")", ")", ";", "return", "text", ".", "subSequence", "(", "index", ",", "index", "+", "1", ")", ";", "}" ]
Support the subscript operator for CharSequence. @param text a CharSequence @param index the index of the Character to get @return the Character at the given index @since 1.0
[ "Support", "the", "subscript", "operator", "for", "CharSequence", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1240-L1243
156,567
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.getAt
public static String getAt(GString text, int index) { return (String) getAt(text.toString(), index); }
java
public static String getAt(GString text, int index) { return (String) getAt(text.toString(), index); }
[ "public", "static", "String", "getAt", "(", "GString", "text", ",", "int", "index", ")", "{", "return", "(", "String", ")", "getAt", "(", "text", ".", "toString", "(", ")", ",", "index", ")", ";", "}" ]
Support the subscript operator for GString. @param text a GString @param index the index of the Character to get @return the Character at the given index @since 2.3.7
[ "Support", "the", "subscript", "operator", "for", "GString", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1253-L1255
156,568
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.getAt
public static CharSequence getAt(CharSequence text, IntRange range) { return getAt(text, (Range) range); }
java
public static CharSequence getAt(CharSequence text, IntRange range) { return getAt(text, (Range) range); }
[ "public", "static", "CharSequence", "getAt", "(", "CharSequence", "text", ",", "IntRange", "range", ")", "{", "return", "getAt", "(", "text", ",", "(", "Range", ")", "range", ")", ";", "}" ]
Support the range subscript operator for CharSequence with IntRange @param text a CharSequence @param range an IntRange @return the subsequence CharSequence @since 1.0
[ "Support", "the", "range", "subscript", "operator", "for", "CharSequence", "with", "IntRange" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1265-L1267
156,569
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.getAt
public static CharSequence getAt(CharSequence text, Range range) { RangeInfo info = subListBorders(text.length(), range); CharSequence sequence = text.subSequence(info.from, info.to); return info.reverse ? reverse(sequence) : sequence; }
java
public static CharSequence getAt(CharSequence text, Range range) { RangeInfo info = subListBorders(text.length(), range); CharSequence sequence = text.subSequence(info.from, info.to); return info.reverse ? reverse(sequence) : sequence; }
[ "public", "static", "CharSequence", "getAt", "(", "CharSequence", "text", ",", "Range", "range", ")", "{", "RangeInfo", "info", "=", "subListBorders", "(", "text", ".", "length", "(", ")", ",", "range", ")", ";", "CharSequence", "sequence", "=", "text", ".", "subSequence", "(", "info", ".", "from", ",", "info", ".", "to", ")", ";", "return", "info", ".", "reverse", "?", "reverse", "(", "sequence", ")", ":", "sequence", ";", "}" ]
Support the range subscript operator for CharSequence @param text a CharSequence @param range a Range @return the subsequence CharSequence @since 1.0
[ "Support", "the", "range", "subscript", "operator", "for", "CharSequence" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1289-L1293
156,570
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.getAt
public static String getAt(GString text, Range range) { return getAt(text.toString(), range); }
java
public static String getAt(GString text, Range range) { return getAt(text.toString(), range); }
[ "public", "static", "String", "getAt", "(", "GString", "text", ",", "Range", "range", ")", "{", "return", "getAt", "(", "text", ".", "toString", "(", ")", ",", "range", ")", ";", "}" ]
Support the range subscript operator for GString @param text a GString @param range a Range @return the String of characters corresponding to the provided range @since 2.3.7
[ "Support", "the", "range", "subscript", "operator", "for", "GString" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1303-L1305
156,571
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.getAt
public static List getAt(Matcher self, Collection indices) { List result = new ArrayList(); for (Object value : indices) { if (value instanceof Range) { result.addAll(getAt(self, (Range) value)); } else { int idx = DefaultTypeTransformation.intUnbox(value); result.add(getAt(self, idx)); } } return result; }
java
public static List getAt(Matcher self, Collection indices) { List result = new ArrayList(); for (Object value : indices) { if (value instanceof Range) { result.addAll(getAt(self, (Range) value)); } else { int idx = DefaultTypeTransformation.intUnbox(value); result.add(getAt(self, idx)); } } return result; }
[ "public", "static", "List", "getAt", "(", "Matcher", "self", ",", "Collection", "indices", ")", "{", "List", "result", "=", "new", "ArrayList", "(", ")", ";", "for", "(", "Object", "value", ":", "indices", ")", "{", "if", "(", "value", "instanceof", "Range", ")", "{", "result", ".", "addAll", "(", "getAt", "(", "self", ",", "(", "Range", ")", "value", ")", ")", ";", "}", "else", "{", "int", "idx", "=", "DefaultTypeTransformation", ".", "intUnbox", "(", "value", ")", ";", "result", ".", "add", "(", "getAt", "(", "self", ",", "idx", ")", ")", ";", "}", "}", "return", "result", ";", "}" ]
Select a List of values from a Matcher using a Collection to identify the indices to be selected. @param self a Matcher @param indices a Collection of indices @return a String of the values at the given indices @since 1.6.0
[ "Select", "a", "List", "of", "values", "from", "a", "Matcher", "using", "a", "Collection", "to", "identify", "the", "indices", "to", "be", "selected", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1316-L1327
156,572
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.getAt
public static String getAt(String text, int index) { index = normaliseIndex(index, text.length()); return text.substring(index, index + 1); }
java
public static String getAt(String text, int index) { index = normaliseIndex(index, text.length()); return text.substring(index, index + 1); }
[ "public", "static", "String", "getAt", "(", "String", "text", ",", "int", "index", ")", "{", "index", "=", "normaliseIndex", "(", "index", ",", "text", ".", "length", "(", ")", ")", ";", "return", "text", ".", "substring", "(", "index", ",", "index", "+", "1", ")", ";", "}" ]
Support the subscript operator for String. @param text a String @param index the index of the Character to get @return the Character at the given index @since 1.0
[ "Support", "the", "subscript", "operator", "for", "String", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1449-L1452
156,573
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.getAt
public static String getAt(String text, IntRange range) { return getAt(text, (Range) range); }
java
public static String getAt(String text, IntRange range) { return getAt(text, (Range) range); }
[ "public", "static", "String", "getAt", "(", "String", "text", ",", "IntRange", "range", ")", "{", "return", "getAt", "(", "text", ",", "(", "Range", ")", "range", ")", ";", "}" ]
Support the range subscript operator for String with IntRange @param text a String @param range an IntRange @return the resulting String @since 1.0
[ "Support", "the", "range", "subscript", "operator", "for", "String", "with", "IntRange" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1462-L1464
156,574
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.getAt
public static String getAt(String text, Range range) { RangeInfo info = subListBorders(text.length(), range); String answer = text.substring(info.from, info.to); if (info.reverse) { answer = reverse(answer); } return answer; }
java
public static String getAt(String text, Range range) { RangeInfo info = subListBorders(text.length(), range); String answer = text.substring(info.from, info.to); if (info.reverse) { answer = reverse(answer); } return answer; }
[ "public", "static", "String", "getAt", "(", "String", "text", ",", "Range", "range", ")", "{", "RangeInfo", "info", "=", "subListBorders", "(", "text", ".", "length", "(", ")", ",", "range", ")", ";", "String", "answer", "=", "text", ".", "substring", "(", "info", ".", "from", ",", "info", ".", "to", ")", ";", "if", "(", "info", ".", "reverse", ")", "{", "answer", "=", "reverse", "(", "answer", ")", ";", "}", "return", "answer", ";", "}" ]
Support the range subscript operator for String @param text a String @param range a Range @return a substring corresponding to the Range @since 1.0
[ "Support", "the", "range", "subscript", "operator", "for", "String" ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1474-L1481
156,575
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.getCount
public static int getCount(Matcher matcher) { int counter = 0; matcher.reset(); while (matcher.find()) { counter++; } return counter; }
java
public static int getCount(Matcher matcher) { int counter = 0; matcher.reset(); while (matcher.find()) { counter++; } return counter; }
[ "public", "static", "int", "getCount", "(", "Matcher", "matcher", ")", "{", "int", "counter", "=", "0", ";", "matcher", ".", "reset", "(", ")", ";", "while", "(", "matcher", ".", "find", "(", ")", ")", "{", "counter", "++", ";", "}", "return", "counter", ";", "}" ]
Find the number of Strings matched to the given Matcher. @param matcher a Matcher @return int the number of Strings matched to the given matcher. @since 1.0
[ "Find", "the", "number", "of", "Strings", "matched", "to", "the", "given", "Matcher", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1511-L1518
156,576
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.isAllWhitespace
public static boolean isAllWhitespace(CharSequence self) { String s = self.toString(); for (int i = 0; i < s.length(); i++) { if (!Character.isWhitespace(s.charAt(i))) return false; } return true; }
java
public static boolean isAllWhitespace(CharSequence self) { String s = self.toString(); for (int i = 0; i < s.length(); i++) { if (!Character.isWhitespace(s.charAt(i))) return false; } return true; }
[ "public", "static", "boolean", "isAllWhitespace", "(", "CharSequence", "self", ")", "{", "String", "s", "=", "self", ".", "toString", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "s", ".", "length", "(", ")", ";", "i", "++", ")", "{", "if", "(", "!", "Character", ".", "isWhitespace", "(", "s", ".", "charAt", "(", "i", ")", ")", ")", "return", "false", ";", "}", "return", "true", ";", "}" ]
True if a CharSequence only contains whitespace characters. @param self The CharSequence to check the characters in @return true If all characters are whitespace characters @see #isAllWhitespace(String) @since 1.8.2
[ "True", "if", "a", "CharSequence", "only", "contains", "whitespace", "characters", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1578-L1585
156,577
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.isBigDecimal
public static boolean isBigDecimal(CharSequence self) { try { new BigDecimal(self.toString().trim()); return true; } catch (NumberFormatException nfe) { return false; } }
java
public static boolean isBigDecimal(CharSequence self) { try { new BigDecimal(self.toString().trim()); return true; } catch (NumberFormatException nfe) { return false; } }
[ "public", "static", "boolean", "isBigDecimal", "(", "CharSequence", "self", ")", "{", "try", "{", "new", "BigDecimal", "(", "self", ".", "toString", "(", ")", ".", "trim", "(", ")", ")", ";", "return", "true", ";", "}", "catch", "(", "NumberFormatException", "nfe", ")", "{", "return", "false", ";", "}", "}" ]
Determine if a CharSequence can be parsed as a BigDecimal. @param self a CharSequence @return true if the CharSequence can be parsed @see #isBigDecimal(String) @since 1.8.2
[ "Determine", "if", "a", "CharSequence", "can", "be", "parsed", "as", "a", "BigDecimal", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1604-L1611
156,578
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.isBigInteger
public static boolean isBigInteger(CharSequence self) { try { new BigInteger(self.toString().trim()); return true; } catch (NumberFormatException nfe) { return false; } }
java
public static boolean isBigInteger(CharSequence self) { try { new BigInteger(self.toString().trim()); return true; } catch (NumberFormatException nfe) { return false; } }
[ "public", "static", "boolean", "isBigInteger", "(", "CharSequence", "self", ")", "{", "try", "{", "new", "BigInteger", "(", "self", ".", "toString", "(", ")", ".", "trim", "(", ")", ")", ";", "return", "true", ";", "}", "catch", "(", "NumberFormatException", "nfe", ")", "{", "return", "false", ";", "}", "}" ]
Determine if a CharSequence can be parsed as a BigInteger. @param self a CharSequence @return true if the CharSequence can be parsed @see #isBigInteger(String) @since 1.8.2
[ "Determine", "if", "a", "CharSequence", "can", "be", "parsed", "as", "a", "BigInteger", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1630-L1637
156,579
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.isDouble
public static boolean isDouble(CharSequence self) { try { Double.valueOf(self.toString().trim()); return true; } catch (NumberFormatException nfe) { return false; } }
java
public static boolean isDouble(CharSequence self) { try { Double.valueOf(self.toString().trim()); return true; } catch (NumberFormatException nfe) { return false; } }
[ "public", "static", "boolean", "isDouble", "(", "CharSequence", "self", ")", "{", "try", "{", "Double", ".", "valueOf", "(", "self", ".", "toString", "(", ")", ".", "trim", "(", ")", ")", ";", "return", "true", ";", "}", "catch", "(", "NumberFormatException", "nfe", ")", "{", "return", "false", ";", "}", "}" ]
Determine if a CharSequence can be parsed as a Double. @param self a CharSequence @return true if the CharSequence can be parsed @see #isDouble(String) @since 1.8.2
[ "Determine", "if", "a", "CharSequence", "can", "be", "parsed", "as", "a", "Double", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1730-L1737
156,580
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.isFloat
public static boolean isFloat(CharSequence self) { try { Float.valueOf(self.toString().trim()); return true; } catch (NumberFormatException nfe) { return false; } }
java
public static boolean isFloat(CharSequence self) { try { Float.valueOf(self.toString().trim()); return true; } catch (NumberFormatException nfe) { return false; } }
[ "public", "static", "boolean", "isFloat", "(", "CharSequence", "self", ")", "{", "try", "{", "Float", ".", "valueOf", "(", "self", ".", "toString", "(", ")", ".", "trim", "(", ")", ")", ";", "return", "true", ";", "}", "catch", "(", "NumberFormatException", "nfe", ")", "{", "return", "false", ";", "}", "}" ]
Determine if a CharSequence can be parsed as a Float. @param self a CharSequence @return true if the CharSequence can be parsed @see #isFloat(String) @since 1.8.2
[ "Determine", "if", "a", "CharSequence", "can", "be", "parsed", "as", "a", "Float", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1756-L1763
156,581
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.isInteger
public static boolean isInteger(CharSequence self) { try { Integer.valueOf(self.toString().trim()); return true; } catch (NumberFormatException nfe) { return false; } }
java
public static boolean isInteger(CharSequence self) { try { Integer.valueOf(self.toString().trim()); return true; } catch (NumberFormatException nfe) { return false; } }
[ "public", "static", "boolean", "isInteger", "(", "CharSequence", "self", ")", "{", "try", "{", "Integer", ".", "valueOf", "(", "self", ".", "toString", "(", ")", ".", "trim", "(", ")", ")", ";", "return", "true", ";", "}", "catch", "(", "NumberFormatException", "nfe", ")", "{", "return", "false", ";", "}", "}" ]
Determine if a CharSequence can be parsed as an Integer. @param self a CharSequence @return true if the CharSequence can be parsed @see #isInteger(String) @since 1.8.2
[ "Determine", "if", "a", "CharSequence", "can", "be", "parsed", "as", "an", "Integer", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1782-L1789
156,582
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.isLong
public static boolean isLong(CharSequence self) { try { Long.valueOf(self.toString().trim()); return true; } catch (NumberFormatException nfe) { return false; } }
java
public static boolean isLong(CharSequence self) { try { Long.valueOf(self.toString().trim()); return true; } catch (NumberFormatException nfe) { return false; } }
[ "public", "static", "boolean", "isLong", "(", "CharSequence", "self", ")", "{", "try", "{", "Long", ".", "valueOf", "(", "self", ".", "toString", "(", ")", ".", "trim", "(", ")", ")", ";", "return", "true", ";", "}", "catch", "(", "NumberFormatException", "nfe", ")", "{", "return", "false", ";", "}", "}" ]
Determine if a CharSequence can be parsed as a Long. @param self a CharSequence @return true if the CharSequence can be parsed @see #isLong(String) @since 1.8.2
[ "Determine", "if", "a", "CharSequence", "can", "be", "parsed", "as", "a", "Long", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1808-L1815
156,583
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.leftShift
public static StringBuffer leftShift(String self, Object value) { return new StringBuffer(self).append(value); }
java
public static StringBuffer leftShift(String self, Object value) { return new StringBuffer(self).append(value); }
[ "public", "static", "StringBuffer", "leftShift", "(", "String", "self", ",", "Object", "value", ")", "{", "return", "new", "StringBuffer", "(", "self", ")", ".", "append", "(", "value", ")", ";", "}" ]
Overloads the left shift operator to provide an easy way to append multiple objects as string representations to a String. @param self a String @param value an Object @return a StringBuffer built from this string @since 1.0
[ "Overloads", "the", "left", "shift", "operator", "to", "provide", "an", "easy", "way", "to", "append", "multiple", "objects", "as", "string", "representations", "to", "a", "String", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1926-L1928
156,584
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.leftShift
public static StringBuilder leftShift(StringBuilder self, Object value) { self.append(value); return self; }
java
public static StringBuilder leftShift(StringBuilder self, Object value) { self.append(value); return self; }
[ "public", "static", "StringBuilder", "leftShift", "(", "StringBuilder", "self", ",", "Object", "value", ")", "{", "self", ".", "append", "(", "value", ")", ";", "return", "self", ";", "}" ]
Overloads the left shift operator to provide syntactic sugar for appending to a StringBuilder. @param self a StringBuilder @param value an Object @return the original StringBuilder @since 1.8.2
[ "Overloads", "the", "left", "shift", "operator", "to", "provide", "syntactic", "sugar", "for", "appending", "to", "a", "StringBuilder", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1952-L1955
156,585
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.minus
public static String minus(CharSequence self, Object target) { String s = self.toString(); String text = DefaultGroovyMethods.toString(target); int index = s.indexOf(text); if (index == -1) return s; int end = index + text.length(); if (s.length() > end) { return s.substring(0, index) + s.substring(end); } return s.substring(0, index); }
java
public static String minus(CharSequence self, Object target) { String s = self.toString(); String text = DefaultGroovyMethods.toString(target); int index = s.indexOf(text); if (index == -1) return s; int end = index + text.length(); if (s.length() > end) { return s.substring(0, index) + s.substring(end); } return s.substring(0, index); }
[ "public", "static", "String", "minus", "(", "CharSequence", "self", ",", "Object", "target", ")", "{", "String", "s", "=", "self", ".", "toString", "(", ")", ";", "String", "text", "=", "DefaultGroovyMethods", ".", "toString", "(", "target", ")", ";", "int", "index", "=", "s", ".", "indexOf", "(", "text", ")", ";", "if", "(", "index", "==", "-", "1", ")", "return", "s", ";", "int", "end", "=", "index", "+", "text", ".", "length", "(", ")", ";", "if", "(", "s", ".", "length", "(", ")", ">", "end", ")", "{", "return", "s", ".", "substring", "(", "0", ",", "index", ")", "+", "s", ".", "substring", "(", "end", ")", ";", "}", "return", "s", ".", "substring", "(", "0", ",", "index", ")", ";", "}" ]
Remove a part of a CharSequence by replacing the first occurrence of target within self with '' and returns the result. @param self a CharSequence @param target an object representing the part to remove @return a String containing the original minus the part to be removed @see #minus(String, Object) @since 1.8.2
[ "Remove", "a", "part", "of", "a", "CharSequence", "by", "replacing", "the", "first", "occurrence", "of", "target", "within", "self", "with", "and", "returns", "the", "result", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L1990-L2000
156,586
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.minus
public static String minus(CharSequence self, Pattern pattern) { return pattern.matcher(self).replaceFirst(""); }
java
public static String minus(CharSequence self, Pattern pattern) { return pattern.matcher(self).replaceFirst(""); }
[ "public", "static", "String", "minus", "(", "CharSequence", "self", ",", "Pattern", "pattern", ")", "{", "return", "pattern", ".", "matcher", "(", "self", ")", ".", "replaceFirst", "(", "\"\"", ")", ";", "}" ]
Remove a part of a CharSequence. This replaces the first occurrence of the pattern within self with '' and returns the result. @param self a String @param pattern a Pattern representing the part to remove @return a String minus the part to be removed @since 2.2.0
[ "Remove", "a", "part", "of", "a", "CharSequence", ".", "This", "replaces", "the", "first", "occurrence", "of", "the", "pattern", "within", "self", "with", "and", "returns", "the", "result", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L2011-L2013
156,587
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.multiply
public static String multiply(CharSequence self, Number factor) { String s = self.toString(); int size = factor.intValue(); if (size == 0) return ""; else if (size < 0) { throw new IllegalArgumentException("multiply() should be called with a number of 0 or greater not: " + size); } StringBuilder answer = new StringBuilder(s); for (int i = 1; i < size; i++) { answer.append(s); } return answer.toString(); }
java
public static String multiply(CharSequence self, Number factor) { String s = self.toString(); int size = factor.intValue(); if (size == 0) return ""; else if (size < 0) { throw new IllegalArgumentException("multiply() should be called with a number of 0 or greater not: " + size); } StringBuilder answer = new StringBuilder(s); for (int i = 1; i < size; i++) { answer.append(s); } return answer.toString(); }
[ "public", "static", "String", "multiply", "(", "CharSequence", "self", ",", "Number", "factor", ")", "{", "String", "s", "=", "self", ".", "toString", "(", ")", ";", "int", "size", "=", "factor", ".", "intValue", "(", ")", ";", "if", "(", "size", "==", "0", ")", "return", "\"\"", ";", "else", "if", "(", "size", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"multiply() should be called with a number of 0 or greater not: \"", "+", "size", ")", ";", "}", "StringBuilder", "answer", "=", "new", "StringBuilder", "(", "s", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "size", ";", "i", "++", ")", "{", "answer", ".", "append", "(", "s", ")", ";", "}", "return", "answer", ".", "toString", "(", ")", ";", "}" ]
Repeat a CharSequence a certain number of times. @param self a CharSequence to be repeated @param factor the number of times the CharSequence should be repeated @return a String composed of a repetition @throws IllegalArgumentException if the number of repetitions is &lt; 0 @since 1.8.2
[ "Repeat", "a", "CharSequence", "a", "certain", "number", "of", "times", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L2042-L2055
156,588
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.next
public static String next(CharSequence self) { StringBuilder buffer = new StringBuilder(self); if (buffer.length() == 0) { buffer.append(Character.MIN_VALUE); } else { char last = buffer.charAt(buffer.length() - 1); if (last == Character.MAX_VALUE) { buffer.append(Character.MIN_VALUE); } else { char next = last; next++; buffer.setCharAt(buffer.length() - 1, next); } } return buffer.toString(); }
java
public static String next(CharSequence self) { StringBuilder buffer = new StringBuilder(self); if (buffer.length() == 0) { buffer.append(Character.MIN_VALUE); } else { char last = buffer.charAt(buffer.length() - 1); if (last == Character.MAX_VALUE) { buffer.append(Character.MIN_VALUE); } else { char next = last; next++; buffer.setCharAt(buffer.length() - 1, next); } } return buffer.toString(); }
[ "public", "static", "String", "next", "(", "CharSequence", "self", ")", "{", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", "self", ")", ";", "if", "(", "buffer", ".", "length", "(", ")", "==", "0", ")", "{", "buffer", ".", "append", "(", "Character", ".", "MIN_VALUE", ")", ";", "}", "else", "{", "char", "last", "=", "buffer", ".", "charAt", "(", "buffer", ".", "length", "(", ")", "-", "1", ")", ";", "if", "(", "last", "==", "Character", ".", "MAX_VALUE", ")", "{", "buffer", ".", "append", "(", "Character", ".", "MIN_VALUE", ")", ";", "}", "else", "{", "char", "next", "=", "last", ";", "next", "++", ";", "buffer", ".", "setCharAt", "(", "buffer", ".", "length", "(", ")", "-", "1", ",", "next", ")", ";", "}", "}", "return", "buffer", ".", "toString", "(", ")", ";", "}" ]
This method is called by the ++ operator for the class CharSequence. It increments the last character in the given CharSequence. If the last character in the CharSequence is Character.MAX_VALUE a Character.MIN_VALUE will be appended. The empty CharSequence is incremented to a string consisting of the character Character.MIN_VALUE. @param self a CharSequence @return a value obtained by incrementing the toString() of the CharSequence @since 1.8.2
[ "This", "method", "is", "called", "by", "the", "++", "operator", "for", "the", "class", "CharSequence", ".", "It", "increments", "the", "last", "character", "in", "the", "given", "CharSequence", ".", "If", "the", "last", "character", "in", "the", "CharSequence", "is", "Character", ".", "MAX_VALUE", "a", "Character", ".", "MIN_VALUE", "will", "be", "appended", ".", "The", "empty", "CharSequence", "is", "incremented", "to", "a", "string", "consisting", "of", "the", "character", "Character", ".", "MIN_VALUE", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L2077-L2092
156,589
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.normalize
public static String normalize(final CharSequence self) { final String s = self.toString(); int nx = s.indexOf('\r'); if (nx < 0) { return s; } final int len = s.length(); final StringBuilder sb = new StringBuilder(len); int i = 0; do { sb.append(s, i, nx); sb.append('\n'); if ((i = nx + 1) >= len) break; if (s.charAt(i) == '\n') { // skip the LF in CR LF if (++i >= len) break; } nx = s.indexOf('\r', i); } while (nx > 0); sb.append(s, i, len); return sb.toString(); }
java
public static String normalize(final CharSequence self) { final String s = self.toString(); int nx = s.indexOf('\r'); if (nx < 0) { return s; } final int len = s.length(); final StringBuilder sb = new StringBuilder(len); int i = 0; do { sb.append(s, i, nx); sb.append('\n'); if ((i = nx + 1) >= len) break; if (s.charAt(i) == '\n') { // skip the LF in CR LF if (++i >= len) break; } nx = s.indexOf('\r', i); } while (nx > 0); sb.append(s, i, len); return sb.toString(); }
[ "public", "static", "String", "normalize", "(", "final", "CharSequence", "self", ")", "{", "final", "String", "s", "=", "self", ".", "toString", "(", ")", ";", "int", "nx", "=", "s", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "nx", "<", "0", ")", "{", "return", "s", ";", "}", "final", "int", "len", "=", "s", ".", "length", "(", ")", ";", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "len", ")", ";", "int", "i", "=", "0", ";", "do", "{", "sb", ".", "append", "(", "s", ",", "i", ",", "nx", ")", ";", "sb", ".", "append", "(", "'", "'", ")", ";", "if", "(", "(", "i", "=", "nx", "+", "1", ")", ">=", "len", ")", "break", ";", "if", "(", "s", ".", "charAt", "(", "i", ")", "==", "'", "'", ")", "{", "// skip the LF in CR LF", "if", "(", "++", "i", ">=", "len", ")", "break", ";", "}", "nx", "=", "s", ".", "indexOf", "(", "'", "'", ",", "i", ")", ";", "}", "while", "(", "nx", ">", "0", ")", ";", "sb", ".", "append", "(", "s", ",", "i", ",", "len", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Return a String with linefeeds and carriage returns normalized to linefeeds. @param self a CharSequence object @return the normalized toString() for the CharSequence @see #normalize(String) @since 1.8.2
[ "Return", "a", "String", "with", "linefeeds", "and", "carriage", "returns", "normalized", "to", "linefeeds", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L2111-L2141
156,590
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.plus
public static String plus(CharSequence left, Object value) { return left + DefaultGroovyMethods.toString(value); }
java
public static String plus(CharSequence left, Object value) { return left + DefaultGroovyMethods.toString(value); }
[ "public", "static", "String", "plus", "(", "CharSequence", "left", ",", "Object", "value", ")", "{", "return", "left", "+", "DefaultGroovyMethods", ".", "toString", "(", "value", ")", ";", "}" ]
Appends the String representation of the given operand to this CharSequence. @param left a CharSequence @param value any Object @return the original toString() of the CharSequence with the object appended @since 1.8.2
[ "Appends", "the", "String", "representation", "of", "the", "given", "operand", "to", "this", "CharSequence", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L2325-L2327
156,591
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.plus
public static String plus(Number value, String right) { return DefaultGroovyMethods.toString(value) + right; }
java
public static String plus(Number value, String right) { return DefaultGroovyMethods.toString(value) + right; }
[ "public", "static", "String", "plus", "(", "Number", "value", ",", "String", "right", ")", "{", "return", "DefaultGroovyMethods", ".", "toString", "(", "value", ")", "+", "right", ";", "}" ]
Appends a String to the string representation of this number. @param value a Number @param right a String @return a String @since 1.0
[ "Appends", "a", "String", "to", "the", "string", "representation", "of", "this", "number", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L2337-L2339
156,592
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.readLines
public static List<String> readLines(CharSequence self) throws IOException { return IOGroovyMethods.readLines(new StringReader(self.toString())); }
java
public static List<String> readLines(CharSequence self) throws IOException { return IOGroovyMethods.readLines(new StringReader(self.toString())); }
[ "public", "static", "List", "<", "String", ">", "readLines", "(", "CharSequence", "self", ")", "throws", "IOException", "{", "return", "IOGroovyMethods", ".", "readLines", "(", "new", "StringReader", "(", "self", ".", "toString", "(", ")", ")", ")", ";", "}" ]
Return the lines of a CharSequence as a List of String. @param self a CharSequence object @return a list of lines @throws java.io.IOException if an error occurs @since 1.8.2
[ "Return", "the", "lines", "of", "a", "CharSequence", "as", "a", "List", "of", "String", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L2443-L2445
156,593
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.replaceAll
public static String replaceAll(final CharSequence self, final CharSequence regex, final CharSequence replacement) { return self.toString().replaceAll(regex.toString(), replacement.toString()); }
java
public static String replaceAll(final CharSequence self, final CharSequence regex, final CharSequence replacement) { return self.toString().replaceAll(regex.toString(), replacement.toString()); }
[ "public", "static", "String", "replaceAll", "(", "final", "CharSequence", "self", ",", "final", "CharSequence", "regex", ",", "final", "CharSequence", "replacement", ")", "{", "return", "self", ".", "toString", "(", ")", ".", "replaceAll", "(", "regex", ".", "toString", "(", ")", ",", "replacement", ".", "toString", "(", ")", ")", ";", "}" ]
Replaces each substring of this CharSequence that matches the given regular expression with the given replacement. @param self a CharSequence @param regex the capturing regex @param replacement the string to be substituted for each match @return the toString() of the CharSequence with content replaced @throws java.util.regex.PatternSyntaxException if the regular expression's syntax is invalid @see String#replaceAll(String, String) @since 1.8.2
[ "Replaces", "each", "substring", "of", "this", "CharSequence", "that", "matches", "the", "given", "regular", "expression", "with", "the", "given", "replacement", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L2468-L2470
156,594
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.replaceFirst
public static String replaceFirst(final CharSequence self, final CharSequence regex, final CharSequence replacement) { return self.toString().replaceFirst(regex.toString(), replacement.toString()); }
java
public static String replaceFirst(final CharSequence self, final CharSequence regex, final CharSequence replacement) { return self.toString().replaceFirst(regex.toString(), replacement.toString()); }
[ "public", "static", "String", "replaceFirst", "(", "final", "CharSequence", "self", ",", "final", "CharSequence", "regex", ",", "final", "CharSequence", "replacement", ")", "{", "return", "self", ".", "toString", "(", ")", ".", "replaceFirst", "(", "regex", ".", "toString", "(", ")", ",", "replacement", ".", "toString", "(", ")", ")", ";", "}" ]
Replaces the first substring of this CharSequence that matches the given regular expression with the given replacement. @param self a CharSequence @param regex the capturing regex @param replacement the CharSequence to be substituted for each match @return a CharSequence with replaced content @throws java.util.regex.PatternSyntaxException if the regular expression's syntax is invalid @see String#replaceFirst(String, String) @since 1.8.2
[ "Replaces", "the", "first", "substring", "of", "this", "CharSequence", "that", "matches", "the", "given", "regular", "expression", "with", "the", "given", "replacement", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L2629-L2631
156,595
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.setIndex
public static void setIndex(Matcher matcher, int idx) { int count = getCount(matcher); if (idx < -count || idx >= count) { throw new IndexOutOfBoundsException("index is out of range " + (-count) + ".." + (count - 1) + " (index = " + idx + ")"); } if (idx == 0) { matcher.reset(); } else if (idx > 0) { matcher.reset(); for (int i = 0; i < idx; i++) { matcher.find(); } } else if (idx < 0) { matcher.reset(); idx += getCount(matcher); for (int i = 0; i < idx; i++) { matcher.find(); } } }
java
public static void setIndex(Matcher matcher, int idx) { int count = getCount(matcher); if (idx < -count || idx >= count) { throw new IndexOutOfBoundsException("index is out of range " + (-count) + ".." + (count - 1) + " (index = " + idx + ")"); } if (idx == 0) { matcher.reset(); } else if (idx > 0) { matcher.reset(); for (int i = 0; i < idx; i++) { matcher.find(); } } else if (idx < 0) { matcher.reset(); idx += getCount(matcher); for (int i = 0; i < idx; i++) { matcher.find(); } } }
[ "public", "static", "void", "setIndex", "(", "Matcher", "matcher", ",", "int", "idx", ")", "{", "int", "count", "=", "getCount", "(", "matcher", ")", ";", "if", "(", "idx", "<", "-", "count", "||", "idx", ">=", "count", ")", "{", "throw", "new", "IndexOutOfBoundsException", "(", "\"index is out of range \"", "+", "(", "-", "count", ")", "+", "\"..\"", "+", "(", "count", "-", "1", ")", "+", "\" (index = \"", "+", "idx", "+", "\")\"", ")", ";", "}", "if", "(", "idx", "==", "0", ")", "{", "matcher", ".", "reset", "(", ")", ";", "}", "else", "if", "(", "idx", ">", "0", ")", "{", "matcher", ".", "reset", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "idx", ";", "i", "++", ")", "{", "matcher", ".", "find", "(", ")", ";", "}", "}", "else", "if", "(", "idx", "<", "0", ")", "{", "matcher", ".", "reset", "(", ")", ";", "idx", "+=", "getCount", "(", "matcher", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "idx", ";", "i", "++", ")", "{", "matcher", ".", "find", "(", ")", ";", "}", "}", "}" ]
Set the position of the given Matcher to the given index. @param matcher a Matcher @param idx the index number @since 1.0
[ "Set", "the", "position", "of", "the", "given", "Matcher", "to", "the", "given", "index", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L2770-L2789
156,596
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.splitEachLine
public static <T> T splitEachLine(CharSequence self, CharSequence regex, @ClosureParams(value=FromString.class,options="List<String>") Closure<T> closure) throws IOException { return splitEachLine(self, Pattern.compile(regex.toString()), closure); }
java
public static <T> T splitEachLine(CharSequence self, CharSequence regex, @ClosureParams(value=FromString.class,options="List<String>") Closure<T> closure) throws IOException { return splitEachLine(self, Pattern.compile(regex.toString()), closure); }
[ "public", "static", "<", "T", ">", "T", "splitEachLine", "(", "CharSequence", "self", ",", "CharSequence", "regex", ",", "@", "ClosureParams", "(", "value", "=", "FromString", ".", "class", ",", "options", "=", "\"List<String>\"", ")", "Closure", "<", "T", ">", "closure", ")", "throws", "IOException", "{", "return", "splitEachLine", "(", "self", ",", "Pattern", ".", "compile", "(", "regex", ".", "toString", "(", ")", ")", ",", "closure", ")", ";", "}" ]
Iterates through the given CharSequence line by line, splitting each line using the given regex delimiter. The list of tokens for each line is then passed to the given closure. @param self a CharSequence @param regex the delimiting regular expression @param closure a closure @return the last value returned by the closure @throws java.io.IOException if an error occurs @throws java.util.regex.PatternSyntaxException if the regular expression's syntax is invalid @see #splitEachLine(CharSequence, java.util.regex.Pattern, groovy.lang.Closure) @since 1.8.2
[ "Iterates", "through", "the", "given", "CharSequence", "line", "by", "line", "splitting", "each", "line", "using", "the", "given", "regex", "delimiter", ".", "The", "list", "of", "tokens", "for", "each", "line", "is", "then", "passed", "to", "the", "given", "closure", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L2885-L2887
156,597
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.splitEachLine
public static <T> T splitEachLine(CharSequence self, Pattern pattern, @ClosureParams(value=FromString.class,options="List<String>") Closure<T> closure) throws IOException { final List<String> list = readLines(self); T result = null; for (String line : list) { List vals = Arrays.asList(pattern.split(line)); result = closure.call(vals); } return result; }
java
public static <T> T splitEachLine(CharSequence self, Pattern pattern, @ClosureParams(value=FromString.class,options="List<String>") Closure<T> closure) throws IOException { final List<String> list = readLines(self); T result = null; for (String line : list) { List vals = Arrays.asList(pattern.split(line)); result = closure.call(vals); } return result; }
[ "public", "static", "<", "T", ">", "T", "splitEachLine", "(", "CharSequence", "self", ",", "Pattern", "pattern", ",", "@", "ClosureParams", "(", "value", "=", "FromString", ".", "class", ",", "options", "=", "\"List<String>\"", ")", "Closure", "<", "T", ">", "closure", ")", "throws", "IOException", "{", "final", "List", "<", "String", ">", "list", "=", "readLines", "(", "self", ")", ";", "T", "result", "=", "null", ";", "for", "(", "String", "line", ":", "list", ")", "{", "List", "vals", "=", "Arrays", ".", "asList", "(", "pattern", ".", "split", "(", "line", ")", ")", ";", "result", "=", "closure", ".", "call", "(", "vals", ")", ";", "}", "return", "result", ";", "}" ]
Iterates through the given CharSequence line by line, splitting each line using the given separator Pattern. The list of tokens for each line is then passed to the given closure. @param self a CharSequence @param pattern the regular expression Pattern for the delimiter @param closure a closure @return the last value returned by the closure @throws java.io.IOException if an error occurs @since 1.8.2
[ "Iterates", "through", "the", "given", "CharSequence", "line", "by", "line", "splitting", "each", "line", "using", "the", "given", "separator", "Pattern", ".", "The", "list", "of", "tokens", "for", "each", "line", "is", "then", "passed", "to", "the", "given", "closure", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L2901-L2909
156,598
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.takeWhile
public static String takeWhile(GString self, @ClosureParams(value=SimpleType.class, options="char") Closure condition) { return (String) takeWhile(self.toString(), condition); }
java
public static String takeWhile(GString self, @ClosureParams(value=SimpleType.class, options="char") Closure condition) { return (String) takeWhile(self.toString(), condition); }
[ "public", "static", "String", "takeWhile", "(", "GString", "self", ",", "@", "ClosureParams", "(", "value", "=", "SimpleType", ".", "class", ",", "options", "=", "\"char\"", ")", "Closure", "condition", ")", "{", "return", "(", "String", ")", "takeWhile", "(", "self", ".", "toString", "(", ")", ",", "condition", ")", ";", "}" ]
A GString variant of the equivalent GString method. @param self the original GString @param condition the closure that must evaluate to true to continue taking elements @return a prefix of elements in the GString where each element passed to the given closure evaluates to true @since 2.3.7
[ "A", "GString", "variant", "of", "the", "equivalent", "GString", "method", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L3206-L3208
156,599
groovy/groovy-core
src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java
StringGroovyMethods.toList
public static List<String> toList(CharSequence self) { String s = self.toString(); int size = s.length(); List<String> answer = new ArrayList<String>(size); for (int i = 0; i < size; i++) { answer.add(s.substring(i, i + 1)); } return answer; }
java
public static List<String> toList(CharSequence self) { String s = self.toString(); int size = s.length(); List<String> answer = new ArrayList<String>(size); for (int i = 0; i < size; i++) { answer.add(s.substring(i, i + 1)); } return answer; }
[ "public", "static", "List", "<", "String", ">", "toList", "(", "CharSequence", "self", ")", "{", "String", "s", "=", "self", ".", "toString", "(", ")", ";", "int", "size", "=", "s", ".", "length", "(", ")", ";", "List", "<", "String", ">", "answer", "=", "new", "ArrayList", "<", "String", ">", "(", "size", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "answer", ".", "add", "(", "s", ".", "substring", "(", "i", ",", "i", "+", "1", ")", ")", ";", "}", "return", "answer", ";", "}" ]
Converts the given CharSequence into a List of Strings of one character. @param self a CharSequence @return a List of characters (a 1-character String) @see #toSet(String) @since 1.8.2
[ "Converts", "the", "given", "CharSequence", "into", "a", "List", "of", "Strings", "of", "one", "character", "." ]
01309f9d4be34ddf93c4a9943b5a97843bff6181
https://github.com/groovy/groovy-core/blob/01309f9d4be34ddf93c4a9943b5a97843bff6181/src/main/org/codehaus/groovy/runtime/StringGroovyMethods.java#L3425-L3433