@Test public void testCompare() { int result = 0; ItemComparator ic = null; ic = new ItemComparator("test", "one", Item.ANY, true); result = ic.compare(one, two); assertTrue("testCompare 0",result == 0); ic = new ItemComparator("test", "one", Item.ANY, true); one.addMetadata("dc", "test", "one", Item.ANY, "1"); result = ic.compare(one, two); assertTrue("testCompare 1",result >= 1); one.clearMetadata("dc", "test", "one", Item.ANY); ic = new ItemComparator("test", "one", Item.ANY, true); two.addMetadata("dc", "test", "one", Item.ANY, "1"); result = ic.compare(one, two); assertTrue("testCompare 2",result <= -1); two.clearMetadata("dc", "test", "one", Item.ANY); ic = new ItemComparator("test", "one", Item.ANY, true); one.addMetadata("dc", "test", "one", Item.ANY, "1"); two.addMetadata("dc", "test", "one", Item.ANY, "2"); result = ic.compare(one, two); assertTrue("testCompare 3",result <= -1); one.clearMetadata("dc", "test", "one", Item.ANY); two.clearMetadata("dc", "test", "one", Item.ANY); ic = new ItemComparator("test", "one", Item.ANY, true); one.addMetadata("dc", "test", "one", Item.ANY, "1"); two.addMetadata("dc", "test", "one", Item.ANY, "1"); result = ic.compare(one, two); assertTrue("testCompare 4",result == 0); one.clearMetadata("dc", "test", "one", Item.ANY); two.clearMetadata("dc", "test", "one", Item.ANY); ic = new ItemComparator("test", "one", Item.ANY, true); one.addMetadata("dc", "test", "one", Item.ANY, "2"); two.addMetadata("dc", "test", "one", Item.ANY, "1"); result = ic.compare(one, two); assertTrue("testCompare 5",result >= 1); one.clearMetadata("dc", "test", "one", Item.ANY); two.clearMetadata("dc", "test", "one", Item.ANY); ic = new ItemComparator("test", "one", Item.ANY, true); one.addMetadata("dc", "test", "one", Item.ANY, "0"); one.addMetadata("dc", "test", "one", Item.ANY, "1"); two.addMetadata("dc", "test", "one", Item.ANY, "2"); two.addMetadata("dc", "test", "one", Item.ANY, "3"); result = ic.compare(one, two); assertTrue("testCompare 3",result <= -1); one.clearMetadata("dc", "test", "one", Item.ANY); two.clearMetadata("dc", "test", "one", Item.ANY); ic = new ItemComparator("test", "one", Item.ANY, true); one.addMetadata("dc", "test", "one", Item.ANY, "0"); one.addMetadata("dc", "test", "one", Item.ANY, "1"); two.addMetadata("dc", "test", "one", Item.ANY, "-1"); two.addMetadata("dc", "test", "one", Item.ANY, "1"); result = ic.compare(one, two); assertTrue("testCompare 4",result == 0); one.clearMetadata("dc", "test", "one", Item.ANY); two.clearMetadata("dc", "test", "one", Item.ANY); ic = new ItemComparator("test", "one", Item.ANY, true); one.addMetadata("dc", "test", "one", Item.ANY, "1"); one.addMetadata("dc", "test", "one", Item.ANY, "2"); two.addMetadata("dc", "test", "one", Item.ANY, "1"); two.addMetadata("dc", "test", "one", Item.ANY, "-1"); result = ic.compare(one, two); assertTrue("testCompare 5",result >= 1); one.clearMetadata("dc", "test", "one", Item.ANY); two.clearMetadata("dc", "test", "one", Item.ANY); ic = new ItemComparator("test", "one", Item.ANY, false); one.addMetadata("dc", "test", "one", Item.ANY, "1"); one.addMetadata("dc", "test", "one", Item.ANY, "2"); two.addMetadata("dc", "test", "one", Item.ANY, "2"); two.addMetadata("dc", "test", "one", Item.ANY, "3"); result = ic.compare(one, two); assertTrue("testCompare 3",result <= -1); one.clearMetadata("dc", "test", "one", Item.ANY); two.clearMetadata("dc", "test", "one", Item.ANY); ic = new ItemComparator("test", "one", Item.ANY, false); one.addMetadata("dc", "test", "one", Item.ANY, "1"); one.addMetadata("dc", "test", "one", Item.ANY, "2"); two.addMetadata("dc", "test", "one", Item.ANY, "1"); two.addMetadata("dc", "test", "one", Item.ANY, "5"); result = ic.compare(one, two); assertTrue("testCompare 4",result == 0); one.clearMetadata("dc", "test", "one", Item.ANY); two.clearMetadata("dc", "test", "one", Item.ANY); ic = new ItemComparator("test", "one", Item.ANY, false); one.addMetadata("dc", "test", "one", Item.ANY, "2"); one.addMetadata("dc", "test", "one", Item.ANY, "3"); two.addMetadata("dc", "test", "one", Item.ANY, "1"); two.addMetadata("dc", "test", "one", Item.ANY, "4"); result = ic.compare(one, two); assertTrue("testCompare 5",result >= 1); one.clearMetadata("dc", "test", "one", Item.ANY); two.clearMetadata("dc", "test", "one", Item.ANY); }
public int compare(Object first, Object second) { if ((!(first instanceof Item)) || (!(second instanceof Item))) { throw new IllegalArgumentException("Arguments must be Items"); } String firstValue = getValue((Item) first); String secondValue = getValue((Item) second); if (firstValue == null && secondValue == null) { return 0; } if (firstValue == null) { return -1; } if (secondValue == null) { return 1; } return firstValue.compareTo(secondValue); }
ItemComparator implements Comparator, Serializable { public int compare(Object first, Object second) { if ((!(first instanceof Item)) || (!(second instanceof Item))) { throw new IllegalArgumentException("Arguments must be Items"); } String firstValue = getValue((Item) first); String secondValue = getValue((Item) second); if (firstValue == null && secondValue == null) { return 0; } if (firstValue == null) { return -1; } if (secondValue == null) { return 1; } return firstValue.compareTo(secondValue); } }
ItemComparator implements Comparator, Serializable { public int compare(Object first, Object second) { if ((!(first instanceof Item)) || (!(second instanceof Item))) { throw new IllegalArgumentException("Arguments must be Items"); } String firstValue = getValue((Item) first); String secondValue = getValue((Item) second); if (firstValue == null && secondValue == null) { return 0; } if (firstValue == null) { return -1; } if (secondValue == null) { return 1; } return firstValue.compareTo(secondValue); } ItemComparator(String element, String qualifier, String language,
            boolean max); }
ItemComparator implements Comparator, Serializable { public int compare(Object first, Object second) { if ((!(first instanceof Item)) || (!(second instanceof Item))) { throw new IllegalArgumentException("Arguments must be Items"); } String firstValue = getValue((Item) first); String secondValue = getValue((Item) second); if (firstValue == null && secondValue == null) { return 0; } if (firstValue == null) { return -1; } if (secondValue == null) { return 1; } return firstValue.compareTo(secondValue); } ItemComparator(String element, String qualifier, String language,
            boolean max); int compare(Object first, Object second); boolean equals(Object obj); int hashCode(); }
ItemComparator implements Comparator, Serializable { public int compare(Object first, Object second) { if ((!(first instanceof Item)) || (!(second instanceof Item))) { throw new IllegalArgumentException("Arguments must be Items"); } String firstValue = getValue((Item) first); String secondValue = getValue((Item) second); if (firstValue == null && secondValue == null) { return 0; } if (firstValue == null) { return -1; } if (secondValue == null) { return 1; } return firstValue.compareTo(secondValue); } ItemComparator(String element, String qualifier, String language,
            boolean max); int compare(Object first, Object second); boolean equals(Object obj); int hashCode();  }