1 21 22 package org.opensubsystems.core.util; 23 24 import java.util.Collection ; 25 import java.util.Collections ; 26 import java.util.HashMap ; 27 import java.util.Iterator ; 28 import java.util.Map ; 29 30 import org.opensubsystems.core.data.DataObject; 31 32 40 public final class DataObjectUtils 41 { 42 44 47 public static final byte COMPARE_ORDER_NO_CHANGE = 0; 48 49 52 public static final byte COMPARE_ORDER_CHANGED = 1; 53 54 57 public static final byte COMPARE_ATTRIBUTES_CHANGED = 2; 58 59 62 public static final byte COMPARE_CHANGED = 4; 63 64 66 69 private DataObjectUtils( 70 ) 71 { 72 } 74 75 77 84 public static String parseCollectionIdsToString( 85 Collection colDataObjects, 86 String strDel 87 ) 88 { 89 StringBuffer strbInts = new StringBuffer (); 90 if ((colDataObjects != null) && (!colDataObjects.isEmpty())) 91 { 92 for (Iterator items = colDataObjects.iterator(); items.hasNext();) 93 { 94 if (strbInts.length() > 0) 95 { 96 strbInts.append(strDel); 97 } 98 strbInts.append(((DataObject)items.next()).getId()); 99 } 100 } 101 return strbInts.toString(); 102 } 103 104 110 public static Map convertCollectionToMap( 111 Collection colDataObjects 112 ) 113 { 114 Map mpData = Collections.EMPTY_MAP; 115 116 if ((colDataObjects != null) && (!colDataObjects.isEmpty())) 117 { 118 DataObject data; 119 120 mpData = new HashMap (colDataObjects.size()); 121 for (Iterator items = colDataObjects.iterator(); items.hasNext();) 122 { 123 data = (DataObject)items.next(); 124 mpData.put(data.getIdAsObject(), data); 125 } 126 } 127 return mpData; 128 } 129 } 130 | Popular Tags |