_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q0 | SCryptUtil.check | train | public static boolean check(String passwd, String hashed) {
try {
String[] parts = hashed.split("\\$");
if (parts.length != 5 || !parts[1].equals("s0")) {
throw new IllegalArgumentException("Invalid hashed value");
}
long params = Long.parseLong(... | java | {
"resource": ""
} |
q1 | Platform.detect | train | public static Platform detect() throws UnsupportedPlatformException {
String osArch = getProperty("os.arch");
String osName = getProperty("os.name");
for (Arch arch : Arch.values()) {
if (arch.pattern.matcher(osArch).matches()) {
for (OS os : OS.values()) {
... | java | {
"resource": ""
} |
q2 | ASTNode.getNodeMetaData | train | public <T> T getNodeMetaData(Object key) {
if (metaDataMap == null) {
return (T) null;
}
return (T) metaDataMap.get(key);
} | java | {
"resource": ""
} |
q3 | ASTNode.copyNodeMetaData | train | public void copyNodeMetaData(ASTNode other) {
if (other.metaDataMap == null) {
return;
}
if (metaDataMap == null) {
metaDataMap = new ListHashMap();
}
metaDataMap.putAll(other.metaDataMap);
} | java | {
"resource": ""
} |
q4 | ASTNode.setNodeMetaData | train | public void setNodeMetaData(Object key, Object value) {
if (key==null) throw new GroovyBugError("Tried to set meta data with null key on "+this+".");
if (metaDataMap == null) {
metaDataMap = new ListHashMap();
}
Object old = metaDataMap.put(key,value);
if (old!=null) ... | java | {
"resource": ""
} |
q5 | ASTNode.putNodeMetaData | train | public Object putNodeMetaData(Object key, Object value) {
if (key == null) throw new GroovyBugError("Tried to set meta data with null key on " + this + ".");
if (metaDataMap == null) {
metaDataMap = new ListHashMap();
}
return metaDataMap.put(key, value);
} | java | {
"resource": ""
} |
q6 | ASTNode.removeNodeMetaData | train | public void removeNodeMetaData(Object key) {
if (key==null) throw new GroovyBugError("Tried to remove meta data with null key "+this+".");
if (metaDataMap == null) {
return;
}
metaDataMap.remove(key);
} | java | {
"resource": ""
} |
q7 | IntRange.subListBorders | train | public RangeInfo subListBorders(int size) {
if (inclusive == null) throw new IllegalStateException("Should not call subListBorders on a non-inclusive aware IntRange");
int tempFrom = from;
if (tempFrom < 0) {
tempFrom += size;
}
int tempTo = to;
if (tempTo < 0... | java | {
"resource": ""
} |
q8 | BindableASTTransformation.createSetterMethod | train | protected void createSetterMethod(ClassNode declaringClass, PropertyNode propertyNode, String setterName, Statement setterBlock) {
MethodNode setter = new MethodNode(
setterName,
propertyNode.getModifiers(),
ClassHelper.VOID_TYPE,
params(param... | java | {
"resource": ""
} |
q9 | CompilationUnit.applyToPrimaryClassNodes | train | public void applyToPrimaryClassNodes(PrimaryClassNodeOperation body) throws CompilationFailedException {
Iterator classNodes = getPrimaryClassNodes(body.needSortedInput()).iterator();
while (classNodes.hasNext()) {
SourceUnit context = null;
try {
ClassNode classN... | java | {
"resource": ""
} |
q10 | SocketGroovyMethods.withStreams | train | public static <T> T withStreams(Socket socket, @ClosureParams(value=SimpleType.class, options={"java.io.InputStream","java.io.OutputStream"}) Closure<T> closure) throws IOException {
InputStream input = socket.getInputStream();
OutputStream output = socket.getOutputStream();
try {
T ... | java | {
"resource": ""
} |
q11 | SocketGroovyMethods.withObjectStreams | train | public static <T> T withObjectStreams(Socket socket, @ClosureParams(value=SimpleType.class, options={"java.io.ObjectInputStream","java.io.ObjectOutputStream"}) Closure<T> closure) throws IOException {
InputStream input = socket.getInputStream();
OutputStream output = socket.getOutputStream();
Ob... | java | {
"resource": ""
} |
q12 | MethodKey.createCopy | train | public MethodKey createCopy() {
int size = getParameterCount();
Class[] paramTypes = new Class[size];
for (int i = 0; i < size; i++) {
paramTypes[i] = getParameterType(i);
}
return new DefaultMethodKey(sender, name, paramTypes, isCallToSuper);
} | java | {
"resource": ""
} |
q13 | TraitComposer.doExtendTraits | train | public static void doExtendTraits(final ClassNode cNode, final SourceUnit unit, final CompilationUnit cu) {
if (cNode.isInterface()) return;
boolean isItselfTrait = Traits.isTrait(cNode);
SuperCallTraitTransformer superCallTransformer = new SuperCallTraitTransformer(unit);
if (isItselfTr... | java | {
"resource": ""
} |
q14 | ErrorCollector.getSyntaxError | train | public SyntaxException getSyntaxError(int index) {
SyntaxException exception = null;
Message message = getError(index);
if (message != null && message instanceof SyntaxErrorMessage) {
exception = ((SyntaxErrorMessage) message).getCause();
}
return exception;
} | java | {
"resource": ""
} |
q15 | GroovyInternalPosixParser.gobble | train | private void gobble(Iterator iter)
{
if (eatTheRest)
{
while (iter.hasNext())
{
tokens.add(iter.next());
}
}
} | java | {
"resource": ""
} |
q16 | StaticTypeCheckingSupport.allParametersAndArgumentsMatch | train | public static int allParametersAndArgumentsMatch(Parameter[] params, ClassNode[] args) {
if (params==null) {
params = Parameter.EMPTY_ARRAY;
}
int dist = 0;
if (args.length<params.length) return -1;
// we already know the lengths are equal
for (int i = 0; i < ... | java | {
"resource": ""
} |
q17 | StaticTypeCheckingSupport.excessArgumentsMatchesVargsParameter | train | static int excessArgumentsMatchesVargsParameter(Parameter[] params, ClassNode[] args) {
// we already know parameter length is bigger zero and last is a vargs
// the excess arguments are all put in an array for the vargs call
// so check against the component type
int dist = 0;
C... | java | {
"resource": ""
} |
q18 | StaticTypeCheckingSupport.lastArgMatchesVarg | train | static int lastArgMatchesVarg(Parameter[] params, ClassNode... args) {
if (!isVargs(params)) return -1;
// case length ==0 handled already
// we have now two cases,
// the argument is wrapped in the vargs array or
// the argument is an array that can be used for the vargs part di... | java | {
"resource": ""
} |
q19 | StaticTypeCheckingSupport.buildParameter | train | private static Parameter buildParameter(final Map<String, GenericsType> genericFromReceiver, final Map<String, GenericsType> placeholdersFromContext, final Parameter methodParameter, final ClassNode paramType) {
if (genericFromReceiver.isEmpty() && (placeholdersFromContext==null||placeholdersFromContext.isEmpty... | java | {
"resource": ""
} |
q20 | StaticTypeCheckingSupport.isClassClassNodeWrappingConcreteType | train | public static boolean isClassClassNodeWrappingConcreteType(ClassNode classNode) {
GenericsType[] genericsTypes = classNode.getGenericsTypes();
return ClassHelper.CLASS_Type.equals(classNode)
&& classNode.isUsingGenerics()
&& genericsTypes!=null
&& !generic... | java | {
"resource": ""
} |
q21 | IOGroovyMethods.splitEachLine | train | public static <T> T splitEachLine(InputStream stream, String regex, String charset, @ClosureParams(value=FromString.class,options="List<String>") Closure<T> closure) throws IOException {
return splitEachLine(new BufferedReader(new InputStreamReader(stream, charset)), regex, closure);
} | java | {
"resource": ""
} |
q22 | IOGroovyMethods.transformChar | train | public static void transformChar(Reader self, Writer writer, @ClosureParams(value=SimpleType.class, options="java.lang.String") Closure closure) throws IOException {
int c;
try {
char[] chars = new char[1];
while ((c = self.read()) != -1) {
chars[0] = (char) c;
... | java | {
"resource": ""
} |
q23 | IOGroovyMethods.withCloseable | train | public static <T, U extends Closeable> T withCloseable(U self, @ClosureParams(value=FirstParam.class) Closure<T> action) throws IOException {
try {
T result = action.call(self);
Closeable temp = self;
self = null;
temp.close();
return result;
... | java | {
"resource": ""
} |
q24 | MetaArrayLengthProperty.getProperty | train | public Object getProperty(Object object) {
return java.lang.reflect.Array.getLength(object);
} | java | {
"resource": ""
} |
q25 | ProxyGeneratorAdapter.makeDelegateCall | train | protected MethodVisitor makeDelegateCall(final String name, final String desc, final String signature, final String[] exceptions, final int accessFlags) {
MethodVisitor mv = super.visitMethod(accessFlags, name, desc, signature, exceptions);
mv.visitVarInsn(ALOAD, 0); // load this
mv.visitFieldIn... | java | {
"resource": ""
} |
q26 | CachedSAMClass.getSAMMethod | train | public static Method getSAMMethod(Class<?> c) {
// SAM = single public abstract method
// if the class is not abstract there is no abstract method
if (!Modifier.isAbstract(c.getModifiers())) return null;
if (c.isInterface()) {
Method[] methods = c.getMethods();
//... | java | {
"resource": ""
} |
q27 | MopWriter.generateMopCalls | train | protected void generateMopCalls(LinkedList<MethodNode> mopCalls, boolean useThis) {
for (MethodNode method : mopCalls) {
String name = getMopMethodName(method, useThis);
Parameter[] parameters = method.getParameters();
String methodDescriptor = BytecodeHelper.getMethodDescrip... | java | {
"resource": ""
} |
q28 | ClassHelper.getWrapper | train | public static ClassNode getWrapper(ClassNode cn) {
cn = cn.redirect();
if (!isPrimitiveType(cn)) return cn;
if (cn==boolean_TYPE) {
return Boolean_TYPE;
} else if (cn==byte_TYPE) {
return Byte_TYPE;
} else if (cn==char_TYPE) {
return Character_... | java | {
"resource": ""
} |
q29 | ClassHelper.findSAM | train | public static MethodNode findSAM(ClassNode type) {
if (!Modifier.isAbstract(type.getModifiers())) return null;
if (type.isInterface()) {
List<MethodNode> methods = type.getMethods();
MethodNode found=null;
for (MethodNode mi : methods) {
// ignore meth... | java | {
"resource": ""
} |
q30 | Types.getPrecedence | train | public static int getPrecedence( int type, boolean throwIfInvalid ) {
switch( type ) {
case LEFT_PARENTHESIS:
return 0;
case EQUAL:
case PLUS_EQUAL:
case MINUS_EQUAL:
case MULTIPLY_EQUAL:
case DIVIDE_EQUAL:
ca... | java | {
"resource": ""
} |
q31 | NullObject.with | train | public <T> T with( Closure<T> closure ) {
return DefaultGroovyMethods.with( null, closure ) ;
} | java | {
"resource": ""
} |
q32 | DefaultGrailsDomainClassInjector.implementsMethod | train | private static boolean implementsMethod(ClassNode classNode, String methodName, Class[] argTypes) {
List methods = classNode.getMethods();
if (argTypes == null || argTypes.length ==0) {
for (Iterator i = methods.iterator(); i.hasNext();) {
MethodNode mn = (MethodNode) i.n... | java | {
"resource": ""
} |
q33 | MethodNode.getTypeDescriptor | train | public String getTypeDescriptor() {
if (typeDescriptor == null) {
StringBuilder buf = new StringBuilder(name.length() + parameters.length * 10);
buf.append(returnType.getName());
buf.append(' ');
buf.append(name);
buf.append('(');
for (int ... | java | {
"resource": ""
} |
q34 | MethodNode.getText | train | @Override
public String getText() {
String retType = AstToTextHelper.getClassText(returnType);
String exceptionTypes = AstToTextHelper.getThrowsClauseText(exceptions);
String parms = AstToTextHelper.getParametersText(parameters);
return AstToTextHelper.getModifiersText(modifiers) + "... | java | {
"resource": ""
} |
q35 | SimpleGroovyClassDoc.constructors | train | public GroovyConstructorDoc[] constructors() {
Collections.sort(constructors);
return constructors.toArray(new GroovyConstructorDoc[constructors.size()]);
} | java | {
"resource": ""
} |
q36 | SimpleGroovyClassDoc.innerClasses | train | public GroovyClassDoc[] innerClasses() {
Collections.sort(nested);
return nested.toArray(new GroovyClassDoc[nested.size()]);
} | java | {
"resource": ""
} |
q37 | SimpleGroovyClassDoc.fields | train | public GroovyFieldDoc[] fields() {
Collections.sort(fields);
return fields.toArray(new GroovyFieldDoc[fields.size()]);
} | java | {
"resource": ""
} |
q38 | SimpleGroovyClassDoc.properties | train | public GroovyFieldDoc[] properties() {
Collections.sort(properties);
return properties.toArray(new GroovyFieldDoc[properties.size()]);
} | java | {
"resource": ""
} |
q39 | SimpleGroovyClassDoc.enumConstants | train | public GroovyFieldDoc[] enumConstants() {
Collections.sort(enumConstants);
return enumConstants.toArray(new GroovyFieldDoc[enumConstants.size()]);
} | java | {
"resource": ""
} |
q40 | SimpleGroovyClassDoc.methods | train | public GroovyMethodDoc[] methods() {
Collections.sort(methods);
return methods.toArray(new GroovyMethodDoc[methods.size()]);
} | java | {
"resource": ""
} |
q41 | DataSet.add | train | public void add(Map<String, Object> map) throws SQLException {
if (withinDataSetBatch) {
if (batchData.size() == 0) {
batchKeys = map.keySet();
} else {
if (!map.keySet().equals(batchKeys)) {
throw new IllegalArgumentException("Inconsis... | java | {
"resource": ""
} |
q42 | DataSet.each | train | public void each(int offset, int maxRows, Closure closure) throws SQLException {
eachRow(getSql(), getParameters(), offset, maxRows, closure);
} | java | {
"resource": ""
} |
q43 | VetoableASTTransformation.wrapSetterMethod | train | private void wrapSetterMethod(ClassNode classNode, boolean bindable, String propertyName) {
String getterName = "get" + MetaClassHelper.capitalize(propertyName);
MethodNode setter = classNode.getSetterMethod("set" + MetaClassHelper.capitalize(propertyName));
if (setter != null) {
... | java | {
"resource": ""
} |
q44 | ResourceGroovyMethods.directorySize | train | public static long directorySize(File self) throws IOException, IllegalArgumentException
{
final long[] size = {0L};
eachFileRecurse(self, FileType.FILES, new Closure<Void>(null) {
public void doCall(Object[] args) {
size[0] += ((File) args[0]).length();
}
... | java | {
"resource": ""
} |
q45 | ResourceGroovyMethods.splitEachLine | train | public static <T> T splitEachLine(File self, String regex, @ClosureParams(value=SimpleType.class, options="java.lang.String[]") Closure<T> closure) throws IOException {
return IOGroovyMethods.splitEachLine(newReader(self), regex, closure);
} | java | {
"resource": ""
} |
q46 | ResourceGroovyMethods.write | train | public static void write(File file, String text, String charset) throws IOException {
Writer writer = null;
try {
FileOutputStream out = new FileOutputStream(file);
writeUTF16BomIfRequired(charset, out);
writer = new OutputStreamWriter(out, charset);
write... | java | {
"resource": ""
} |
q47 | ResourceGroovyMethods.append | train | public static void append(File file, Object text) throws IOException {
Writer writer = null;
try {
writer = new FileWriter(file, true);
InvokerHelper.write(writer, text);
writer.flush();
Writer temp = writer;
writer = null;
temp.cl... | java | {
"resource": ""
} |
q48 | ResourceGroovyMethods.append | train | public static void append(File file, Object text, String charset) throws IOException {
Writer writer = null;
try {
FileOutputStream out = new FileOutputStream(file, true);
if (!file.exists()) {
writeUTF16BomIfRequired(charset, out);
}
write... | java | {
"resource": ""
} |
q49 | ResourceGroovyMethods.append | train | public static void append(File file, Writer writer, String charset) throws IOException {
appendBuffered(file, writer, charset);
} | java | {
"resource": ""
} |
q50 | ResourceGroovyMethods.writeUtf16Bom | train | private static void writeUtf16Bom(OutputStream stream, boolean bigEndian) throws IOException {
if (bigEndian) {
stream.write(-2);
stream.write(-1);
} else {
stream.write(-1);
stream.write(-2);
}
} | java | {
"resource": ""
} |
q51 | GroovyClassLoader.getClassCacheEntry | train | protected Class getClassCacheEntry(String name) {
if (name == null) return null;
synchronized (classCache) {
return classCache.get(name);
}
} | java | {
"resource": ""
} |
q52 | MetaClassRegistryImpl.getMetaClassRegistryChangeEventListeners | train | public MetaClassRegistryChangeEventListener[] getMetaClassRegistryChangeEventListeners() {
synchronized (changeListenerList) {
ArrayList<MetaClassRegistryChangeEventListener> ret =
new ArrayList<MetaClassRegistryChangeEventListener>(changeListenerList.size()+nonRemoveableChangeLi... | java | {
"resource": ""
} |
q53 | MetaClassRegistryImpl.getInstance | train | public static MetaClassRegistry getInstance(int includeExtension) {
if (includeExtension != DONT_LOAD_DEFAULT) {
if (instanceInclude == null) {
instanceInclude = new MetaClassRegistryImpl();
}
return instanceInclude;
} else {
if (instanceEx... | java | {
"resource": ""
} |
q54 | Reduction.get | train | public CSTNode get( int index )
{
CSTNode element = null;
if( index < size() )
{
element = (CSTNode)elements.get( index );
}
return element;
} | java | {
"resource": ""
} |
q55 | Reduction.set | train | public CSTNode set( int index, CSTNode element )
{
if( elements == null )
{
throw new GroovyBugError( "attempt to set() on a EMPTY Reduction" );
}
if( index == 0 && !(element instanceof Token) )
{
//
// It's not the greatest o... | java | {
"resource": ""
} |
q56 | ManagedLinkedList.add | train | public void add(T value) {
Element<T> element = new Element<T>(bundle, value);
element.previous = tail;
if (tail != null) tail.next = element;
tail = element;
if (head == null) head = element;
} | java | {
"resource": ""
} |
q57 | ManagedLinkedList.toArray | train | public T[] toArray(T[] tArray) {
List<T> array = new ArrayList<T>(100);
for (Iterator<T> it = iterator(); it.hasNext();) {
T val = it.next();
if (val != null) array.add(val);
}
return array.toArray(tArray);
} | java | {
"resource": ""
} |
q58 | ValueMapImpl.get | train | public Value get(Object key) {
/* If the length is under and we are asking for the key, then just look for the key. Don't build the map. */
if (map == null && items.length < 20) {
for (Object item : items) {
MapItemValue miv = (MapItemValue) item;
if (key.equa... | java | {
"resource": ""
} |
q59 | DefaultGroovyMethods.unique | train | public static <T> Iterator<T> unique(Iterator<T> self) {
return toList((Iterable<T>) unique(toList(self))).listIterator();
} | java | {
"resource": ""
} |
q60 | DefaultGroovyMethods.numberAwareCompareTo | train | public static int numberAwareCompareTo(Comparable self, Comparable other) {
NumberAwareComparator<Comparable> numberAwareComparator = new NumberAwareComparator<Comparable>();
return numberAwareComparator.compare(self, other);
} | java | {
"resource": ""
} |
q61 | DefaultGroovyMethods.any | train | public static boolean any(Object self, Closure closure) {
BooleanClosureWrapper bcw = new BooleanClosureWrapper(closure);
for (Iterator iter = InvokerHelper.asIterator(self); iter.hasNext();) {
if (bcw.call(iter.next())) return true;
}
return false;
} | java | {
"resource": ""
} |
q62 | DefaultGroovyMethods.findResult | train | public static Object findResult(Object self, Object defaultResult, Closure closure) {
Object result = findResult(self, closure);
if (result == null) return defaultResult;
return result;
} | java | {
"resource": ""
} |
q63 | DefaultGroovyMethods.groupAnswer | train | protected static <K, T> void groupAnswer(final Map<K, List<T>> answer, T element, K value) {
if (answer.containsKey(value)) {
answer.get(value).add(element);
} else {
List<T> groupedElements = new ArrayList<T>();
groupedElements.add(element);
answer.put(va... | java | {
"resource": ""
} |
q64 | DefaultGroovyMethods.asImmutable | train | public static <K,V> Map<K,V> asImmutable(Map<? extends K, ? extends V> self) {
return Collections.unmodifiableMap(self);
} | java | {
"resource": ""
} |
q65 | DefaultGroovyMethods.asImmutable | train | public static <K,V> SortedMap<K,V> asImmutable(SortedMap<K, ? extends V> self) {
return Collections.unmodifiableSortedMap(self);
} | java | {
"resource": ""
} |
q66 | DefaultGroovyMethods.asImmutable | train | public static <T> List<T> asImmutable(List<? extends T> self) {
return Collections.unmodifiableList(self);
} | java | {
"resource": ""
} |
q67 | DefaultGroovyMethods.asImmutable | train | public static <T> Set<T> asImmutable(Set<? extends T> self) {
return Collections.unmodifiableSet(self);
} | java | {
"resource": ""
} |
q68 | DefaultGroovyMethods.asImmutable | train | public static <T> SortedSet<T> asImmutable(SortedSet<T> self) {
return Collections.unmodifiableSortedSet(self);
} | java | {
"resource": ""
} |
q69 | DefaultGroovyMethods.sort | train | public static <T> T[] sort(T[] self, Comparator<T> comparator) {
return sort(self, true, comparator);
} | java | {
"resource": ""
} |
q70 | DefaultGroovyMethods.addAll | train | public static <T> boolean addAll(Collection<T> self, Iterator<T> items) {
boolean changed = false;
while (items.hasNext()) {
T next = items.next();
if (self.add(next)) changed = true;
}
return changed;
} | java | {
"resource": ""
} |
q71 | DefaultGroovyMethods.addAll | train | public static <T> boolean addAll(Collection<T> self, Iterable<T> items) {
boolean changed = false;
for (T next : items) {
if (self.add(next)) changed = true;
}
return changed;
} | java | {
"resource": ""
} |
q72 | DefaultGroovyMethods.minus | train | public static <K,V> Map<K,V> minus(Map<K,V> self, Map removeMe) {
final Map<K,V> ansMap = createSimilarMap(self);
ansMap.putAll(self);
if (removeMe != null && removeMe.size() > 0) {
for (Map.Entry<K, V> e1 : self.entrySet()) {
for (Object e2 : removeMe.entrySet()) {
... | java | {
"resource": ""
} |
q73 | DefaultGroovyMethods.findLastIndexOf | train | public static int findLastIndexOf(Object self, int startIndex, Closure closure) {
int result = -1;
int i = 0;
BooleanClosureWrapper bcw = new BooleanClosureWrapper(closure);
for (Iterator iter = InvokerHelper.asIterator(self); iter.hasNext(); i++) {
Object value = iter.next()... | java | {
"resource": ""
} |
q74 | DefaultGroovyMethods.findIndexValues | train | public static List<Number> findIndexValues(Object self, Closure closure) {
return findIndexValues(self, 0, closure);
} | java | {
"resource": ""
} |
q75 | DefaultGroovyMethods.findIndexValues | train | public static List<Number> findIndexValues(Object self, Number startIndex, Closure closure) {
List<Number> result = new ArrayList<Number>();
long count = 0;
long startCount = startIndex.longValue();
BooleanClosureWrapper bcw = new BooleanClosureWrapper(closure);
for (Iterator ite... | java | {
"resource": ""
} |
q76 | HandleMetaClass.getProperty | train | public Object getProperty(String property) {
if(ExpandoMetaClass.isValidExpandoProperty(property)) {
if(property.equals(ExpandoMetaClass.STATIC_QUALIFIER) ||
property.equals(ExpandoMetaClass.CONSTRUCTOR) ||
myMetaClass.hasProperty(this, property) == null) {
... | java | {
"resource": ""
} |
q77 | Message.create | train | public static Message create( String text, Object data, ProcessingUnit owner )
{
return new SimpleMessage( text, data, owner);
} | java | {
"resource": ""
} |
q78 | JsonDelegate.invokeMethod | train | public Object invokeMethod(String name, Object args) {
Object val = null;
if (args != null && Object[].class.isAssignableFrom(args.getClass())) {
Object[] arr = (Object[]) args;
if (arr.length == 1) {
val = arr[0];
} else if (arr.length == 2 && arr[0]... | java | {
"resource": ""
} |
q79 | Binding.setVariable | train | public void setVariable(String name, Object value) {
if (variables == null)
variables = new LinkedHashMap();
variables.put(name, value);
} | java | {
"resource": ""
} |
q80 | MetaBeanProperty.getProperty | train | public Object getProperty(Object object) {
MetaMethod getter = getGetter();
if (getter == null) {
if (field != null) return field.getProperty(object);
//TODO: create a WriteOnlyException class?
throw new GroovyRuntimeException("Cannot read write-only property: " + nam... | java | {
"resource": ""
} |
q81 | MetaBeanProperty.setProperty | train | public void setProperty(Object object, Object newValue) {
MetaMethod setter = getSetter();
if (setter == null) {
if (field != null && !Modifier.isFinal(field.getModifiers())) {
field.setProperty(object, newValue);
return;
}
throw new Gr... | java | {
"resource": ""
} |
q82 | MetaBeanProperty.getModifiers | train | public int getModifiers() {
MetaMethod getter = getGetter();
MetaMethod setter = getSetter();
if (setter != null && getter == null) return setter.getModifiers();
if (getter != null && setter == null) return getter.getModifiers();
int modifiers = getter.getModifiers() | setter.get... | java | {
"resource": ""
} |
q83 | Traits.isTrait | train | public static boolean isTrait(final ClassNode cNode) {
return cNode!=null
&& ((cNode.isInterface() && !cNode.getAnnotations(TRAIT_CLASSNODE).isEmpty())
|| isAnnotatedWithTrait(cNode));
} | java | {
"resource": ""
} |
q84 | Traits.getBridgeMethodTarget | train | public static Method getBridgeMethodTarget(Method someMethod) {
TraitBridge annotation = someMethod.getAnnotation(TraitBridge.class);
if (annotation==null) {
return null;
}
Class aClass = annotation.traitClass();
String desc = annotation.desc();
for (Method me... | java | {
"resource": ""
} |
q85 | FindReplaceUtility.findNext | train | private static int findNext(boolean reverse, int pos) {
boolean backwards = IS_BACKWARDS_CHECKBOX.isSelected();
backwards = backwards ? !reverse : reverse;
String pattern = (String) FIND_FIELD.getSelectedItem();
if (pattern != null && pattern.length() > 0) {
try {
... | java | {
"resource": ""
} |
q86 | IndyInterface.invalidateSwitchPoints | train | protected static void invalidateSwitchPoints() {
if (LOG_ENABLED) {
LOG.info("invalidating switch point");
}
SwitchPoint old = switchPoint;
switchPoint = new SwitchPoint();
synchronized(IndyInterface.class) { SwitchPoint.invalidateAll(new SwitchP... | java | {
"resource": ""
} |
q87 | IndyInterface.bootstrapCurrent | train | public static CallSite bootstrapCurrent(Lookup caller, String name, MethodType type) {
return realBootstrap(caller, name, CALL_TYPES.METHOD.ordinal(), type, false, true, false);
} | java | {
"resource": ""
} |
q88 | IndyInterface.realBootstrap | train | private static CallSite realBootstrap(Lookup caller, String name, int callID, MethodType type, boolean safe, boolean thisCall, boolean spreadCall) {
// since indy does not give us the runtime types
// we produce first a dummy call site, which then changes the target to one,
// that d... | java | {
"resource": ""
} |
q89 | TableLayout.addCell | train | public void addCell(TableLayoutCell cell) {
GridBagConstraints constraints = cell.getConstraints();
constraints.insets = new Insets(cellpadding, cellpadding, cellpadding, cellpadding);
add(cell.getComponent(), constraints);
} | java | {
"resource": ""
} |
q90 | CompileUnit.addClass | train | public void addClass(ClassNode node) {
node = node.redirect();
String name = node.getName();
ClassNode stored = classes.get(name);
if (stored != null && stored != node) {
// we have a duplicate class!
// One possibility for this is, that we declared a script and a... | java | {
"resource": ""
} |
q91 | LoaderConfiguration.getSlashyPath | train | private String getSlashyPath(final String path) {
String changedPath = path;
if (File.separatorChar != '/')
changedPath = changedPath.replace(File.separatorChar, '/');
return changedPath;
} | java | {
"resource": ""
} |
q92 | NioGroovyMethods.write | train | public static void write(Path self, String text, String charset) throws IOException {
Writer writer = null;
try {
writer = new OutputStreamWriter(Files.newOutputStream(self, CREATE, APPEND), Charset.forName(charset));
writer.write(text);
writer.flush();
W... | java | {
"resource": ""
} |
q93 | NioGroovyMethods.append | train | public static void append(Path self, Object text) throws IOException {
Writer writer = null;
try {
writer = new OutputStreamWriter(Files.newOutputStream(self, CREATE, APPEND), Charset.defaultCharset());
InvokerHelper.write(writer, text);
writer.flush();
W... | java | {
"resource": ""
} |
q94 | StringGroovyMethods.count | train | public static int count(CharSequence self, CharSequence text) {
int answer = 0;
for (int idx = 0; true; idx++) {
idx = self.toString().indexOf(text.toString(), idx);
// break once idx goes to -1 or for case of empty string once
// we get to the end to avoid JDK librar... | java | {
"resource": ""
} |
q95 | StringGroovyMethods.eachMatch | train | public static <T extends CharSequence> T eachMatch(T self, CharSequence regex, @ClosureParams(value=FromString.class, options={"List<String>","String[]"}) Closure closure) {
eachMatch(self.toString(), regex.toString(), closure);
return self;
} | java | {
"resource": ""
} |
q96 | StringGroovyMethods.eachMatch | train | public static String eachMatch(String self, String regex, @ClosureParams(value=FromString.class, options={"List<String>","String[]"}) Closure closure) {
return eachMatch(self, Pattern.compile(regex), closure);
} | java | {
"resource": ""
} |
q97 | StringGroovyMethods.expandLine | train | public static String expandLine(CharSequence self, int tabStop) {
String s = self.toString();
int index;
while ((index = s.indexOf('\t')) != -1) {
StringBuilder builder = new StringBuilder(s);
int count = tabStop - index % tabStop;
builder.deleteCharAt(index);... | java | {
"resource": ""
} |
q98 | StringGroovyMethods.find | train | public static String find(CharSequence self, CharSequence regex, @ClosureParams(value=SimpleType.class, options="java.lang.String[]") Closure closure) {
return find(self.toString(), Pattern.compile(regex.toString()), closure);
} | java | {
"resource": ""
} |
q99 | StringGroovyMethods.getAt | train | public static String getAt(CharSequence self, Collection indices) {
StringBuilder answer = new StringBuilder();
for (Object value : indices) {
if (value instanceof Range) {
answer.append(getAt(self, (Range) value));
} else if (value instanceof Collection) {
... | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.