1 10 package org.mmbase.module.core; 11 12 import org.mmbase.util.*; 13 14 20 public class MMObjectDCompare implements CompareInterface { 21 String compareField; 22 23 public MMObjectDCompare(String fieldName) { 24 compareField = fieldName; 25 } 26 27 public int compare(Object thisOne, Object other) { 28 Object object1; 29 Object object2; 30 int result = 0; 31 32 object1 = ((MMObjectNode)thisOne).getValue(compareField); 33 object2 = ((MMObjectNode)other).getValue(compareField); 34 35 if(object1 instanceof String ) 36 result = internalStringCompare(object1, object2); 37 else if(object1 instanceof Integer ) 38 result = internalIntCompare(object1, object2); 39 40 return (result); 41 } 42 43 int internalIntCompare(Object thisOne, Object other) { 44 return(((Integer )other).intValue()-((Integer )thisOne).intValue()); 45 } 46 47 int internalStringCompare(Object thisOne, Object other) { 48 return(((String )other).compareTo((String )thisOne)); 49 } 50 } 51 | Popular Tags |