Examples of AlphanumericComparator


Examples of net.sf.robocode.util.AlphanumericComparator

    // for IgnoredItem
    return 0;
  }

  private static int compare(String p1, String c1, String v1, String p2, String c2, String v2) {
    AlphanumericComparator alphaNumComparator = new AlphanumericComparator();

    // Compare packages
    int result = alphaNumComparator.compare(p1, p2);

    if (result != 0) {
      return result;
    }

    // Same package, so compare classes
    result = alphaNumComparator.compare(c1, c2);
    if (result != 0) {
      return result;
    }

    // Same robot, so compare versions
    if (v1 == null && v2 == null) {
      return 0;
    }
    if (v1 == null) {
      return 1;
    }
    if (v2 == null) {
      return -1;
    }

    if (v1.equals(v2)) {
      return 0;
    }

    if (v1.indexOf(".") < 0 || v2.indexOf(".") < 0) {
      return alphaNumComparator.compare(v1, v2);
    }

    // Dot separated versions.
    StringTokenizer s1 = new StringTokenizer(v1, ".");
    StringTokenizer s2 = new StringTokenizer(v2, ".");

    while (s1.hasMoreTokens() && s2.hasMoreTokens()) {
      String tok1 = s1.nextToken();
      String tok2 = s2.nextToken();

      try {
        int i1 = Integer.parseInt(tok1);
        int i2 = Integer.parseInt(tok2);

        if (i1 != i2) {
          return i1 - i2;
        }
      } catch (NumberFormatException e) {
        int tc = alphaNumComparator.compare(tok1, tok2);

        if (tc != 0) {
          return tc;
        }
      }
View Full Code Here

Examples of net.sf.robocode.util.AlphanumericComparator

    // Make sure the input and expected output string arrays have the same length
    Assert.assertEquals(unsortedStrings.length, correctlySortedStrings.length);

    // Sort the unsorted strings
    Arrays.sort(unsortedStrings, new AlphanumericComparator());

    // Check the result against our expected result
    boolean sortedCorrectly = true;

    for (int i = 0; i < unsortedStrings.length; i++) {
View Full Code Here

Examples of net.sf.robocode.util.AlphanumericComparator

    return new CheckListItem(this);
  }

  // Must be here (for sorting)
  public int compareTo(CheckListItem item) {
    return new AlphanumericComparator().compare(label, item.label);
  }
View Full Code Here

Examples of org.restlet.engine.util.AlphaNumericComparator

    private static List<Reference> expected = refs("1", "1.0", "1.1", "1.1.1",
            "2", "2.0", "2.2", "2.2.2", "3", "3.0", "3.3");

    public void testBug() {
        List<Reference> result = new ArrayList<Reference>(unsorted);
        Collections.sort(result, new AlphaNumericComparator());
        Assert.assertEquals(expected, result);
    }
View Full Code Here

Examples of org.restlet.engine.util.AlphaNumericComparator

            // We don't take the risk of exposing directory "file:///C:/AA"
            // if only "file:///C:/A" was intended
            this.rootRef = new Reference(rootIdentifier + "/");
        }

        this.comparator = new AlphaNumericComparator();
        this.deeplyAccessible = true;
        this.indexName = "index";
        this.listingAllowed = false;
        this.modifiable = false;
        this.negotiatingContent = true;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.