List of usage examples for java.lang String compareTo
public int compareTo(String anotherString)
From source file:fr.gael.dhus.util.functional.collect.SortedMapTest.java
/** Tests if map is sorted (values). */ @Test/*from w ww .j a v a 2 s .co m*/ public void sortedValuesTest() { SortedMap<Integer, String> sorted_map = new SortedMap<>(dataSet, cmp); String prev_val = null; for (String val : sorted_map.values()) { if (prev_val != null) { Assert.assertTrue(val.compareTo(prev_val) >= 0); } prev_val = val; } }
From source file:fr.gael.dhus.util.functional.collect.SortedMapTest.java
/** Tests if map is sorted (keySet). */ @Test//from ww w .j a v a2 s.co m public void sortedKeysTest() { SortedMap<Integer, String> sorted_map = new SortedMap<>(dataSet, cmp); // the map should have been sorted in the lexicographic order. String prev_val = null; for (Integer key : sorted_map.keySet()) { String curr_val = dataSet.get(key); if (prev_val != null) { Assert.assertTrue(curr_val.compareTo(prev_val) >= 0); } prev_val = curr_val; } }
From source file:io.apicurio.studio.tools.release.ReleaseTool.java
/** * Returns all issues (as JSON nodes) that were closed since the given date. * @param since/*from w ww . ja v a2s.c o m*/ * @param githubPAT */ private static List<JSONObject> getIssuesForRelease(String since, String githubPAT) throws Exception { List<JSONObject> rval = new ArrayList<>(); String currentPageUrl = "https://api.github.com/repos/apicurio/apicurio-studio/issues?state=closed"; int pageNum = 1; while (currentPageUrl != null) { System.out.println("Querying page " + pageNum + " of issues."); HttpResponse<JsonNode> response = Unirest.get(currentPageUrl).header("Accept", "application/json") .header("Authorization", "token " + githubPAT).asJson(); if (response.getStatus() != 200) { throw new Exception("Failed to list Issues: " + response.getStatusText()); } JSONArray issueNodes = response.getBody().getArray(); issueNodes.forEach(issueNode -> { JSONObject issue = (JSONObject) issueNode; String closedOn = issue.getString("closed_at"); if (since.compareTo(closedOn) < 0) { rval.add(issue); } }); System.out.println("Processing page " + pageNum + " of issues."); System.out.println(" Found " + issueNodes.length() + " issues on page."); String allLinks = response.getHeaders().getFirst("Link"); Map<String, Link> links = Link.parseAll(allLinks); if (links.containsKey("next")) { currentPageUrl = links.get("next").getUrl(); } else { currentPageUrl = null; } pageNum++; } return rval; }
From source file:com.logicalpractice.flumechronicle.channel.ChronicleCleanup.java
private FileFilter directoriesLessThan(final String currentFolder) { return new FileFilter() { @Override/*from w w w.j a va 2 s . co m*/ public boolean accept(File pathname) { String name = pathname.getName(); return pathname.isDirectory() && name.length() == currentFolder.length() && isAllNumeric(name) && name.compareTo(currentFolder) < 0; } }; }
From source file:com.uber.hoodie.utilities.sources.HiveIncrPullSource.java
/** * Finds the first commit from source, greater than the target's last commit, and reads it out. *///w w w . j ava 2s . c om private Optional<String> findCommitToPull(Optional<String> latestTargetCommit) throws IOException { log.info("Looking for commits "); FileStatus[] commitTimePaths = fs.listStatus(new Path(incrPullRootPath)); List<String> commitTimes = new ArrayList<>(commitTimePaths.length); for (FileStatus commitTimePath : commitTimePaths) { String[] splits = commitTimePath.getPath().toString().split("/"); commitTimes.add(splits[splits.length - 1]); } Collections.sort(commitTimes); log.info("Retrieved commit times " + commitTimes); if (!latestTargetCommit.isPresent()) { // start from the beginning return Optional.of(commitTimes.get(0)); } for (String commitTime : commitTimes) { //TODO(vc): Add an option to delete consumed commits if (commitTime.compareTo(latestTargetCommit.get()) > 0) { return Optional.of(commitTime); } } return Optional.empty(); }
From source file:at.tuwien.minimee.util.PslistWinParser.java
private void parseLine(String line) throws IOException { StringTokenizer tokenizer = new StringTokenizer(line, " "); if (!tokenizer.hasMoreTokens()) { return;/*from ww w. j a v a2s .co m*/ } String start = tokenizer.nextToken(); if (start.compareTo("Name") == 0) { this.dataLine = true; return; } else if (!dataLine) return; // only if dataline is true can read the informations WinProcessExecutionFootprint pfp = parseProcessLine(tokenizer); line = input.readLine(); line = input.readLine(); tokenizer = new StringTokenizer(line, " "); if (line != null && line != "") parseProcessTimeLine(tokenizer, pfp); list.add(pfp); dataLine = false; // } }
From source file:TComp.java
public int compare(String a, String b) { int i, j, k;//from w ww . j a v a 2s . co m String aStr, bStr; aStr = a; bStr = b; i = aStr.lastIndexOf(' '); j = bStr.lastIndexOf(' '); k = aStr.substring(i).compareTo(bStr.substring(j)); if (k == 0) // last names match, check entire name return aStr.compareTo(bStr); else return k; }
From source file:biospectra.lucene.SequenceCompressFilter.java
@Override public boolean incrementToken() throws IOException { if (this.input.incrementToken()) { char[] buffer = this.termAtt.buffer(); final int length = this.termAtt.length(); if (this.minStrand) { char[] reverseComplement = SequenceHelper.getReverseComplement(buffer, length); String originalSeq = String.valueOf(buffer, 0, length); String revcompSeq = String.valueOf(reverseComplement); if (originalSeq.compareTo(revcompSeq) > 0) { // use reverse-complement sequence for (int i = 0; i < length; i++) { buffer[i] = reverseComplement[i]; }/*from w w w .j a va 2 s . c o m*/ } } if (this.base64Compress) { byte[] compressed = SequenceHelper.compress(buffer, length); byte[] encoded = Base64.encodeBase64(compressed); buffer = this.termAtt.resizeBuffer(encoded.length); for (int i = 0; i < buffer.length; i++) { if (i < encoded.length) { buffer[i] = (char) encoded[i]; } else { buffer[i] = 0; } } this.termAtt.setLength(encoded.length); //System.out.println("comp: " + String.valueOf(buffer)); } return true; } else { return false; } }
From source file:RaceApplet.java
public void init() { String raceType = getParameter("type"); for (int i = 0; i < NUMRUNNERS; i++) { runners[i] = new Runner(); if (raceType.compareTo("unfair") == 0) runners[i].setPriority(i + 2); else// w w w .j ava2 s . c o m runners[i].setPriority(2); } if (updateThread == null) { updateThread = new Thread(this, "Thread Race"); updateThread.setPriority(NUMRUNNERS + 2); } addMouseListener(new MyAdapter()); setContentPane(new AppletContentPane()); }
From source file:de.iteratec.iteraplan.businesslogic.exchange.elasticExcel.excelimport.UniversaltypeSheetImporter.java
/** * @param fromName// w ww. java 2 s.c om * @param toName * @return unique name for the relationship */ private String createRelationshipName(String fromName, String toName) { if (fromName.compareTo(toName) < 0) { return fromName + "-" + toName; } else { return toName + "-" + fromName; } }