List of usage examples for java.lang String compareTo
public int compareTo(String anotherString)
From source file:net.sourceforge.fenixedu.util.CalendarUtil.java
public static boolean intersectTimes(Date startTime1, Date endTime1, Date startTime2, Date endTime2) { String startTime1String = time2string(startTime1); String endTime1String = time2string(endTime1); String startTime2String = time2string(startTime2); String endTime2String = time2string(endTime2); boolean doesNotIntersect = (endTime2String.compareTo(startTime1String) <= 0) || (startTime2String.compareTo(endTime1String) >= 0); return !doesNotIntersect; }
From source file:net.sourceforge.fenixedu.util.CalendarUtil.java
public static boolean intersectDates(Calendar startDate1, Calendar endDate1, Calendar startDate2, Calendar endDate2) {//from www. jav a 2s .co m String startDate1String = date2string(startDate1); String endDate1String = date2string(endDate1); String startDate2String = date2string(startDate2); String endDate2String = date2string(endDate2); boolean doesNotIntersect = (endDate2String.compareTo(startDate1String) < 0) || (startDate2String.compareTo(endDate1String) > 0); return !doesNotIntersect; }
From source file:Main.java
/** Determines if value is a negative infinity according to the IEEE754 standard * @param value the binary string of 64 bits * @return true if the value is negative infinity *//*from w w w.j a va 2s.com*/ public static boolean isNegativeInfinity(String value) { if (is64BinaryString(value)) { if (value.compareTo(MINUSINFINITY) == 0) { return true; } } return false; }
From source file:Main.java
/** * Sorts Attributes of a given Node//from w w w . j a va 2 s . c o m * * @param attrs the NamedNodeMap containing Node Attributes * @return Array containing sorted Attributes */ protected static Attr[] sortAttributes(NamedNodeMap attrs) { int len = (attrs != null) ? attrs.getLength() : 0; Attr array[] = new Attr[len]; for (int i = 0; i < len; i++) { array[i] = (Attr) attrs.item(i); } for (int i = 0; i < len - 1; i++) { String name = array[i].getNodeName(); int index = i; for (int j = i + 1; j < len; j++) { String curName = array[j].getNodeName(); if (curName.compareTo(name) < 0) { name = curName; index = j; } } if (index != i) { Attr temp = array[i]; array[i] = array[index]; array[index] = temp; } } return (array); }
From source file:Main.java
public static String getParsingData(String str) { String dd = str.substring(0, 15); String mock = ""; try {/*from w ww . j av a 2s. co m*/ String a = parseMockData(dd)[0].trim(); String b = parseMockData(dd)[1].trim(); String c = parseMockData(dd)[2].trim(); if (a.compareTo("") != 0) mock = a + "#MD"; else if (b.compareTo("") != 0) mock = b + "#ML"; else if (c.compareTo("") != 0) mock = c + "#MS"; } catch (Exception e) { String a = parseMockDataSec(dd)[0].trim(); mock = a + "#ML"; } return mock; // 2.6 2.5 -.- }
From source file:Main.java
public static Element getElement(Element item, String tag) { NodeList nodes = item.getElementsByTagName(tag); if (nodes != null && nodes.getLength() > 0) { Element element = (Element) nodes.item(0); String nodeName = null; if (element != null) { nodeName = element.getNodeName(); }/*from w w w . j a va 2 s.c o m*/ if (nodeName != null && nodeName.compareTo(tag) == 0) { return element; } } return null; }
From source file:com.newlandframework.avatarmq.consumer.ConsumerContext.java
public static ConsumerClusters selectByClusters(String clusters) { Predicate predicate = new Predicate() { public boolean evaluate(Object object) { String id = ((ClustersRelation) object).getId(); return id.compareTo(clusters) == 0; }/*from w w w. ja va2 s . co m*/ }; Iterator iterator = new FilterIterator(relationArray.iterator(), predicate); ClustersRelation relation = null; while (iterator.hasNext()) { relation = (ClustersRelation) iterator.next(); break; } return (relation != null) ? relation.getClusters() : null; }
From source file:com.xpn.xwiki.plugin.packaging.DocumentInfo.java
public static int actionToInt(String status) { if (status.compareTo("merge") == 0) { return ACTION_MERGE; } else if (status.compareTo("overwrite") == 0) { return ACTION_OVERWRITE; } else if (status.compareTo("skip") == 0) { return ACTION_SKIP; }/*from w w w. j ava2 s .c o m*/ return ACTION_NOT_DEFINED; }
From source file:net.firejack.platform.core.utils.SortFileUtils.java
/** * @param files/* w ww.ja va 2s. c o m*/ * @param desc * @return */ public static File[] sortingByName(File[] files, boolean desc) { Arrays.sort(files, new Comparator() { public int compare(final Object o1, final Object o2) { String s1 = ((File) o1).getName().toLowerCase(); String s2 = ((File) o2).getName().toLowerCase(); return s1.compareTo(s2); } }); if (desc) { org.apache.commons.lang.ArrayUtils.reverse(files); } return files; }
From source file:Main.java
public static List<String> getSortedStringList(Collection<String> toSort) { List<String> sorted = new LinkedList<String>(); final PriorityQueue<String> ordered = new PriorityQueue<String>( toSort.size() + 1/*In case the toSort is empty*/, new Comparator<String>() { @Override//from www . ja v a2 s. c om public int compare(String lhs, String rhs) { lhs = lhs.replaceAll("[^a-zA-Z0-9]", ""); rhs = rhs.replaceAll("[^a-zA-Z0-9]", ""); int result = rhs.compareTo(lhs); return result; } }); ordered.addAll(toSort); int originalSize = ordered.size(); for (int i = 0; i < originalSize; i++) { sorted.add(ordered.poll()); } return sorted; }