_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q17800
backup_policy.get
train
public static backup_policy get(nitro_service client, backup_policy resource) throws Exception { resource.validate("get"); return ((backup_policy[]) resource.get_resources(client))[0]; }
java
{ "resource": "" }
q17801
Reflection.registerFieldsToFilter
train
public static synchronized void registerFieldsToFilter(Class<?> containingClass, String ... fieldNames) { fieldFilterMap = registerFilter(fieldFilterMap, containingClass, fieldNames); }
java
{ "resource": "" }
q17802
Reflection.registerMethodsToFilter
train
public static synchronized void registerMethodsToFilter(Class<?> containingClass, String ... methodNames) { methodFilterMap = registerFilter(methodFilterMap, containingClass, methodNames); }
java
{ "resource": "" }
q17803
DateTimeUtils.create
train
public static Calendar create(long timeInMilliseconds) { Calendar dateTime = Calendar.getInstance(); dateTime.clear(); dateTime.setTimeInMillis(timeInMilliseconds); return dateTime; }
java
{ "resource": "" }
q17804
ChannelQuery.execute
train
public void execute(ChannelQueryListener listener) { addChannelQueryListener(listener); // Make a local copy to avoid synchronization Result localResult = result; // If the query was executed, just call the listener if (localResult != null) { listener.queryExecuted(localResult); } else { execute(); } }
java
{ "resource": "" }
q17805
current_timezone.get
train
public static current_timezone get(nitro_service client) throws Exception { current_timezone resource = new current_timezone(); resource.validate("get"); return ((current_timezone[]) resource.get_resources(client))[0]; }
java
{ "resource": "" }
q17806
mps_network_config.get
train
public static mps_network_config get(nitro_service client) throws Exception { mps_network_config resource = new mps_network_config(); resource.validate("get"); return ((mps_network_config[]) resource.get_resources(client))[0]; }
java
{ "resource": "" }
q17807
ClearIdentityVisitor.visit
train
@Override @SuppressWarnings("unchecked") public void visit(final Visitable visitable) { if (visitable instanceof Identifiable) { ((Identifiable) visitable).setId(null); } }
java
{ "resource": "" }
q17808
OrderableComparator.compare
train
@Override public int compare(final Orderable<T> orderable1, final Orderable<T> orderable2) { return orderable1.getOrder().compareTo(orderable2.getOrder()); }
java
{ "resource": "" }
q17809
xen_supplemental_pack.install
train
public static xen_supplemental_pack install(nitro_service client, xen_supplemental_pack resource) throws Exception { return ((xen_supplemental_pack[]) resource.perform_operation(client, "install"))[0]; }
java
{ "resource": "" }
q17810
jazz_license.get
train
public static jazz_license get(nitro_service client) throws Exception { jazz_license resource = new jazz_license(); resource.validate("get"); return ((jazz_license[]) resource.get_resources(client))[0]; }
java
{ "resource": "" }
q17811
xen_hotfix.apply
train
public static xen_hotfix apply(nitro_service client, xen_hotfix resource) throws Exception { return ((xen_hotfix[]) resource.perform_operation(client, "apply"))[0]; }
java
{ "resource": "" }
q17812
StringUtils.toInitialCase
train
public static String toInitialCase(String s) { if (isBlank(s)) return s; if (s.length() == 1) return s.toUpperCase(); return s.substring(0, 1).toUpperCase() + s.substring(1); }
java
{ "resource": "" }
q17813
StringUtils.replicate
train
public static String replicate(String s, int times) { if (s==null) return null; if (times <= 0 || s.length() == 0) return ""; StringBuilder b = new StringBuilder(s.length() * times); for (int k = 1; k <= times; ++k) b.append(s); return b.toString(); }
java
{ "resource": "" }
q17814
StringUtils.md5
train
public static String md5(String s) { try { MessageDigest md5 = MessageDigest.getInstance("MD5"); byte[] digest = md5.digest(s.getBytes(Charset.forName("UTF-8"))); StringBuilder buf = new StringBuilder(2 * digest.length); for (byte oneByte : digest) { buf.append(Integer.toHexString((oneByte & 0xFF) | 0x100).substring(1, 3)); } return buf.toString(); } catch (NoSuchAlgorithmException ignore) { } return s; }
java
{ "resource": "" }
q17815
StringUtils.percentageBar
train
public static String percentageBar(double percentage) { final char dot = '.'; final char mark = '#'; final int slots = 40; StringBuilder bar = new StringBuilder(replicate(String.valueOf(dot), slots)); int numSlots = (int) (slots * percentage / 100.0); for (int k = 0; k < numSlots; ++k) bar.setCharAt(k, mark); return String.format("[%s] %3.0f%%", bar, percentage); }
java
{ "resource": "" }
q17816
ChannelInitializers.httpServer
train
public static final ChannelInitializer<Channel> httpServer( final SimpleChannelInboundHandler<HttpRequest> handler) { Preconditions.checkArgument(handler.isSharable()); return new ChannelInitializer<Channel>() { @Override protected void initChannel(Channel channel) throws Exception { ChannelPipeline pipeline = channel.pipeline(); pipeline.addLast("httpCodec", new HttpServerCodec()); pipeline.addLast("aggregator", new HttpObjectAggregator(10 * 1024 * 1024)); pipeline.addLast("httpServerHandler", handler); } }; }
java
{ "resource": "" }
q17817
ChannelInitializers.httpClient
train
public static final ChannelInitializer<Channel> httpClient( final SimpleChannelInboundHandler<HttpResponse> handler) { return new ChannelInitializer<Channel>() { @Override protected void initChannel(Channel channel) throws Exception { ChannelPipeline pipeline = channel.pipeline(); pipeline.addLast("httpCodec", new HttpClientCodec()); pipeline.addLast("aggregator", new HttpObjectAggregator(10 * 1024 * 1024)); pipeline.addLast("httpClientHandler", handler); } }; }
java
{ "resource": "" }
q17818
ThreadUtils.isBlocked
train
@NullSafe public static boolean isBlocked(Thread thread) { return (thread != null && Thread.State.BLOCKED.equals(thread.getState())); }
java
{ "resource": "" }
q17819
ThreadUtils.isNew
train
@NullSafe public static boolean isNew(Thread thread) { return (thread != null && Thread.State.NEW.equals(thread.getState())); }
java
{ "resource": "" }
q17820
ThreadUtils.isTimedWaiting
train
@NullSafe public static boolean isTimedWaiting(Thread thread) { return (thread != null && Thread.State.TIMED_WAITING.equals(thread.getState())); }
java
{ "resource": "" }
q17821
ThreadUtils.isWaiting
train
@NullSafe public static boolean isWaiting(Thread thread) { return (thread != null && Thread.State.WAITING.equals(thread.getState())); }
java
{ "resource": "" }
q17822
ThreadUtils.getContextClassLoader
train
@NullSafe public static ClassLoader getContextClassLoader(Thread thread) { return (thread != null ? thread.getContextClassLoader() : ThreadUtils.class.getClassLoader()); }
java
{ "resource": "" }
q17823
ThreadUtils.getName
train
@NullSafe public static String getName(Thread thread) { return (thread != null ? thread.getName() : null); }
java
{ "resource": "" }
q17824
ThreadUtils.getStackTrace
train
@NullSafe public static StackTraceElement[] getStackTrace(Thread thread) { return (thread != null ? thread.getStackTrace() : new StackTraceElement[0]); }
java
{ "resource": "" }
q17825
ThreadUtils.getState
train
@NullSafe public static Thread.State getState(Thread thread) { return (thread != null ? thread.getState() : null); }
java
{ "resource": "" }
q17826
ThreadUtils.getThreadGroup
train
@NullSafe public static ThreadGroup getThreadGroup(Thread thread) { return (thread != null ? thread.getThreadGroup() : null); }
java
{ "resource": "" }
q17827
ThreadUtils.interrupt
train
@NullSafe public static void interrupt(Thread thread) { Optional.ofNullable(thread).ifPresent(Thread::interrupt); }
java
{ "resource": "" }
q17828
ThreadUtils.join
train
@NullSafe public static boolean join(Thread thread, long milliseconds, int nanoseconds) { try { if (thread != null) { thread.join(milliseconds, nanoseconds); return true; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } return false; }
java
{ "resource": "" }
q17829
ThreadUtils.sleep
train
public static boolean sleep(long milliseconds, int nanoseconds) { try { Thread.sleep(milliseconds, nanoseconds); return true; } catch (InterruptedException e) { Thread.currentThread().interrupt(); return false; } }
java
{ "resource": "" }
q17830
EchoServer.runEchoService
train
protected void runEchoService(ServerSocket serverSocket) { if (isRunning(serverSocket)) { echoService = newExecutorService(); echoService.submit(() -> { try { while (isRunning(serverSocket)) { Socket echoClient = serverSocket.accept(); getLogger().info(() -> String.format("EchoClient connected from [%s]", echoClient.getRemoteSocketAddress())); echoService.submit(() -> { sendResponse(echoClient, receiveMessage(echoClient)); close(echoClient); }); } } catch (IOException cause) { if (isRunning(serverSocket)) { getLogger().warning(() -> String.format("An IO error occurred while listening for EchoClients:%n%s", ThrowableUtils.getStackTrace(cause))); } } }); getLogger().info(() -> String.format("EchoServer running on port [%d]", getPort())); } }
java
{ "resource": "" }
q17831
EchoServer.stopEchoService
train
protected boolean stopEchoService() { return Optional.ofNullable(getEchoService()).map(localEchoService -> { localEchoService.shutdown(); try { if (!localEchoService.awaitTermination(30, TimeUnit.SECONDS)) { localEchoService.shutdownNow(); if (!localEchoService.awaitTermination(30, TimeUnit.SECONDS)) { getLogger().warning("Failed to shutdown EchoService"); } } } catch (InterruptedException ignore) { Thread.currentThread().interrupt(); } return localEchoService.isShutdown(); }).orElse(false); }
java
{ "resource": "" }
q17832
ns.reboot
train
public static ns reboot(nitro_service client, ns resource) throws Exception { return ((ns[]) resource.perform_operation(client, "reboot"))[0]; }
java
{ "resource": "" }
q17833
ns.stop
train
public static ns stop(nitro_service client, ns resource) throws Exception { return ((ns[]) resource.perform_operation(client, "stop"))[0]; }
java
{ "resource": "" }
q17834
ns.force_reboot
train
public static ns force_reboot(nitro_service client, ns resource) throws Exception { return ((ns[]) resource.perform_operation(client, "force_reboot"))[0]; }
java
{ "resource": "" }
q17835
ns.force_stop
train
public static ns force_stop(nitro_service client, ns resource) throws Exception { return ((ns[]) resource.perform_operation(client, "force_stop"))[0]; }
java
{ "resource": "" }
q17836
ns.start
train
public static ns start(nitro_service client, ns resource) throws Exception { return ((ns[]) resource.perform_operation(client, "start"))[0]; }
java
{ "resource": "" }
q17837
ns.get_filtered
train
public static ns[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception { ns obj = new ns(); options option = new options(); option.set_filter(filter); ns[] response = (ns[]) obj.getfiltered(service, option); return response; }
java
{ "resource": "" }
q17838
BoundedDroppingQueue.put
train
public void put(ElementType x) { if (full()) { getIdx = (getIdx + 1) % elements.length; } else { size++; } elements[putIdx] = x; putIdx = (putIdx + 1) % elements.length; }
java
{ "resource": "" }
q17839
BoundedDroppingQueue.get
train
public ElementType get() { if (empty()) throw new IllegalArgumentException("Empty queue"); ElementType x = (ElementType) elements[getIdx]; getIdx = (getIdx + 1) % elements.length; size--; return x; }
java
{ "resource": "" }
q17840
BoundedDroppingQueue.iterator
train
public Iterator<ElementType> iterator() { return new Iterator<ElementType>() { int idx = getIdx; int N = size; public boolean hasNext() { return N > 0; } public ElementType next() { ElementType x = (ElementType) elements[idx]; idx = (idx + 1) % elements.length; N--; return x; } public void remove() { throw new UnsupportedOperationException("remove"); } }; }
java
{ "resource": "" }
q17841
BoundedDroppingQueue.toList
train
public List<ElementType> toList() { List<ElementType> result = new ArrayList<ElementType>(size()); for (ElementType e : this) result.add(e); return result; }
java
{ "resource": "" }
q17842
PropertiesAdapter.defaultIfNotSet
train
protected <T> T defaultIfNotSet(String propertyName, T defaultValue, Class<T> type) { return (isSet(propertyName) ? convert(propertyName, type) : defaultValue); }
java
{ "resource": "" }
q17843
PropertiesAdapter.filter
train
public PropertiesAdapter filter(Filter<String> filter) { Properties properties = new Properties(); for (String propertyName : this) { if (filter.accept(propertyName)) { properties.setProperty(propertyName, get(propertyName)); } } return from(properties); }
java
{ "resource": "" }
q17844
mail_profile.get
train
public static mail_profile get(nitro_service client, mail_profile resource) throws Exception { resource.validate("get"); return ((mail_profile[]) resource.get_resources(client))[0]; }
java
{ "resource": "" }
q17845
TimeUnitComparator.compare
train
@Override public int compare(final TimeUnit timeUnitOne, final TimeUnit timeUnitTwo) { return Integer.valueOf(String.valueOf(TIME_UNIT_VALUE.get(timeUnitOne))).compareTo( TIME_UNIT_VALUE.get(timeUnitTwo)); }
java
{ "resource": "" }
q17846
ReflectionUtils.getArgumentTypes
train
@NullSafe public static Class[] getArgumentTypes(Object... arguments) { Class[] argumentTypes = null; if (arguments != null) { argumentTypes = new Class[arguments.length]; for (int index = 0; index < arguments.length; index++) { argumentTypes[index] = getClass(arguments[index]); } } return argumentTypes; }
java
{ "resource": "" }
q17847
BinaryUtils.nextPermutation
train
public static final long nextPermutation(long val) { long tmp = val | (val - 1); return (tmp + 1) | (((-tmp & -~tmp) - 1) >> (Long.numberOfTrailingZeros(val) + 1)); }
java
{ "resource": "" }
q17848
BinaryUtils.getBitsSet
train
public static final int[] getBitsSet(final long val) { long tmp = val; int[] retVal = new int[Long.bitCount(val)]; for (int i = 0; i < retVal.length; i++) { retVal[i] = Long.numberOfTrailingZeros(tmp); tmp = tmp ^ Long.lowestOneBit(tmp); } return retVal; }
java
{ "resource": "" }
q17849
MergeSort.sort
train
@Override @SuppressWarnings("unchecked") public <E> E[] sort(final E... elements) { return (E[]) sort(new SortableArrayList(elements)).toArray( (E[]) Array.newInstance(elements.getClass().getComponentType(), elements.length)); }
java
{ "resource": "" }
q17850
MergeSort.sort
train
@Override public <E> List<E> sort(final List<E> elements) { if (elements.size() > 1) { int size = elements.size(); int count = ((size / 2) + (size % 2)); List<E> leftElements = sort(elements.subList(0, count)); List<E> rightElements = sort(elements.subList(count, size)); return merge(leftElements, rightElements); } return elements; }
java
{ "resource": "" }
q17851
Metadata.fromPomProperties
train
public static Metadata fromPomProperties(InputStream is) { Metadata metadata = new Metadata(); BufferedReader input = new BufferedReader(new InputStreamReader(is)); try { String line; while ((line = input.readLine()) != null) { if (line.startsWith("#")) continue; String[] property = line.trim().split("="); if (property.length == 2) metadata.put(property[0], property[1]); } } catch (IOException e) { // Problems? Too bad! } return metadata; }
java
{ "resource": "" }
q17852
Metadata.fromManifest
train
public static Metadata fromManifest(InputStream is) { try { Manifest mf = new Manifest(is); return fromManifest(mf); } catch (IOException e) { // Problems? Too bad! } return new Metadata(); }
java
{ "resource": "" }
q17853
af_persistant_stat_info.get_filtered
train
public static af_persistant_stat_info[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception { af_persistant_stat_info obj = new af_persistant_stat_info(); options option = new options(); option.set_filter(filter); af_persistant_stat_info[] response = (af_persistant_stat_info[]) obj.getfiltered(service, option); return response; }
java
{ "resource": "" }
q17854
CachingTemplate.withCaching
train
@SuppressWarnings("unchecked") public <T extends VALUE> T withCaching(KEY key, Supplier<VALUE> cacheableOperation) { Assert.notNull(key, "Key is required"); Assert.notNull(cacheableOperation, "Supplier is required"); ReadWriteLock lock = getLock(); return (T) Optional.ofNullable(read(lock, key)).orElseGet(() -> Optional.ofNullable(cacheableOperation.get()) .map(value -> write(lock, key, value)) .orElse(null)); }
java
{ "resource": "" }
q17855
syslog_server.get_filtered
train
public static syslog_server[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception { syslog_server obj = new syslog_server(); options option = new options(); option.set_filter(filter); syslog_server[] response = (syslog_server[]) obj.getfiltered(service, option); return response; }
java
{ "resource": "" }
q17856
Json.string_to_resource
train
public Object string_to_resource(Class<?> responseClass, String response) { try { Gson gson = new Gson(); return gson.fromJson(response, responseClass); }catch(Exception e) { System.out.println(e.getMessage()); } return null; }
java
{ "resource": "" }
q17857
Json.resource_to_string
train
public String resource_to_string(base_resource resrc, options option) { String result = "{ "; if (option != null && option.get_action() != null) result = result + "\"params\": {\"action\":\"" + option.get_action() + "\"},"; result = result + "\"" + resrc.get_object_type() + "\":" + this.resource_to_string(resrc) + "}"; return result; }
java
{ "resource": "" }
q17858
Json.resource_to_string
train
public String resource_to_string(base_resource resources[], options option) { String objecttype = resources[0].get_object_type(); String request = "{"; if (option != null && option.get_action() != null) request = request + "\"params\": {\"action\": \"" + option.get_action() + "\"},"; request = request + "\"" + objecttype + "\":["; for (int i = 0; i < resources.length ; i++) { String str = this.resource_to_string(resources[i]); request = request + str + ","; } request = request + "]}"; return request; }
java
{ "resource": "" }
q17859
Json.resource_to_string
train
public String resource_to_string(base_resource resources[], options option, String onerror) { String objecttype = resources[0].get_object_type(); String request = "{"; if ( (option != null && option.get_action() != null) || (!onerror.equals("")) ) { request = request + "\"params\":{"; if (option != null) { if(option.get_action() != null) { request = request + "\"action\":\"" + option.get_action()+"\","; } } if((!onerror.equals(""))) { request = request + "\"onerror\":\"" + onerror + "\""; } request = request + "},"; } request = request + "\"" + objecttype + "\":["; for (int i = 0; i < resources.length ; i++) { String str = this.resource_to_string(resources[i]); request = request + str + ","; } request = request + "]}"; return request; }
java
{ "resource": "" }
q17860
ClassUtils.getClass
train
@NullSafe public static Class<?> getClass(Object obj) { return obj != null ? obj.getClass() : null; }
java
{ "resource": "" }
q17861
ClassUtils.getClassSimpleName
train
@NullSafe public static String getClassSimpleName(Object obj) { return obj != null ? obj.getClass().getSimpleName() : null; }
java
{ "resource": "" }
q17862
ClassUtils.findConstructor
train
@SuppressWarnings({ "unchecked", "all" }) public static <T> Constructor<T> findConstructor(Class<T> type, Object... arguments) { for (Constructor<?> constructor : type.getDeclaredConstructors()) { Class<?>[] parameterTypes = constructor.getParameterTypes(); if (ArrayUtils.nullSafeLength(arguments) == parameterTypes.length) { boolean match = true; for (int index = 0; match && index < parameterTypes.length; index++) { match &= instanceOf(arguments[index], parameterTypes[index]); } if (match) { return (Constructor<T>) constructor; } } } return null; }
java
{ "resource": "" }
q17863
ClassUtils.getConstructor
train
public static <T> Constructor<T> getConstructor(Class<T> type, Class<?>... parameterTypes) { try { return type.getDeclaredConstructor(parameterTypes); } catch (NoSuchMethodException cause) { throw new ConstructorNotFoundException(cause); } }
java
{ "resource": "" }
q17864
ClassUtils.resolveConstructor
train
public static <T> Constructor<T> resolveConstructor(Class<T> type, Class<?>[] parameterTypes, Object... arguments) { try { return getConstructor(type, parameterTypes); } catch (ConstructorNotFoundException cause) { Constructor<T> constructor = findConstructor(type, arguments); Assert.notNull(constructor, new ConstructorNotFoundException(String.format( "Failed to resolve constructor with signature [%1$s] on class type [%2$s]", getMethodSignature(getSimpleName(type), parameterTypes, Void.class), getName(type)), cause.getCause())); return constructor; } }
java
{ "resource": "" }
q17865
ClassUtils.getField
train
public static Field getField(Class<?> type, String fieldName) { try { return type.getDeclaredField(fieldName); } catch (NoSuchFieldException cause) { if (type.getSuperclass() != null) { return getField(type.getSuperclass(), fieldName); } throw new FieldNotFoundException(cause); } }
java
{ "resource": "" }
q17866
ClassUtils.findMethod
train
@SuppressWarnings("all") public static Method findMethod(Class<?> type, String methodName, Object... arguments) { for (Method method : type.getDeclaredMethods()) { if (method.getName().equals(methodName)) { Class<?>[] parameterTypes = method.getParameterTypes(); if (ArrayUtils.nullSafeLength(arguments) == parameterTypes.length) { boolean match = true; for (int index = 0; match && index < parameterTypes.length; index++) { match &= instanceOf(arguments[index], parameterTypes[index]); } if (match) { return method; } } } } return (type.getSuperclass() != null ? findMethod(type.getSuperclass(), methodName, arguments) : null); }
java
{ "resource": "" }
q17867
ClassUtils.getMethod
train
public static Method getMethod(Class<?> type, String methodName, Class<?>... parameterTypes) { try { return type.getDeclaredMethod(methodName, parameterTypes); } catch (NoSuchMethodException cause) { if (type.getSuperclass() != null) { return getMethod(type.getSuperclass(), methodName, parameterTypes); } throw new MethodNotFoundException(cause); } }
java
{ "resource": "" }
q17868
ClassUtils.resolveMethod
train
public static Method resolveMethod(Class<?> type, String methodName, Class<?>[] parameterTypes, Object[] arguments, Class<?> returnType) { try { return getMethod(type, methodName, parameterTypes); } catch (MethodNotFoundException cause) { Method method = findMethod(type, methodName, arguments); Assert.notNull(method, new MethodNotFoundException(String.format( "Failed to resolve method with signature [%1$s] on class type [%2$s]", getMethodSignature(methodName, parameterTypes, returnType), getName(type)), cause.getCause())); return method; } }
java
{ "resource": "" }
q17869
ClassUtils.getMethodSignature
train
protected static String getMethodSignature(Method method) { return getMethodSignature(method.getName(), method.getParameterTypes(), method.getReturnType()); }
java
{ "resource": "" }
q17870
ClassUtils.getMethodSignature
train
protected static String getMethodSignature(String methodName, Class<?>[] parameterTypes, Class<?> returnType) { StringBuilder buffer = new StringBuilder(methodName); buffer.append("("); if (parameterTypes != null) { int index = 0; for (Class<?> parameterType : parameterTypes) { buffer.append(index++ > 0 ? ", :" : ":"); buffer.append(getSimpleName(parameterType)); } } buffer.append("):"); buffer.append(returnType == null || Void.class.equals(returnType) ? "void" : getSimpleName(returnType)); return buffer.toString(); }
java
{ "resource": "" }
q17871
ClassUtils.getName
train
@NullSafe public static String getName(Class type) { return type != null ? type.getName() : null; }
java
{ "resource": "" }
q17872
ClassUtils.getSimpleName
train
@NullSafe public static String getSimpleName(Class type) { return type != null ? type.getSimpleName() : null; }
java
{ "resource": "" }
q17873
ClassUtils.instanceOf
train
@NullSafe public static boolean instanceOf(Object obj, Class<?> type) { return type != null && type.isInstance(obj); }
java
{ "resource": "" }
q17874
ClassUtils.isAnnotationPresent
train
@NullSafe public static boolean isAnnotationPresent(Class<? extends Annotation> annotation, AnnotatedElement... members) { return stream(ArrayUtils.nullSafeArray(members, AnnotatedElement.class)) .anyMatch(member -> member != null && member.isAnnotationPresent(annotation)); }
java
{ "resource": "" }
q17875
ClassUtils.isClass
train
@NullSafe public static boolean isClass(Class type) { return type != null && !(type.isAnnotation() || type.isArray() || type.isEnum() || type.isInterface() || type.isPrimitive()); }
java
{ "resource": "" }
q17876
ClassUtils.loadClass
train
public static <T> Class<T> loadClass(String fullyQualifiedClassName) { return loadClass(fullyQualifiedClassName, DEFAULT_INITIALIZE_LOADED_CLASS, Thread.currentThread().getContextClassLoader()); }
java
{ "resource": "" }
q17877
ClassUtils.notInstanceOf
train
@NullSafe @SuppressWarnings("all") public static boolean notInstanceOf(Object obj, Class... types) { boolean result = true; for (int index = 0; result && index < ArrayUtils.nullSafeLength(types); index++) { result &= !instanceOf(obj, types[index]); } return result; }
java
{ "resource": "" }
q17878
Rc4Utils.encrypt
train
public static byte[] encrypt(byte[] data, byte[] key) { checkNotNull(data); checkNotNull(key); checkArgument(key.length >= 5 && key.length <= 256); StreamCipher rc4 = new RC4Engine(); rc4.init(true, new KeyParameter(key)); byte[] encrypted = new byte[data.length]; rc4.processBytes(data, 0, data.length, encrypted, 0); return encrypted; }
java
{ "resource": "" }
q17879
Rc4Utils.encrypt
train
public static OutputStream encrypt(OutputStream outputStream, byte[] key) { checkNotNull(outputStream); checkNotNull(key); checkArgument(key.length >= 5 && key.length <= 256); StreamCipher rc4 = new RC4Engine(); rc4.init(true, new KeyParameter(key)); return new CipherOutputStream(outputStream, rc4); }
java
{ "resource": "" }
q17880
Rc4Utils.decrypt
train
public static byte[] decrypt(byte[] data, byte[] key) { checkNotNull(data); checkNotNull(key); checkArgument(key.length >= 5 && key.length <= 256); StreamCipher rc4 = new RC4Engine(); rc4.init(false, new KeyParameter(key)); byte[] decrypted = new byte[data.length]; rc4.processBytes(data, 0, data.length, decrypted, 0); return decrypted; }
java
{ "resource": "" }
q17881
Rc4Utils.decrypt
train
public static InputStream decrypt(InputStream inputStream, byte[] key) { checkNotNull(inputStream); checkNotNull(key); checkArgument(key.length >= 5 && key.length <= 256); StreamCipher rc4 = new RC4Engine(); rc4.init(false, new KeyParameter(key)); return new CipherInputStream(inputStream, rc4); }
java
{ "resource": "" }
q17882
Rc4Utils.createRC4DropCipher
train
public static StreamCipher createRC4DropCipher(byte[] key, int drop) { checkArgument(key.length >= 5 && key.length <= 256); checkArgument(drop > 0); RC4Engine rc4Engine = new RC4Engine(); rc4Engine.init(true, new KeyParameter(key)); byte[] dropBytes = new byte[drop]; Arrays.fill(dropBytes, (byte) 0); rc4Engine.processBytes(dropBytes, 0, dropBytes.length, dropBytes, 0); return rc4Engine; }
java
{ "resource": "" }
q17883
xen_health_interface.get
train
public static xen_health_interface get(nitro_service client, xen_health_interface resource) throws Exception { resource.validate("get"); return ((xen_health_interface[]) resource.get_resources(client))[0]; }
java
{ "resource": "" }
q17884
FtpUploaderCommons.listFiles
train
private Map<String, Long> listFiles() throws FtpException { int attempts = 0; Map<String, Long> files = new LinkedHashMap<String, Long>(); while (true){ try { FTPListParseEngine engine = null; if (type.startsWith("UNIX")) { engine = ftpClient.initiateListParsing(FTPClientConfig.SYST_UNIX, null); } else { engine = ftpClient.initiateListParsing(); } FTPFile[] list = engine.getFiles(); if (list != null){ for (FTPFile ftpFile : list){ files.put(ftpFile.getName(), ftpFile.getSize()); } } return files; } catch (Exception e) { attempts++; if (attempts > 3) { throw new FtpListFilesException(e); } else { LOGGER.trace("First attempt to get list of files FAILED! attempt={}", attempts); } } } }
java
{ "resource": "" }
q17885
VictimsRecord.normalizeKey
train
public static String normalizeKey(Algorithms alg) { if (alg.equals(Algorithms.SHA512)) { return FieldName.SHA512; } return alg.toString().toLowerCase(); }
java
{ "resource": "" }
q17886
JsonRpcClientHandler.newProvisionalResponse
train
<O extends Message> JsonResponseFuture<O> newProvisionalResponse(ClientMethod<O> method) { long requestId = RANDOM.nextLong(); JsonResponseFuture<O> outputFuture = new JsonResponseFuture<>(requestId, method); inFlightRequests.put(requestId, outputFuture); return outputFuture; }
java
{ "resource": "" }
q17887
StringUtils.concat
train
public static String concat(String[] values, String delimiter) { Assert.notNull(values, "The array of String values to concatenate cannot be null!"); StringBuilder buffer = new StringBuilder(); for (String value : values) { buffer.append(buffer.length() > 0 ? delimiter : EMPTY_STRING); buffer.append(value); } return buffer.toString(); }
java
{ "resource": "" }
q17888
StringUtils.contains
train
@NullSafe public static boolean contains(String text, String value) { return text != null && value != null && text.contains(value); }
java
{ "resource": "" }
q17889
StringUtils.containsDigits
train
@NullSafe public static boolean containsDigits(String value) { for (char chr : toCharArray(value)) { if (Character.isDigit(chr)) { return true; } } return false; }
java
{ "resource": "" }
q17890
StringUtils.containsLetters
train
@NullSafe public static boolean containsLetters(String value) { for (char chr: toCharArray(value)) { if (Character.isLetter(chr)) { return true; } } return false; }
java
{ "resource": "" }
q17891
StringUtils.containsWhitespace
train
@NullSafe public static boolean containsWhitespace(String value) { for (char chr : toCharArray(value)) { if (Character.isWhitespace(chr)) { return true; } } return false; }
java
{ "resource": "" }
q17892
StringUtils.defaultIfBlank
train
@NullSafe public static String defaultIfBlank(String value, String... defaultValues) { if (isBlank(value)) { for (String defaultValue : defaultValues) { if (hasText(defaultValue)) { return defaultValue; } } } return value; }
java
{ "resource": "" }
q17893
StringUtils.equalsIgnoreCase
train
@NullSafe public static boolean equalsIgnoreCase(String stringOne, String stringTwo) { return stringOne != null && stringOne.equalsIgnoreCase(stringTwo); }
java
{ "resource": "" }
q17894
StringUtils.getDigits
train
public static String getDigits(String value) { StringBuilder digits = new StringBuilder(value.length()); for (char chr : value.toCharArray()) { if (Character.isDigit(chr)) { digits.append(chr); } } return digits.toString(); }
java
{ "resource": "" }
q17895
StringUtils.getLetters
train
public static String getLetters(String value) { StringBuilder letters = new StringBuilder(value.length()); for (char chr : value.toCharArray()) { if (Character.isLetter(chr)) { letters.append(chr); } } return letters.toString(); }
java
{ "resource": "" }
q17896
StringUtils.getSpaces
train
public static String getSpaces(int number) { Assert.argument(number >= 0, "The number [{0}] of desired spaces must be greater than equal to 0", number); StringBuilder spaces = new StringBuilder(Math.max(number, 0)); while (number > 0) { int count = Math.min(SPACES.length - 1, number); spaces.append(SPACES[count]); number -= count; } return spaces.toString(); }
java
{ "resource": "" }
q17897
StringUtils.indexOf
train
@NullSafe public static int indexOf(String text, String value) { return text != null && value != null ? text.indexOf(value) : -1; }
java
{ "resource": "" }
q17898
StringUtils.isDigits
train
@NullSafe public static boolean isDigits(String value) { for (char chr : toCharArray(value)) { if (!Character.isDigit(chr)) { return false; } } return hasText(value); }
java
{ "resource": "" }
q17899
StringUtils.isLetters
train
@NullSafe public static boolean isLetters(String value) { for (char chr : toCharArray(value)) { if (!Character.isLetter(chr)) { return false; } } return hasText(value); }
java
{ "resource": "" }