_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q159500
NettyConfigBuilderBase.setNiftyName
train
protected T setNiftyName(String niftyName) { Preconditions.checkNotNull(niftyName, "niftyName cannot be null"); this.niftyName = niftyName; return (T) this; }
java
{ "resource": "" }
q159501
ThriftServerDefBuilderBase.withProcessor
train
public T withProcessor(final NiftyProcessor processor) { this.niftyProcessorFactory = new NiftyProcessorFactory() { @Override public NiftyProcessor getProcessor(TTransport transport) { return processor; } }; return (T) this; ...
java
{ "resource": "" }
q159502
ThriftServerDefBuilderBase.build
train
public ThriftServerDef build() { checkState(niftyProcessorFactory != null || thriftProcessorFactory != null, "Processor not defined!"); checkState(niftyProcessorFactory == null || thriftProcessorFactory == null, "TProcessors will be automatically adapted to Nift...
java
{ "resource": "" }
q159503
PollingMultiFileWatcher.start
train
@Override public void start(Set<File> files, Consumer<Set<File>> callback) { if (isStarted()) { throw new IllegalStateException("start() should not be called more than once"); } Set<File> filesCopy = ImmutableSet.copyOf(files); Preconditions.checkArgument(filesCopy.size() > 0...
java
{ "resource": "" }
q159504
PollingMultiFileWatcher.shutdown
train
@Override public void shutdown() { if (isStarted()) { future.cancel(true); executorService.shutdown(); future = null; executorService = null; watchedFiles = ImmutableSet.of(); callback = null; metadataCacheRef.set(ImmutableMap.o...
java
{ "resource": "" }
q159505
PollingMultiFileWatcher.scanFilesForChanges
train
private void scanFilesForChanges() { MessageDigest digest; try { digest = MessageDigest.getInstance("SHA-256"); } catch (NoSuchAlgorithmException e) { // This should never happen, all JVM implementations must support SHA-256 according to Oracle docs. t...
java
{ "resource": "" }
q159506
PollingMultiFileWatcher.computeFileHash
train
private static String computeFileHash(File file, MessageDigest md) throws IOException { md.reset(); return BaseEncoding.base16().encode(md.digest(Files.toByteArray(file))); }
java
{ "resource": "" }
q159507
CryptoUtil.extract
train
private static byte[] extract(byte[] salt, byte[] inputKeyingMaterial) { return initHmacSha256(salt == null ? NULL_SALT : salt).doFinal(inputKeyingMaterial); }
java
{ "resource": "" }
q159508
TNiftyClientTransport.read
train
private int read(byte[] bytes, int offset, int length, Duration receiveTimeout) throws InterruptedException, TTransportException { long timeRemaining = receiveTimeout.roundTo(TimeUnit.NANOSECONDS); lock.lock(); try { while (!closed) { int bytesAvailabl...
java
{ "resource": "" }
q159509
TChannelBufferOutputTransport.resetOutputBuffer
train
public void resetOutputBuffer() { int shrunkenSize = shrinkBufferSize(); if (outputBuffer.writerIndex() < shrunkenSize) { // Less than the shrunken size of the buffer was actually used, so increment // the under-use counter ++bufferUnderUsedCounter; } ...
java
{ "resource": "" }
q159510
TicketSeedFileParser.parse
train
public List<SessionTicketKey> parse(File file) throws IOException { return parseBytes(Files.toByteArray(file)); }
java
{ "resource": "" }
q159511
TicketSeedFileParser.parseBytes
train
public List<SessionTicketKey> parseBytes(byte[] json) throws IOException { List<String> allSeeds = TicketSeeds.parseFromJSONBytes(json, objectMapper).getAllSeeds(); return allSeeds.stream().map(this::deriveKeyFromSeed).collect(Collectors.toList()); }
java
{ "resource": "" }
q159512
SslPlaintextHandler.looksLikeTLS
train
private static boolean looksLikeTLS(ChannelBuffer buffer) { // TLS starts as // 0: 0x16 - handshake protocol magic // 1: 0x03 - SSL version major // 2: 0x00 to 0x03 - SSL version minor (SSLv3 or TLS1.0 through TLS1.2) // 3-4: length (2 bytes) // 5: 0x01 - handshake type (...
java
{ "resource": "" }
q159513
TInputOutputCompositeTransport.read
train
@Override public int read(byte[] buf, int off, int len) throws TTransportException { return inputTransport.read(buf, off, len); }
java
{ "resource": "" }
q159514
AnnotationProperties.putArrayValues
train
public void putArrayValues(String name, Set<String> values) { arrayValues.put(name, values); }
java
{ "resource": "" }
q159515
PrefabValues.giveTuple
train
public <T> Tuple<T> giveTuple(TypeTag tag) { realizeCacheFor(tag, emptyStack()); return cache.getTuple(tag); }
java
{ "resource": "" }
q159516
PrefabValues.giveOther
train
public <T> T giveOther(TypeTag tag, T value) { Class<T> type = tag.getType(); if (value != null && !type.isAssignableFrom(value.getClass()) && !wraps(type, value.getClass())) { throw new ReflectionException("TypeTag does not match value."); } Tuple<T> tuple = giveTuple(tag);...
java
{ "resource": "" }
q159517
PrefabValues.realizeCacheFor
train
public <T> void realizeCacheFor(TypeTag tag, LinkedHashSet<TypeTag> typeStack) { if (!cache.contains(tag)) { Tuple<T> tuple = createTuple(tag, typeStack); addToCache(tag, tuple); } }
java
{ "resource": "" }
q159518
FactoryCache.put
train
public <T> void put(Class<?> type, PrefabValueFactory<T> factory) { if (type != null) { cache.put(type.getName(), factory); } }
java
{ "resource": "" }
q159519
FactoryCache.put
train
public <T> void put(String typeName, PrefabValueFactory<T> factory) { if (typeName != null) { cache.put(typeName, factory); } }
java
{ "resource": "" }
q159520
FactoryCache.get
train
@SuppressWarnings("unchecked") public <T> PrefabValueFactory<T> get(Class<T> type) { if (type == null) { return null; } return (PrefabValueFactory<T>)cache.get(type.getName()); }
java
{ "resource": "" }
q159521
FactoryCache.iterator
train
@Override public Iterator<Map.Entry<String, PrefabValueFactory<?>>> iterator() { return cache.entrySet().iterator(); }
java
{ "resource": "" }
q159522
ListBuilders.buildListOfAtLeastOne
train
@SafeVarargs public static <T> List<T> buildListOfAtLeastOne(T first, T... more) { if (first == null) { throw new IllegalArgumentException("First example is null."); } List<T> result = new ArrayList<>(); result.add(first); addArrayElementsToList(result, more); ...
java
{ "resource": "" }
q159523
ListBuilders.buildListOfAtLeastTwo
train
@SafeVarargs public static <T> List<T> buildListOfAtLeastTwo(T first, T second, T... more) { if (first == null) { throw new IllegalArgumentException("First example is null."); } if (second == null) { throw new IllegalArgumentException("Second example is null."); ...
java
{ "resource": "" }
q159524
ListBuilders.listContainsDuplicates
train
public static <T> boolean listContainsDuplicates(List<T> list) { return list.size() != new HashSet<>(list).size(); }
java
{ "resource": "" }
q159525
Assert.assertEquals
train
public static void assertEquals(Formatter message, Object expected, Object actual) { if (!expected.equals(actual)) { throw new AssertionException(message); } }
java
{ "resource": "" }
q159526
Instantiator.instantiateAnonymousSubclass
train
public T instantiateAnonymousSubclass() { Class<T> proxyClass = giveDynamicSubclass(type); return objenesis.newInstance(proxyClass); }
java
{ "resource": "" }
q159527
Util.classForName
train
@SuppressWarnings("unchecked") public static <T> Class<T> classForName(String className) { try { return (Class<T>)Class.forName(className); } catch (ClassNotFoundException | VerifyError e) { // Catching VerifyError fixes issue #147. I don't know how to unit test it. ...
java
{ "resource": "" }
q159528
Util.objects
train
public static Object[] objects(Object first, Object second, Object third) { return new Object[] { first, second, third }; }
java
{ "resource": "" }
q159529
Util.setOf
train
@SafeVarargs public static <T> Set<T> setOf(T... ts) { return new HashSet<>(Arrays.asList(ts)); }
java
{ "resource": "" }
q159530
Cache.put
train
public <T> void put(TypeTag tag, T red, T black, T redCopy) { cache.put(tag, new Tuple<>(red, black, redCopy)); }
java
{ "resource": "" }
q159531
ConfiguredEqualsVerifier.forClass
train
public <T> EqualsVerifierApi<T> forClass(Class<T> type) { return new EqualsVerifierApi<>(type, EnumSet.copyOf(warningsToSuppress), factoryCache, usingGetClass); }
java
{ "resource": "" }
q159532
ObjectAccessor.copy
train
public T copy() { T copy = Instantiator.of(type).instantiate(); return copyInto(copy); }
java
{ "resource": "" }
q159533
ObjectAccessor.copyIntoSubclass
train
public <S extends T> S copyIntoSubclass(Class<S> subclass) { S copy = Instantiator.of(subclass).instantiate(); return copyInto(copy); }
java
{ "resource": "" }
q159534
ObjectAccessor.copyIntoAnonymousSubclass
train
public T copyIntoAnonymousSubclass() { T copy = Instantiator.of(type).instantiateAnonymousSubclass(); return copyInto(copy); }
java
{ "resource": "" }
q159535
ObjectAccessor.scramble
train
public void scramble(PrefabValues prefabValues, TypeTag enclosingType) { for (Field field : FieldIterable.of(type)) { FieldAccessor accessor = new FieldAccessor(object, field); accessor.changeField(prefabValues, enclosingType); } }
java
{ "resource": "" }
q159536
ObjectAccessor.shallowScramble
train
public void shallowScramble(PrefabValues prefabValues, TypeTag enclosingType) { for (Field field : FieldIterable.ofIgnoringSuper(type)) { FieldAccessor accessor = new FieldAccessor(object, field); accessor.changeField(prefabValues, enclosingType); } }
java
{ "resource": "" }
q159537
NonnullAnnotationVerifier.fieldIsNonnull
train
public static boolean fieldIsNonnull(Field field, AnnotationCache annotationCache) { Class<?> type = field.getDeclaringClass(); if (annotationCache.hasFieldAnnotation(type, field.getName(), NONNULL)) { return true; } if (annotationCache.hasFieldAnnotation(type, field.getName(...
java
{ "resource": "" }
q159538
ClassAccessor.declaresField
train
public boolean declaresField(Field field) { try { type.getDeclaredField(field.getName()); return true; } catch (NoSuchFieldException e) { return false; } }
java
{ "resource": "" }
q159539
ConditionalInstantiator.instantiate
train
@SuppressFBWarnings(value = "DP_DO_INSIDE_DO_PRIVILEGED", justification = "EV is run only from within unit tests") public <T> T instantiate(Class<?>[] paramTypes, Object[] paramValues) { try { Class<T> type = resolve(); if (type == null) { return null; } ...
java
{ "resource": "" }
q159540
ConditionalInstantiator.callFactory
train
public <T> T callFactory(String factoryMethod, Class<?>[] paramTypes, Object[] paramValues) { return callFactory(fullyQualifiedClassName, factoryMethod, paramTypes, paramValues); }
java
{ "resource": "" }
q159541
ConditionalInstantiator.callFactory
train
@SuppressFBWarnings(value = "DP_DO_INSIDE_DO_PRIVILEGED", justification = "EV is run only from within unit tests") @SuppressWarnings("unchecked") public <T> T callFactory(String factoryTypeName, String factoryMethod, Class<?>[] paramTypes, Object[] paramValues) { try { Class<T> type = resolv...
java
{ "resource": "" }
q159542
ConditionalInstantiator.returnConstant
train
@SuppressFBWarnings(value = "DP_DO_INSIDE_DO_PRIVILEGED", justification = "EV is run only from within unit tests") @SuppressWarnings("unchecked") public <T> T returnConstant(String constantName) { try { Class<T> type = resolve(); if (type == null) { return null; ...
java
{ "resource": "" }
q159543
Tuple.of
train
@SuppressWarnings("unchecked") public static <U> Tuple<U> of(Object red, Object black, Object redCopy) { return new Tuple<>((U)red, (U)black, (U)redCopy); }
java
{ "resource": "" }
q159544
SuperclassIterable.of
train
public static <T> SuperclassIterable<T> of(Class<T> type) { return new SuperclassIterable<>(type, false); }
java
{ "resource": "" }
q159545
SuperclassIterable.ofIncludeSelf
train
public static <T> SuperclassIterable<T> ofIncludeSelf(Class<T> type) { return new SuperclassIterable<>(type, true); }
java
{ "resource": "" }
q159546
EqualsVerifier.forRelaxedEqualExamples
train
@SafeVarargs public static <T> RelaxedEqualsVerifierApi<T> forRelaxedEqualExamples(T first, T second, T... more) { List<T> examples = ListBuilders.buildListOfAtLeastTwo(first, second, more); @SuppressWarnings("unchecked") Class<T> type = (Class<T>)first.getClass(); return new Relax...
java
{ "resource": "" }
q159547
FieldAccessor.get
train
@SuppressFBWarnings(value = "DP_DO_INSIDE_DO_PRIVILEGED", justification = "Only called in test code, not production.") public Object get() { field.setAccessible(true); try { return field.get(object); } catch (IllegalAccessException e) { throw new ReflectionExc...
java
{ "resource": "" }
q159548
FieldAccessor.copyTo
train
public void copyTo(Object to) { modify(() -> field.set(to, field.get(object)), false); }
java
{ "resource": "" }
q159549
FieldAccessor.changeField
train
public void changeField(PrefabValues prefabValues, TypeTag enclosingType) { modify(() -> { Object newValue = prefabValues.giveOther(TypeTag.of(field, enclosingType), field.get(object)); field.set(object, newValue); }, false); }
java
{ "resource": "" }
q159550
FieldAccessor.canBeModifiedReflectively
train
public boolean canBeModifiedReflectively() { if (field.isSynthetic()) { return false; } int modifiers = field.getModifiers(); if (Modifier.isFinal(modifiers) && Modifier.isStatic(modifiers)) { return false; } return true; }
java
{ "resource": "" }
q159551
EqualsVerifierApi.withIgnoredAnnotations
train
public EqualsVerifierApi<T> withIgnoredAnnotations(Class<?>... annotations) { Validations.validateGivenAnnotations(annotations); for (Class<?> ignoredAnnotation : annotations) { ignoredAnnotationClassNames.add(ignoredAnnotation.getCanonicalName()); } return this; }
java
{ "resource": "" }
q159552
Formatter.format
train
public String format() { String result = message; for (Object object : objects) { String s = result.replaceFirst("%%", Matcher.quoteReplacement(stringify(object))); if (result.equals(s)) { throw new IllegalStateException("Too many parameters"); } ...
java
{ "resource": "" }
q159553
InjectionUtil.callConstructor
train
public static <T> T callConstructor(Class<T> targetClass, Class[] argClasses, Object[] args) { T output; try { Constructor classConstructor = targetClass.getDeclaredConstructor(argClasses); output = AccessController.doPrivileged( new SetConstructorPrivileged...
java
{ "resource": "" }
q159554
MapsUtil.initialHashMapCapacity
train
public static int initialHashMapCapacity(int expectedSize) { if (expectedSize < 0) { throw new ParcelerRuntimeException("Expected size must be non-negative"); } if (expectedSize < 3) { return expectedSize + 1; } if (expectedSize < MAX_POWER_OF_TWO) { ...
java
{ "resource": "" }
q159555
RestHandlerExceptionResolverBuilder.defaultContentType
train
public RestHandlerExceptionResolverBuilder defaultContentType(String mediaType) { defaultContentType( hasText(mediaType) ? MediaType.parseMediaType(mediaType) : null ); return this; }
java
{ "resource": "" }
q159556
RestHandlerExceptionResolverBuilder.addHandler
train
public <E extends Exception> RestHandlerExceptionResolverBuilder addHandler( Class<? extends E> exceptionClass, RestExceptionHandler<E, ?> exceptionHandler) { exceptionHandlers.put(exceptionClass, exceptionHandler); return this; }
java
{ "resource": "" }
q159557
Ghprb.getSkipBuildPhrases
train
public Set<String> getSkipBuildPhrases() { return new HashSet<String>(Arrays.asList(getTrigger().getSkipBuildPhrase().split("[\\r\\n]+"))); }
java
{ "resource": "" }
q159558
Ghprb.checkBlackListCommitAuthor
train
public String checkBlackListCommitAuthor(String author) { Set<String> authors = getBlacklistedCommitAuthors(); authors.remove(""); Map<Pattern, String> skipPatterns = new HashMap<Pattern, String>(); for (String s : authors) { s = s.trim(); if (compilePattern(s).m...
java
{ "resource": "" }
q159559
Ghprb.checkSkipBuildPhrase
train
public String checkSkipBuildPhrase(GHIssue issue) { Set<String> skipBuildPhrases = getSkipBuildPhrases(); skipBuildPhrases.remove(""); Map<Pattern, String> skipPatterns = new HashMap<Pattern, String>(); for (String skipBuildPhrase : skipBuildPhrases) { skipBuildPhrase = skip...
java
{ "resource": "" }
q159560
Ghprb.checkSkipBuildInString
train
private String checkSkipBuildInString(Map<Pattern, String> patterns, String string) { // check for skip build phrase in the passed string if (!patterns.isEmpty() && StringUtils.isNotBlank(string)) { for (Map.Entry<Pattern, String> e : patterns.entrySet()) { if (e.getKey().mat...
java
{ "resource": "" }
q159561
GhprbUpstreamStatusListener.returnEnvironmentVars
train
private Map<String, String> returnEnvironmentVars(AbstractBuild<?, ?> build, TaskListener listener) { Map<String, String> envVars = Ghprb.getEnvVars(build, listener); if (!envVars.containsKey("ghprbUpstreamStatus")) { return null; } GhprbGitHubAuth auth = GhprbTrigger.getDs...
java
{ "resource": "" }
q159562
GhprbUpstreamStatusListener.setUpEnvironment
train
@Override public Environment setUpEnvironment(@SuppressWarnings("rawtypes") AbstractBuild build, Launcher launcher, BuildListener listener) { Map<String, String> envVars = returnEnvironmentVars(build, listener); if (envVars != null) { LOGGER.log(Level.FINE, "Job: " + build.getFullDisplay...
java
{ "resource": "" }
q159563
GhprbUpstreamStatusListener.onCompleted
train
@Override public void onCompleted(AbstractBuild<?, ?> build, TaskListener listener) { Map<String, String> envVars = returnEnvironmentVars(build, listener); if (envVars == null) { return; } try { returnGhprbSimpleStatus(envVars).onBuildComplete(build, listener...
java
{ "resource": "" }
q159564
BuildFlowBuildManager.calculateBuildUrl
train
@SuppressWarnings("unchecked") @Override public String calculateBuildUrl(String publishedURL) { Iterator<JobInvocation> iterator = (Iterator<JobInvocation>) downstreamProjects(); StringBuilder sb = new StringBuilder(); while (iterator.hasNext()) { JobInvocation jobInvocatio...
java
{ "resource": "" }
q159565
BuildFlowBuildManager.downstreamProjects
train
@Override public Iterator<?> downstreamProjects() { FlowRun flowRun = (FlowRun) build; DirectedGraph<JobInvocation, FlowRun.JobEdge> directedGraph = flowRun.getJobsGraph(); return directedGraph.vertexSet().iterator(); }
java
{ "resource": "" }
q159566
GhprbExtensionContext.commitStatus
train
void commitStatus(Runnable closure) { GhprbSimpleStatusContext context = new GhprbSimpleStatusContext(); ContextExtensionPoint.executeInContext(closure, context); extensions.add(new GhprbSimpleStatus( context.showMatrixStatus, context.context, con...
java
{ "resource": "" }
q159567
GhprbExtensionContext.buildStatus
train
void buildStatus(Runnable closure) { GhprbBuildStatusContext context = new GhprbBuildStatusContext(); ContextExtensionPoint.executeInContext(closure, context); extensions.add(new GhprbBuildStatus(context.getCompletedStatus())); }
java
{ "resource": "" }
q159568
GhprbExtensionContext.commentFilePath
train
void commentFilePath(Runnable closure) { GhprbCommentFilePathContext context = new GhprbCommentFilePathContext(); ContextExtensionPoint.executeInContext(closure, context); extensions.add(new GhprbCommentFile(context.getCommentFilePath())); }
java
{ "resource": "" }
q159569
GhprbExtensionContext.cancelBuildsOnUpdate
train
void cancelBuildsOnUpdate(Runnable closure) { GhprbCancelBuildsOnUpdateContext context = new GhprbCancelBuildsOnUpdateContext(); ContextExtensionPoint.executeInContext(closure, context); extensions.add(new GhprbCancelBuildsOnUpdate(context.getOverrideGlobal())); }
java
{ "resource": "" }
q159570
GhprbUpstreamStatus.makeBuildVariables
train
@Override public void makeBuildVariables(@SuppressWarnings("rawtypes") AbstractBuild build, Map<String, String> variables) { variables.put("ghprbShowMatrixStatus", Boolean.toString(getShowMatrixStatus())); variables.put("ghprbUpstreamStatus", "true"); variables.put("ghprbCommitStatusContext"...
java
{ "resource": "" }
q159571
GhprbExtensionDescriptor.getExtensions
train
private static List<GhprbExtensionDescriptor> getExtensions() { List<GhprbExtensionDescriptor> list = new ArrayList<GhprbExtensionDescriptor>(); list.addAll(getExtensionList()); return list; }
java
{ "resource": "" }
q159572
GhprbTriggerContext.whiteListTargetBranches
train
public void whiteListTargetBranches(Iterable<String> branches) { for (String branch : branches) { whiteListTargetBranches.add(new GhprbBranch(branch)); } }
java
{ "resource": "" }
q159573
GhprbTriggerContext.blackListTargetBranches
train
public void blackListTargetBranches(Iterable<String> branches) { for (String branch : branches) { blackListTargetBranches.add(new GhprbBranch(branch)); } }
java
{ "resource": "" }
q159574
GhprbPullRequest.setUpdated
train
private boolean setUpdated(Date lastUpdateTime) { // Because there is no gaurantee of order of delivery, // we want to ensure that we do not set the updated time if it was // earlier than the current updated time if (updated == null || updated.compareTo(lastUpdateTime) < 0) { ...
java
{ "resource": "" }
q159575
GhprbPullRequest.containsComment
train
private boolean containsComment(GHPullRequest ghPullRequest, String expectedBody) { List<GHIssueComment> prComments; try { prComments = ghPullRequest.getComments(); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to get comments for PR " + ghPullRequest, e); ...
java
{ "resource": "" }
q159576
GhprbPullRequest.check
train
public void check(GHPullRequest ghpr, boolean isWebhook) { if (helper.isProjectDisabled()) { LOGGER.log(Level.FINE, "Project is disabled, ignoring pull request"); return; } // Call update PR with the update PR info and no comment updatePR(ghpr, null /*GHIssueComme...
java
{ "resource": "" }
q159577
GhprbPullRequest.isAllowedTargetBranch
train
public boolean isAllowedTargetBranch() { List<GhprbBranch> whiteListBranches = helper.getWhiteListTargetBranches(); List<GhprbBranch> blackListBranches = helper.getBlackListTargetBranches(); String target = getTarget(); // First check if it matches any whitelist branch. It matches if ...
java
{ "resource": "" }
q159578
GhprbPullRequest.checkCommit
train
private boolean checkCommit(GHPullRequest pr) { GHCommitPointer head = pr.getHead(); GHCommitPointer base = pr.getBase(); String headSha = head.getSha(); String baseSha = base.getSha(); if (StringUtils.equals(headSha, this.head) && StringUtils.equals(baseSha, this.base)) { ...
java
{ "resource": "" }
q159579
GhprbPullRequest.getPullRequest
train
public GHPullRequest getPullRequest(boolean force) throws IOException { if (this.pr == null || force) { setPullRequest(repo.getActualPullRequest(this.id)); } return pr; }
java
{ "resource": "" }
q159580
GhprbPullRequest.getAuthorEmail
train
public String getAuthorEmail() { if (StringUtils.isEmpty(authorEmail)) { try { GHUser user = getPullRequestAuthor(); authorEmail = user.getEmail(); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Unable to fetch author info for " + id);...
java
{ "resource": "" }
q159581
OptionHandlerRegistry.initHandlers
train
private void initHandlers() { registerHandler(Boolean.class,BooleanOptionHandler.class); registerHandler(boolean.class,BooleanOptionHandler.class); registerHandler(File.class,FileOptionHandler.class); registerHandler(URL.class, URLOptionHandler.class); registerHandler(URI.class, ...
java
{ "resource": "" }
q159582
OptionHandlerRegistry.getConstructor
train
private static Constructor<? extends OptionHandler> getConstructor(Class<? extends OptionHandler> handlerClass) { try { return handlerClass.getConstructor(CmdLineParser.class, OptionDef.class, Setter.class); } catch (NoSuchMethodException e) { throw new IllegalArgumentException(M...
java
{ "resource": "" }
q159583
MapOptionHandler.addToMap
train
protected void addToMap(String argument, Map m) throws CmdLineException { if (String.valueOf(argument).indexOf('=') == -1) { throw new CmdLineException(owner,Messages.FORMAT_ERROR_FOR_MAP); } String mapKey; String mapValue; //Splitting off the key from the value int idx = argument.indexO...
java
{ "resource": "" }
q159584
MapOptionHandler.addToMap
train
protected void addToMap(Map m, String key, String value) { m.put(key,value); }
java
{ "resource": "" }
q159585
ArrayFieldSetter.trySetDefault
train
private void trySetDefault(Object bean1) throws IllegalAccessError { try { doSetDefault(bean1); } catch (IllegalAccessException ex) { try { // try again f.setAccessible(true); doSetDefault(bean1); }catch (IllegalAccessEx...
java
{ "resource": "" }
q159586
CmdLineParser.printExample
train
public String printExample(OptionHandlerFilter mode, ResourceBundle rb) { StringBuilder buf = new StringBuilder(); checkNonNull(mode, "mode"); for (OptionHandler h : options) { OptionDef option = h.option; if(option.usage().length()==0) continue; // ignore ...
java
{ "resource": "" }
q159587
CmdLineParser.printOption
train
protected void printOption(PrintWriter out, OptionHandler handler, int len, ResourceBundle rb, OptionHandlerFilter filter) { // Hiding options without usage information if (handler.option.usage() == null || handler.option.usage().length() == 0 || !filter.select(handler)) { return...
java
{ "resource": "" }
q159588
CmdLineParser.wrapLines
train
private List<String> wrapLines(String line, final int maxLength) { List<String> rv = new ArrayList<String>(); for (String restOfLine : line.split("\\n")) { while (restOfLine.length() > maxLength) { // try to wrap at space, but don't try too hard as some languages don't even have...
java
{ "resource": "" }
q159589
CmdLineParser.parseArgument
train
public void parseArgument(final String... args) throws CmdLineException { checkNonNull(args, "args"); String expandedArgs[] = args; if (parserProperties.getAtSyntax()) { expandedArgs = expandAtFiles(args); } CmdLineImpl cmdLine = new CmdLineImpl(expa...
java
{ "resource": "" }
q159590
CmdLineParser.expandAtFiles
train
private String[] expandAtFiles(String args[]) throws CmdLineException { List<String> result = new ArrayList<String>(); for (String arg : args) { if (arg.startsWith("@")) { File file = new File(arg.substring(1)); if (!file.exists()) throw ne...
java
{ "resource": "" }
q159591
CmdLineParser.readAllLines
train
private static List<String> readAllLines(File f) throws IOException { BufferedReader r = new BufferedReader(new FileReader(f)); try { List<String> result = new ArrayList<String>(); String line; while ((line = r.readLine()) != null) { result.add(line); ...
java
{ "resource": "" }
q159592
Config.parse
train
public static Config parse(InputSource xml) throws IOException, SAXException { Config rv = new Config(); XMLReader reader = XMLReaderFactory.createXMLReader(); ConfigHandler handler = rv.new ConfigHandler(rv); reader.setContentHandler(handler); reader.parse(xml); return rv; }
java
{ "resource": "" }
q159593
MultimediaObject.getInfo
train
public MultimediaInfo getInfo() throws InputFormatException, EncoderException { if (inputFile.canRead()) { FFMPEGExecutor ffmpeg = locator.createExecutor(); ffmpeg.addArgument("-i"); ffmpeg.addArgument(inputFile.getAbsolutePath()); try ...
java
{ "resource": "" }
q159594
ScreenExtractor.render
train
public void render(MultimediaObject multimediaObject, int width, int height, int seconds, File outputDir, String fileNamePrefix, String extension, int quality) throws InputFormatException, EncoderException { File inputFile = multimediaObject.getFile(); try { i...
java
{ "resource": "" }
q159595
ScreenExtractor.render
train
public void render(MultimediaObject multimediaObject, int width, int height, int seconds, File target, int quality) throws EncoderException { File inputFile = multimediaObject.getFile(); target = target.getAbsoluteFile(); target.getParentFile().mkdirs(); try { ...
java
{ "resource": "" }
q159596
Encoder.getCoders
train
protected String[] getCoders(boolean encoder, boolean audio) throws EncoderException { ArrayList<String> res = new ArrayList<>(); FFMPEGExecutor localFFMPEG = locator.createExecutor(); localFFMPEG.addArgument(encoder ? "-encoders" : "-decoders"); try { localFFMPEG.exe...
java
{ "resource": "" }
q159597
FFMPEGExecutor.execute
train
public void execute() throws IOException { int argsSize = args.size(); String[] cmd = new String[argsSize + 2]; cmd[0] = ffmpegExecutablePath; for (int i = 0; i < argsSize; i++) { cmd[i + 1] = args.get(i); } cmd[argsSize + 1] = "-hide_banner"; // Don'...
java
{ "resource": "" }
q159598
FFMPEGExecutor.destroy
train
public void destroy() { if (inputStream != null) { try { inputStream.close(); } catch (Throwable t) { LOG.warn("Error closing input stream", t); } inputStream = null; } if (outputStrea...
java
{ "resource": "" }
q159599
FFMPEGExecutor.getProcessExitCode
train
public int getProcessExitCode() { // Make sure it's terminated try { ffmpeg.waitFor(); } catch (InterruptedException ex) { LOG.warn("Interrupted during waiting on process, forced shutdown?", ex); } return ffmpeg.exitValue(); ...
java
{ "resource": "" }