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
12,900
apache/groovy
src/main/groovy/groovy/lang/ExpandoMetaClass.java
ExpandoMetaClass.registerBeanProperty
public void registerBeanProperty(final String property, final Object newValue) { performOperationOnMetaClass(new Callable() { public void call() { Class type = newValue == null ? Object.class : newValue.getClass(); MetaBeanProperty mbp = newValue instanceof MetaBeanProperty ? (MetaBeanProperty) newValue : new ThreadManagedMetaBeanProperty(theClass, property, type, newValue); final MetaMethod getter = mbp.getGetter(); final MethodKey getterKey = new DefaultCachedMethodKey(theClass, getter.getName(), CachedClass.EMPTY_ARRAY, false); final MetaMethod setter = mbp.getSetter(); final MethodKey setterKey = new DefaultCachedMethodKey(theClass, setter.getName(), setter.getParameterTypes(), false); addMetaMethod(getter); addMetaMethod(setter); expandoMethods.put(setterKey, setter); expandoMethods.put(getterKey, getter); expandoProperties.put(mbp.getName(), mbp); addMetaBeanProperty(mbp); performRegistryCallbacks(); } }); }
java
public void registerBeanProperty(final String property, final Object newValue) { performOperationOnMetaClass(new Callable() { public void call() { Class type = newValue == null ? Object.class : newValue.getClass(); MetaBeanProperty mbp = newValue instanceof MetaBeanProperty ? (MetaBeanProperty) newValue : new ThreadManagedMetaBeanProperty(theClass, property, type, newValue); final MetaMethod getter = mbp.getGetter(); final MethodKey getterKey = new DefaultCachedMethodKey(theClass, getter.getName(), CachedClass.EMPTY_ARRAY, false); final MetaMethod setter = mbp.getSetter(); final MethodKey setterKey = new DefaultCachedMethodKey(theClass, setter.getName(), setter.getParameterTypes(), false); addMetaMethod(getter); addMetaMethod(setter); expandoMethods.put(setterKey, setter); expandoMethods.put(getterKey, getter); expandoProperties.put(mbp.getName(), mbp); addMetaBeanProperty(mbp); performRegistryCallbacks(); } }); }
[ "public", "void", "registerBeanProperty", "(", "final", "String", "property", ",", "final", "Object", "newValue", ")", "{", "performOperationOnMetaClass", "(", "new", "Callable", "(", ")", "{", "public", "void", "call", "(", ")", "{", "Class", "type", "=", "...
Registers a new bean property @param property The property name @param newValue The properties initial value
[ "Registers", "a", "new", "bean", "property" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/ExpandoMetaClass.java#L845-L868
12,901
apache/groovy
src/main/groovy/groovy/lang/ExpandoMetaClass.java
ExpandoMetaClass.registerInstanceMethod
public void registerInstanceMethod(final MetaMethod metaMethod) { final boolean inited = this.initCalled; performOperationOnMetaClass(new Callable() { public void call() { String methodName = metaMethod.getName(); checkIfGroovyObjectMethod(metaMethod); MethodKey key = new DefaultCachedMethodKey(theClass, methodName, metaMethod.getParameterTypes(), false); if (isInitialized()) { throw new RuntimeException("Already initialized, cannot add new method: " + metaMethod); } // we always adds meta methods to class itself addMetaMethodToIndex(metaMethod, metaMethodIndex.getHeader(theClass)); dropMethodCache(methodName); expandoMethods.put(key, metaMethod); if (inited && isGetter(methodName, metaMethod.getParameterTypes())) { String propertyName = getPropertyForGetter(methodName); registerBeanPropertyForMethod(metaMethod, propertyName, true, false); } else if (inited && isSetter(methodName, metaMethod.getParameterTypes())) { String propertyName = getPropertyForSetter(methodName); registerBeanPropertyForMethod(metaMethod, propertyName, false, false); } performRegistryCallbacks(); } }); }
java
public void registerInstanceMethod(final MetaMethod metaMethod) { final boolean inited = this.initCalled; performOperationOnMetaClass(new Callable() { public void call() { String methodName = metaMethod.getName(); checkIfGroovyObjectMethod(metaMethod); MethodKey key = new DefaultCachedMethodKey(theClass, methodName, metaMethod.getParameterTypes(), false); if (isInitialized()) { throw new RuntimeException("Already initialized, cannot add new method: " + metaMethod); } // we always adds meta methods to class itself addMetaMethodToIndex(metaMethod, metaMethodIndex.getHeader(theClass)); dropMethodCache(methodName); expandoMethods.put(key, metaMethod); if (inited && isGetter(methodName, metaMethod.getParameterTypes())) { String propertyName = getPropertyForGetter(methodName); registerBeanPropertyForMethod(metaMethod, propertyName, true, false); } else if (inited && isSetter(methodName, metaMethod.getParameterTypes())) { String propertyName = getPropertyForSetter(methodName); registerBeanPropertyForMethod(metaMethod, propertyName, false, false); } performRegistryCallbacks(); } }); }
[ "public", "void", "registerInstanceMethod", "(", "final", "MetaMethod", "metaMethod", ")", "{", "final", "boolean", "inited", "=", "this", ".", "initCalled", ";", "performOperationOnMetaClass", "(", "new", "Callable", "(", ")", "{", "public", "void", "call", "("...
Registers a new instance method for the given method name and closure on this MetaClass @param metaMethod
[ "Registers", "a", "new", "instance", "method", "for", "the", "given", "method", "name", "and", "closure", "on", "this", "MetaClass" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/ExpandoMetaClass.java#L875-L904
12,902
apache/groovy
src/main/groovy/groovy/lang/ExpandoMetaClass.java
ExpandoMetaClass.registerStaticMethod
protected void registerStaticMethod(final String name, final Closure callable, final Class[] paramTypes) { performOperationOnMetaClass(new Callable() { public void call() { String methodName; if (name.equals(METHOD_MISSING)) methodName = STATIC_METHOD_MISSING; else if (name.equals(PROPERTY_MISSING)) methodName = STATIC_PROPERTY_MISSING; else methodName = name; ClosureStaticMetaMethod metaMethod = null; if (paramTypes != null) { metaMethod = new ClosureStaticMetaMethod(methodName, theClass, callable, paramTypes); } else { metaMethod = new ClosureStaticMetaMethod(methodName, theClass, callable); } if (methodName.equals(INVOKE_METHOD_METHOD) && callable.getParameterTypes().length == 2) { invokeStaticMethodMethod = metaMethod; } else { if (methodName.equals(METHOD_MISSING)) { methodName = STATIC_METHOD_MISSING; } MethodKey key = new DefaultCachedMethodKey(theClass, methodName, metaMethod.getParameterTypes(), false); addMetaMethod(metaMethod); dropStaticMethodCache(methodName); // cacheStaticMethod(key,metaMethod); if (isGetter(methodName, metaMethod.getParameterTypes())) { String propertyName = getPropertyForGetter(methodName); registerBeanPropertyForMethod(metaMethod, propertyName, true, true); } else if (isSetter(methodName, metaMethod.getParameterTypes())) { String propertyName = getPropertyForSetter(methodName); registerBeanPropertyForMethod(metaMethod, propertyName, false, true); } performRegistryCallbacks(); expandoMethods.put(key, metaMethod); } } }); }
java
protected void registerStaticMethod(final String name, final Closure callable, final Class[] paramTypes) { performOperationOnMetaClass(new Callable() { public void call() { String methodName; if (name.equals(METHOD_MISSING)) methodName = STATIC_METHOD_MISSING; else if (name.equals(PROPERTY_MISSING)) methodName = STATIC_PROPERTY_MISSING; else methodName = name; ClosureStaticMetaMethod metaMethod = null; if (paramTypes != null) { metaMethod = new ClosureStaticMetaMethod(methodName, theClass, callable, paramTypes); } else { metaMethod = new ClosureStaticMetaMethod(methodName, theClass, callable); } if (methodName.equals(INVOKE_METHOD_METHOD) && callable.getParameterTypes().length == 2) { invokeStaticMethodMethod = metaMethod; } else { if (methodName.equals(METHOD_MISSING)) { methodName = STATIC_METHOD_MISSING; } MethodKey key = new DefaultCachedMethodKey(theClass, methodName, metaMethod.getParameterTypes(), false); addMetaMethod(metaMethod); dropStaticMethodCache(methodName); // cacheStaticMethod(key,metaMethod); if (isGetter(methodName, metaMethod.getParameterTypes())) { String propertyName = getPropertyForGetter(methodName); registerBeanPropertyForMethod(metaMethod, propertyName, true, true); } else if (isSetter(methodName, metaMethod.getParameterTypes())) { String propertyName = getPropertyForSetter(methodName); registerBeanPropertyForMethod(metaMethod, propertyName, false, true); } performRegistryCallbacks(); expandoMethods.put(key, metaMethod); } } }); }
[ "protected", "void", "registerStaticMethod", "(", "final", "String", "name", ",", "final", "Closure", "callable", ",", "final", "Class", "[", "]", "paramTypes", ")", "{", "performOperationOnMetaClass", "(", "new", "Callable", "(", ")", "{", "public", "void", "...
Registers a new static method for the given method name and closure on this MetaClass @param name The method name @param callable The callable Closure
[ "Registers", "a", "new", "static", "method", "for", "the", "given", "method", "name", "and", "closure", "on", "this", "MetaClass" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/ExpandoMetaClass.java#L1001-L1046
12,903
apache/groovy
src/main/groovy/groovy/lang/ExpandoMetaClass.java
ExpandoMetaClass.refreshInheritedMethods
public void refreshInheritedMethods(Set modifiedSuperExpandos) { for (Iterator i = modifiedSuperExpandos.iterator(); i.hasNext();) { ExpandoMetaClass superExpando = (ExpandoMetaClass) i.next(); if (superExpando != this) { refreshInheritedMethods(superExpando); } } }
java
public void refreshInheritedMethods(Set modifiedSuperExpandos) { for (Iterator i = modifiedSuperExpandos.iterator(); i.hasNext();) { ExpandoMetaClass superExpando = (ExpandoMetaClass) i.next(); if (superExpando != this) { refreshInheritedMethods(superExpando); } } }
[ "public", "void", "refreshInheritedMethods", "(", "Set", "modifiedSuperExpandos", ")", "{", "for", "(", "Iterator", "i", "=", "modifiedSuperExpandos", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "ExpandoMetaClass", "superExpan...
Called from ExpandoMetaClassCreationHandle in the registry if it exists to set up inheritance handling @param modifiedSuperExpandos A list of modified super ExpandoMetaClass
[ "Called", "from", "ExpandoMetaClassCreationHandle", "in", "the", "registry", "if", "it", "exists", "to", "set", "up", "inheritance", "handling" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/ExpandoMetaClass.java#L1068-L1075
12,904
apache/groovy
src/main/groovy/groovy/lang/ExpandoMetaClass.java
ExpandoMetaClass.invokeMethod
public Object invokeMethod(Class sender, Object object, String methodName, Object[] originalArguments, boolean isCallToSuper, boolean fromInsideClass) { if (invokeMethodMethod != null) { MetaClassHelper.unwrap(originalArguments); return invokeMethodMethod.invoke(object, new Object[]{methodName, originalArguments}); } return super.invokeMethod(sender, object, methodName, originalArguments, isCallToSuper, fromInsideClass); }
java
public Object invokeMethod(Class sender, Object object, String methodName, Object[] originalArguments, boolean isCallToSuper, boolean fromInsideClass) { if (invokeMethodMethod != null) { MetaClassHelper.unwrap(originalArguments); return invokeMethodMethod.invoke(object, new Object[]{methodName, originalArguments}); } return super.invokeMethod(sender, object, methodName, originalArguments, isCallToSuper, fromInsideClass); }
[ "public", "Object", "invokeMethod", "(", "Class", "sender", ",", "Object", "object", ",", "String", "methodName", ",", "Object", "[", "]", "originalArguments", ",", "boolean", "isCallToSuper", ",", "boolean", "fromInsideClass", ")", "{", "if", "(", "invokeMethod...
Overrides default implementation just in case invokeMethod has been overridden by ExpandoMetaClass @see groovy.lang.MetaClassImpl#invokeMethod(Class, Object, String, Object[], boolean, boolean)
[ "Overrides", "default", "implementation", "just", "in", "case", "invokeMethod", "has", "been", "overridden", "by", "ExpandoMetaClass" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/ExpandoMetaClass.java#L1120-L1126
12,905
apache/groovy
src/main/groovy/groovy/lang/ExpandoMetaClass.java
ExpandoMetaClass.invokeStaticMethod
public Object invokeStaticMethod(Object object, String methodName, Object[] arguments) { if (invokeStaticMethodMethod != null) { MetaClassHelper.unwrap(arguments); return invokeStaticMethodMethod.invoke(object, new Object[]{methodName, arguments}); } return super.invokeStaticMethod(object, methodName, arguments); }
java
public Object invokeStaticMethod(Object object, String methodName, Object[] arguments) { if (invokeStaticMethodMethod != null) { MetaClassHelper.unwrap(arguments); return invokeStaticMethodMethod.invoke(object, new Object[]{methodName, arguments}); } return super.invokeStaticMethod(object, methodName, arguments); }
[ "public", "Object", "invokeStaticMethod", "(", "Object", "object", ",", "String", "methodName", ",", "Object", "[", "]", "arguments", ")", "{", "if", "(", "invokeStaticMethodMethod", "!=", "null", ")", "{", "MetaClassHelper", ".", "unwrap", "(", "arguments", "...
Overrides default implementation just in case a static invoke method has been set on ExpandoMetaClass @see MetaClassImpl#invokeStaticMethod(Object, String, Object[])
[ "Overrides", "default", "implementation", "just", "in", "case", "a", "static", "invoke", "method", "has", "been", "set", "on", "ExpandoMetaClass" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/ExpandoMetaClass.java#L1133-L1139
12,906
apache/groovy
src/main/groovy/groovy/lang/ExpandoMetaClass.java
ExpandoMetaClass.setProperty
public void setProperty(Class sender, Object object, String name, Object newValue, boolean useSuper, boolean fromInsideClass) { if (setPropertyMethod != null && !name.equals(META_CLASS_PROPERTY) && getJavaClass().isInstance(object)) { setPropertyMethod.invoke(object, new Object[]{name, newValue}); return; } super.setProperty(sender, object, name, newValue, useSuper, fromInsideClass); }
java
public void setProperty(Class sender, Object object, String name, Object newValue, boolean useSuper, boolean fromInsideClass) { if (setPropertyMethod != null && !name.equals(META_CLASS_PROPERTY) && getJavaClass().isInstance(object)) { setPropertyMethod.invoke(object, new Object[]{name, newValue}); return; } super.setProperty(sender, object, name, newValue, useSuper, fromInsideClass); }
[ "public", "void", "setProperty", "(", "Class", "sender", ",", "Object", "object", ",", "String", "name", ",", "Object", "newValue", ",", "boolean", "useSuper", ",", "boolean", "fromInsideClass", ")", "{", "if", "(", "setPropertyMethod", "!=", "null", "&&", "...
Overrides default implementation just in case setProperty method has been overridden by ExpandoMetaClass @see MetaClassImpl#setProperty(Class, Object, String, Object, boolean, boolean)
[ "Overrides", "default", "implementation", "just", "in", "case", "setProperty", "method", "has", "been", "overridden", "by", "ExpandoMetaClass" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/ExpandoMetaClass.java#L1180-L1186
12,907
apache/groovy
src/main/groovy/groovy/lang/ExpandoMetaClass.java
ExpandoMetaClass.getMetaProperty
public MetaProperty getMetaProperty(String name) { MetaProperty mp = this.expandoProperties.get(name); if (mp != null) return mp; return super.getMetaProperty(name); }
java
public MetaProperty getMetaProperty(String name) { MetaProperty mp = this.expandoProperties.get(name); if (mp != null) return mp; return super.getMetaProperty(name); }
[ "public", "MetaProperty", "getMetaProperty", "(", "String", "name", ")", "{", "MetaProperty", "mp", "=", "this", ".", "expandoProperties", ".", "get", "(", "name", ")", ";", "if", "(", "mp", "!=", "null", ")", "return", "mp", ";", "return", "super", ".",...
Looks up an existing MetaProperty by name @param name The name of the MetaProperty @return The MetaProperty or null if it doesn't exist
[ "Looks", "up", "an", "existing", "MetaProperty", "by", "name" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/ExpandoMetaClass.java#L1194-L1198
12,908
apache/groovy
src/main/groovy/groovy/lang/ExpandoMetaClass.java
ExpandoMetaClass.isPropertyName
private static boolean isPropertyName(String name) { return ((name.length() > 0) && Character.isUpperCase(name.charAt(0))) || ((name.length() > 1) && Character.isUpperCase(name.charAt(1))); }
java
private static boolean isPropertyName(String name) { return ((name.length() > 0) && Character.isUpperCase(name.charAt(0))) || ((name.length() > 1) && Character.isUpperCase(name.charAt(1))); }
[ "private", "static", "boolean", "isPropertyName", "(", "String", "name", ")", "{", "return", "(", "(", "name", ".", "length", "(", ")", ">", "0", ")", "&&", "Character", ".", "isUpperCase", "(", "name", ".", "charAt", "(", "0", ")", ")", ")", "||", ...
Determine if this method name suffix is a legitimate bean property name. Either the first or second letter must be upperCase for that to be true.
[ "Determine", "if", "this", "method", "name", "suffix", "is", "a", "legitimate", "bean", "property", "name", ".", "Either", "the", "first", "or", "second", "letter", "must", "be", "upperCase", "for", "that", "to", "be", "true", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/ExpandoMetaClass.java#L1225-L1227
12,909
apache/groovy
src/main/groovy/groovy/lang/ExpandoMetaClass.java
ExpandoMetaClass.isGetter
private boolean isGetter(String name, CachedClass[] args) { if (name == null || name.length() == 0 || args == null) return false; if (args.length != 0) return false; if (name.startsWith("get")) { name = name.substring(3); return isPropertyName(name); } else if (name.startsWith("is")) { name = name.substring(2); return isPropertyName(name); } return false; }
java
private boolean isGetter(String name, CachedClass[] args) { if (name == null || name.length() == 0 || args == null) return false; if (args.length != 0) return false; if (name.startsWith("get")) { name = name.substring(3); return isPropertyName(name); } else if (name.startsWith("is")) { name = name.substring(2); return isPropertyName(name); } return false; }
[ "private", "boolean", "isGetter", "(", "String", "name", ",", "CachedClass", "[", "]", "args", ")", "{", "if", "(", "name", "==", "null", "||", "name", ".", "length", "(", ")", "==", "0", "||", "args", "==", "null", ")", "return", "false", ";", "if...
Returns true if the name of the method specified and the number of arguments make it a javabean property @param name True if its a Javabean property @param args The arguments @return True if it is a javabean property method
[ "Returns", "true", "if", "the", "name", "of", "the", "method", "specified", "and", "the", "number", "of", "arguments", "make", "it", "a", "javabean", "property" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/ExpandoMetaClass.java#L1236-L1248
12,910
apache/groovy
src/main/groovy/groovy/lang/ExpandoMetaClass.java
ExpandoMetaClass.getPropertyForGetter
private String getPropertyForGetter(String getterName) { if (getterName == null || getterName.length() == 0) return null; if (getterName.startsWith("get")) { String prop = getterName.substring(3); return MetaClassHelper.convertPropertyName(prop); } else if (getterName.startsWith("is")) { String prop = getterName.substring(2); return MetaClassHelper.convertPropertyName(prop); } return null; }
java
private String getPropertyForGetter(String getterName) { if (getterName == null || getterName.length() == 0) return null; if (getterName.startsWith("get")) { String prop = getterName.substring(3); return MetaClassHelper.convertPropertyName(prop); } else if (getterName.startsWith("is")) { String prop = getterName.substring(2); return MetaClassHelper.convertPropertyName(prop); } return null; }
[ "private", "String", "getPropertyForGetter", "(", "String", "getterName", ")", "{", "if", "(", "getterName", "==", "null", "||", "getterName", ".", "length", "(", ")", "==", "0", ")", "return", "null", ";", "if", "(", "getterName", ".", "startsWith", "(", ...
Returns a property name equivalent for the given getter name or null if it is not a getter @param getterName The getter name @return The property name equivalent
[ "Returns", "a", "property", "name", "equivalent", "for", "the", "given", "getter", "name", "or", "null", "if", "it", "is", "not", "a", "getter" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/ExpandoMetaClass.java#L1256-L1267
12,911
apache/groovy
src/main/groovy/groovy/lang/ExpandoMetaClass.java
ExpandoMetaClass.getPropertyForSetter
public String getPropertyForSetter(String setterName) { if (setterName == null || setterName.length() == 0) return null; if (setterName.startsWith("set")) { String prop = setterName.substring(3); return MetaClassHelper.convertPropertyName(prop); } return null; }
java
public String getPropertyForSetter(String setterName) { if (setterName == null || setterName.length() == 0) return null; if (setterName.startsWith("set")) { String prop = setterName.substring(3); return MetaClassHelper.convertPropertyName(prop); } return null; }
[ "public", "String", "getPropertyForSetter", "(", "String", "setterName", ")", "{", "if", "(", "setterName", "==", "null", "||", "setterName", ".", "length", "(", ")", "==", "0", ")", "return", "null", ";", "if", "(", "setterName", ".", "startsWith", "(", ...
Returns a property name equivalent for the given setter name or null if it is not a getter @param setterName The setter name @return The property name equivalent
[ "Returns", "a", "property", "name", "equivalent", "for", "the", "given", "setter", "name", "or", "null", "if", "it", "is", "not", "a", "getter" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/ExpandoMetaClass.java#L1275-L1283
12,912
apache/groovy
src/main/java/org/codehaus/groovy/syntax/Types.java
Types.getText
public static String getText(int type) { String text = ""; if (TEXTS.containsKey(type)) { text = TEXTS.get(type); } return text; }
java
public static String getText(int type) { String text = ""; if (TEXTS.containsKey(type)) { text = TEXTS.get(type); } return text; }
[ "public", "static", "String", "getText", "(", "int", "type", ")", "{", "String", "text", "=", "\"\"", ";", "if", "(", "TEXTS", ".", "containsKey", "(", "type", ")", ")", "{", "text", "=", "TEXTS", ".", "get", "(", "type", ")", ";", "}", "return", ...
Returns the text for the specified type. Returns "" if the text isn't found.
[ "Returns", "the", "text", "for", "the", "specified", "type", ".", "Returns", "if", "the", "text", "isn", "t", "found", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/syntax/Types.java#L1088-L1096
12,913
apache/groovy
src/main/java/org/codehaus/groovy/syntax/Types.java
Types.addTranslation
private static void addTranslation(String text, int type) { TEXTS.put(type, text); LOOKUP.put(text, type); }
java
private static void addTranslation(String text, int type) { TEXTS.put(type, text); LOOKUP.put(text, type); }
[ "private", "static", "void", "addTranslation", "(", "String", "text", ",", "int", "type", ")", "{", "TEXTS", ".", "put", "(", "type", ",", "text", ")", ";", "LOOKUP", ".", "put", "(", "text", ",", "type", ")", ";", "}" ]
Adds a element to the TEXTS and LOOKUP.
[ "Adds", "a", "element", "to", "the", "TEXTS", "and", "LOOKUP", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/syntax/Types.java#L1102-L1105
12,914
apache/groovy
src/main/java/org/codehaus/groovy/syntax/Types.java
Types.addKeyword
private static void addKeyword(String text, int type) { KEYWORDS.add(text); addTranslation(text, type); }
java
private static void addKeyword(String text, int type) { KEYWORDS.add(text); addTranslation(text, type); }
[ "private", "static", "void", "addKeyword", "(", "String", "text", ",", "int", "type", ")", "{", "KEYWORDS", ".", "add", "(", "text", ")", ";", "addTranslation", "(", "text", ",", "type", ")", ";", "}" ]
Adds a element to the KEYWORDS, TEXTS and LOOKUP.
[ "Adds", "a", "element", "to", "the", "KEYWORDS", "TEXTS", "and", "LOOKUP", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/syntax/Types.java#L1110-L1113
12,915
apache/groovy
src/main/java/org/codehaus/groovy/syntax/Types.java
Types.addDescription
private static void addDescription(int type, String description) { if (description.startsWith("<") && description.endsWith(">")) { DESCRIPTIONS.put(type, description); } else { DESCRIPTIONS.put(type, '"' + description + '"'); } }
java
private static void addDescription(int type, String description) { if (description.startsWith("<") && description.endsWith(">")) { DESCRIPTIONS.put(type, description); } else { DESCRIPTIONS.put(type, '"' + description + '"'); } }
[ "private", "static", "void", "addDescription", "(", "int", "type", ",", "String", "description", ")", "{", "if", "(", "description", ".", "startsWith", "(", "\"<\"", ")", "&&", "description", ".", "endsWith", "(", "\">\"", ")", ")", "{", "DESCRIPTIONS", "....
Adds a description to the set.
[ "Adds", "a", "description", "to", "the", "set", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/syntax/Types.java#L1289-L1295
12,916
apache/groovy
subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/Node.java
Node.text
public String text() { final StringBuilder sb = new StringBuilder(); for (Object child : this.children) { if (child instanceof Node) { sb.append(((Node) child).text()); } else { sb.append(child); } } return sb.toString(); }
java
public String text() { final StringBuilder sb = new StringBuilder(); for (Object child : this.children) { if (child instanceof Node) { sb.append(((Node) child).text()); } else { sb.append(child); } } return sb.toString(); }
[ "public", "String", "text", "(", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Object", "child", ":", "this", ".", "children", ")", "{", "if", "(", "child", "instanceof", "Node", ")", "{", "sb", "....
Returns a string containing the text of the children of this Node. @return a string containing the text of the children of this Node
[ "Returns", "a", "string", "containing", "the", "text", "of", "the", "children", "of", "this", "Node", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/Node.java#L150-L160
12,917
apache/groovy
subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/Node.java
Node.childNodes
public Iterator childNodes() { return new Iterator() { private final Iterator iter = Node.this.children.iterator(); private Object nextElementNodes = getNextElementNodes(); public boolean hasNext() { return this.nextElementNodes != null; } public Object next() { try { return this.nextElementNodes; } finally { this.nextElementNodes = getNextElementNodes(); } } public void remove() { throw new UnsupportedOperationException(); } private Object getNextElementNodes() { while (iter.hasNext()) { final Object node = iter.next(); if (node instanceof Node) { return node; } } return null; } }; }
java
public Iterator childNodes() { return new Iterator() { private final Iterator iter = Node.this.children.iterator(); private Object nextElementNodes = getNextElementNodes(); public boolean hasNext() { return this.nextElementNodes != null; } public Object next() { try { return this.nextElementNodes; } finally { this.nextElementNodes = getNextElementNodes(); } } public void remove() { throw new UnsupportedOperationException(); } private Object getNextElementNodes() { while (iter.hasNext()) { final Object node = iter.next(); if (node instanceof Node) { return node; } } return null; } }; }
[ "public", "Iterator", "childNodes", "(", ")", "{", "return", "new", "Iterator", "(", ")", "{", "private", "final", "Iterator", "iter", "=", "Node", ".", "this", ".", "children", ".", "iterator", "(", ")", ";", "private", "Object", "nextElementNodes", "=", ...
Returns an iterator over the child nodes of this Node. @return an iterator over the child nodes of this Node
[ "Returns", "an", "iterator", "over", "the", "child", "nodes", "of", "this", "Node", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/util/slurpersupport/Node.java#L182-L213
12,918
apache/groovy
subprojects/groovy-sql/src/main/java/groovy/sql/GroovyResultSetExtension.java
GroovyResultSetExtension.getAt
public Object getAt(int index) throws SQLException { index = normalizeIndex(index); return getResultSet().getObject(index); }
java
public Object getAt(int index) throws SQLException { index = normalizeIndex(index); return getResultSet().getObject(index); }
[ "public", "Object", "getAt", "(", "int", "index", ")", "throws", "SQLException", "{", "index", "=", "normalizeIndex", "(", "index", ")", ";", "return", "getResultSet", "(", ")", ".", "getObject", "(", "index", ")", ";", "}" ]
Supports integer based subscript operators for accessing at numbered columns starting at zero. Negative indices are supported, they will count from the last column backwards. @param index is the number of the column to look at starting at 1 @return the returned column value @throws java.sql.SQLException if something goes wrong @see ResultSet#getObject(int)
[ "Supports", "integer", "based", "subscript", "operators", "for", "accessing", "at", "numbered", "columns", "starting", "at", "zero", ".", "Negative", "indices", "are", "supported", "they", "will", "count", "from", "the", "last", "column", "backwards", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-sql/src/main/java/groovy/sql/GroovyResultSetExtension.java#L152-L155
12,919
apache/groovy
subprojects/groovy-sql/src/main/java/groovy/sql/GroovyResultSetExtension.java
GroovyResultSetExtension.putAt
public void putAt(int index, Object newValue) throws SQLException { index = normalizeIndex(index); getResultSet().updateObject(index, newValue); }
java
public void putAt(int index, Object newValue) throws SQLException { index = normalizeIndex(index); getResultSet().updateObject(index, newValue); }
[ "public", "void", "putAt", "(", "int", "index", ",", "Object", "newValue", ")", "throws", "SQLException", "{", "index", "=", "normalizeIndex", "(", "index", ")", ";", "getResultSet", "(", ")", ".", "updateObject", "(", "index", ",", "newValue", ")", ";", ...
Supports integer based subscript operators for updating the values of numbered columns starting at zero. Negative indices are supported, they will count from the last column backwards. @param index is the number of the column to look at starting at 1 @param newValue the updated value @throws java.sql.SQLException if something goes wrong @see ResultSet#updateObject(java.lang.String, java.lang.Object)
[ "Supports", "integer", "based", "subscript", "operators", "for", "updating", "the", "values", "of", "numbered", "columns", "starting", "at", "zero", ".", "Negative", "indices", "are", "supported", "they", "will", "count", "from", "the", "last", "column", "backwa...
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-sql/src/main/java/groovy/sql/GroovyResultSetExtension.java#L166-L169
12,920
apache/groovy
subprojects/groovy-sql/src/main/java/groovy/sql/GroovyResultSetExtension.java
GroovyResultSetExtension.add
public void add(Map values) throws SQLException { getResultSet().moveToInsertRow(); for (Iterator iter = values.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); getResultSet().updateObject(entry.getKey().toString(), entry.getValue()); } getResultSet().insertRow(); }
java
public void add(Map values) throws SQLException { getResultSet().moveToInsertRow(); for (Iterator iter = values.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); getResultSet().updateObject(entry.getKey().toString(), entry.getValue()); } getResultSet().insertRow(); }
[ "public", "void", "add", "(", "Map", "values", ")", "throws", "SQLException", "{", "getResultSet", "(", ")", ".", "moveToInsertRow", "(", ")", ";", "for", "(", "Iterator", "iter", "=", "values", ".", "entrySet", "(", ")", ".", "iterator", "(", ")", ";"...
Adds a new row to the result set @param values a map containing the mappings for column names and values @throws java.sql.SQLException if something goes wrong @see ResultSet#insertRow() @see ResultSet#updateObject(java.lang.String, java.lang.Object) @see ResultSet#moveToInsertRow()
[ "Adds", "a", "new", "row", "to", "the", "result", "set" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-sql/src/main/java/groovy/sql/GroovyResultSetExtension.java#L180-L187
12,921
apache/groovy
subprojects/groovy-sql/src/main/java/groovy/sql/GroovyResultSetExtension.java
GroovyResultSetExtension.normalizeIndex
protected int normalizeIndex(int index) throws SQLException { if (index < 0) { int columnCount = getResultSet().getMetaData().getColumnCount(); do { index += columnCount; } while (index < 0); } return index + 1; }
java
protected int normalizeIndex(int index) throws SQLException { if (index < 0) { int columnCount = getResultSet().getMetaData().getColumnCount(); do { index += columnCount; } while (index < 0); } return index + 1; }
[ "protected", "int", "normalizeIndex", "(", "int", "index", ")", "throws", "SQLException", "{", "if", "(", "index", "<", "0", ")", "{", "int", "columnCount", "=", "getResultSet", "(", ")", ".", "getMetaData", "(", ")", ".", "getColumnCount", "(", ")", ";"...
Takes a zero based index and convert it into an SQL based 1 based index. A negative index will count backwards from the last column. @param index the raw requested index (may be negative) @return a JDBC index @throws SQLException if some exception occurs finding out the column count
[ "Takes", "a", "zero", "based", "index", "and", "convert", "it", "into", "an", "SQL", "based", "1", "based", "index", ".", "A", "negative", "index", "will", "count", "backwards", "from", "the", "last", "column", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-sql/src/main/java/groovy/sql/GroovyResultSetExtension.java#L197-L206
12,922
apache/groovy
subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocAssembler.java
SimpleGroovyClassDocAssembler.postProcessClassDocs
private void postProcessClassDocs() { for (GroovyClassDoc groovyClassDoc : classDocs.values()) { SimpleGroovyClassDoc classDoc = (SimpleGroovyClassDoc) groovyClassDoc; // potentially add default constructor to class docs (but not interfaces) if (classDoc.isClass()) { GroovyConstructorDoc[] constructors = classDoc.constructors(); if (constructors != null && constructors.length == 0) { // add default constructor to doc // name of class for the constructor GroovyConstructorDoc constructorDoc = new SimpleGroovyConstructorDoc(classDoc.name(), classDoc); // don't forget to tell the class about this default constructor. classDoc.add(constructorDoc); } } } }
java
private void postProcessClassDocs() { for (GroovyClassDoc groovyClassDoc : classDocs.values()) { SimpleGroovyClassDoc classDoc = (SimpleGroovyClassDoc) groovyClassDoc; // potentially add default constructor to class docs (but not interfaces) if (classDoc.isClass()) { GroovyConstructorDoc[] constructors = classDoc.constructors(); if (constructors != null && constructors.length == 0) { // add default constructor to doc // name of class for the constructor GroovyConstructorDoc constructorDoc = new SimpleGroovyConstructorDoc(classDoc.name(), classDoc); // don't forget to tell the class about this default constructor. classDoc.add(constructorDoc); } } } }
[ "private", "void", "postProcessClassDocs", "(", ")", "{", "for", "(", "GroovyClassDoc", "groovyClassDoc", ":", "classDocs", ".", "values", "(", ")", ")", "{", "SimpleGroovyClassDoc", "classDoc", "=", "(", "SimpleGroovyClassDoc", ")", "groovyClassDoc", ";", "// pot...
Step through ClassDocs and tie up loose ends
[ "Step", "through", "ClassDocs", "and", "tie", "up", "loose", "ends" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocAssembler.java#L492-L507
12,923
apache/groovy
subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocAssembler.java
SimpleGroovyClassDocAssembler.processModifiers
private boolean processModifiers(GroovySourceAST t, SimpleGroovyAbstractableElementDoc memberOrClass) { GroovySourceAST modifiers = t.childOfType(MODIFIERS); boolean hasNonPublicVisibility = false; boolean hasPublicVisibility = false; if (modifiers != null) { AST currentModifier = modifiers.getFirstChild(); while (currentModifier != null) { int type = currentModifier.getType(); switch (type) { case LITERAL_public: memberOrClass.setPublic(true); hasPublicVisibility = true; break; case LITERAL_protected: memberOrClass.setProtected(true); hasNonPublicVisibility = true; break; case LITERAL_private: memberOrClass.setPrivate(true); hasNonPublicVisibility = true; break; case LITERAL_static: memberOrClass.setStatic(true); break; case FINAL: memberOrClass.setFinal(true); break; case ABSTRACT: memberOrClass.setAbstract(true); break; } currentModifier = currentModifier.getNextSibling(); } if (!hasNonPublicVisibility && isGroovy && !(memberOrClass instanceof GroovyFieldDoc)) { // in groovy, methods and classes are assumed public, unless informed otherwise if (isPackageScope(modifiers)) { memberOrClass.setPackagePrivate(true); hasNonPublicVisibility = true; } else { memberOrClass.setPublic(true); } } else if (!hasNonPublicVisibility && !hasPublicVisibility && !isGroovy) { if (insideInterface(memberOrClass) || insideAnnotationDef(memberOrClass)) { memberOrClass.setPublic(true); } else { memberOrClass.setPackagePrivate(true); } } if (memberOrClass instanceof GroovyFieldDoc && isGroovy && !hasNonPublicVisibility & !hasPublicVisibility) { if (isPackageScope(modifiers)) { memberOrClass.setPackagePrivate(true); hasNonPublicVisibility = true; } } if (memberOrClass instanceof GroovyFieldDoc && !hasNonPublicVisibility && !hasPublicVisibility && isGroovy) return true; } else if (isGroovy && !(memberOrClass instanceof GroovyFieldDoc)) { // in groovy, methods and classes are assumed public, unless informed otherwise memberOrClass.setPublic(true); } else if (!isGroovy) { if (insideInterface(memberOrClass) || insideAnnotationDef(memberOrClass)) { memberOrClass.setPublic(true); } else { memberOrClass.setPackagePrivate(true); } } return memberOrClass instanceof GroovyFieldDoc && isGroovy && !hasNonPublicVisibility & !hasPublicVisibility; }
java
private boolean processModifiers(GroovySourceAST t, SimpleGroovyAbstractableElementDoc memberOrClass) { GroovySourceAST modifiers = t.childOfType(MODIFIERS); boolean hasNonPublicVisibility = false; boolean hasPublicVisibility = false; if (modifiers != null) { AST currentModifier = modifiers.getFirstChild(); while (currentModifier != null) { int type = currentModifier.getType(); switch (type) { case LITERAL_public: memberOrClass.setPublic(true); hasPublicVisibility = true; break; case LITERAL_protected: memberOrClass.setProtected(true); hasNonPublicVisibility = true; break; case LITERAL_private: memberOrClass.setPrivate(true); hasNonPublicVisibility = true; break; case LITERAL_static: memberOrClass.setStatic(true); break; case FINAL: memberOrClass.setFinal(true); break; case ABSTRACT: memberOrClass.setAbstract(true); break; } currentModifier = currentModifier.getNextSibling(); } if (!hasNonPublicVisibility && isGroovy && !(memberOrClass instanceof GroovyFieldDoc)) { // in groovy, methods and classes are assumed public, unless informed otherwise if (isPackageScope(modifiers)) { memberOrClass.setPackagePrivate(true); hasNonPublicVisibility = true; } else { memberOrClass.setPublic(true); } } else if (!hasNonPublicVisibility && !hasPublicVisibility && !isGroovy) { if (insideInterface(memberOrClass) || insideAnnotationDef(memberOrClass)) { memberOrClass.setPublic(true); } else { memberOrClass.setPackagePrivate(true); } } if (memberOrClass instanceof GroovyFieldDoc && isGroovy && !hasNonPublicVisibility & !hasPublicVisibility) { if (isPackageScope(modifiers)) { memberOrClass.setPackagePrivate(true); hasNonPublicVisibility = true; } } if (memberOrClass instanceof GroovyFieldDoc && !hasNonPublicVisibility && !hasPublicVisibility && isGroovy) return true; } else if (isGroovy && !(memberOrClass instanceof GroovyFieldDoc)) { // in groovy, methods and classes are assumed public, unless informed otherwise memberOrClass.setPublic(true); } else if (!isGroovy) { if (insideInterface(memberOrClass) || insideAnnotationDef(memberOrClass)) { memberOrClass.setPublic(true); } else { memberOrClass.setPackagePrivate(true); } } return memberOrClass instanceof GroovyFieldDoc && isGroovy && !hasNonPublicVisibility & !hasPublicVisibility; }
[ "private", "boolean", "processModifiers", "(", "GroovySourceAST", "t", ",", "SimpleGroovyAbstractableElementDoc", "memberOrClass", ")", "{", "GroovySourceAST", "modifiers", "=", "t", ".", "childOfType", "(", "MODIFIERS", ")", ";", "boolean", "hasNonPublicVisibility", "=...
return true if a property is found
[ "return", "true", "if", "a", "property", "is", "found" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocAssembler.java#L629-L695
12,924
apache/groovy
subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocAssembler.java
SimpleGroovyClassDocAssembler.getJavaDocCommentsBeforeNode
private String getJavaDocCommentsBeforeNode(GroovySourceAST t) { String result = ""; LineColumn thisLineCol = new LineColumn(t.getLine(), t.getColumn()); String text = sourceBuffer.getSnippet(lastLineCol, thisLineCol); if (text != null) { Matcher m = PREV_JAVADOC_COMMENT_PATTERN.matcher(text); if (m.find()) { result = m.group(1); } } if (isMajorType(t)) { lastLineCol = thisLineCol; } return result; }
java
private String getJavaDocCommentsBeforeNode(GroovySourceAST t) { String result = ""; LineColumn thisLineCol = new LineColumn(t.getLine(), t.getColumn()); String text = sourceBuffer.getSnippet(lastLineCol, thisLineCol); if (text != null) { Matcher m = PREV_JAVADOC_COMMENT_PATTERN.matcher(text); if (m.find()) { result = m.group(1); } } if (isMajorType(t)) { lastLineCol = thisLineCol; } return result; }
[ "private", "String", "getJavaDocCommentsBeforeNode", "(", "GroovySourceAST", "t", ")", "{", "String", "result", "=", "\"\"", ";", "LineColumn", "thisLineCol", "=", "new", "LineColumn", "(", "t", ".", "getLine", "(", ")", ",", "t", ".", "getColumn", "(", ")",...
todo - If no comment before node, then get comment from same node on parent class - ouch!
[ "todo", "-", "If", "no", "comment", "before", "node", "then", "get", "comment", "from", "same", "node", "on", "parent", "class", "-", "ouch!" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDocAssembler.java#L725-L739
12,925
apache/groovy
src/main/java/org/codehaus/groovy/runtime/EncodingGroovyMethods.java
EncodingGroovyMethods.decodeHex
public static byte[] decodeHex(final String value) { // if string length is odd then throw exception if (value.length() % 2 != 0) { throw new NumberFormatException("odd number of characters in hex string"); } byte[] bytes = new byte[value.length() / 2]; for (int i = 0; i < value.length(); i += 2) { bytes[i / 2] = (byte) Integer.parseInt(value.substring(i, i + 2), 16); } return bytes; }
java
public static byte[] decodeHex(final String value) { // if string length is odd then throw exception if (value.length() % 2 != 0) { throw new NumberFormatException("odd number of characters in hex string"); } byte[] bytes = new byte[value.length() / 2]; for (int i = 0; i < value.length(); i += 2) { bytes[i / 2] = (byte) Integer.parseInt(value.substring(i, i + 2), 16); } return bytes; }
[ "public", "static", "byte", "[", "]", "decodeHex", "(", "final", "String", "value", ")", "{", "// if string length is odd then throw exception", "if", "(", "value", ".", "length", "(", ")", "%", "2", "!=", "0", ")", "{", "throw", "new", "NumberFormatException"...
Decodes a hex string to a byte array. The hex string can contain either upper case or lower case letters. @param value string to be decoded @return decoded byte array @throws NumberFormatException If the string contains an odd number of characters or if the characters are not valid hexadecimal values.
[ "Decodes", "a", "hex", "string", "to", "a", "byte", "array", ".", "The", "hex", "string", "can", "contain", "either", "upper", "case", "or", "lower", "case", "letters", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/EncodingGroovyMethods.java#L358-L370
12,926
apache/groovy
src/main/java/org/codehaus/groovy/runtime/EncodingGroovyMethods.java
EncodingGroovyMethods.digest
public static String digest(CharSequence self, String algorithm) throws NoSuchAlgorithmException { final String text = self.toString(); return digest(text.getBytes(StandardCharsets.UTF_8), algorithm); }
java
public static String digest(CharSequence self, String algorithm) throws NoSuchAlgorithmException { final String text = self.toString(); return digest(text.getBytes(StandardCharsets.UTF_8), algorithm); }
[ "public", "static", "String", "digest", "(", "CharSequence", "self", ",", "String", "algorithm", ")", "throws", "NoSuchAlgorithmException", "{", "final", "String", "text", "=", "self", ".", "toString", "(", ")", ";", "return", "digest", "(", "text", ".", "ge...
digest the CharSequence instance @param algorithm the name of the algorithm requested, e.g. MD5, SHA-1, SHA-256, etc. @return digested value @throws NoSuchAlgorithmException if the algorithm not found @since 2.5.0 @see MessageDigest#getInstance(java.lang.String)
[ "digest", "the", "CharSequence", "instance" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/EncodingGroovyMethods.java#L420-L424
12,927
apache/groovy
src/main/java/org/codehaus/groovy/runtime/EncodingGroovyMethods.java
EncodingGroovyMethods.digest
public static String digest(byte[] self, String algorithm) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance(algorithm); md.update(ByteBuffer.wrap(self)); return encodeHex(md.digest()).toString(); }
java
public static String digest(byte[] self, String algorithm) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance(algorithm); md.update(ByteBuffer.wrap(self)); return encodeHex(md.digest()).toString(); }
[ "public", "static", "String", "digest", "(", "byte", "[", "]", "self", ",", "String", "algorithm", ")", "throws", "NoSuchAlgorithmException", "{", "MessageDigest", "md", "=", "MessageDigest", ".", "getInstance", "(", "algorithm", ")", ";", "md", ".", "update",...
digest the byte array @param algorithm the name of the algorithm requested, e.g. MD5, SHA-1, SHA-256, etc. @return digested value @throws NoSuchAlgorithmException if the algorithm not found @since 2.5.0 @see MessageDigest#getInstance(java.lang.String)
[ "digest", "the", "byte", "array" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/EncodingGroovyMethods.java#L434-L439
12,928
apache/groovy
src/main/java/org/codehaus/groovy/tools/Compiler.java
Compiler.compile
public void compile(File file) throws CompilationFailedException { CompilationUnit unit = new CompilationUnit(configuration); unit.addSource(file); unit.compile(); }
java
public void compile(File file) throws CompilationFailedException { CompilationUnit unit = new CompilationUnit(configuration); unit.addSource(file); unit.compile(); }
[ "public", "void", "compile", "(", "File", "file", ")", "throws", "CompilationFailedException", "{", "CompilationUnit", "unit", "=", "new", "CompilationUnit", "(", "configuration", ")", ";", "unit", ".", "addSource", "(", "file", ")", ";", "unit", ".", "compile...
Compiles a single File.
[ "Compiles", "a", "single", "File", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/tools/Compiler.java#L57-L61
12,929
apache/groovy
src/main/java/org/codehaus/groovy/tools/Compiler.java
Compiler.compile
public void compile(File[] files) throws CompilationFailedException { CompilationUnit unit = new CompilationUnit(configuration); unit.addSources(files); unit.compile(); }
java
public void compile(File[] files) throws CompilationFailedException { CompilationUnit unit = new CompilationUnit(configuration); unit.addSources(files); unit.compile(); }
[ "public", "void", "compile", "(", "File", "[", "]", "files", ")", "throws", "CompilationFailedException", "{", "CompilationUnit", "unit", "=", "new", "CompilationUnit", "(", "configuration", ")", ";", "unit", ".", "addSources", "(", "files", ")", ";", "unit", ...
Compiles a series of Files.
[ "Compiles", "a", "series", "of", "Files", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/tools/Compiler.java#L67-L71
12,930
apache/groovy
src/main/java/org/codehaus/groovy/tools/Compiler.java
Compiler.compile
public void compile(String[] files) throws CompilationFailedException { CompilationUnit unit = new CompilationUnit(configuration); unit.addSources(files); unit.compile(); }
java
public void compile(String[] files) throws CompilationFailedException { CompilationUnit unit = new CompilationUnit(configuration); unit.addSources(files); unit.compile(); }
[ "public", "void", "compile", "(", "String", "[", "]", "files", ")", "throws", "CompilationFailedException", "{", "CompilationUnit", "unit", "=", "new", "CompilationUnit", "(", "configuration", ")", ";", "unit", ".", "addSources", "(", "files", ")", ";", "unit"...
Compiles a series of Files from file names.
[ "Compiles", "a", "series", "of", "Files", "from", "file", "names", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/tools/Compiler.java#L77-L81
12,931
apache/groovy
src/main/java/org/codehaus/groovy/tools/Compiler.java
Compiler.compile
public void compile(String name, String code) throws CompilationFailedException { CompilationUnit unit = new CompilationUnit(configuration); unit.addSource(new SourceUnit(name, code, configuration, unit.getClassLoader(), unit.getErrorCollector())); unit.compile(); }
java
public void compile(String name, String code) throws CompilationFailedException { CompilationUnit unit = new CompilationUnit(configuration); unit.addSource(new SourceUnit(name, code, configuration, unit.getClassLoader(), unit.getErrorCollector())); unit.compile(); }
[ "public", "void", "compile", "(", "String", "name", ",", "String", "code", ")", "throws", "CompilationFailedException", "{", "CompilationUnit", "unit", "=", "new", "CompilationUnit", "(", "configuration", ")", ";", "unit", ".", "addSource", "(", "new", "SourceUn...
Compiles a string of code.
[ "Compiles", "a", "string", "of", "code", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/tools/Compiler.java#L87-L91
12,932
apache/groovy
src/main/groovy/groovy/inspect/Inspector.java
Inspector.getClassProps
public String[] getClassProps() { String[] result = new String[CLASS_OTHER_IDX + 1]; Package pack = getClassUnderInspection().getPackage(); result[CLASS_PACKAGE_IDX] = "package " + ((pack == null) ? NOT_APPLICABLE : pack.getName()); String modifiers = Modifier.toString(getClassUnderInspection().getModifiers()); result[CLASS_CLASS_IDX] = modifiers + " class " + shortName(getClassUnderInspection()); result[CLASS_INTERFACE_IDX] = "implements "; Class[] interfaces = getClassUnderInspection().getInterfaces(); for (Class anInterface : interfaces) { result[CLASS_INTERFACE_IDX] += shortName(anInterface) + " "; } result[CLASS_SUPERCLASS_IDX] = "extends " + shortName(getClassUnderInspection().getSuperclass()); result[CLASS_OTHER_IDX] = "is Primitive: " + getClassUnderInspection().isPrimitive() + ", is Array: " + getClassUnderInspection().isArray() + ", is Groovy: " + isGroovy(); return result; }
java
public String[] getClassProps() { String[] result = new String[CLASS_OTHER_IDX + 1]; Package pack = getClassUnderInspection().getPackage(); result[CLASS_PACKAGE_IDX] = "package " + ((pack == null) ? NOT_APPLICABLE : pack.getName()); String modifiers = Modifier.toString(getClassUnderInspection().getModifiers()); result[CLASS_CLASS_IDX] = modifiers + " class " + shortName(getClassUnderInspection()); result[CLASS_INTERFACE_IDX] = "implements "; Class[] interfaces = getClassUnderInspection().getInterfaces(); for (Class anInterface : interfaces) { result[CLASS_INTERFACE_IDX] += shortName(anInterface) + " "; } result[CLASS_SUPERCLASS_IDX] = "extends " + shortName(getClassUnderInspection().getSuperclass()); result[CLASS_OTHER_IDX] = "is Primitive: " + getClassUnderInspection().isPrimitive() + ", is Array: " + getClassUnderInspection().isArray() + ", is Groovy: " + isGroovy(); return result; }
[ "public", "String", "[", "]", "getClassProps", "(", ")", "{", "String", "[", "]", "result", "=", "new", "String", "[", "CLASS_OTHER_IDX", "+", "1", "]", ";", "Package", "pack", "=", "getClassUnderInspection", "(", ")", ".", "getPackage", "(", ")", ";", ...
Get the Class Properties of the object under inspection. @return String array to be indexed by the CLASS_xxx_IDX constants
[ "Get", "the", "Class", "Properties", "of", "the", "object", "under", "inspection", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/inspect/Inspector.java#L83-L99
12,933
apache/groovy
src/main/groovy/groovy/inspect/Inspector.java
Inspector.getMethods
public Object[] getMethods() { Method[] methods = getClassUnderInspection().getMethods(); Constructor[] ctors = getClassUnderInspection().getConstructors(); Object[] result = new Object[methods.length + ctors.length]; int resultIndex = 0; for (; resultIndex < methods.length; resultIndex++) { Method method = methods[resultIndex]; result[resultIndex] = methodInfo(method); } for (int i = 0; i < ctors.length; i++, resultIndex++) { Constructor ctor = ctors[i]; result[resultIndex] = methodInfo(ctor); } return result; }
java
public Object[] getMethods() { Method[] methods = getClassUnderInspection().getMethods(); Constructor[] ctors = getClassUnderInspection().getConstructors(); Object[] result = new Object[methods.length + ctors.length]; int resultIndex = 0; for (; resultIndex < methods.length; resultIndex++) { Method method = methods[resultIndex]; result[resultIndex] = methodInfo(method); } for (int i = 0; i < ctors.length; i++, resultIndex++) { Constructor ctor = ctors[i]; result[resultIndex] = methodInfo(ctor); } return result; }
[ "public", "Object", "[", "]", "getMethods", "(", ")", "{", "Method", "[", "]", "methods", "=", "getClassUnderInspection", "(", ")", ".", "getMethods", "(", ")", ";", "Constructor", "[", "]", "ctors", "=", "getClassUnderInspection", "(", ")", ".", "getConst...
Get info about usual Java instance and class Methods as well as Constructors. @return Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants
[ "Get", "info", "about", "usual", "Java", "instance", "and", "class", "Methods", "as", "well", "as", "Constructors", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/inspect/Inspector.java#L119-L133
12,934
apache/groovy
src/main/groovy/groovy/inspect/Inspector.java
Inspector.getMetaMethods
public Object[] getMetaMethods() { MetaClass metaClass = InvokerHelper.getMetaClass(objectUnderInspection); List metaMethods = metaClass.getMetaMethods(); Object[] result = new Object[metaMethods.size()]; int i = 0; for (Iterator iter = metaMethods.iterator(); iter.hasNext(); i++) { MetaMethod metaMethod = (MetaMethod) iter.next(); result[i] = methodInfo(metaMethod); } return result; }
java
public Object[] getMetaMethods() { MetaClass metaClass = InvokerHelper.getMetaClass(objectUnderInspection); List metaMethods = metaClass.getMetaMethods(); Object[] result = new Object[metaMethods.size()]; int i = 0; for (Iterator iter = metaMethods.iterator(); iter.hasNext(); i++) { MetaMethod metaMethod = (MetaMethod) iter.next(); result[i] = methodInfo(metaMethod); } return result; }
[ "public", "Object", "[", "]", "getMetaMethods", "(", ")", "{", "MetaClass", "metaClass", "=", "InvokerHelper", ".", "getMetaClass", "(", "objectUnderInspection", ")", ";", "List", "metaMethods", "=", "metaClass", ".", "getMetaMethods", "(", ")", ";", "Object", ...
Get info about instance and class Methods that are dynamically added through Groovy. @return Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants
[ "Get", "info", "about", "instance", "and", "class", "Methods", "that", "are", "dynamically", "added", "through", "Groovy", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/inspect/Inspector.java#L140-L150
12,935
apache/groovy
src/main/groovy/groovy/inspect/Inspector.java
Inspector.getPublicFields
public Object[] getPublicFields() { Field[] fields = getClassUnderInspection().getFields(); Object[] result = new Object[fields.length]; for (int i = 0; i < fields.length; i++) { Field field = fields[i]; result[i] = fieldInfo(field); } return result; }
java
public Object[] getPublicFields() { Field[] fields = getClassUnderInspection().getFields(); Object[] result = new Object[fields.length]; for (int i = 0; i < fields.length; i++) { Field field = fields[i]; result[i] = fieldInfo(field); } return result; }
[ "public", "Object", "[", "]", "getPublicFields", "(", ")", "{", "Field", "[", "]", "fields", "=", "getClassUnderInspection", "(", ")", ".", "getFields", "(", ")", ";", "Object", "[", "]", "result", "=", "new", "Object", "[", "fields", ".", "length", "]...
Get info about usual Java public fields incl. constants. @return Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants
[ "Get", "info", "about", "usual", "Java", "public", "fields", "incl", ".", "constants", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/inspect/Inspector.java#L157-L165
12,936
apache/groovy
src/main/java/org/codehaus/groovy/ast/expr/BinaryExpression.java
BinaryExpression.newAssignmentExpression
public static BinaryExpression newAssignmentExpression(Variable variable, Expression rhs) { VariableExpression lhs = new VariableExpression(variable); Token operator = Token.newPlaceholder(Types.ASSIGN); return new BinaryExpression(lhs, operator, rhs); }
java
public static BinaryExpression newAssignmentExpression(Variable variable, Expression rhs) { VariableExpression lhs = new VariableExpression(variable); Token operator = Token.newPlaceholder(Types.ASSIGN); return new BinaryExpression(lhs, operator, rhs); }
[ "public", "static", "BinaryExpression", "newAssignmentExpression", "(", "Variable", "variable", ",", "Expression", "rhs", ")", "{", "VariableExpression", "lhs", "=", "new", "VariableExpression", "(", "variable", ")", ";", "Token", "operator", "=", "Token", ".", "n...
Creates an assignment expression in which the specified expression is written into the specified variable name.
[ "Creates", "an", "assignment", "expression", "in", "which", "the", "specified", "expression", "is", "written", "into", "the", "specified", "variable", "name", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/ast/expr/BinaryExpression.java#L108-L113
12,937
apache/groovy
src/main/java/org/codehaus/groovy/ast/expr/BinaryExpression.java
BinaryExpression.newInitializationExpression
public static BinaryExpression newInitializationExpression(String variable, ClassNode type, Expression rhs) { VariableExpression lhs = new VariableExpression(variable); if (type != null) { lhs.setType(type); } Token operator = Token.newPlaceholder(Types.ASSIGN); return new BinaryExpression(lhs, operator, rhs); }
java
public static BinaryExpression newInitializationExpression(String variable, ClassNode type, Expression rhs) { VariableExpression lhs = new VariableExpression(variable); if (type != null) { lhs.setType(type); } Token operator = Token.newPlaceholder(Types.ASSIGN); return new BinaryExpression(lhs, operator, rhs); }
[ "public", "static", "BinaryExpression", "newInitializationExpression", "(", "String", "variable", ",", "ClassNode", "type", ",", "Expression", "rhs", ")", "{", "VariableExpression", "lhs", "=", "new", "VariableExpression", "(", "variable", ")", ";", "if", "(", "ty...
Creates variable initialization expression in which the specified expression is written into the specified variable name.
[ "Creates", "variable", "initialization", "expression", "in", "which", "the", "specified", "expression", "is", "written", "into", "the", "specified", "variable", "name", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/ast/expr/BinaryExpression.java#L121-L131
12,938
apache/groovy
src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java
IndyInterface.makeFallBack
protected static MethodHandle makeFallBack(MutableCallSite mc, Class<?> sender, String name, int callID, MethodType type, boolean safeNavigation, boolean thisCall, boolean spreadCall) { MethodHandle mh = MethodHandles.insertArguments(SELECT_METHOD, 0, mc, sender, name, callID, safeNavigation, thisCall, spreadCall, /*dummy receiver:*/ 1); mh = mh.asCollector(Object[].class, type.parameterCount()). asType(type); return mh; }
java
protected static MethodHandle makeFallBack(MutableCallSite mc, Class<?> sender, String name, int callID, MethodType type, boolean safeNavigation, boolean thisCall, boolean spreadCall) { MethodHandle mh = MethodHandles.insertArguments(SELECT_METHOD, 0, mc, sender, name, callID, safeNavigation, thisCall, spreadCall, /*dummy receiver:*/ 1); mh = mh.asCollector(Object[].class, type.parameterCount()). asType(type); return mh; }
[ "protected", "static", "MethodHandle", "makeFallBack", "(", "MutableCallSite", "mc", ",", "Class", "<", "?", ">", "sender", ",", "String", "name", ",", "int", "callID", ",", "MethodType", "type", ",", "boolean", "safeNavigation", ",", "boolean", "thisCall", ",...
Makes a fallback method for an invalidated method selection
[ "Makes", "a", "fallback", "method", "for", "an", "invalidated", "method", "selection" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java#L218-L223
12,939
apache/groovy
src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java
IndyInterface.selectMethod
public static Object selectMethod(MutableCallSite callSite, Class sender, String methodName, int callID, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object dummyReceiver, Object[] arguments) throws Throwable { Selector selector = Selector.getSelector(callSite, sender, methodName, callID, safeNavigation, thisCall, spreadCall, arguments); selector.setCallSiteTarget(); MethodHandle call = selector.handle.asSpreader(Object[].class, arguments.length); call = call.asType(MethodType.methodType(Object.class,Object[].class)); return call.invokeExact(arguments); }
java
public static Object selectMethod(MutableCallSite callSite, Class sender, String methodName, int callID, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object dummyReceiver, Object[] arguments) throws Throwable { Selector selector = Selector.getSelector(callSite, sender, methodName, callID, safeNavigation, thisCall, spreadCall, arguments); selector.setCallSiteTarget(); MethodHandle call = selector.handle.asSpreader(Object[].class, arguments.length); call = call.asType(MethodType.methodType(Object.class,Object[].class)); return call.invokeExact(arguments); }
[ "public", "static", "Object", "selectMethod", "(", "MutableCallSite", "callSite", ",", "Class", "sender", ",", "String", "methodName", ",", "int", "callID", ",", "Boolean", "safeNavigation", ",", "Boolean", "thisCall", ",", "Boolean", "spreadCall", ",", "Object", ...
Core method for indy method selection using runtime types.
[ "Core", "method", "for", "indy", "method", "selection", "using", "runtime", "types", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java#L228-L235
12,940
apache/groovy
src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
ProxyGeneratorAdapter.addDelegateFields
private void addDelegateFields() { visitField(ACC_PRIVATE + ACC_FINAL, CLOSURES_MAP_FIELD, "Ljava/util/Map;", null, null); if (generateDelegateField) { visitField(ACC_PRIVATE + ACC_FINAL, DELEGATE_OBJECT_FIELD, BytecodeHelper.getTypeDescription(delegateClass), null, null); } }
java
private void addDelegateFields() { visitField(ACC_PRIVATE + ACC_FINAL, CLOSURES_MAP_FIELD, "Ljava/util/Map;", null, null); if (generateDelegateField) { visitField(ACC_PRIVATE + ACC_FINAL, DELEGATE_OBJECT_FIELD, BytecodeHelper.getTypeDescription(delegateClass), null, null); } }
[ "private", "void", "addDelegateFields", "(", ")", "{", "visitField", "(", "ACC_PRIVATE", "+", "ACC_FINAL", ",", "CLOSURES_MAP_FIELD", ",", "\"Ljava/util/Map;\"", ",", "null", ",", "null", ")", ";", "if", "(", "generateDelegateField", ")", "{", "visitField", "(",...
Creates delegate fields for every closure defined in the map.
[ "Creates", "delegate", "fields", "for", "every", "closure", "defined", "in", "the", "map", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java#L519-L524
12,941
apache/groovy
src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
ProxyGeneratorAdapter.ensureClosure
@SuppressWarnings("unchecked") public static Closure ensureClosure(Object o) { if (o == null) throw new UnsupportedOperationException(); if (o instanceof Closure) return (Closure) o; return new ReturnValueWrappingClosure(o); }
java
@SuppressWarnings("unchecked") public static Closure ensureClosure(Object o) { if (o == null) throw new UnsupportedOperationException(); if (o instanceof Closure) return (Closure) o; return new ReturnValueWrappingClosure(o); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "Closure", "ensureClosure", "(", "Object", "o", ")", "{", "if", "(", "o", "==", "null", ")", "throw", "new", "UnsupportedOperationException", "(", ")", ";", "if", "(", "o", "instanceof",...
Ensures that the provided object is wrapped into a closure if it's not a closure. Do not trust IDEs, this method is used in bytecode.
[ "Ensures", "that", "the", "provided", "object", "is", "wrapped", "into", "a", "closure", "if", "it", "s", "not", "a", "closure", ".", "Do", "not", "trust", "IDEs", "this", "method", "is", "used", "in", "bytecode", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java#L860-L865
12,942
apache/groovy
subprojects/groovy-yaml/src/main/java/org/apache/groovy/yaml/util/YamlConverter.java
YamlConverter.convertYamlToJson
public static String convertYamlToJson(Reader yamlReader) { try (Reader reader = yamlReader) { Object yaml = new ObjectMapper(new YAMLFactory()).readValue(reader, Object.class); return new ObjectMapper().writeValueAsString(yaml); } catch (IOException e) { throw new YamlRuntimeException(e); } }
java
public static String convertYamlToJson(Reader yamlReader) { try (Reader reader = yamlReader) { Object yaml = new ObjectMapper(new YAMLFactory()).readValue(reader, Object.class); return new ObjectMapper().writeValueAsString(yaml); } catch (IOException e) { throw new YamlRuntimeException(e); } }
[ "public", "static", "String", "convertYamlToJson", "(", "Reader", "yamlReader", ")", "{", "try", "(", "Reader", "reader", "=", "yamlReader", ")", "{", "Object", "yaml", "=", "new", "ObjectMapper", "(", "new", "YAMLFactory", "(", ")", ")", ".", "readValue", ...
Convert yaml to json @param yamlReader the reader of yaml @return the text of json
[ "Convert", "yaml", "to", "json" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-yaml/src/main/java/org/apache/groovy/yaml/util/YamlConverter.java#L40-L48
12,943
apache/groovy
subprojects/groovy-yaml/src/main/java/org/apache/groovy/yaml/util/YamlConverter.java
YamlConverter.convertJsonToYaml
public static String convertJsonToYaml(Reader jsonReader) { try (Reader reader = jsonReader) { JsonNode json = new ObjectMapper().readTree(reader); return new YAMLMapper().writeValueAsString(json); } catch (IOException e) { throw new YamlRuntimeException(e); } }
java
public static String convertJsonToYaml(Reader jsonReader) { try (Reader reader = jsonReader) { JsonNode json = new ObjectMapper().readTree(reader); return new YAMLMapper().writeValueAsString(json); } catch (IOException e) { throw new YamlRuntimeException(e); } }
[ "public", "static", "String", "convertJsonToYaml", "(", "Reader", "jsonReader", ")", "{", "try", "(", "Reader", "reader", "=", "jsonReader", ")", "{", "JsonNode", "json", "=", "new", "ObjectMapper", "(", ")", ".", "readTree", "(", "reader", ")", ";", "retu...
Convert json to yaml @param jsonReader the reader of json @return the text of yaml
[ "Convert", "json", "to", "yaml" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-yaml/src/main/java/org/apache/groovy/yaml/util/YamlConverter.java#L55-L63
12,944
apache/groovy
src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java
StaticTypesMethodReferenceExpressionWriter.chooseMethodRefMethodCandidate
private MethodNode chooseMethodRefMethodCandidate(Expression methodRef, List<MethodNode> candidates) { if (1 == candidates.size()) return candidates.get(0); return candidates.stream() .map(e -> Tuple.tuple(e, matchingScore(e, methodRef))) .min((t1, t2) -> Integer.compare(t2.getV2(), t1.getV2())) .map(Tuple2::getV1) .orElse(null); }
java
private MethodNode chooseMethodRefMethodCandidate(Expression methodRef, List<MethodNode> candidates) { if (1 == candidates.size()) return candidates.get(0); return candidates.stream() .map(e -> Tuple.tuple(e, matchingScore(e, methodRef))) .min((t1, t2) -> Integer.compare(t2.getV2(), t1.getV2())) .map(Tuple2::getV1) .orElse(null); }
[ "private", "MethodNode", "chooseMethodRefMethodCandidate", "(", "Expression", "methodRef", ",", "List", "<", "MethodNode", ">", "candidates", ")", "{", "if", "(", "1", "==", "candidates", ".", "size", "(", ")", ")", "return", "candidates", ".", "get", "(", "...
Choose the best method node for method reference.
[ "Choose", "the", "best", "method", "node", "for", "method", "reference", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesMethodReferenceExpressionWriter.java#L273-L281
12,945
apache/groovy
subprojects/groovy-xml/src/main/java/groovy/util/XmlNodePrinter.java
XmlNodePrinter.printEscaped
private void printEscaped(String s, boolean isAttributeValue) { for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); switch (c) { case '<': out.print("&lt;"); break; case '>': out.print("&gt;"); break; case '&': out.print("&amp;"); break; case '\'': if (isAttributeValue && quote.equals("'")) out.print("&apos;"); else out.print(c); break; case '"': if (isAttributeValue && quote.equals("\"")) out.print("&quot;"); else out.print(c); break; case '\n': if (isAttributeValue) out.print("&#10;"); else out.print(c); break; case '\r': if (isAttributeValue) out.print("&#13;"); else out.print(c); break; default: out.print(c); } } }
java
private void printEscaped(String s, boolean isAttributeValue) { for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); switch (c) { case '<': out.print("&lt;"); break; case '>': out.print("&gt;"); break; case '&': out.print("&amp;"); break; case '\'': if (isAttributeValue && quote.equals("'")) out.print("&apos;"); else out.print(c); break; case '"': if (isAttributeValue && quote.equals("\"")) out.print("&quot;"); else out.print(c); break; case '\n': if (isAttributeValue) out.print("&#10;"); else out.print(c); break; case '\r': if (isAttributeValue) out.print("&#13;"); else out.print(c); break; default: out.print(c); } } }
[ "private", "void", "printEscaped", "(", "String", "s", ",", "boolean", "isAttributeValue", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "s", ".", "length", "(", ")", ";", "i", "++", ")", "{", "char", "c", "=", "s", ".", "charAt", ...
we could always escape if we wanted to.
[ "we", "could", "always", "escape", "if", "we", "wanted", "to", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-xml/src/main/java/groovy/util/XmlNodePrinter.java#L373-L414
12,946
apache/groovy
src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java
CompileStack.clear
public void clear() { if (stateStack.size()>1) { int size = stateStack.size()-1; throw new GroovyBugError("the compile stack contains "+size+" more push instruction"+(size==1?"":"s")+" than pops."); } if (lhsStack.size()>1) { int size = lhsStack.size()-1; throw new GroovyBugError("lhs stack is supposed to be empty, but has " + size + " elements left."); } if (implicitThisStack.size()>1) { int size = implicitThisStack.size()-1; throw new GroovyBugError("implicit 'this' stack is supposed to be empty, but has " + size + " elements left."); } clear = true; MethodVisitor mv = controller.getMethodVisitor(); // br experiment with local var table so debuggers can retrieve variable names if (true) {//AsmClassGenerator.CREATE_DEBUG_INFO) { if (thisEndLabel==null) setEndLabels(); if (!scope.isInStaticContext()) { // write "this" mv.visitLocalVariable("this", className, null, thisStartLabel, thisEndLabel, 0); } for (Iterator iterator = usedVariables.iterator(); iterator.hasNext();) { BytecodeVariable v = (BytecodeVariable) iterator.next(); ClassNode t = v.getType(); if (v.isHolder()) t = ClassHelper.REFERENCE_TYPE; String type = BytecodeHelper.getTypeDescription(t); Label start = v.getStartLabel(); Label end = v.getEndLabel(); mv.visitLocalVariable(v.getName(), type, null, start, end, v.getIndex()); } } //exception table writing for (ExceptionTableEntry ep : typedExceptions) { mv.visitTryCatchBlock(ep.start, ep.end, ep.goal, ep.sig); } //exception table writing for (ExceptionTableEntry ep : untypedExceptions) { mv.visitTryCatchBlock(ep.start, ep.end, ep.goal, ep.sig); } pop(); typedExceptions.clear(); untypedExceptions.clear(); stackVariables.clear(); usedVariables.clear(); scope = null; finallyBlocks.clear(); resetVariableIndex(false); superBlockNamedLabels.clear(); currentBlockNamedLabels.clear(); namedLoopBreakLabel.clear(); namedLoopContinueLabel.clear(); continueLabel=null; breakLabel=null; thisStartLabel=null; thisEndLabel=null; mv = null; }
java
public void clear() { if (stateStack.size()>1) { int size = stateStack.size()-1; throw new GroovyBugError("the compile stack contains "+size+" more push instruction"+(size==1?"":"s")+" than pops."); } if (lhsStack.size()>1) { int size = lhsStack.size()-1; throw new GroovyBugError("lhs stack is supposed to be empty, but has " + size + " elements left."); } if (implicitThisStack.size()>1) { int size = implicitThisStack.size()-1; throw new GroovyBugError("implicit 'this' stack is supposed to be empty, but has " + size + " elements left."); } clear = true; MethodVisitor mv = controller.getMethodVisitor(); // br experiment with local var table so debuggers can retrieve variable names if (true) {//AsmClassGenerator.CREATE_DEBUG_INFO) { if (thisEndLabel==null) setEndLabels(); if (!scope.isInStaticContext()) { // write "this" mv.visitLocalVariable("this", className, null, thisStartLabel, thisEndLabel, 0); } for (Iterator iterator = usedVariables.iterator(); iterator.hasNext();) { BytecodeVariable v = (BytecodeVariable) iterator.next(); ClassNode t = v.getType(); if (v.isHolder()) t = ClassHelper.REFERENCE_TYPE; String type = BytecodeHelper.getTypeDescription(t); Label start = v.getStartLabel(); Label end = v.getEndLabel(); mv.visitLocalVariable(v.getName(), type, null, start, end, v.getIndex()); } } //exception table writing for (ExceptionTableEntry ep : typedExceptions) { mv.visitTryCatchBlock(ep.start, ep.end, ep.goal, ep.sig); } //exception table writing for (ExceptionTableEntry ep : untypedExceptions) { mv.visitTryCatchBlock(ep.start, ep.end, ep.goal, ep.sig); } pop(); typedExceptions.clear(); untypedExceptions.clear(); stackVariables.clear(); usedVariables.clear(); scope = null; finallyBlocks.clear(); resetVariableIndex(false); superBlockNamedLabels.clear(); currentBlockNamedLabels.clear(); namedLoopBreakLabel.clear(); namedLoopContinueLabel.clear(); continueLabel=null; breakLabel=null; thisStartLabel=null; thisEndLabel=null; mv = null; }
[ "public", "void", "clear", "(", ")", "{", "if", "(", "stateStack", ".", "size", "(", ")", ">", "1", ")", "{", "int", "size", "=", "stateStack", ".", "size", "(", ")", "-", "1", ";", "throw", "new", "GroovyBugError", "(", "\"the compile stack contains \...
Clears the state of the class. This method should be called after a MethodNode is visited. Note that a call to init will fail if clear is not called before
[ "Clears", "the", "state", "of", "the", "class", ".", "This", "method", "should", "be", "called", "after", "a", "MethodNode", "is", "visited", ".", "Note", "that", "a", "call", "to", "init", "will", "fail", "if", "clear", "is", "not", "called", "before" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java#L342-L406
12,947
apache/groovy
src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java
CompileStack.pushVariableScope
public void pushVariableScope(VariableScope el) { pushState(); scope = el; superBlockNamedLabels = new HashMap(superBlockNamedLabels); superBlockNamedLabels.putAll(currentBlockNamedLabels); currentBlockNamedLabels = new HashMap(); }
java
public void pushVariableScope(VariableScope el) { pushState(); scope = el; superBlockNamedLabels = new HashMap(superBlockNamedLabels); superBlockNamedLabels.putAll(currentBlockNamedLabels); currentBlockNamedLabels = new HashMap(); }
[ "public", "void", "pushVariableScope", "(", "VariableScope", "el", ")", "{", "pushState", "(", ")", ";", "scope", "=", "el", ";", "superBlockNamedLabels", "=", "new", "HashMap", "(", "superBlockNamedLabels", ")", ";", "superBlockNamedLabels", ".", "putAll", "(",...
Causes the state-stack to add an element and sets the given scope as new current variable scope. Creates a element for the state stack so pop has to be called later
[ "Causes", "the", "state", "-", "stack", "to", "add", "an", "element", "and", "sets", "the", "given", "scope", "as", "new", "current", "variable", "scope", ".", "Creates", "a", "element", "for", "the", "state", "stack", "so", "pop", "has", "to", "be", "...
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java#L445-L451
12,948
apache/groovy
src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java
CompileStack.pushLoop
public void pushLoop(List<String> labelNames) { pushState(); continueLabel = new Label(); breakLabel = new Label(); if (labelNames != null) { for (String labelName : labelNames) { initLoopLabels(labelName); } } }
java
public void pushLoop(List<String> labelNames) { pushState(); continueLabel = new Label(); breakLabel = new Label(); if (labelNames != null) { for (String labelName : labelNames) { initLoopLabels(labelName); } } }
[ "public", "void", "pushLoop", "(", "List", "<", "String", ">", "labelNames", ")", "{", "pushState", "(", ")", ";", "continueLabel", "=", "new", "Label", "(", ")", ";", "breakLabel", "=", "new", "Label", "(", ")", ";", "if", "(", "labelNames", "!=", "...
Should be called when descending into a loop that does not define a scope. Creates a element for the state stack so pop has to be called later
[ "Should", "be", "called", "when", "descending", "into", "a", "loop", "that", "does", "not", "define", "a", "scope", ".", "Creates", "a", "element", "for", "the", "state", "stack", "so", "pop", "has", "to", "be", "called", "later" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java#L507-L516
12,949
apache/groovy
src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java
CompileStack.defineVariable
public BytecodeVariable defineVariable(Variable v, boolean initFromStack) { return defineVariable(v, v.getOriginType(), initFromStack); }
java
public BytecodeVariable defineVariable(Variable v, boolean initFromStack) { return defineVariable(v, v.getOriginType(), initFromStack); }
[ "public", "BytecodeVariable", "defineVariable", "(", "Variable", "v", ",", "boolean", "initFromStack", ")", "{", "return", "defineVariable", "(", "v", ",", "v", ".", "getOriginType", "(", ")", ",", "initFromStack", ")", ";", "}" ]
Defines a new Variable using an AST variable. @param initFromStack if true the last element of the stack will be used to initialize the new variable. If false null will be used.
[ "Defines", "a", "new", "Variable", "using", "an", "AST", "variable", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java#L662-L664
12,950
apache/groovy
src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java
CompileStack.makeNextVariableID
private void makeNextVariableID(ClassNode type, boolean useReferenceDirectly) { currentVariableIndex = nextVariableIndex; if ((type== ClassHelper.long_TYPE || type== ClassHelper.double_TYPE) && !useReferenceDirectly) { nextVariableIndex++; } nextVariableIndex++; }
java
private void makeNextVariableID(ClassNode type, boolean useReferenceDirectly) { currentVariableIndex = nextVariableIndex; if ((type== ClassHelper.long_TYPE || type== ClassHelper.double_TYPE) && !useReferenceDirectly) { nextVariableIndex++; } nextVariableIndex++; }
[ "private", "void", "makeNextVariableID", "(", "ClassNode", "type", ",", "boolean", "useReferenceDirectly", ")", "{", "currentVariableIndex", "=", "nextVariableIndex", ";", "if", "(", "(", "type", "==", "ClassHelper", ".", "long_TYPE", "||", "type", "==", "ClassHel...
Calculates the index of the next free register stores it and sets the current variable index to the old value
[ "Calculates", "the", "index", "of", "the", "next", "free", "register", "stores", "it", "and", "sets", "the", "current", "variable", "index", "to", "the", "old", "value" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java#L712-L718
12,951
apache/groovy
src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java
CompileStack.getLabel
public Label getLabel(String name) { if (name==null) return null; Label l = (Label) superBlockNamedLabels.get(name); if (l==null) l = createLocalLabel(name); return l; }
java
public Label getLabel(String name) { if (name==null) return null; Label l = (Label) superBlockNamedLabels.get(name); if (l==null) l = createLocalLabel(name); return l; }
[ "public", "Label", "getLabel", "(", "String", "name", ")", "{", "if", "(", "name", "==", "null", ")", "return", "null", ";", "Label", "l", "=", "(", "Label", ")", "superBlockNamedLabels", ".", "get", "(", "name", ")", ";", "if", "(", "l", "==", "nu...
Returns the label for the given name
[ "Returns", "the", "label", "for", "the", "given", "name" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java#L723-L728
12,952
apache/groovy
src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java
CompileStack.createLocalLabel
public Label createLocalLabel(String name) { Label l = (Label) currentBlockNamedLabels.get(name); if (l==null) { l = new Label(); currentBlockNamedLabels.put(name,l); } return l; }
java
public Label createLocalLabel(String name) { Label l = (Label) currentBlockNamedLabels.get(name); if (l==null) { l = new Label(); currentBlockNamedLabels.put(name,l); } return l; }
[ "public", "Label", "createLocalLabel", "(", "String", "name", ")", "{", "Label", "l", "=", "(", "Label", ")", "currentBlockNamedLabels", ".", "get", "(", "name", ")", ";", "if", "(", "l", "==", "null", ")", "{", "l", "=", "new", "Label", "(", ")", ...
creates a new named label
[ "creates", "a", "new", "named", "label" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/classgen/asm/CompileStack.java#L733-L740
12,953
apache/groovy
src/main/java/org/codehaus/groovy/runtime/GroovyCategorySupport.java
GroovyCategorySupport.use
public static <T> T use(Class categoryClass, Closure<T> closure) { return THREAD_INFO.getInfo().use(categoryClass, closure); }
java
public static <T> T use(Class categoryClass, Closure<T> closure) { return THREAD_INFO.getInfo().use(categoryClass, closure); }
[ "public", "static", "<", "T", ">", "T", "use", "(", "Class", "categoryClass", ",", "Closure", "<", "T", ">", "closure", ")", "{", "return", "THREAD_INFO", ".", "getInfo", "(", ")", ".", "use", "(", "categoryClass", ",", "closure", ")", ";", "}" ]
Create a scope based on given categoryClass and invoke closure within that scope. @param categoryClass the class containing category methods @param closure the closure during which to make the category class methods available @return the value returned from the closure
[ "Create", "a", "scope", "based", "on", "given", "categoryClass", "and", "invoke", "closure", "within", "that", "scope", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/GroovyCategorySupport.java#L261-L263
12,954
apache/groovy
src/main/java/org/codehaus/groovy/runtime/GroovyCategorySupport.java
GroovyCategorySupport.use
public static <T> T use(List<Class> categoryClasses, Closure<T> closure) { return THREAD_INFO.getInfo().use(categoryClasses, closure); }
java
public static <T> T use(List<Class> categoryClasses, Closure<T> closure) { return THREAD_INFO.getInfo().use(categoryClasses, closure); }
[ "public", "static", "<", "T", ">", "T", "use", "(", "List", "<", "Class", ">", "categoryClasses", ",", "Closure", "<", "T", ">", "closure", ")", "{", "return", "THREAD_INFO", ".", "getInfo", "(", ")", ".", "use", "(", "categoryClasses", ",", "closure",...
Create a scope based on given categoryClasses and invoke closure within that scope. @param categoryClasses the list of classes containing category methods @param closure the closure during which to make the category class methods available @return the value returned from the closure
[ "Create", "a", "scope", "based", "on", "given", "categoryClasses", "and", "invoke", "closure", "within", "that", "scope", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/GroovyCategorySupport.java#L272-L274
12,955
apache/groovy
src/main/java/org/codehaus/groovy/runtime/GroovyCategorySupport.java
GroovyCategorySupport.getCategoryMethods
public static CategoryMethodList getCategoryMethods(String name) { final ThreadCategoryInfo categoryInfo = THREAD_INFO.getInfoNullable(); return categoryInfo == null ? null : categoryInfo.getCategoryMethods(name); }
java
public static CategoryMethodList getCategoryMethods(String name) { final ThreadCategoryInfo categoryInfo = THREAD_INFO.getInfoNullable(); return categoryInfo == null ? null : categoryInfo.getCategoryMethods(name); }
[ "public", "static", "CategoryMethodList", "getCategoryMethods", "(", "String", "name", ")", "{", "final", "ThreadCategoryInfo", "categoryInfo", "=", "THREAD_INFO", ".", "getInfoNullable", "(", ")", ";", "return", "categoryInfo", "==", "null", "?", "null", ":", "ca...
This method is used to pull all the new methods out of the local thread context with a particular name. @param name the method name of interest @return the list of methods
[ "This", "method", "is", "used", "to", "pull", "all", "the", "new", "methods", "out", "of", "the", "local", "thread", "context", "with", "a", "particular", "name", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/runtime/GroovyCategorySupport.java#L313-L316
12,956
apache/groovy
src/main/java/org/codehaus/groovy/control/ErrorCollector.java
ErrorCollector.addErrorAndContinue
public void addErrorAndContinue(Message message) { if (this.errors == null) { this.errors = new LinkedList(); } this.errors.add(message); }
java
public void addErrorAndContinue(Message message) { if (this.errors == null) { this.errors = new LinkedList(); } this.errors.add(message); }
[ "public", "void", "addErrorAndContinue", "(", "Message", "message", ")", "{", "if", "(", "this", ".", "errors", "==", "null", ")", "{", "this", ".", "errors", "=", "new", "LinkedList", "(", ")", ";", "}", "this", ".", "errors", ".", "add", "(", "mess...
Adds an error to the message set, but does not cause a failure. The message is not required to have a source line and column specified, but it is best practice to try and include that information.
[ "Adds", "an", "error", "to", "the", "message", "set", "but", "does", "not", "cause", "a", "failure", ".", "The", "message", "is", "not", "required", "to", "have", "a", "source", "line", "and", "column", "specified", "but", "it", "is", "best", "practice",...
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/control/ErrorCollector.java#L91-L97
12,957
apache/groovy
src/main/java/org/codehaus/groovy/control/ErrorCollector.java
ErrorCollector.addError
public void addError(Message message) throws CompilationFailedException { addErrorAndContinue(message); if (errors!=null && this.errors.size() >= configuration.getTolerance()) { failIfErrors(); } }
java
public void addError(Message message) throws CompilationFailedException { addErrorAndContinue(message); if (errors!=null && this.errors.size() >= configuration.getTolerance()) { failIfErrors(); } }
[ "public", "void", "addError", "(", "Message", "message", ")", "throws", "CompilationFailedException", "{", "addErrorAndContinue", "(", "message", ")", ";", "if", "(", "errors", "!=", "null", "&&", "this", ".", "errors", ".", "size", "(", ")", ">=", "configur...
Adds a non-fatal error to the message set, which may cause a failure if the error threshold is exceeded. The message is not required to have a source line and column specified, but it is best practice to try and include that information.
[ "Adds", "a", "non", "-", "fatal", "error", "to", "the", "message", "set", "which", "may", "cause", "a", "failure", "if", "the", "error", "threshold", "is", "exceeded", ".", "The", "message", "is", "not", "required", "to", "have", "a", "source", "line", ...
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/control/ErrorCollector.java#L104-L110
12,958
apache/groovy
src/main/java/org/codehaus/groovy/control/ErrorCollector.java
ErrorCollector.addError
public void addError(Message message, boolean fatal) throws CompilationFailedException { if (fatal) { addFatalError(message); } else { addError(message); } }
java
public void addError(Message message, boolean fatal) throws CompilationFailedException { if (fatal) { addFatalError(message); } else { addError(message); } }
[ "public", "void", "addError", "(", "Message", "message", ",", "boolean", "fatal", ")", "throws", "CompilationFailedException", "{", "if", "(", "fatal", ")", "{", "addFatalError", "(", "message", ")", ";", "}", "else", "{", "addError", "(", "message", ")", ...
Adds an optionally-fatal error to the message set. The message is not required to have a source line and column specified, but it is best practice to try and include that information. @param fatal if true then then processing will stop
[ "Adds", "an", "optionally", "-", "fatal", "error", "to", "the", "message", "set", ".", "The", "message", "is", "not", "required", "to", "have", "a", "source", "line", "and", "column", "specified", "but", "it", "is", "best", "practice", "to", "try", "and"...
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/control/ErrorCollector.java#L119-L126
12,959
apache/groovy
src/main/java/org/codehaus/groovy/control/ErrorCollector.java
ErrorCollector.getWarning
public WarningMessage getWarning(int index) { if (index < getWarningCount()) { return (WarningMessage) this.warnings.get(index); } return null; }
java
public WarningMessage getWarning(int index) { if (index < getWarningCount()) { return (WarningMessage) this.warnings.get(index); } return null; }
[ "public", "WarningMessage", "getWarning", "(", "int", "index", ")", "{", "if", "(", "index", "<", "getWarningCount", "(", ")", ")", "{", "return", "(", "WarningMessage", ")", "this", ".", "warnings", ".", "get", "(", "index", ")", ";", "}", "return", "...
Returns the specified warning message, or null.
[ "Returns", "the", "specified", "warning", "message", "or", "null", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/control/ErrorCollector.java#L212-L217
12,960
apache/groovy
src/main/java/org/codehaus/groovy/control/ErrorCollector.java
ErrorCollector.getError
public Message getError(int index) { if (index < getErrorCount()) { return (Message) this.errors.get(index); } return null; }
java
public Message getError(int index) { if (index < getErrorCount()) { return (Message) this.errors.get(index); } return null; }
[ "public", "Message", "getError", "(", "int", "index", ")", "{", "if", "(", "index", "<", "getErrorCount", "(", ")", ")", "{", "return", "(", "Message", ")", "this", ".", "errors", ".", "get", "(", "index", ")", ";", "}", "return", "null", ";", "}" ...
Returns the specified error message, or null.
[ "Returns", "the", "specified", "error", "message", "or", "null", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/control/ErrorCollector.java#L222-L227
12,961
apache/groovy
src/main/java/org/codehaus/groovy/control/ErrorCollector.java
ErrorCollector.getException
public Exception getException(int index) { Exception exception = null; Message message = getError(index); if (message != null) { if (message instanceof ExceptionMessage) { exception = ((ExceptionMessage) message).getCause(); } else if (message instanceof SyntaxErrorMessage) { exception = ((SyntaxErrorMessage) message).getCause(); } } return exception; }
java
public Exception getException(int index) { Exception exception = null; Message message = getError(index); if (message != null) { if (message instanceof ExceptionMessage) { exception = ((ExceptionMessage) message).getCause(); } else if (message instanceof SyntaxErrorMessage) { exception = ((SyntaxErrorMessage) message).getCause(); } } return exception; }
[ "public", "Exception", "getException", "(", "int", "index", ")", "{", "Exception", "exception", "=", "null", ";", "Message", "message", "=", "getError", "(", "index", ")", ";", "if", "(", "message", "!=", "null", ")", "{", "if", "(", "message", "instance...
Convenience routine to return the specified error's underlying Exception, or null if it isn't one.
[ "Convenience", "routine", "to", "return", "the", "specified", "error", "s", "underlying", "Exception", "or", "null", "if", "it", "isn", "t", "one", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/control/ErrorCollector.java#L254-L267
12,962
apache/groovy
src/main/java/org/codehaus/groovy/control/ErrorCollector.java
ErrorCollector.addWarning
public void addWarning(WarningMessage message) { if (message.isRelevant(configuration.getWarningLevel())) { if (this.warnings == null) { this.warnings = new LinkedList(); } this.warnings.add(message); } }
java
public void addWarning(WarningMessage message) { if (message.isRelevant(configuration.getWarningLevel())) { if (this.warnings == null) { this.warnings = new LinkedList(); } this.warnings.add(message); } }
[ "public", "void", "addWarning", "(", "WarningMessage", "message", ")", "{", "if", "(", "message", ".", "isRelevant", "(", "configuration", ".", "getWarningLevel", "(", ")", ")", ")", "{", "if", "(", "this", ".", "warnings", "==", "null", ")", "{", "this"...
Adds a WarningMessage to the message set.
[ "Adds", "a", "WarningMessage", "to", "the", "message", "set", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/control/ErrorCollector.java#L272-L280
12,963
apache/groovy
src/main/java/org/codehaus/groovy/control/ErrorCollector.java
ErrorCollector.write
public void write(PrintWriter writer, Janitor janitor) { write(writer,janitor,warnings,"warning"); write(writer,janitor,errors,"error"); }
java
public void write(PrintWriter writer, Janitor janitor) { write(writer,janitor,warnings,"warning"); write(writer,janitor,errors,"error"); }
[ "public", "void", "write", "(", "PrintWriter", "writer", ",", "Janitor", "janitor", ")", "{", "write", "(", "writer", ",", "janitor", ",", "warnings", ",", "\"warning\"", ")", ";", "write", "(", "writer", ",", "janitor", ",", "errors", ",", "\"error\"", ...
Writes error messages to the specified PrintWriter.
[ "Writes", "error", "messages", "to", "the", "specified", "PrintWriter", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/control/ErrorCollector.java#L342-L345
12,964
apache/groovy
src/main/java/org/codehaus/groovy/control/CompilationUnit.java
CompilationUnit.getClassNode
public ClassNode getClassNode(final String name) { final ClassNode[] result = new ClassNode[]{null}; PrimaryClassNodeOperation handler = new PrimaryClassNodeOperation() { public void call(SourceUnit source, GeneratorContext context, ClassNode classNode) { if (classNode.getName().equals(name)) { result[0] = classNode; } } }; try { applyToPrimaryClassNodes(handler); } catch (CompilationFailedException e) { if (debug) e.printStackTrace(); } return result[0]; }
java
public ClassNode getClassNode(final String name) { final ClassNode[] result = new ClassNode[]{null}; PrimaryClassNodeOperation handler = new PrimaryClassNodeOperation() { public void call(SourceUnit source, GeneratorContext context, ClassNode classNode) { if (classNode.getName().equals(name)) { result[0] = classNode; } } }; try { applyToPrimaryClassNodes(handler); } catch (CompilationFailedException e) { if (debug) e.printStackTrace(); } return result[0]; }
[ "public", "ClassNode", "getClassNode", "(", "final", "String", "name", ")", "{", "final", "ClassNode", "[", "]", "result", "=", "new", "ClassNode", "[", "]", "{", "null", "}", ";", "PrimaryClassNodeOperation", "handler", "=", "new", "PrimaryClassNodeOperation", ...
Convenience routine to get the named ClassNode.
[ "Convenience", "routine", "to", "get", "the", "named", "ClassNode", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/control/CompilationUnit.java#L403-L419
12,965
apache/groovy
src/main/java/org/codehaus/groovy/control/CompilationUnit.java
CompilationUnit.addSource
public SourceUnit addSource(String name, InputStream stream) { ReaderSource source = new InputStreamReaderSource(stream, configuration); return addSource(new SourceUnit(name, source, configuration, classLoader, getErrorCollector())); }
java
public SourceUnit addSource(String name, InputStream stream) { ReaderSource source = new InputStreamReaderSource(stream, configuration); return addSource(new SourceUnit(name, source, configuration, classLoader, getErrorCollector())); }
[ "public", "SourceUnit", "addSource", "(", "String", "name", ",", "InputStream", "stream", ")", "{", "ReaderSource", "source", "=", "new", "InputStreamReaderSource", "(", "stream", ",", "configuration", ")", ";", "return", "addSource", "(", "new", "SourceUnit", "...
Adds a InputStream source to the unit.
[ "Adds", "a", "InputStream", "source", "to", "the", "unit", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/control/CompilationUnit.java#L470-L473
12,966
apache/groovy
src/main/java/org/codehaus/groovy/control/CompilationUnit.java
CompilationUnit.addSource
public SourceUnit addSource(SourceUnit source) { String name = source.getName(); source.setClassLoader(this.classLoader); for (SourceUnit su : queuedSources) { if (name.equals(su.getName())) return su; } queuedSources.add(source); return source; }
java
public SourceUnit addSource(SourceUnit source) { String name = source.getName(); source.setClassLoader(this.classLoader); for (SourceUnit su : queuedSources) { if (name.equals(su.getName())) return su; } queuedSources.add(source); return source; }
[ "public", "SourceUnit", "addSource", "(", "SourceUnit", "source", ")", "{", "String", "name", "=", "source", ".", "getName", "(", ")", ";", "source", ".", "setClassLoader", "(", "this", ".", "classLoader", ")", ";", "for", "(", "SourceUnit", "su", ":", "...
Adds a SourceUnit to the unit.
[ "Adds", "a", "SourceUnit", "to", "the", "unit", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/control/CompilationUnit.java#L482-L490
12,967
apache/groovy
src/main/java/org/codehaus/groovy/control/CompilationUnit.java
CompilationUnit.iterator
public Iterator<SourceUnit> iterator() { return new Iterator<SourceUnit>() { Iterator<String> nameIterator = names.iterator(); public boolean hasNext() { return nameIterator.hasNext(); } public SourceUnit next() { String name = nameIterator.next(); return sources.get(name); } public void remove() { throw new UnsupportedOperationException(); } }; }
java
public Iterator<SourceUnit> iterator() { return new Iterator<SourceUnit>() { Iterator<String> nameIterator = names.iterator(); public boolean hasNext() { return nameIterator.hasNext(); } public SourceUnit next() { String name = nameIterator.next(); return sources.get(name); } public void remove() { throw new UnsupportedOperationException(); } }; }
[ "public", "Iterator", "<", "SourceUnit", ">", "iterator", "(", ")", "{", "return", "new", "Iterator", "<", "SourceUnit", ">", "(", ")", "{", "Iterator", "<", "String", ">", "nameIterator", "=", "names", ".", "iterator", "(", ")", ";", "public", "boolean"...
Returns an iterator on the unit's SourceUnits.
[ "Returns", "an", "iterator", "on", "the", "unit", "s", "SourceUnits", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/control/CompilationUnit.java#L496-L513
12,968
apache/groovy
src/main/java/org/codehaus/groovy/control/CompilationUnit.java
CompilationUnit.compile
public void compile(int throughPhase) throws CompilationFailedException { // // To support delta compilations, we always restart // the compiler. The individual passes are responsible // for not reprocessing old code. gotoPhase(Phases.INITIALIZATION); throughPhase = Math.min(throughPhase, Phases.ALL); while (throughPhase >= phase && phase <= Phases.ALL) { if (phase == Phases.SEMANTIC_ANALYSIS) { doPhaseOperation(resolve); if (dequeued()) continue; } processPhaseOperations(phase); // Grab processing may have brought in new AST transforms into various phases, process them as well processNewPhaseOperations(phase); if (progressCallback != null) progressCallback.call(this, phase); completePhase(); applyToSourceUnits(mark); if (dequeued()) continue; gotoPhase(phase + 1); if (phase == Phases.CLASS_GENERATION) { sortClasses(); } } errorCollector.failIfErrors(); }
java
public void compile(int throughPhase) throws CompilationFailedException { // // To support delta compilations, we always restart // the compiler. The individual passes are responsible // for not reprocessing old code. gotoPhase(Phases.INITIALIZATION); throughPhase = Math.min(throughPhase, Phases.ALL); while (throughPhase >= phase && phase <= Phases.ALL) { if (phase == Phases.SEMANTIC_ANALYSIS) { doPhaseOperation(resolve); if (dequeued()) continue; } processPhaseOperations(phase); // Grab processing may have brought in new AST transforms into various phases, process them as well processNewPhaseOperations(phase); if (progressCallback != null) progressCallback.call(this, phase); completePhase(); applyToSourceUnits(mark); if (dequeued()) continue; gotoPhase(phase + 1); if (phase == Phases.CLASS_GENERATION) { sortClasses(); } } errorCollector.failIfErrors(); }
[ "public", "void", "compile", "(", "int", "throughPhase", ")", "throws", "CompilationFailedException", "{", "//", "// To support delta compilations, we always restart", "// the compiler. The individual passes are responsible", "// for not reprocessing old code.", "gotoPhase", "(", "P...
Compiles the compilation unit from sources.
[ "Compiles", "the", "compilation", "unit", "from", "sources", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/control/CompilationUnit.java#L591-L624
12,969
apache/groovy
src/main/java/org/codehaus/groovy/control/CompilationUnit.java
CompilationUnit.applyToSourceUnits
public void applyToSourceUnits(SourceUnitOperation body) throws CompilationFailedException { for (String name : names) { SourceUnit source = sources.get(name); if ((source.phase < phase) || (source.phase == phase && !source.phaseComplete)) { try { body.call(source); } catch (CompilationFailedException e) { throw e; } catch (Exception e) { GroovyBugError gbe = new GroovyBugError(e); changeBugText(gbe, source); throw gbe; } catch (GroovyBugError e) { changeBugText(e, source); throw e; } } } getErrorCollector().failIfErrors(); }
java
public void applyToSourceUnits(SourceUnitOperation body) throws CompilationFailedException { for (String name : names) { SourceUnit source = sources.get(name); if ((source.phase < phase) || (source.phase == phase && !source.phaseComplete)) { try { body.call(source); } catch (CompilationFailedException e) { throw e; } catch (Exception e) { GroovyBugError gbe = new GroovyBugError(e); changeBugText(gbe, source); throw gbe; } catch (GroovyBugError e) { changeBugText(e, source); throw e; } } } getErrorCollector().failIfErrors(); }
[ "public", "void", "applyToSourceUnits", "(", "SourceUnitOperation", "body", ")", "throws", "CompilationFailedException", "{", "for", "(", "String", "name", ":", "names", ")", "{", "SourceUnit", "source", "=", "sources", ".", "get", "(", "name", ")", ";", "if",...
A loop driver for applying operations to all SourceUnits. Automatically skips units that have already been processed through the current phase.
[ "A", "loop", "driver", "for", "applying", "operations", "to", "all", "SourceUnits", ".", "Automatically", "skips", "units", "that", "have", "already", "been", "processed", "through", "the", "current", "phase", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/control/CompilationUnit.java#L966-L987
12,970
apache/groovy
src/main/java/org/codehaus/groovy/transform/stc/TypeCheckingExtension.java
TypeCheckingExtension.handleMissingMethod
public List<MethodNode> handleMissingMethod(ClassNode receiver, String name, ArgumentListExpression argumentList, ClassNode[] argumentTypes, MethodCall call) { return Collections.emptyList(); }
java
public List<MethodNode> handleMissingMethod(ClassNode receiver, String name, ArgumentListExpression argumentList, ClassNode[] argumentTypes, MethodCall call) { return Collections.emptyList(); }
[ "public", "List", "<", "MethodNode", ">", "handleMissingMethod", "(", "ClassNode", "receiver", ",", "String", "name", ",", "ArgumentListExpression", "argumentList", ",", "ClassNode", "[", "]", "argumentTypes", ",", "MethodCall", "call", ")", "{", "return", "Collec...
This method is called by the type checker when a method call cannot be resolved. Extensions may override this method to handle missing methods and prevent the type checker from throwing an error. @param receiver the type of the receiver @param name the name of the called method @param argumentList the list of arguments of the call @param argumentTypes the types of the arguments of the call @param call the method call itself, if needed @return an empty list if the extension cannot resolve the method, or a list of potential methods if the extension finds candidates. This method must not return null.
[ "This", "method", "is", "called", "by", "the", "type", "checker", "when", "a", "method", "call", "cannot", "be", "resolved", ".", "Extensions", "may", "override", "this", "method", "to", "handle", "missing", "methods", "and", "prevent", "the", "type", "check...
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/transform/stc/TypeCheckingExtension.java#L128-L130
12,971
apache/groovy
src/main/java/org/codehaus/groovy/transform/stc/TypeCheckingExtension.java
TypeCheckingExtension.lookupClassNodeFor
public ClassNode lookupClassNodeFor(String type) { for (ClassNode cn : typeCheckingVisitor.getSourceUnit().getAST().getClasses()) { if (cn.getName().equals(type)) return cn; } return null; }
java
public ClassNode lookupClassNodeFor(String type) { for (ClassNode cn : typeCheckingVisitor.getSourceUnit().getAST().getClasses()) { if (cn.getName().equals(type)) return cn; } return null; }
[ "public", "ClassNode", "lookupClassNodeFor", "(", "String", "type", ")", "{", "for", "(", "ClassNode", "cn", ":", "typeCheckingVisitor", ".", "getSourceUnit", "(", ")", ".", "getAST", "(", ")", ".", "getClasses", "(", ")", ")", "{", "if", "(", "cn", ".",...
Lookup a ClassNode by its name from the source unit @param type the name of the class whose ClassNode we want to lookup @return a ClassNode representing the class
[ "Lookup", "a", "ClassNode", "by", "its", "name", "from", "the", "source", "unit" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/transform/stc/TypeCheckingExtension.java#L318-L325
12,972
apache/groovy
src/main/java/org/codehaus/groovy/transform/stc/TypeCheckingExtension.java
TypeCheckingExtension.buildMapType
public ClassNode buildMapType(ClassNode keyType, ClassNode valueType) { return parameterizedType(ClassHelper.MAP_TYPE, keyType, valueType); }
java
public ClassNode buildMapType(ClassNode keyType, ClassNode valueType) { return parameterizedType(ClassHelper.MAP_TYPE, keyType, valueType); }
[ "public", "ClassNode", "buildMapType", "(", "ClassNode", "keyType", ",", "ClassNode", "valueType", ")", "{", "return", "parameterizedType", "(", "ClassHelper", ".", "MAP_TYPE", ",", "keyType", ",", "valueType", ")", ";", "}" ]
Builds a parametrized class node representing the Map&lt;keyType,valueType&gt; type. @param keyType the classnode type of the key @param valueType the classnode type of the value @return a class node for Map&lt;keyType,valueType&gt; @since 2.2.0
[ "Builds", "a", "parametrized", "class", "node", "representing", "the", "Map&lt", ";", "keyType", "valueType&gt", ";", "type", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/transform/stc/TypeCheckingExtension.java#L361-L363
12,973
apache/groovy
src/main/java/org/codehaus/groovy/transform/stc/TypeCheckingExtension.java
TypeCheckingExtension.isStaticMethodCallOnClass
public boolean isStaticMethodCallOnClass(MethodCall call, ClassNode receiver) { ClassNode staticReceiver = extractStaticReceiver(call); return staticReceiver!=null && staticReceiver.equals(receiver); }
java
public boolean isStaticMethodCallOnClass(MethodCall call, ClassNode receiver) { ClassNode staticReceiver = extractStaticReceiver(call); return staticReceiver!=null && staticReceiver.equals(receiver); }
[ "public", "boolean", "isStaticMethodCallOnClass", "(", "MethodCall", "call", ",", "ClassNode", "receiver", ")", "{", "ClassNode", "staticReceiver", "=", "extractStaticReceiver", "(", "call", ")", ";", "return", "staticReceiver", "!=", "null", "&&", "staticReceiver", ...
Given a method call, checks if it's a static method call and if it is, tells if the receiver matches the one supplied as an argument. @param call a method call @param receiver a class node @return true if the method call is a static method call on the receiver
[ "Given", "a", "method", "call", "checks", "if", "it", "s", "a", "static", "method", "call", "and", "if", "it", "is", "tells", "if", "the", "receiver", "matches", "the", "one", "supplied", "as", "an", "argument", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/java/org/codehaus/groovy/transform/stc/TypeCheckingExtension.java#L398-L401
12,974
apache/groovy
subprojects/groovy-console/src/main/groovy/groovy/ui/text/StructuredSyntaxDocumentFilter.java
StructuredSyntaxDocumentFilter.getMultiLineRun
private MultiLineRun getMultiLineRun(int offset) { MultiLineRun ml = null; if (offset > 0) { Integer os = offset; SortedSet set = mlTextRunSet.headSet(os); if (!set.isEmpty()) { ml = (MultiLineRun)set.last(); ml = ml.end() >= offset ? ml : null; } } return ml; }
java
private MultiLineRun getMultiLineRun(int offset) { MultiLineRun ml = null; if (offset > 0) { Integer os = offset; SortedSet set = mlTextRunSet.headSet(os); if (!set.isEmpty()) { ml = (MultiLineRun)set.last(); ml = ml.end() >= offset ? ml : null; } } return ml; }
[ "private", "MultiLineRun", "getMultiLineRun", "(", "int", "offset", ")", "{", "MultiLineRun", "ml", "=", "null", ";", "if", "(", "offset", ">", "0", ")", "{", "Integer", "os", "=", "offset", ";", "SortedSet", "set", "=", "mlTextRunSet", ".", "headSet", "...
given an offset, return the mlr it resides in
[ "given", "an", "offset", "return", "the", "mlr", "it", "resides", "in" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-console/src/main/groovy/groovy/ui/text/StructuredSyntaxDocumentFilter.java#L131-L144
12,975
apache/groovy
subprojects/groovy-console/src/main/groovy/groovy/ui/text/StructuredSyntaxDocumentFilter.java
StructuredSyntaxDocumentFilter.parseDocument
protected void parseDocument(int offset, int length) throws BadLocationException { // initialize the segment with the complete document so the segment doesn't // have an underlying gap in the buffer styledDocument.getText(0, styledDocument.getLength(), segment); buffer = CharBuffer.wrap(segment.array).asReadOnlyBuffer(); // initialize the lexer if necessary if (!lexer.isInitialized()) { // prime the parser and reparse whole document lexer.initialize(); offset = 0; length = styledDocument.getLength(); } else { int end = offset + length; offset = calcBeginParse(offset); length = calcEndParse(end) - offset; // clean the tree by ensuring multi line styles are reset in area // of parsing SortedSet set = mlTextRunSet.subSet(offset, offset + length); if (set != null) { set.clear(); } } // parse the document lexer.parse(buffer, offset, length); }
java
protected void parseDocument(int offset, int length) throws BadLocationException { // initialize the segment with the complete document so the segment doesn't // have an underlying gap in the buffer styledDocument.getText(0, styledDocument.getLength(), segment); buffer = CharBuffer.wrap(segment.array).asReadOnlyBuffer(); // initialize the lexer if necessary if (!lexer.isInitialized()) { // prime the parser and reparse whole document lexer.initialize(); offset = 0; length = styledDocument.getLength(); } else { int end = offset + length; offset = calcBeginParse(offset); length = calcEndParse(end) - offset; // clean the tree by ensuring multi line styles are reset in area // of parsing SortedSet set = mlTextRunSet.subSet(offset, offset + length); if (set != null) { set.clear(); } } // parse the document lexer.parse(buffer, offset, length); }
[ "protected", "void", "parseDocument", "(", "int", "offset", ",", "int", "length", ")", "throws", "BadLocationException", "{", "// initialize the segment with the complete document so the segment doesn't", "// have an underlying gap in the buffer", "styledDocument", ".", "getText", ...
Parse the Document to update the character styles given an initial start position. Called by the filter after it has updated the text. @param offset @param length @throws BadLocationException
[ "Parse", "the", "Document", "to", "update", "the", "character", "styles", "given", "an", "initial", "start", "position", ".", "Called", "by", "the", "filter", "after", "it", "has", "updated", "the", "text", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-console/src/main/groovy/groovy/ui/text/StructuredSyntaxDocumentFilter.java#L186-L216
12,976
apache/groovy
subprojects/groovy-console/src/main/groovy/groovy/ui/text/StructuredSyntaxDocumentFilter.java
StructuredSyntaxDocumentFilter.remove
public void remove(DocumentFilter.FilterBypass fb, int offset, int length) throws BadLocationException { // FRICKIN' HACK!!!!! For some reason, deleting a string at offset 0 // does not get done properly, so first replace and remove after parsing if (offset == 0 && length != fb.getDocument().getLength()) { fb.replace(0, length, "\n", lexer.defaultStyle); // start on either side of the removed text parseDocument(offset, 2); fb.remove(offset, 1); } else { fb.remove(offset, length); // start on either side of the removed text if (offset + 1 < fb.getDocument().getLength()) { parseDocument(offset, 1); } else if (offset - 1 > 0) { parseDocument(offset - 1, 1); } else { // empty text mlTextRunSet.clear(); } } }
java
public void remove(DocumentFilter.FilterBypass fb, int offset, int length) throws BadLocationException { // FRICKIN' HACK!!!!! For some reason, deleting a string at offset 0 // does not get done properly, so first replace and remove after parsing if (offset == 0 && length != fb.getDocument().getLength()) { fb.replace(0, length, "\n", lexer.defaultStyle); // start on either side of the removed text parseDocument(offset, 2); fb.remove(offset, 1); } else { fb.remove(offset, length); // start on either side of the removed text if (offset + 1 < fb.getDocument().getLength()) { parseDocument(offset, 1); } else if (offset - 1 > 0) { parseDocument(offset - 1, 1); } else { // empty text mlTextRunSet.clear(); } } }
[ "public", "void", "remove", "(", "DocumentFilter", ".", "FilterBypass", "fb", ",", "int", "offset", ",", "int", "length", ")", "throws", "BadLocationException", "{", "// FRICKIN' HACK!!!!! For some reason, deleting a string at offset 0", "// does not get done properly, so first...
Remove a string from the document, and then parse it if the parser has been set. @param fb @param offset @param length @throws BadLocationException
[ "Remove", "a", "string", "from", "the", "document", "and", "then", "parse", "it", "if", "the", "parser", "has", "been", "set", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-console/src/main/groovy/groovy/ui/text/StructuredSyntaxDocumentFilter.java#L227-L254
12,977
apache/groovy
src/main/groovy/groovy/time/TimeCategory.java
TimeCategory.minus
public static TimeDuration minus(final Date lhs, final Date rhs) { long milliseconds = lhs.getTime() - rhs.getTime(); long days = milliseconds / (24 * 60 * 60 * 1000); milliseconds -= days * 24 * 60 * 60 * 1000; int hours = (int) (milliseconds / (60 * 60 * 1000)); milliseconds -= hours * 60 * 60 * 1000; int minutes = (int) (milliseconds / (60 * 1000)); milliseconds -= minutes * 60 * 1000; int seconds = (int) (milliseconds / 1000); milliseconds -= seconds * 1000; return new TimeDuration((int) days, hours, minutes, seconds, (int) milliseconds); }
java
public static TimeDuration minus(final Date lhs, final Date rhs) { long milliseconds = lhs.getTime() - rhs.getTime(); long days = milliseconds / (24 * 60 * 60 * 1000); milliseconds -= days * 24 * 60 * 60 * 1000; int hours = (int) (milliseconds / (60 * 60 * 1000)); milliseconds -= hours * 60 * 60 * 1000; int minutes = (int) (milliseconds / (60 * 1000)); milliseconds -= minutes * 60 * 1000; int seconds = (int) (milliseconds / 1000); milliseconds -= seconds * 1000; return new TimeDuration((int) days, hours, minutes, seconds, (int) milliseconds); }
[ "public", "static", "TimeDuration", "minus", "(", "final", "Date", "lhs", ",", "final", "Date", "rhs", ")", "{", "long", "milliseconds", "=", "lhs", ".", "getTime", "(", ")", "-", "rhs", ".", "getTime", "(", ")", ";", "long", "days", "=", "milliseconds...
Subtract one date from the other. @param lhs a Date @param rhs another Date @return a Duration
[ "Subtract", "one", "date", "from", "the", "other", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/time/TimeCategory.java#L118-L130
12,978
apache/groovy
subprojects/groovy-yaml/src/main/java/groovy/yaml/YamlSlurper.java
YamlSlurper.parse
public Object parse(Reader reader) { return jsonSlurper.parse(new StringReader(YamlConverter.convertYamlToJson(reader))); }
java
public Object parse(Reader reader) { return jsonSlurper.parse(new StringReader(YamlConverter.convertYamlToJson(reader))); }
[ "public", "Object", "parse", "(", "Reader", "reader", ")", "{", "return", "jsonSlurper", ".", "parse", "(", "new", "StringReader", "(", "YamlConverter", ".", "convertYamlToJson", "(", "reader", ")", ")", ")", ";", "}" ]
Parse the content of the specified reader into a tree of Nodes. @param reader the reader of yaml @return the root node of the parsed tree of Nodes
[ "Parse", "the", "content", "of", "the", "specified", "reader", "into", "a", "tree", "of", "Nodes", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-yaml/src/main/java/groovy/yaml/YamlSlurper.java#L55-L57
12,979
apache/groovy
src/main/groovy/groovy/util/GroovyScriptEngine.java
GroovyScriptEngine.main
public static void main(String[] urls) throws Exception { GroovyScriptEngine gse = new GroovyScriptEngine(urls); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line; while (true) { System.out.print("groovy> "); if ((line = br.readLine()) == null || line.equals("quit")) { break; } try { System.out.println(gse.run(line, new Binding())); } catch (Exception e) { e.printStackTrace(); } } }
java
public static void main(String[] urls) throws Exception { GroovyScriptEngine gse = new GroovyScriptEngine(urls); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line; while (true) { System.out.print("groovy> "); if ((line = br.readLine()) == null || line.equals("quit")) { break; } try { System.out.println(gse.run(line, new Binding())); } catch (Exception e) { e.printStackTrace(); } } }
[ "public", "static", "void", "main", "(", "String", "[", "]", "urls", ")", "throws", "Exception", "{", "GroovyScriptEngine", "gse", "=", "new", "GroovyScriptEngine", "(", "urls", ")", ";", "BufferedReader", "br", "=", "new", "BufferedReader", "(", "new", "Inp...
Simple testing harness for the GSE. Enter script roots as arguments and then input script names to run them. @param urls an array of URLs @throws Exception if something goes wrong
[ "Simple", "testing", "harness", "for", "the", "GSE", ".", "Enter", "script", "roots", "as", "arguments", "and", "then", "input", "script", "names", "to", "run", "them", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/GroovyScriptEngine.java#L327-L342
12,980
apache/groovy
src/main/groovy/groovy/util/GroovyScriptEngine.java
GroovyScriptEngine.loadScriptByName
public Class loadScriptByName(String scriptName) throws ResourceException, ScriptException { URLConnection conn = rc.getResourceConnection(scriptName); String path = conn.getURL().toExternalForm(); ScriptCacheEntry entry = scriptCache.get(path); Class clazz = null; if (entry != null) clazz = entry.scriptClass; try { if (isSourceNewer(entry)) { try { String encoding = conn.getContentEncoding() != null ? conn.getContentEncoding() : config.getSourceEncoding(); String content = IOGroovyMethods.getText(conn.getInputStream(), encoding); clazz = groovyLoader.parseClass(content, path); } catch (IOException e) { throw new ResourceException(e); } } } finally { forceClose(conn); } return clazz; }
java
public Class loadScriptByName(String scriptName) throws ResourceException, ScriptException { URLConnection conn = rc.getResourceConnection(scriptName); String path = conn.getURL().toExternalForm(); ScriptCacheEntry entry = scriptCache.get(path); Class clazz = null; if (entry != null) clazz = entry.scriptClass; try { if (isSourceNewer(entry)) { try { String encoding = conn.getContentEncoding() != null ? conn.getContentEncoding() : config.getSourceEncoding(); String content = IOGroovyMethods.getText(conn.getInputStream(), encoding); clazz = groovyLoader.parseClass(content, path); } catch (IOException e) { throw new ResourceException(e); } } } finally { forceClose(conn); } return clazz; }
[ "public", "Class", "loadScriptByName", "(", "String", "scriptName", ")", "throws", "ResourceException", ",", "ScriptException", "{", "URLConnection", "conn", "=", "rc", ".", "getResourceConnection", "(", "scriptName", ")", ";", "String", "path", "=", "conn", ".", ...
Get the class of the scriptName in question, so that you can instantiate Groovy objects with caching and reloading. @param scriptName resource name pointing to the script @return the loaded scriptName as a compiled class @throws ResourceException if there is a problem accessing the script @throws ScriptException if there is a problem parsing the script
[ "Get", "the", "class", "of", "the", "scriptName", "in", "question", "so", "that", "you", "can", "instantiate", "Groovy", "objects", "with", "caching", "and", "reloading", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/GroovyScriptEngine.java#L530-L550
12,981
apache/groovy
src/main/groovy/groovy/util/GroovyScriptEngine.java
GroovyScriptEngine.run
public String run(String scriptName, String argument) throws ResourceException, ScriptException { Binding binding = new Binding(); binding.setVariable("arg", argument); Object result = run(scriptName, binding); return result == null ? "" : result.toString(); }
java
public String run(String scriptName, String argument) throws ResourceException, ScriptException { Binding binding = new Binding(); binding.setVariable("arg", argument); Object result = run(scriptName, binding); return result == null ? "" : result.toString(); }
[ "public", "String", "run", "(", "String", "scriptName", ",", "String", "argument", ")", "throws", "ResourceException", ",", "ScriptException", "{", "Binding", "binding", "=", "new", "Binding", "(", ")", ";", "binding", ".", "setVariable", "(", "\"arg\"", ",", ...
Run a script identified by name with a single argument. @param scriptName name of the script to run @param argument a single argument passed as a variable named <code>arg</code> in the binding @return a <code>toString()</code> representation of the result of the execution of the script @throws ResourceException if there is a problem accessing the script @throws ScriptException if there is a problem parsing the script
[ "Run", "a", "script", "identified", "by", "name", "with", "a", "single", "argument", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/GroovyScriptEngine.java#L561-L566
12,982
apache/groovy
src/main/groovy/groovy/util/GroovyScriptEngine.java
GroovyScriptEngine.run
public Object run(String scriptName, Binding binding) throws ResourceException, ScriptException { return createScript(scriptName, binding).run(); }
java
public Object run(String scriptName, Binding binding) throws ResourceException, ScriptException { return createScript(scriptName, binding).run(); }
[ "public", "Object", "run", "(", "String", "scriptName", ",", "Binding", "binding", ")", "throws", "ResourceException", ",", "ScriptException", "{", "return", "createScript", "(", "scriptName", ",", "binding", ")", ".", "run", "(", ")", ";", "}" ]
Run a script identified by name with a given binding. @param scriptName name of the script to run @param binding the binding to pass to the script @return an object @throws ResourceException if there is a problem accessing the script @throws ScriptException if there is a problem parsing the script
[ "Run", "a", "script", "identified", "by", "name", "with", "a", "given", "binding", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/GroovyScriptEngine.java#L577-L579
12,983
apache/groovy
src/main/groovy/groovy/util/GroovyScriptEngine.java
GroovyScriptEngine.createScript
public Script createScript(String scriptName, Binding binding) throws ResourceException, ScriptException { return InvokerHelper.createScript(loadScriptByName(scriptName), binding); }
java
public Script createScript(String scriptName, Binding binding) throws ResourceException, ScriptException { return InvokerHelper.createScript(loadScriptByName(scriptName), binding); }
[ "public", "Script", "createScript", "(", "String", "scriptName", ",", "Binding", "binding", ")", "throws", "ResourceException", ",", "ScriptException", "{", "return", "InvokerHelper", ".", "createScript", "(", "loadScriptByName", "(", "scriptName", ")", ",", "bindin...
Creates a Script with a given scriptName and binding. @param scriptName name of the script to run @param binding the binding to pass to the script @return the script object @throws ResourceException if there is a problem accessing the script @throws ScriptException if there is a problem parsing the script
[ "Creates", "a", "Script", "with", "a", "given", "scriptName", "and", "binding", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/GroovyScriptEngine.java#L590-L592
12,984
apache/groovy
src/main/groovy/groovy/util/GroovyScriptEngine.java
GroovyScriptEngine.setConfig
public void setConfig(CompilerConfiguration config) { if (config == null) throw new NullPointerException("configuration cannot be null"); this.config = config; this.groovyLoader = initGroovyLoader(); }
java
public void setConfig(CompilerConfiguration config) { if (config == null) throw new NullPointerException("configuration cannot be null"); this.config = config; this.groovyLoader = initGroovyLoader(); }
[ "public", "void", "setConfig", "(", "CompilerConfiguration", "config", ")", "{", "if", "(", "config", "==", "null", ")", "throw", "new", "NullPointerException", "(", "\"configuration cannot be null\"", ")", ";", "this", ".", "config", "=", "config", ";", "this",...
sets a compiler configuration @param config - the compiler configuration @throws NullPointerException if config is null
[ "sets", "a", "compiler", "configuration" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/util/GroovyScriptEngine.java#L675-L679
12,985
apache/groovy
src/main/groovy/groovy/lang/TrampolineClosure.java
TrampolineClosure.trampoline
@Override public Closure<V> trampoline(final Object... args) { return new TrampolineClosure<V>(original.curry(args)); }
java
@Override public Closure<V> trampoline(final Object... args) { return new TrampolineClosure<V>(original.curry(args)); }
[ "@", "Override", "public", "Closure", "<", "V", ">", "trampoline", "(", "final", "Object", "...", "args", ")", "{", "return", "new", "TrampolineClosure", "<", "V", ">", "(", "original", ".", "curry", "(", "args", ")", ")", ";", "}" ]
Builds a trampolined variant of the current closure. @param args Parameters to curry to the underlying closure. @return An instance of TrampolineClosure wrapping the original closure after currying.
[ "Builds", "a", "trampolined", "variant", "of", "the", "current", "closure", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/TrampolineClosure.java#L97-L100
12,986
apache/groovy
src/main/groovy/groovy/lang/NumberRange.java
NumberRange.contains
@Override public boolean contains(Object value) { if (value == null) { return false; } final Iterator it = new StepIterator(this, stepSize); while (it.hasNext()) { if (compareEqual(value, it.next())) { return true; } } return false; }
java
@Override public boolean contains(Object value) { if (value == null) { return false; } final Iterator it = new StepIterator(this, stepSize); while (it.hasNext()) { if (compareEqual(value, it.next())) { return true; } } return false; }
[ "@", "Override", "public", "boolean", "contains", "(", "Object", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "false", ";", "}", "final", "Iterator", "it", "=", "new", "StepIterator", "(", "this", ",", "stepSize", ")", ";", ...
iterates over all values and returns true if one value matches. Also see containsWithinBounds.
[ "iterates", "over", "all", "values", "and", "returns", "true", "if", "one", "value", "matches", ".", "Also", "see", "containsWithinBounds", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/NumberRange.java#L498-L510
12,987
apache/groovy
src/main/groovy/groovy/lang/NumberRange.java
NumberRange.increment
@SuppressWarnings("unchecked") private Comparable increment(Object value, Number step) { return (Comparable) plus((Number) value, step); }
java
@SuppressWarnings("unchecked") private Comparable increment(Object value, Number step) { return (Comparable) plus((Number) value, step); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "Comparable", "increment", "(", "Object", "value", ",", "Number", "step", ")", "{", "return", "(", "Comparable", ")", "plus", "(", "(", "Number", ")", "value", ",", "step", ")", ";", "}" ]
Increments by given step @param value the value to increment @param step the amount to increment @return the incremented value
[ "Increments", "by", "given", "step" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/NumberRange.java#L613-L616
12,988
apache/groovy
src/main/groovy/groovy/lang/NumberRange.java
NumberRange.decrement
@SuppressWarnings("unchecked") private Comparable decrement(Object value, Number step) { return (Comparable) minus((Number) value, step); }
java
@SuppressWarnings("unchecked") private Comparable decrement(Object value, Number step) { return (Comparable) minus((Number) value, step); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "Comparable", "decrement", "(", "Object", "value", ",", "Number", "step", ")", "{", "return", "(", "Comparable", ")", "minus", "(", "(", "Number", ")", "value", ",", "step", ")", ";", "}" ]
Decrements by given step @param value the value to decrement @param step the amount to decrement @return the decremented value
[ "Decrements", "by", "given", "step" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/NumberRange.java#L625-L628
12,989
apache/groovy
subprojects/groovy-jmx/src/main/java/groovy/util/GroovyMBean.java
GroovyMBean.listAttributeNames
public Collection<String> listAttributeNames() { List<String> list = new ArrayList<String>(); try { MBeanAttributeInfo[] attrs = beanInfo.getAttributes(); for (MBeanAttributeInfo attr : attrs) { list.add(attr.getName()); } } catch (Exception e) { throwException("Could not list attribute names. Reason: ", e); } return list; }
java
public Collection<String> listAttributeNames() { List<String> list = new ArrayList<String>(); try { MBeanAttributeInfo[] attrs = beanInfo.getAttributes(); for (MBeanAttributeInfo attr : attrs) { list.add(attr.getName()); } } catch (Exception e) { throwException("Could not list attribute names. Reason: ", e); } return list; }
[ "public", "Collection", "<", "String", ">", "listAttributeNames", "(", ")", "{", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "try", "{", "MBeanAttributeInfo", "[", "]", "attrs", "=", "beanInfo", ".", ...
List of the names of each of the attributes on the MBean @return list of attribute names
[ "List", "of", "the", "names", "of", "each", "of", "the", "attributes", "on", "the", "MBean" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-jmx/src/main/java/groovy/util/GroovyMBean.java#L174-L185
12,990
apache/groovy
subprojects/groovy-jmx/src/main/java/groovy/util/GroovyMBean.java
GroovyMBean.listAttributeValues
public List<String> listAttributeValues() { List<String> list = new ArrayList<String>(); Collection<String> names = listAttributeNames(); for (String name : names) { try { Object val = this.getProperty(name); if (val != null) { list.add(name + " : " + val.toString()); } } catch (Exception e) { throwException("Could not list attribute values. Reason: ", e); } } return list; }
java
public List<String> listAttributeValues() { List<String> list = new ArrayList<String>(); Collection<String> names = listAttributeNames(); for (String name : names) { try { Object val = this.getProperty(name); if (val != null) { list.add(name + " : " + val.toString()); } } catch (Exception e) { throwException("Could not list attribute values. Reason: ", e); } } return list; }
[ "public", "List", "<", "String", ">", "listAttributeValues", "(", ")", "{", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "Collection", "<", "String", ">", "names", "=", "listAttributeNames", "(", ")", ...
The values of each of the attributes on the MBean @return list of values of each attribute
[ "The", "values", "of", "each", "of", "the", "attributes", "on", "the", "MBean" ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-jmx/src/main/java/groovy/util/GroovyMBean.java#L192-L206
12,991
apache/groovy
subprojects/groovy-jmx/src/main/java/groovy/util/GroovyMBean.java
GroovyMBean.listAttributeDescriptions
public Collection<String> listAttributeDescriptions() { List<String> list = new ArrayList<String>(); try { MBeanAttributeInfo[] attrs = beanInfo.getAttributes(); for (MBeanAttributeInfo attr : attrs) { list.add(describeAttribute(attr)); } } catch (Exception e) { throwException("Could not list attribute descriptions. Reason: ", e); } return list; }
java
public Collection<String> listAttributeDescriptions() { List<String> list = new ArrayList<String>(); try { MBeanAttributeInfo[] attrs = beanInfo.getAttributes(); for (MBeanAttributeInfo attr : attrs) { list.add(describeAttribute(attr)); } } catch (Exception e) { throwException("Could not list attribute descriptions. Reason: ", e); } return list; }
[ "public", "Collection", "<", "String", ">", "listAttributeDescriptions", "(", ")", "{", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "try", "{", "MBeanAttributeInfo", "[", "]", "attrs", "=", "beanInfo", ...
List of string representations of all of the attributes on the MBean. @return list of descriptions of each attribute on the mbean
[ "List", "of", "string", "representations", "of", "all", "of", "the", "attributes", "on", "the", "MBean", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-jmx/src/main/java/groovy/util/GroovyMBean.java#L213-L224
12,992
apache/groovy
subprojects/groovy-jmx/src/main/java/groovy/util/GroovyMBean.java
GroovyMBean.listOperationNames
public Collection<String> listOperationNames() { List<String> list = new ArrayList<String>(); try { MBeanOperationInfo[] operations = beanInfo.getOperations(); for (MBeanOperationInfo operation : operations) { list.add(operation.getName()); } } catch (Exception e) { throwException("Could not list operation names. Reason: ", e); } return list; }
java
public Collection<String> listOperationNames() { List<String> list = new ArrayList<String>(); try { MBeanOperationInfo[] operations = beanInfo.getOperations(); for (MBeanOperationInfo operation : operations) { list.add(operation.getName()); } } catch (Exception e) { throwException("Could not list operation names. Reason: ", e); } return list; }
[ "public", "Collection", "<", "String", ">", "listOperationNames", "(", ")", "{", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "try", "{", "MBeanOperationInfo", "[", "]", "operations", "=", "beanInfo", "....
Names of all the operations available on the MBean. @return all the operations on the MBean
[ "Names", "of", "all", "the", "operations", "available", "on", "the", "MBean", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-jmx/src/main/java/groovy/util/GroovyMBean.java#L274-L285
12,993
apache/groovy
subprojects/groovy-jmx/src/main/java/groovy/util/GroovyMBean.java
GroovyMBean.listOperationDescriptions
public Collection<String> listOperationDescriptions() { List<String> list = new ArrayList<String>(); try { MBeanOperationInfo[] operations = beanInfo.getOperations(); for (MBeanOperationInfo operation : operations) { list.add(describeOperation(operation)); } } catch (Exception e) { throwException("Could not list operation descriptions. Reason: ", e); } return list; }
java
public Collection<String> listOperationDescriptions() { List<String> list = new ArrayList<String>(); try { MBeanOperationInfo[] operations = beanInfo.getOperations(); for (MBeanOperationInfo operation : operations) { list.add(describeOperation(operation)); } } catch (Exception e) { throwException("Could not list operation descriptions. Reason: ", e); } return list; }
[ "public", "Collection", "<", "String", ">", "listOperationDescriptions", "(", ")", "{", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "try", "{", "MBeanOperationInfo", "[", "]", "operations", "=", "beanInfo...
Description of all of the operations available on the MBean. @return full description of each operation on the MBean
[ "Description", "of", "all", "of", "the", "operations", "available", "on", "the", "MBean", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-jmx/src/main/java/groovy/util/GroovyMBean.java#L292-L303
12,994
apache/groovy
subprojects/groovy-jmx/src/main/java/groovy/util/GroovyMBean.java
GroovyMBean.describeOperation
public List<String> describeOperation(String operationName) { List<String> list = new ArrayList<String>(); try { MBeanOperationInfo[] operations = beanInfo.getOperations(); for (MBeanOperationInfo operation : operations) { if (operation.getName().equals(operationName)) { list.add(describeOperation(operation)); } } } catch (Exception e) { throwException("Could not describe operations matching name '" + operationName + "'. Reason: ", e); } return list; }
java
public List<String> describeOperation(String operationName) { List<String> list = new ArrayList<String>(); try { MBeanOperationInfo[] operations = beanInfo.getOperations(); for (MBeanOperationInfo operation : operations) { if (operation.getName().equals(operationName)) { list.add(describeOperation(operation)); } } } catch (Exception e) { throwException("Could not describe operations matching name '" + operationName + "'. Reason: ", e); } return list; }
[ "public", "List", "<", "String", ">", "describeOperation", "(", "String", "operationName", ")", "{", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "try", "{", "MBeanOperationInfo", "[", "]", "operations", ...
Get the description of the specified operation. This returns a Collection since operations can be overloaded and one operationName can have multiple forms. @param operationName the name of the operation to describe @return Collection of operation description
[ "Get", "the", "description", "of", "the", "specified", "operation", ".", "This", "returns", "a", "Collection", "since", "operations", "can", "be", "overloaded", "and", "one", "operationName", "can", "have", "multiple", "forms", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-jmx/src/main/java/groovy/util/GroovyMBean.java#L312-L325
12,995
apache/groovy
subprojects/groovy-jmx/src/main/java/groovy/util/GroovyMBean.java
GroovyMBean.describeOperation
protected String describeOperation(MBeanOperationInfo operation) { StringBuilder buf = new StringBuilder(); buf.append(operation.getReturnType()) .append(" ") .append(operation.getName()) .append("("); MBeanParameterInfo[] params = operation.getSignature(); for (int j = 0; j < params.length; j++) { MBeanParameterInfo param = params[j]; if (j != 0) { buf.append(", "); } buf.append(param.getType()) .append(" ") .append(param.getName()); } buf.append(")"); return buf.toString(); }
java
protected String describeOperation(MBeanOperationInfo operation) { StringBuilder buf = new StringBuilder(); buf.append(operation.getReturnType()) .append(" ") .append(operation.getName()) .append("("); MBeanParameterInfo[] params = operation.getSignature(); for (int j = 0; j < params.length; j++) { MBeanParameterInfo param = params[j]; if (j != 0) { buf.append(", "); } buf.append(param.getType()) .append(" ") .append(param.getName()); } buf.append(")"); return buf.toString(); }
[ "protected", "String", "describeOperation", "(", "MBeanOperationInfo", "operation", ")", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "buf", ".", "append", "(", "operation", ".", "getReturnType", "(", ")", ")", ".", "append", "(", ...
Description of the operation. @param operation the operation to describe @return pretty-printed description
[ "Description", "of", "the", "operation", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-jmx/src/main/java/groovy/util/GroovyMBean.java#L333-L352
12,996
apache/groovy
src/main/groovy/groovy/lang/ObjectRange.java
ObjectRange.contains
@Override public boolean contains(Object value) { final Iterator<Comparable> iter = new StepIterator(this, 1); if (value == null) { return false; } while (iter.hasNext()) { if (DefaultTypeTransformation.compareEqual(value, iter.next())) return true; } return false; }
java
@Override public boolean contains(Object value) { final Iterator<Comparable> iter = new StepIterator(this, 1); if (value == null) { return false; } while (iter.hasNext()) { if (DefaultTypeTransformation.compareEqual(value, iter.next())) return true; } return false; }
[ "@", "Override", "public", "boolean", "contains", "(", "Object", "value", ")", "{", "final", "Iterator", "<", "Comparable", ">", "iter", "=", "new", "StepIterator", "(", "this", ",", "1", ")", ";", "if", "(", "value", "==", "null", ")", "{", "return", ...
Iterates over all values and returns true if one value matches. @see #containsWithinBounds(Object)
[ "Iterates", "over", "all", "values", "and", "returns", "true", "if", "one", "value", "matches", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/ObjectRange.java#L382-L392
12,997
apache/groovy
src/main/groovy/groovy/lang/ObjectRange.java
ObjectRange.normaliseStringType
private static Comparable normaliseStringType(final Comparable operand) { if (operand instanceof Character) { return (int) (Character) operand; } if (operand instanceof String) { final String string = (String) operand; if (string.length() == 1) { return (int) string.charAt(0); } return string; } return operand; }
java
private static Comparable normaliseStringType(final Comparable operand) { if (operand instanceof Character) { return (int) (Character) operand; } if (operand instanceof String) { final String string = (String) operand; if (string.length() == 1) { return (int) string.charAt(0); } return string; } return operand; }
[ "private", "static", "Comparable", "normaliseStringType", "(", "final", "Comparable", "operand", ")", "{", "if", "(", "operand", "instanceof", "Character", ")", "{", "return", "(", "int", ")", "(", "Character", ")", "operand", ";", "}", "if", "(", "operand",...
if operand is a Character or a String with one character, return that character's int value.
[ "if", "operand", "is", "a", "Character", "or", "a", "String", "with", "one", "character", "return", "that", "character", "s", "int", "value", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/src/main/groovy/groovy/lang/ObjectRange.java#L525-L538
12,998
apache/groovy
subprojects/groovy-json/src/main/java/groovy/json/JsonOutput.java
JsonOutput.prettyPrint
public static String prettyPrint(String jsonPayload) { int indentSize = 0; // Just a guess that the pretty view will take 20 percent more than original. final CharBuf output = CharBuf.create((int) (jsonPayload.length() * 1.2)); JsonLexer lexer = new JsonLexer(new StringReader(jsonPayload)); // Will store already created indents. Map<Integer, char[]> indentCache = new HashMap<Integer, char[]>(); while (lexer.hasNext()) { JsonToken token = lexer.next(); switch (token.getType()) { case OPEN_CURLY: indentSize += 4; output.addChars(Chr.array(OPEN_BRACE, NEW_LINE)).addChars(getIndent(indentSize, indentCache)); break; case CLOSE_CURLY: indentSize -= 4; output.addChar(NEW_LINE); if (indentSize > 0) { output.addChars(getIndent(indentSize, indentCache)); } output.addChar(CLOSE_BRACE); break; case OPEN_BRACKET: indentSize += 4; output.addChars(Chr.array(OPEN_BRACKET, NEW_LINE)).addChars(getIndent(indentSize, indentCache)); break; case CLOSE_BRACKET: indentSize -= 4; output.addChar(NEW_LINE); if (indentSize > 0) { output.addChars(getIndent(indentSize, indentCache)); } output.addChar(CLOSE_BRACKET); break; case COMMA: output.addChars(Chr.array(COMMA, NEW_LINE)).addChars(getIndent(indentSize, indentCache)); break; case COLON: output.addChars(Chr.array(COLON, SPACE)); break; case STRING: String textStr = token.getText(); String textWithoutQuotes = textStr.substring(1, textStr.length() - 1); if (textWithoutQuotes.length() > 0) { output.addJsonEscapedString(textWithoutQuotes); } else { output.addQuoted(Chr.array()); } break; default: output.addString(token.getText()); } } return output.toString(); }
java
public static String prettyPrint(String jsonPayload) { int indentSize = 0; // Just a guess that the pretty view will take 20 percent more than original. final CharBuf output = CharBuf.create((int) (jsonPayload.length() * 1.2)); JsonLexer lexer = new JsonLexer(new StringReader(jsonPayload)); // Will store already created indents. Map<Integer, char[]> indentCache = new HashMap<Integer, char[]>(); while (lexer.hasNext()) { JsonToken token = lexer.next(); switch (token.getType()) { case OPEN_CURLY: indentSize += 4; output.addChars(Chr.array(OPEN_BRACE, NEW_LINE)).addChars(getIndent(indentSize, indentCache)); break; case CLOSE_CURLY: indentSize -= 4; output.addChar(NEW_LINE); if (indentSize > 0) { output.addChars(getIndent(indentSize, indentCache)); } output.addChar(CLOSE_BRACE); break; case OPEN_BRACKET: indentSize += 4; output.addChars(Chr.array(OPEN_BRACKET, NEW_LINE)).addChars(getIndent(indentSize, indentCache)); break; case CLOSE_BRACKET: indentSize -= 4; output.addChar(NEW_LINE); if (indentSize > 0) { output.addChars(getIndent(indentSize, indentCache)); } output.addChar(CLOSE_BRACKET); break; case COMMA: output.addChars(Chr.array(COMMA, NEW_LINE)).addChars(getIndent(indentSize, indentCache)); break; case COLON: output.addChars(Chr.array(COLON, SPACE)); break; case STRING: String textStr = token.getText(); String textWithoutQuotes = textStr.substring(1, textStr.length() - 1); if (textWithoutQuotes.length() > 0) { output.addJsonEscapedString(textWithoutQuotes); } else { output.addQuoted(Chr.array()); } break; default: output.addString(token.getText()); } } return output.toString(); }
[ "public", "static", "String", "prettyPrint", "(", "String", "jsonPayload", ")", "{", "int", "indentSize", "=", "0", ";", "// Just a guess that the pretty view will take 20 percent more than original.", "final", "CharBuf", "output", "=", "CharBuf", ".", "create", "(", "(...
Pretty print a JSON payload. @param jsonPayload @return a pretty representation of JSON payload.
[ "Pretty", "print", "a", "JSON", "payload", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-json/src/main/java/groovy/json/JsonOutput.java#L162-L225
12,999
apache/groovy
subprojects/groovy-json/src/main/java/groovy/json/JsonOutput.java
JsonOutput.getIndent
private static char[] getIndent(int indentSize, Map<Integer, char[]> indentCache) { char[] indent = indentCache.get(indentSize); if (indent == null) { indent = new char[indentSize]; Arrays.fill(indent, SPACE); indentCache.put(indentSize, indent); } return indent; }
java
private static char[] getIndent(int indentSize, Map<Integer, char[]> indentCache) { char[] indent = indentCache.get(indentSize); if (indent == null) { indent = new char[indentSize]; Arrays.fill(indent, SPACE); indentCache.put(indentSize, indent); } return indent; }
[ "private", "static", "char", "[", "]", "getIndent", "(", "int", "indentSize", ",", "Map", "<", "Integer", ",", "char", "[", "]", ">", "indentCache", ")", "{", "char", "[", "]", "indent", "=", "indentCache", ".", "get", "(", "indentSize", ")", ";", "i...
Creates new indent if it not exists in the indent cache. @return indent with the specified size.
[ "Creates", "new", "indent", "if", "it", "not", "exists", "in", "the", "indent", "cache", "." ]
71cf20addb611bb8d097a59e395fd20bc7f31772
https://github.com/apache/groovy/blob/71cf20addb611bb8d097a59e395fd20bc7f31772/subprojects/groovy-json/src/main/java/groovy/json/JsonOutput.java#L232-L241