Class PathUtils.PathComparator

java.lang.Object
com.ibm.wsspi.kernel.service.utils.PathUtils.PathComparator
All Implemented Interfaces:
Serializable, Comparator<String>
Enclosing class:
PathUtils

public static class PathUtils.PathComparator extends Object implements Comparator<String>, Serializable
Comparator for normalized paths.
See Also:
  • Field Details

    • PATH_SEPARATOR

      public static final char PATH_SEPARATOR
      The separator character for normalized paths. ('/').
      See Also:
  • Constructor Details

    • PathComparator

      public PathComparator()
  • Method Details

    • compare

      public int compare(String o1, String o2)
      Compare two relative paths. Take into account the presence of path separator characters. That is, the path are compared lists of path segments. The result will be one of CMP_LT, #CMP_EQ, CMP_GT, or, an integer value which measures the difference between the two path (subtracting the second value from the first), with the sign of the difference indicating the comparison result. In effect: Math.signum(compare(path1, path2)) == Math.signum(path1 - path2) "In effect", because an actual difference between two path values is not defined. This implementation answers the difference between the first characters which do not match, or the differences between the path lengths if all characters of the shorter path match characters of the longer path, or CMP_LT or CMP_GT if slashes are not in the same positions in both paths. For example, "parent/child" is compared as \{ "parent", "child" \}. Then, "parent/child" is less than "parentAlt/child", because "parent" is less than "parentAlt".
      Specified by:
      compare in interface Comparator<String>
      Parameters:
      path1 - The first relative path which is to be compared. An exception will result if the path is null.
      path2 - The second second path which is to be compared. An exception will result if the path is null.
      Returns:
      A integer value which corresponds to the comparison result. A value less than zero indicates that the first path is less than the second path. A value greater than zero indicates that first path is greater than the second. A value of zero indicates that the two paths are equal.