1 /*
2 * Copyright 2010 Fraunhofer Gesellschaft, Munich, Germany,
3 * for its Fraunhofer Institute for Computer Architecture and Software
4 * Technology (FIRST), Berlin, Germany. All rights reserved.
5 * http://www.first.fraunhofer.de/
6 */
7
8 package net.kwfgrid.gwes.util;
9
10 import net.kwfgrid.gworkflowdl.structure.Transition;
11 import net.kwfgrid.gworkflowdl.structure.Operation;
12
13 import java.util.Comparator;
14
15 /**
16 * Compares two Strings by means of its string length.
17 * @author Andreas Hoheisel
18 * (<a href="http://www.andreas-hoheisel.de">www.andreas-hoheisel.de</a>)
19 * @version $Id: StringLengthComparator.java 1433 2010-11-29 18:06:07Z hoheisel $
20 */
21 public class StringLengthComparator implements Comparator {
22
23 /**
24 * Compares its two Strings for order. Returns a negative integer,
25 * zero, or a positive integer as the length of the first String is less than, equal
26 * to, or greater than the second.<p>
27 * <p/>
28 * Note: this comparator imposes orderings that are inconsistent with equals.
29 *
30 * @param o1 the first object to be compared.
31 * @param o2 the second object to be compared.
32 * @return a negative integer, zero, or a positive integer as the
33 * first argument is less than, equal to, or greater than the
34 * second.
35 * @throws ClassCastException if the arguments' types prevent them from
36 * being compared by this Comparator.
37 */
38 public int compare(Object o1, Object o2) {
39 int size1 = ((String) o1).length();
40 int size2 = ((String) o2).length();
41 return size1-size2;
42 }
43 }