Package net.sf.robocode.util

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


    // 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

    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

TOP

Related Classes of net.sf.robocode.util.AlphanumericComparator

Copyright © 2018 www.massapicom. 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.