_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q15100
VariableNames.toEnvironmentVariableName
train
public static String toEnvironmentVariableName(String bootiqueVariable) { if (Strings.isNullOrEmpty(bootiqueVariable)) { return null; } final StringBuilder name = new StringBuilder(); final Pattern pattern = Pattern.compile("((?:[a-z0_9_]+)|(?:[A-Z]+[^A-Z]*))"); //$NON-NLS-1$ for (final String component : bootiqueVariable.split("[^a-zA-Z0_9_]+")) { //$NON-NLS-1$ final Matcher matcher = pattern.matcher(component); while (matcher.find()) { final String word = matcher.group(1); if (name.length() > 0) { name.append("_"); //$NON-NLS-1$ } name.append(word.toUpperCase()); } } return name.toString(); }
java
{ "resource": "" }
q15101
WatchDir.processEvent
train
void processEvent(DelayQueue<Delayed> delayQueue) { // wait for key to be signaled WatchKey key; try { key = watcher.poll(250, TimeUnit.MILLISECONDS); } catch (InterruptedException | ClosedWatchServiceException x) { return; } if(key == null) { return; } Path dir = keys.get(key); if (dir == null) { return; } for (WatchEvent<?> event : key.pollEvents()) { WatchEvent.Kind<?> kind = event.kind(); if (kind == OVERFLOW) { continue; } // Context for directory entry event is the file name of entry @SuppressWarnings("unchecked") WatchEvent<Path> ev = (WatchEvent<Path>) event; Path name = ev.context(); Path child = dir.resolve(name); // if (ignore.contains(child)) { return; } if (!ignorePattern.stream().anyMatch( m -> child.getFileSystem().getPathMatcher(m).matches(child.getFileName()))) { delayQueue.add(new WatchDirDelay()); } // if directory is created, and watching recursively, then // register it and its sub-directories if (kind == ENTRY_CREATE) { try { if (Files.isDirectory(child, NOFOLLOW_LINKS)) { registerAll(child); } } catch (IOException x) { } } } // reset key and remove from set if directory no longer accessible boolean valid = key.reset(); if (!valid) { keys.remove(key); // all directories are inaccessible if (keys.isEmpty()) { return; } } }
java
{ "resource": "" }
q15102
ImageExtensions.concatenateImages
train
public static BufferedImage concatenateImages(final List<BufferedImage> imgCollection, final int width, final int height, final int imageType, final Direction concatenationDirection) { final BufferedImage img = new BufferedImage(width, height, imageType); int x = 0; int y = 0; for (final BufferedImage bi : imgCollection) { final boolean imageDrawn = img.createGraphics().drawImage(bi, x, y, null); if (!imageDrawn) { throw new RuntimeException("BufferedImage could not be drawn:" + bi.toString()); } if (concatenationDirection.equals(Direction.vertical)) { y += bi.getHeight(); } else { x += bi.getWidth(); } } return img; }
java
{ "resource": "" }
q15103
ImageExtensions.createPdf
train
public static void createPdf(final OutputStream result, final List<BufferedImage> images) throws DocumentException, IOException { final Document document = new Document(); PdfWriter.getInstance(document, result); for (final BufferedImage image : images) { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(image, "png", baos); final Image img = Image.getInstance(baos.toByteArray()); document.setPageSize(img); document.newPage(); img.setAbsolutePosition(0, 0); document.add(img); } document.close(); }
java
{ "resource": "" }
q15104
ImageExtensions.resize
train
public static byte[] resize(final BufferedImage originalImage, final Method scalingMethod, final Mode resizeMode, final String formatName, final int targetWidth, final int targetHeight) { try { final BufferedImage resizedImage = Scalr.resize(originalImage, scalingMethod, resizeMode, targetWidth, targetHeight); return toByteArray(resizedImage, formatName); } catch (final Exception e) { return null; } }
java
{ "resource": "" }
q15105
ImageExtensions.resize
train
public static byte[] resize(final BufferedImage originalImage, final String formatName, final int targetWidth, final int targetHeight) { return resize(originalImage, Scalr.Method.QUALITY, Scalr.Mode.FIT_EXACT, formatName, targetWidth, targetHeight); }
java
{ "resource": "" }
q15106
ImageExtensions.toByteArray
train
public static byte[] toByteArray(final BufferedImage bi, final String formatName) throws IOException { try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { ImageIO.write(bi, formatName, baos); baos.flush(); final byte[] byteArray = baos.toByteArray(); return byteArray; } }
java
{ "resource": "" }
q15107
AbstractGISTreeSetNode.calcBounds
train
@Pure protected Rectangle2d calcBounds() { final Rectangle2d bb = new Rectangle2d(); boolean first = true; Rectangle2afp<?, ?, ?, ?, ?, ?> b; // Child bounds N child; for (int i = 0; i < getChildCount(); ++i) { child = getChildAt(i); if (child != null) { b = child.getBounds(); if (b != null) { if (first) { first = false; bb.setFromCorners( b.getMinX(), b.getMinY(), b.getMaxX(), b.getMaxY()); } else { bb.setUnion(b); } } } } // Data bounds P primitive; GeoLocation location; for (int i = 0; i < getUserDataCount(); ++i) { primitive = getUserDataAt(i); if (primitive != null) { location = primitive.getGeoLocation(); if (location != null) { b = location.toBounds2D(); if (b != null) { if (first) { first = false; bb.setFromCorners( b.getMinX(), b.getMinY(), b.getMaxX(), b.getMaxY()); } else { bb.setUnion(b); } } } } } return first ? null : bb; }
java
{ "resource": "" }
q15108
AbstractGISElement.setContainer
train
public boolean setContainer(C container) { this.mapContainer = container == null ? null : new WeakReference<>(container); return true; }
java
{ "resource": "" }
q15109
AbstractGISElement.getTopContainer
train
@Pure public Object getTopContainer() { if (this.mapContainer == null) { return null; } final C container = this.mapContainer.get(); if (container == null) { return null; } if (container instanceof GISContentElement<?>) { return ((GISContentElement<?>) container).getTopContainer(); } return container; }
java
{ "resource": "" }
q15110
AbstractGISElement.getUUID
train
@Override @Pure public UUID getUUID() { if (this.uid == null) { this.uid = UUID.randomUUID(); } return this.uid; }
java
{ "resource": "" }
q15111
XMLBusNetworkUtil.writeBusNetwork
train
@SuppressWarnings("checkstyle:npathcomplexity") public static Node writeBusNetwork(BusNetwork busNetwork, XMLBuilder builder, XMLResources resources) throws IOException { final Element element = builder.createElement(NODE_BUSNETWORK); writeGISElementAttributes(element, busNetwork, builder, resources); final Integer color = busNetwork.getRawColor(); if (color != null) { element.setAttribute(ATTR_COLOR, toColor(color)); } final Element stopsNode = builder.createElement(NODE_BUSSTOPS); for (final BusStop stop : busNetwork.busStops()) { final Node stopNode = writeBusStop(stop, builder, resources); if (stopNode != null) { stopsNode.appendChild(stopNode); } } if (stopsNode.getChildNodes().getLength() > 0) { element.appendChild(stopsNode); } final Element hubsNode = builder.createElement(NODE_BUSHUBS); for (final BusHub hub : busNetwork.busHubs()) { final Node hubNode = writeBusHub(hub, builder, resources); if (hubNode != null) { hubsNode.appendChild(hubNode); } } if (hubsNode.getChildNodes().getLength() > 0) { element.appendChild(hubsNode); } final Element linesNode = builder.createElement(NODE_BUSLINES); for (final BusLine line : busNetwork.busLines()) { final Node lineNode = writeBusLine(line, builder, resources); if (lineNode != null) { linesNode.appendChild(lineNode); } } if (linesNode.getChildNodes().getLength() > 0) { element.appendChild(linesNode); } return element; }
java
{ "resource": "" }
q15112
XMLBusNetworkUtil.readBusNetwork
train
public static BusNetwork readBusNetwork(Element xmlNode, RoadNetwork roadNetwork, PathBuilder pathBuilder, XMLResources resources) throws IOException { final UUID id = getAttributeUUID(xmlNode, NODE_BUSNETWORK, ATTR_ID); final BusNetwork busNetwork = new BusNetwork(id, roadNetwork); final Node stopsNode = getNodeFromPath(xmlNode, NODE_BUSNETWORK, NODE_BUSSTOPS); if (stopsNode != null) { for (final Element stopNode : getElementsFromPath(stopsNode, NODE_BUSSTOP)) { final BusStop stop = readBusStop(stopNode, pathBuilder, resources); if (stop != null) { busNetwork.addBusStop(stop); } } } final Node hubsNode = getNodeFromPath(xmlNode, NODE_BUSNETWORK, NODE_BUSHUBS); if (hubsNode != null) { for (final Element hubNode : getElementsFromPath(hubsNode, NODE_BUSHUB)) { readBusHub(hubNode, busNetwork, pathBuilder, resources); } } final Node linesNode = getNodeFromPath(xmlNode, NODE_BUSNETWORK, NODE_BUSLINES); if (linesNode != null) { BusLine line; for (final Element lineNode : getElementsFromPath(linesNode, NODE_BUSLINE)) { line = readBusLine(lineNode, busNetwork, roadNetwork, pathBuilder, resources); if (line != null) { busNetwork.addBusLine(line); } } } readGISElementAttributes(xmlNode, busNetwork, pathBuilder, resources); final Integer color = getAttributeColorWithDefault(xmlNode, null, ATTR_COLOR); if (color != null) { busNetwork.setColor(color); } // Force the validity checking to be sure // that all the primitives are valid or not busNetwork.revalidate(); return busNetwork; }
java
{ "resource": "" }
q15113
LittleEndianDataInputStream.readBELong
train
public long readBELong() throws IOException { return EndianNumbers.toBELong(read(), read(), read(), read(), read(), read(), read(), read()); }
java
{ "resource": "" }
q15114
LittleEndianDataInputStream.readLELong
train
public long readLELong() throws IOException { return EndianNumbers.toLELong(read(), read(), read(), read(), read(), read(), read(), read()); }
java
{ "resource": "" }
q15115
Drawers.getAllDrawers
train
@SuppressWarnings("unchecked") @Pure public static Iterator<Drawer<?>> getAllDrawers() { if (services == null) { services = ServiceLoader.load(Drawer.class); } return services.iterator(); }
java
{ "resource": "" }
q15116
Drawers.getDrawerFor
train
@SuppressWarnings("unchecked") @Pure public static <T> Drawer<T> getDrawerFor(Class<? extends T> type) { assert type != null : AssertMessages.notNullParameter(); final Drawer<?> bufferedType = buffer.get(type); Drawer<T> defaultChoice = null; if (bufferedType != null) { defaultChoice = (Drawer<T>) bufferedType; } else { final Iterator<Drawer<?>> iterator = getAllDrawers(); while (iterator.hasNext()) { final Drawer<?> drawer = iterator.next(); final Class<?> drawerType = drawer.getPrimitiveType(); if (drawerType.equals(type)) { defaultChoice = (Drawer<T>) drawer; break; } else if (drawerType.isAssignableFrom(type) && (defaultChoice == null || drawerType.isAssignableFrom(defaultChoice.getPrimitiveType()))) { defaultChoice = (Drawer<T>) drawer; } } if (defaultChoice != null) { buffer.put(type, defaultChoice); } } return defaultChoice; }
java
{ "resource": "" }
q15117
RoundRectangle2dfx.arcWidthProperty
train
public DoubleProperty arcWidthProperty() { if (this.arcWidth == null) { this.arcWidth = new DependentSimpleDoubleProperty<ReadOnlyDoubleProperty>( this, MathFXAttributeNames.ARC_WIDTH, widthProperty()) { @Override protected void invalidated(ReadOnlyDoubleProperty dependency) { final double value = get(); if (value < 0.) { set(0.); } else { final double maxArcWidth = dependency.get() / 2.; if (value > maxArcWidth) { set(maxArcWidth); } } } }; } return this.arcWidth; }
java
{ "resource": "" }
q15118
RoundRectangle2dfx.arcHeightProperty
train
public DoubleProperty arcHeightProperty() { if (this.arcHeight == null) { this.arcHeight = new DependentSimpleDoubleProperty<ReadOnlyDoubleProperty>( this, MathFXAttributeNames.ARC_HEIGHT, heightProperty()) { @Override protected void invalidated(ReadOnlyDoubleProperty dependency) { final double value = get(); if (value < 0.) { set(0.); } else { final double maxArcHeight = dependency.get() / 2.; if (value > maxArcHeight) { set(maxArcHeight); } } } }; } return this.arcHeight; }
java
{ "resource": "" }
q15119
GeoId.toBounds2D
train
@Pure public Rectangle2d toBounds2D() { int startIndex = this.id.indexOf('#'); if (startIndex <= 0) { return null; } try { int endIndex = this.id.indexOf(';', startIndex); if (endIndex <= startIndex) { return null; } final long minx = Long.parseLong(this.id.substring(startIndex + 1, endIndex)); startIndex = endIndex + 1; endIndex = this.id.indexOf(';', startIndex); if (endIndex <= startIndex) { return null; } final long miny = Long.parseLong(this.id.substring(startIndex, endIndex)); startIndex = endIndex + 1; endIndex = this.id.indexOf(';', startIndex); if (endIndex <= startIndex) { return null; } final long maxx = Long.parseLong(this.id.substring(startIndex, endIndex)); startIndex = endIndex + 1; final long maxy = Long.parseLong(this.id.substring(startIndex)); final Rectangle2d r = new Rectangle2d(); r.setFromCorners(minx, miny, maxx, maxy); return r; } catch (Throwable exception) { // } return null; }
java
{ "resource": "" }
q15120
GeoId.getInternalId
train
@Pure public String getInternalId() { final int endIndex = this.id.indexOf('#'); if (endIndex <= 0) { return null; } return this.id.substring(0, endIndex); }
java
{ "resource": "" }
q15121
Reactor.checkSessionTimeout
train
private final long checkSessionTimeout() { long nextTimeout = 0; if (configuration.getCheckSessionTimeoutInterval() > 0) { gate.lock(); try { if (selectTries * 1000 >= configuration .getCheckSessionTimeoutInterval()) { nextTimeout = configuration .getCheckSessionTimeoutInterval(); for (SelectionKey key : selector.keys()) { if (key.attachment() != null) { long n = checkExpiredIdle(key, getSessionFromAttchment(key)); nextTimeout = n < nextTimeout ? n : nextTimeout; } } selectTries = 0; } } finally { gate.unlock(); } } return nextTimeout; }
java
{ "resource": "" }
q15122
Vector1d.convert
train
public static Vector1d convert(Tuple1d<?> tuple) { if (tuple instanceof Vector1d) { return (Vector1d) tuple; } return new Vector1d(tuple.getSegment(), tuple.getX(), tuple.getY()); }
java
{ "resource": "" }
q15123
AbstractArakhneMojo.getContributorURL
train
protected static URL getContributorURL(Contributor contributor, Log log) { URL url = null; if (contributor != null) { String rawUrl = contributor.getUrl(); if (rawUrl != null && !EMPTY_STRING.equals(rawUrl)) { try { url = new URL(rawUrl); } catch (Throwable exception) { url = null; } } if (url == null) { rawUrl = contributor.getEmail(); if (rawUrl != null && !EMPTY_STRING.equals(rawUrl)) { try { url = new URL("mailto:" + rawUrl); //$NON-NLS-1$ } catch (Throwable exception) { url = null; } } } } return url; }
java
{ "resource": "" }
q15124
AbstractArakhneMojo.dirCopy
train
public final void dirCopy(File in, File out, boolean skipHiddenFiles) throws IOException { assert in != null; assert out != null; getLog().debug(in.toString() + "->" + out.toString()); //$NON-NLS-1$ getLog().debug("Ignore hidden files: " + skipHiddenFiles); //$NON-NLS-1$ out.mkdirs(); final LinkedList<File> candidates = new LinkedList<>(); candidates.add(in); File[] children; while (!candidates.isEmpty()) { final File f = candidates.removeFirst(); getLog().debug("Scanning: " + f); //$NON-NLS-1$ if (f.isDirectory()) { children = f.listFiles(); if (children != null && children.length > 0) { // Non empty directory for (final File c : children) { if (!skipHiddenFiles || !c.isHidden()) { getLog().debug("Discovering: " + c); //$NON-NLS-1$ candidates.add(c); } } } } else { // not a directory final File targetFile = toOutput(in, f, out); targetFile.getParentFile().mkdirs(); fileCopy(f, targetFile); } } }
java
{ "resource": "" }
q15125
AbstractArakhneMojo.dirRemove
train
public final void dirRemove(File dir) throws IOException { if (dir != null) { getLog().debug("Deleting tree: " + dir.toString()); //$NON-NLS-1$ final LinkedList<File> candidates = new LinkedList<>(); candidates.add(dir); File[] children; final BuildContext buildContext = getBuildContext(); while (!candidates.isEmpty()) { final File f = candidates.getFirst(); getLog().debug("Scanning: " + f); //$NON-NLS-1$ if (f.isDirectory()) { children = f.listFiles(); if (children != null && children.length > 0) { // Non empty directory for (final File c : children) { getLog().debug("Discovering: " + c); //$NON-NLS-1$ candidates.push(c); } } else { // empty directory getLog().debug("Deleting: " + f); //$NON-NLS-1$ candidates.removeFirst(); f.delete(); buildContext.refresh(f.getParentFile()); } } else { // not a directory candidates.removeFirst(); if (f.exists()) { getLog().debug("Deleting: " + f); //$NON-NLS-1$ f.delete(); buildContext.refresh(f.getParentFile()); } } } getLog().debug("Deletion done"); //$NON-NLS-1$ } }
java
{ "resource": "" }
q15126
AbstractArakhneMojo.getLString
train
public static final String getLString(Class<?> source, String label, Object... params) { final ResourceBundle rb = ResourceBundle.getBundle(source.getCanonicalName()); String text = rb.getString(label); text = text.replaceAll("[\\n\\r]", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ text = text.replaceAll("\\t", "\t"); //$NON-NLS-1$ //$NON-NLS-2$ text = MessageFormat.format(text, params); return text; }
java
{ "resource": "" }
q15127
AbstractArakhneMojo.removePathPrefix
train
public static final String removePathPrefix(File prefix, File file) { final String r = file.getAbsolutePath().replaceFirst( "^" //$NON-NLS-1$ + Pattern.quote(prefix.getAbsolutePath()), EMPTY_STRING); if (r.startsWith(File.separator)) { return r.substring(File.separator.length()); } return r; }
java
{ "resource": "" }
q15128
AbstractArakhneMojo.searchArtifact
train
public final synchronized ExtendedArtifact searchArtifact(File file) { final String filename = removePathPrefix(getBaseDirectory(), file); getLog().debug("Retreiving module for " + filename); //$NON-NLS-1$ File theFile = file; File pomDirectory = null; while (theFile != null && pomDirectory == null) { if (theFile.isDirectory()) { final File pomFile = new File(theFile, "pom.xml"); //$NON-NLS-1$ if (pomFile.exists()) { pomDirectory = theFile; } } theFile = theFile.getParentFile(); } if (pomDirectory != null) { ExtendedArtifact a = this.localArtifactDescriptions.get(pomDirectory); if (a == null) { a = readPom(pomDirectory); this.localArtifactDescriptions.put(pomDirectory, a); getLog().debug("Found local module description for " //$NON-NLS-1$ + a.toString()); } return a; } final BuildContext buildContext = getBuildContext(); buildContext.addMessage(file, 1, 1, "The maven module for this file cannot be retreived.", //$NON-NLS-1$ BuildContext.SEVERITY_WARNING, null); return null; }
java
{ "resource": "" }
q15129
AbstractArakhneMojo.resolveArtifact
train
public final Artifact resolveArtifact(Artifact mavenArtifact) throws MojoExecutionException { final org.eclipse.aether.artifact.Artifact aetherArtifact = createArtifact(mavenArtifact); final ArtifactRequest request = new ArtifactRequest(); request.setArtifact(aetherArtifact); request.setRepositories(getRemoteRepositoryList()); final ArtifactResult result; try { result = getRepositorySystem().resolveArtifact(getRepositorySystemSession(), request); } catch (ArtifactResolutionException e) { throw new MojoExecutionException(e.getMessage(), e); } return createArtifact(result.getArtifact()); }
java
{ "resource": "" }
q15130
AbstractArakhneMojo.resolveArtifact
train
public final Artifact resolveArtifact(String groupId, String artifactId, String version) throws MojoExecutionException { return resolveArtifact(createArtifact(groupId, artifactId, version)); }
java
{ "resource": "" }
q15131
AbstractArakhneMojo.createArtifact
train
public final Artifact createArtifact(String groupId, String artifactId, String version) { return createArtifact(groupId, artifactId, version, "runtime", "jar"); //$NON-NLS-1$ //$NON-NLS-2$ }
java
{ "resource": "" }
q15132
AbstractArakhneMojo.createArtifact
train
protected static final org.eclipse.aether.artifact.Artifact createArtifact(Artifact artifact) { return new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifact.getType(), artifact.getVersion()); }
java
{ "resource": "" }
q15133
AbstractArakhneMojo.createArtifact
train
protected final Artifact createArtifact(org.eclipse.aether.artifact.Artifact artifact) { return createArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()); }
java
{ "resource": "" }
q15134
AbstractArakhneMojo.createArtifact
train
public final Artifact createArtifact(String groupId, String artifactId, String version, String scope, String type) { VersionRange versionRange = null; if (version != null) { versionRange = VersionRange.createFromVersion(version); } String desiredScope = scope; if (Artifact.SCOPE_TEST.equals(desiredScope)) { desiredScope = Artifact.SCOPE_TEST; } if (Artifact.SCOPE_PROVIDED.equals(desiredScope)) { desiredScope = Artifact.SCOPE_PROVIDED; } if (Artifact.SCOPE_SYSTEM.equals(desiredScope)) { // system scopes come through unchanged... desiredScope = Artifact.SCOPE_SYSTEM; } final ArtifactHandler handler = getArtifactHandlerManager().getArtifactHandler(type); return new org.apache.maven.artifact.DefaultArtifact( groupId, artifactId, versionRange, desiredScope, type, null, handler, false); }
java
{ "resource": "" }
q15135
AbstractArakhneMojo.assertNotNull
train
protected final void assertNotNull(String message, Object obj) { if (getLog().isDebugEnabled()) { getLog().debug( "\t(" //$NON-NLS-1$ + getLogType(obj) + ") " //$NON-NLS-1$ + message + " = " //$NON-NLS-1$ + obj); } if (obj == null) { throw new AssertionError("assertNotNull: " + message); //$NON-NLS-1$ } }
java
{ "resource": "" }
q15136
AbstractArakhneMojo.join
train
public static String join(String joint, String... values) { final StringBuilder b = new StringBuilder(); for (final String value : values) { if (value != null && !EMPTY_STRING.equals(value)) { if (b.length() > 0) { b.append(joint); } b.append(value); } } return b.toString(); }
java
{ "resource": "" }
q15137
AbstractArakhneMojo.getMavenProject
train
public MavenProject getMavenProject(Artifact artifact) { try { final MavenSession session = getMavenSession(); final MavenProject current = session.getCurrentProject(); final MavenProject prj = getMavenProjectBuilder().buildFromRepository( artifact, current.getRemoteArtifactRepositories(), session.getLocalRepository()); return prj; } catch (ProjectBuildingException e) { getLog().warn(e); } return null; }
java
{ "resource": "" }
q15138
GraphIterator.getNextSegments
train
@SuppressWarnings("checkstyle:nestedifdepth") protected final List<GraphIterationElement<ST, PT>> getNextSegments(boolean avoid_visited_segments, GraphIterationElement<ST, PT> element) { assert this.allowManyReplies || this.visited != null; if (element != null) { final ST segment = element.getSegment(); final PT point = element.getPoint(); if ((segment != null) && (point != null)) { final PT pts = segment.getOtherSidePoint(point); if (pts != null) { final double distanceToReach = element.getDistanceToReachSegment() + segment.getLength(); GraphIterationElement<ST, PT> candidate; final double restToConsume = element.distanceToConsume - segment.getLength(); final List<GraphIterationElement<ST, PT>> list = new ArrayList<>(); for (final ST theSegment : pts.getConnectedSegmentsStartingFrom(segment)) { if (!theSegment.equals(segment)) { candidate = newIterationElement( segment, theSegment, pts, distanceToReach, restToConsume); if ((this.allowManyReplies) || (!avoid_visited_segments) || (!this.visited.contains(candidate))) { list.add(candidate); } } } return list; } } } throw new NoSuchElementException(); }
java
{ "resource": "" }
q15139
GraphIterator.nextElement
train
public final GraphIterationElement<ST, PT> nextElement() { if (!this.courseModel.isEmpty()) { final GraphIterationElement<ST, PT> theElement = this.courseModel.removeNextIterationElement(); if (theElement != null) { final List<GraphIterationElement<ST, PT>> list = getNextSegments(true, theElement); final Iterator<GraphIterationElement<ST, PT>> iterator; boolean hasFollowingSegments = false; GraphIterationElement<ST, PT> elt; if (this.courseModel.isReversedRestitution()) { iterator = new ReverseIterator<>(list); } else { iterator = list.iterator(); } while (iterator.hasNext()) { elt = iterator.next(); if (canGotoIntoElement(elt)) { hasFollowingSegments = true; this.courseModel.addIterationElement(elt); if (!this.allowManyReplies) { this.visited.add(elt); } } } theElement.setTerminalSegment(!hasFollowingSegments); theElement.replied = true; this.current = theElement; return this.current; } } clear(); throw new NoSuchElementException(); }
java
{ "resource": "" }
q15140
GraphIterator.newIterationElement
train
protected GraphIterationElement<ST, PT> newIterationElement( ST previous_segment, ST segment, PT point, double distanceToReach, double distanceToConsume) { return new GraphIterationElement<>( previous_segment, segment, point, distanceToReach, distanceToConsume); }
java
{ "resource": "" }
q15141
GraphIterator.ignoreElementsAfter
train
public void ignoreElementsAfter(GraphIterationElement<ST, PT> element) { final List<GraphIterationElement<ST, PT>> nexts = getNextSegments(false, element); this.courseModel.removeIterationElements(nexts); }
java
{ "resource": "" }
q15142
AbstractGenericTreeNode.removeChild
train
@Override public void removeChild(final ITreeNode<T> child) { if (children != null) { children.remove(child); } else { children = new ArrayList<>(); } }
java
{ "resource": "" }
q15143
XMLGISElementUtil.getDefaultMapElementNodeName
train
public static String getDefaultMapElementNodeName(Class<? extends MapElement> type) { if (MapPolyline.class.isAssignableFrom(type)) { return NODE_POLYLINE; } if (MapPoint.class.isAssignableFrom(type)) { return NODE_POINT; } if (MapPolygon.class.isAssignableFrom(type)) { return NODE_POLYGON; } if (MapCircle.class.isAssignableFrom(type)) { return NODE_CIRCLE; } if (MapMultiPoint.class.isAssignableFrom(type)) { return NODE_MULTIPOINT; } return null; }
java
{ "resource": "" }
q15144
XMLGISElementUtil.writeGISElementAttributes
train
public static void writeGISElementAttributes(Element element, GISElement primitive, XMLBuilder builder, XMLResources resources) throws IOException { XMLAttributeUtil.writeAttributeContainer(element, primitive, builder, resources, false); element.setAttribute(XMLUtil.ATTR_NAME, primitive.getName()); element.setAttribute(XMLAttributeUtil.ATTR_GEOID, primitive.getGeoId().toString()); element.setAttribute(XMLUtil.ATTR_ID, primitive.getUUID().toString()); }
java
{ "resource": "" }
q15145
XMLGISElementUtil.readGISElementAttributes
train
public static void readGISElementAttributes(Element element, GISElement primitive, PathBuilder pathBuilder, XMLResources resources) throws IOException { XMLAttributeUtil.readAttributeContainer(element, primitive, pathBuilder, resources, false); primitive.setName(XMLUtil.getAttributeValueWithDefault(element, null, XMLUtil.ATTR_NAME)); }
java
{ "resource": "" }
q15146
MultimapAlignment.alignedToRightItem
train
@SuppressWarnings("unchecked") @Override public Set<LeftT> alignedToRightItem(final Object rightItem) { if (rightToLeft.containsKey(rightItem)) { return rightToLeft.get((RightT)rightItem); } else { return ImmutableSet.of(); } }
java
{ "resource": "" }
q15147
MultimapAlignment.alignedToLeftItem
train
@SuppressWarnings("unchecked") @Override public Set<RightT> alignedToLeftItem(final Object leftItem) { if (leftToRight.containsKey(leftItem)) { return leftToRight.get((LeftT)leftItem); } else { return ImmutableSet.of(); } }
java
{ "resource": "" }
q15148
FileUtils.ensureParentDirectoryExists
train
public static void ensureParentDirectoryExists(File f) throws IOException { final File parent = f.getParentFile(); if (parent != null) { java.nio.file.Files.createDirectories(parent.toPath()); } }
java
{ "resource": "" }
q15149
FileUtils.loadFileList
train
public static ImmutableList<File> loadFileList(final Iterable<String> fileNames) throws IOException { final ImmutableList.Builder<File> ret = ImmutableList.builder(); for (String filename : fileNames) { if (!filename.isEmpty()) { ret.add(new File(filename.trim())); } } return ret.build(); }
java
{ "resource": "" }
q15150
FileUtils.writeFileList
train
public static void writeFileList(Iterable<File> files, CharSink sink) throws IOException { writeUnixLines(FluentIterable.from(files) .transform(toAbsolutePathFunction()), sink); }
java
{ "resource": "" }
q15151
FileUtils.writeSymbolToFileMap
train
public static void writeSymbolToFileMap(Map<Symbol, File> symbolToFileMap, CharSink sink) throws IOException { writeSymbolToFileEntries(symbolToFileMap.entrySet(), sink); }
java
{ "resource": "" }
q15152
FileUtils.writeSymbolToFileEntries
train
public static void writeSymbolToFileEntries(final Iterable<Map.Entry<Symbol, File>> entries, final CharSink sink) throws IOException { writeUnixLines( transform( MapUtils.transformValues(entries, toAbsolutePathFunction()), TO_TAB_SEPARATED_ENTRY), sink); }
java
{ "resource": "" }
q15153
FileUtils.writeIntegerToStart
train
public static void writeIntegerToStart(final File f, final int num) throws IOException { final RandomAccessFile fixupFile = new RandomAccessFile(f, "rw"); fixupFile.writeInt(num); fixupFile.close(); }
java
{ "resource": "" }
q15154
FileUtils.siblingDirectory
train
public static File siblingDirectory(final File f, final String siblingDirName) { checkNotNull(f); checkNotNull(siblingDirName); checkArgument(!siblingDirName.isEmpty()); final File parent = f.getParentFile(); if (parent != null) { return new File(parent, siblingDirName); } else { throw new RuntimeException(String .format("Cannot create sibling directory %s of %s because the latter has no parent.", siblingDirName, f)); } }
java
{ "resource": "" }
q15155
FileUtils.endsWithPredicate
train
public static Predicate<File> endsWithPredicate(final String suffix) { checkArgument(!suffix.isEmpty()); return new EndsWithPredicate(suffix); }
java
{ "resource": "" }
q15156
FileUtils.isDirectoryPredicate
train
public static Predicate<File> isDirectoryPredicate() { return new Predicate<File>() { @Override public boolean apply(final File input) { return input.isDirectory(); } }; }
java
{ "resource": "" }
q15157
FileUtils.toLinesFunction
train
public static Function<File, Iterable<String>> toLinesFunction(final Charset charset) { return new Function<File, Iterable<String>>() { @Override public Iterable<String> apply(final File input) { try { return Files.readLines(input, charset); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException(e); } } }; }
java
{ "resource": "" }
q15158
FileUtils.recursivelyDeleteDirectory
train
public static void recursivelyDeleteDirectory(File directory) throws IOException { if (!directory.exists()) { return; } checkArgument(directory.isDirectory(), "Cannot recursively delete a non-directory"); walkFileTree(directory.toPath(), new DeletionFileVisitor()); }
java
{ "resource": "" }
q15159
FileUtils.recursivelyCopyDirectory
train
public static void recursivelyCopyDirectory(final File sourceDir, final File destDir, final StandardCopyOption copyOption) throws IOException { checkNotNull(sourceDir); checkNotNull(destDir); checkArgument(sourceDir.isDirectory(), "Source directory does not exist"); java.nio.file.Files.createDirectories(destDir.toPath()); walkFileTree(sourceDir.toPath(), new CopyFileVisitor(sourceDir.toPath(), destDir.toPath(), copyOption)); }
java
{ "resource": "" }
q15160
FileUtils.loadSymbolMultimap
train
@Deprecated public static ImmutableMultimap<Symbol, Symbol> loadSymbolMultimap(File multimapFile) throws IOException { return loadSymbolMultimap(Files.asCharSource(multimapFile, Charsets.UTF_8)); }
java
{ "resource": "" }
q15161
ESRIFileUtil.toESRI_x
train
@Pure public static double toESRI_x(double x) throws IOException { if (Double.isInfinite(x) || Double.isNaN(x)) { throw new InvalidNumericValueException(x); } return x; }
java
{ "resource": "" }
q15162
ESRIFileUtil.fromESRI_x
train
@Pure public static double fromESRI_x(double x) throws IOException { if (Double.isInfinite(x) || Double.isNaN(x)) { throw new InvalidNumericValueException(x); } return x; }
java
{ "resource": "" }
q15163
ESRIFileUtil.toESRI_y
train
@Pure public static double toESRI_y(double y) throws IOException { if (Double.isInfinite(y) || Double.isNaN(y)) { throw new InvalidNumericValueException(y); } return y; }
java
{ "resource": "" }
q15164
ESRIFileUtil.fromESRI_y
train
@Pure public static double fromESRI_y(double y) throws IOException { if (Double.isInfinite(y) || Double.isNaN(y)) { throw new InvalidNumericValueException(y); } return y; }
java
{ "resource": "" }
q15165
ESRIFileUtil.toESRI_z
train
@Pure public static double toESRI_z(double z) { if (Double.isInfinite(z) || Double.isNaN(z)) { return ESRI_NAN; } return z; }
java
{ "resource": "" }
q15166
ESRIFileUtil.toESRI_m
train
@Pure public static double toESRI_m(double measure) { if (Double.isInfinite(measure) || Double.isNaN(measure)) { return ESRI_NAN; } return measure; }
java
{ "resource": "" }
q15167
MenuExtensions.setAccelerator
train
public static void setAccelerator(final JMenuItem jmi, final Character keyChar, final int modifiers) { jmi.setAccelerator(KeyStroke.getKeyStroke(keyChar, modifiers)); }
java
{ "resource": "" }
q15168
MenuExtensions.setAccelerator
train
public static void setAccelerator(final JMenuItem jmi, final int keyCode, final int modifiers) { jmi.setAccelerator(KeyStroke.getKeyStroke(keyCode, modifiers)); }
java
{ "resource": "" }
q15169
MenuExtensions.setAccelerator
train
public static void setAccelerator(final JMenuItem jmi, final String parsableKeystrokeString) { jmi.setAccelerator(KeyStroke.getKeyStroke(parsableKeystrokeString)); }
java
{ "resource": "" }
q15170
Base64Coder.decode
train
@Pure @Inline(value = "Base64Coder.decode(($1).toCharArray())", imported = {Base64Coder.class}) public static byte[] decode(String string) { return decode(string.toCharArray()); }
java
{ "resource": "" }
q15171
ClassLoaderFinder.setPreferredClassLoader
train
public static void setPreferredClassLoader(ClassLoader classLoader) { if (classLoader != dynamicLoader) { dynamicLoader = classLoader; final Thread[] threads = new Thread[Thread.activeCount()]; Thread.enumerate(threads); for (final Thread t : threads) { if (t != null) { t.setContextClassLoader(classLoader); } } } }
java
{ "resource": "" }
q15172
ClassLoaderFinder.popPreferredClassLoader
train
public static void popPreferredClassLoader() { final ClassLoader sysLoader = ClassLoaderFinder.class.getClassLoader(); if ((dynamicLoader == null) || (dynamicLoader == sysLoader)) { dynamicLoader = null; final Thread[] threads = new Thread[Thread.activeCount()]; Thread.enumerate(threads); for (final Thread t : threads) { if (t != null) { t.setContextClassLoader(sysLoader); } } return; } final ClassLoader parent = dynamicLoader.getParent(); dynamicLoader = (parent == sysLoader) ? null : parent; final Thread[] threads = new Thread[Thread.activeCount()]; Thread.enumerate(threads); for (final Thread t : threads) { if (t != null) { t.setContextClassLoader(parent); } } }
java
{ "resource": "" }
q15173
ProgressionUtil.isMinValue
train
public static boolean isMinValue(Progression model) { if (model != null) { return model.getValue() <= model.getMinimum(); } return true; }
java
{ "resource": "" }
q15174
AbstractMapMultiPointDrawer.defineSmallRectangles
train
protected void defineSmallRectangles(ZoomableGraphicsContext gc, T element) { final double ptsSize = element.getPointSize() / 2.; final Rectangle2afp<?, ?, ?, ?, ?, ?> visibleArea = gc.getVisibleArea(); for (final Point2d point : element.points()) { if (visibleArea.contains(point)) { final double x = point.getX() - ptsSize; final double y = point.getY() - ptsSize; final double mx = point.getX() + ptsSize; final double my = point.getY() + ptsSize; gc.moveTo(x, y); gc.lineTo(mx, y); gc.lineTo(mx, my); gc.lineTo(x, my); gc.closePath(); } } }
java
{ "resource": "" }
q15175
Point1dfx.convert
train
public static Point1dfx convert(Tuple1dfx<?> tuple) { if (tuple instanceof Point1dfx) { return (Point1dfx) tuple; } return new Point1dfx(tuple.getSegment(), tuple.getX(), tuple.getY()); }
java
{ "resource": "" }
q15176
CoreNLPSentence.offsets
train
public OffsetRange<CharOffset> offsets() { final CharOffset start = tokens.get(0).offsets().startInclusive(); final CharOffset end = tokens.reverse().get(0).offsets().endInclusive(); return OffsetRange.charOffsetRange(start.asInt(), end.asInt()); }
java
{ "resource": "" }
q15177
DssatControllerInput.readFile
train
@Override public HashMap readFile(String arg0) { HashMap brMap; try { brMap = getBufferReader(arg0); } catch (FileNotFoundException fe) { LOG.warn("File not found under following path : [" + arg0 + "]!"); return new HashMap(); } catch (IOException e) { LOG.error(Functions.getStackTrace(e)); return new HashMap(); } return read(brMap); }
java
{ "resource": "" }
q15178
DssatControllerInput.readFile
train
public HashMap readFile(List<File> files) { HashMap brMap; try { brMap = getBufferReader(files); } catch (IOException e) { LOG.error(Functions.getStackTrace(e)); return new HashMap(); } return read(brMap); }
java
{ "resource": "" }
q15179
DssatControllerInput.readFileFromCRAFT
train
public HashMap readFileFromCRAFT(String arg0) { HashMap brMap; try { File dir = new File(arg0); // Data frin CRAFT with DSSAT format if (dir.isDirectory()) { List<File> files = new ArrayList(); for (File f : dir.listFiles()) { String name = f.getName().toUpperCase(); // XFile folder if (name.equals("FILEX")) { for (File exp : f.listFiles()) { if (exp.isFile()) { String expName = exp.getName().toUpperCase(); if (expName.matches(".+\\.\\w{2}X")) { files.add(exp); } } } } // Weather folder else if (name.equals("WEATHER")) { for (File wth : f.listFiles()) { if (wth.isFile()) { String wthName = wth.getName().toUpperCase(); if (wthName.endsWith(".WTH")) { files.add(wth); } } } } // Soil file else if (f.isFile() && name.endsWith(".SOL")) { files.add(f); } } brMap = getBufferReader(files); } else { LOG.error("You need to provide the CRAFT working folder used for generating DSSAT files."); return new HashMap(); } } catch (IOException e) { LOG.error(Functions.getStackTrace(e)); return new HashMap(); } return read(brMap); }
java
{ "resource": "" }
q15180
BufferedMagicNumberStream.ensureBuffer
train
private int ensureBuffer(int offset, int length) throws IOException { final int lastPos = offset + length - 1; final int desiredSize = ((lastPos / BUFFER_SIZE) + 1) * BUFFER_SIZE; final int currentSize = this.buffer.length; if (desiredSize > currentSize) { final byte[] readBuffer = new byte[desiredSize - currentSize]; final int count = this.in.read(readBuffer); if (count > 0) { final byte[] newBuffer = new byte[currentSize + count]; System.arraycopy(this.buffer, 0, newBuffer, 0, currentSize); System.arraycopy(readBuffer, 0, newBuffer, currentSize, count); this.buffer = newBuffer; } return (lastPos < this.buffer.length) ? length : length - (lastPos - this.buffer.length + 1); } return length; }
java
{ "resource": "" }
q15181
BufferedMagicNumberStream.read
train
public byte[] read(int offset, int length) throws IOException { if (ensureBuffer(offset, length) >= length) { final byte[] array = new byte[length]; System.arraycopy(this.buffer, offset, array, 0, length); this.pos = offset + length; return array; } throw new EOFException(); }
java
{ "resource": "" }
q15182
BufferedMagicNumberStream.read
train
public byte read(int offset) throws IOException { if (ensureBuffer(offset, 1) > 0) { this.pos = offset + 1; return this.buffer[offset]; } throw new EOFException(); }
java
{ "resource": "" }
q15183
Parameters.getString
train
public String getString(final String param) { checkNotNull(param); checkArgument(!param.isEmpty()); final String ret = params.get(param); observeWithListeners(param); if (ret != null) { return ret; } else { throw new MissingRequiredParameter(fullString(param)); } }
java
{ "resource": "" }
q15184
Parameters.getMapped
train
public <T> T getMapped(final String param, final Map<String, T> possibleValues) { checkNotNull(possibleValues); checkArgument(!possibleValues.isEmpty()); final String value = getString(param); final T ret = possibleValues.get(value); if (ret == null) { throw new InvalidEnumeratedPropertyException(fullString(param), value, possibleValues.keySet()); } return ret; }
java
{ "resource": "" }
q15185
Parameters.getExistingFile
train
public File getExistingFile(final String param) { return get(param, getFileConverter(), new And<>(new FileExists(), new IsFile()), "existing file"); }
java
{ "resource": "" }
q15186
Parameters.getAndMakeDirectory
train
public File getAndMakeDirectory(final String param) { final File f = get(param, new StringToFile(), new AlwaysValid<File>(), "existing or creatable directory"); if (f.exists()) { if (f.isDirectory()) { return f.getAbsoluteFile(); } else { throw new ParameterValidationException(fullString(param), f .getAbsolutePath().toString(), new ValidationException("Not an existing or creatable directory")); } } else { f.getAbsoluteFile().mkdirs(); return f.getAbsoluteFile(); } }
java
{ "resource": "" }
q15187
Parameters.getExistingDirectory
train
public File getExistingDirectory(final String param) { return get(param, new StringToFile(), new And<>(new FileExists(), new IsDirectory()), "existing directory"); }
java
{ "resource": "" }
q15188
Parameters.getStringSet
train
public Set<String> getStringSet(final String param) { return get(param, new StringToStringSet(","), new AlwaysValid<Set<String>>(), "comma-separated list of strings"); }
java
{ "resource": "" }
q15189
Parameters.getSymbolSet
train
public Set<Symbol> getSymbolSet(final String param) { return get(param, new StringToSymbolSet(","), new AlwaysValid<Set<Symbol>>(), "comma-separated list of strings"); }
java
{ "resource": "" }
q15190
Parameters.assertAtLeastOneDefined
train
public void assertAtLeastOneDefined(final String param1, final String param2) { if (!isPresent(param1) && !isPresent(param2)) { throw new ParameterException( String.format("At least one of %s and %s must be defined.", param1, param2)); } }
java
{ "resource": "" }
q15191
Parameters.assertAtLeastOneDefined
train
public void assertAtLeastOneDefined(final String param1, final String... moreParams) { if (!isPresent(param1)) { for (final String moreParam : moreParams) { if (isPresent(moreParam)) { return; } } final List<String> paramsForError = Lists.newArrayList(); paramsForError.add(param1); paramsForError.addAll(Arrays.asList(moreParams)); throw new ParameterException( String.format("At least one of %s must be defined.", StringUtils.CommaSpaceJoiner.join(paramsForError))); } }
java
{ "resource": "" }
q15192
ShufflingIterable.iterator
train
@Override public Iterator<T> iterator() { final List<T> shuffledList = Lists.newArrayList(data); Collections.shuffle(shuffledList, rng); return Collections.unmodifiableList(shuffledList).iterator(); }
java
{ "resource": "" }
q15193
DssatBatchFileOutput.writeFile
train
@Override public void writeFile(String arg0, Map result) { // Initial variables BufferedWriter bwB; // output object StringBuilder sbData = new StringBuilder(); // construct the data info in the output try { // Set default value for missing data setDefVal(); // Get version number if (dssatVerStr == null) { dssatVerStr = getObjectOr(result, "crop_model_version", "").replaceAll("\\D", ""); if (!dssatVerStr.matches("\\d+")) { dssatVerStr = DssatVersion.DSSAT45.toString(); } } // Initial BufferedWriter arg0 = revisePath(arg0); outputFile = new File(arg0 + "DSSBatch.v" + dssatVerStr); bwB = new BufferedWriter(new FileWriter(outputFile)); // Output Batch File // Titel Section String crop = getCropName(result); String dssatPath = "C:\\DSSAT" + dssatVerStr + "\\"; String exFileName = getFileName(result, "X"); int expNo = 1; // Write title section sbData.append("$BATCH(").append(crop).append(")\r\n!\r\n"); sbData.append(String.format("! Command Line : %1$sDSCSM0%2$s.EXE B DSSBatch.v%2$s\r\n", dssatPath, dssatVerStr)); sbData.append("! Crop : ").append(crop).append("\r\n"); sbData.append("! Experiment : ").append(exFileName).append("\r\n"); sbData.append("! ExpNo : ").append(expNo).append("\r\n"); sbData.append(String.format("! Debug : %1$sDSCSM0%2$s.EXE \" B DSSBatch.v%2$s\"\r\n!\r\n", dssatPath, dssatVerStr)); // Body Section sbData.append("@FILEX TRTNO RP SQ OP CO\r\n"); // Get DSSAT Sequence info HashMap dssatSeqData = getObjectOr(result, "dssat_sequence", new HashMap()); ArrayList<HashMap> dssatSeqArr = getObjectOr(dssatSeqData, "data", new ArrayList<HashMap>()); // If missing, set default value if (dssatSeqArr.isEmpty()) { HashMap tmp = new HashMap(); tmp.put("sq", "1"); tmp.put("op", "1"); tmp.put("co", "0"); dssatSeqArr.add(tmp); } // Output all info for (HashMap dssatSeqSubData : dssatSeqArr) { sbData.append(String.format("%1$-92s %2$6s %3$6s %4$6s %5$6s %6$6s", exFileName, "1", "1", getObjectOr(dssatSeqSubData, "sq", "1"), getObjectOr(dssatSeqSubData, "op", "1"), getObjectOr(dssatSeqSubData, "co", "0"))); } // Output finish bwB.write(sbError.toString()); bwB.write(sbData.toString()); bwB.close(); } catch (IOException e) { LOG.error(DssatCommonOutput.getStackTrace(e)); } }
java
{ "resource": "" }
q15194
DssatBatchFileOutput.getCropName
train
private String getCropName(Map result) { String ret; String crid; // Get crop id crid = getCrid(result); // Get crop name string ret = LookupCodes.lookupCode("CRID", crid, "common", "DSSAT"); if (ret.equals(crid)) { ret = "Unkown"; sbError.append("! Warning: Undefined crop id: [").append(crid).append("]\r\n"); } // // Get crop name string // if ("BH".equals(crid)) { // ret = "Bahia"; // } else if ("BA".equals(crid)) { // ret = "Barley"; // } else if ("BR".equals(crid)) { // ret = "Brachiaria"; // } else if ("CB".equals(crid)) { // ret = "Cabbage"; // } else if ("CS".equals(crid)) { // ret = "Cassava"; // } else if ("CH".equals(crid)) { // ret = "Chickpea"; // } else if ("CO".equals(crid)) { // ret = "Cotton"; // } else if ("CP".equals(crid)) { // ret = "Cowpea"; // } else if ("BN".equals(crid)) { // ret = "Drybean"; // } else if ("FB".equals(crid)) { // ret = "FabaBean"; // } else if ("FA".equals(crid)) { // ret = "Fallow"; // } else if ("GB".equals(crid)) { // ret = "GreenBean"; // } else if ("MZ".equals(crid)) { // ret = "Maize"; // } else if ("ML".equals(crid)) { // ret = "Millet"; // } else if ("PN".equals(crid)) { // ret = "Peanut"; // } else if ("PR".equals(crid)) { // ret = "Pepper"; // } else if ("PI".equals(crid)) { // ret = "PineApple"; // } else if ("PT".equals(crid)) { // ret = "Potato"; // } else if ("RI".equals(crid)) { // ret = "Rice"; // } else if ("SG".equals(crid)) { // ret = "Sorghum"; // } else if ("SB".equals(crid)) { // ret = "Soybean"; // } else if ("SC".equals(crid)) { // ret = "Sugarcane"; // } else if ("SU".equals(crid)) { // ret = "Sunflower"; // } else if ("SW".equals(crid)) { // ret = "SweetCorn"; // } else if ("TN".equals(crid)) { // ret = "Tanier"; // } else if ("TR".equals(crid)) { // ret = "Taro"; // } else if ("TM".equals(crid)) { // ret = "Tomato"; // } else if ("VB".equals(crid)) { // ret = "Velvetbean"; // } else if ("WH".equals(crid)) { // ret = "Wheat"; // } else if ("SQ".equals(crid)) { // ret = "Sequence"; // } else { // ret = "Unkown"; // sbError.append("! Warning: Undefined crop id: [").append(crid).append("]\r\n"); // } return ret; }
java
{ "resource": "" }
q15195
CoreNLPConstituencyParse.smallestContainerForRange
train
private static <T extends Comparable<T>> Optional<Range<T>> smallestContainerForRange( Collection<Range<T>> ranges, Range<T> target) { Range<T> best = Range.all(); for (final Range<T> r : ranges) { if (r.equals(target)) { continue; } // prefer a smaller range, always; if (r.encloses(target) && best.encloses(r)) { best = r; } } if (best.equals(Range.<T>all())) { return Optional.absent(); } return Optional.of(best); }
java
{ "resource": "" }
q15196
And.validate
train
@Override public void validate(T arg) throws ValidationException { for (final Validator<T> validator : validators) { validator.validate(arg); } }
java
{ "resource": "" }
q15197
HSClientImpl.setSocketOption
train
public <T> void setSocketOption(SocketOption<T> socketOption, T value) { this.socketOptions.put(socketOption, value); }
java
{ "resource": "" }
q15198
OrientedBox3d.setCenterProperties
train
public void setCenterProperties(Point3d center1) { this.center.setProperties(center1.xProperty, center1.yProperty, center1.zProperty); }
java
{ "resource": "" }
q15199
EnableButtonBehavior.onChange
train
protected void onChange() { enabled = false; if (getDocument().getLength() > 0) { enabled = true; } buttonModel.setEnabled(enabled); }
java
{ "resource": "" }