01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.rewriter.util.collections;
06:
07: import com.sun.portal.rewriter.util.StringHelper;
08:
09: import java.util.Iterator;
10: import java.util.Map;
11:
12: public class CollectionHelper {
13: public static ListMap processMAPValues(Map aMap, String aDelim) {
14: ListMap lResult = new ListMap();
15: Iterator lIterator = aMap.keySet().iterator();
16: while (lIterator.hasNext()) {
17: String bKey = (String) lIterator.next();
18: String bValue = (String) aMap.get(bKey);
19: String[] bValueArray = StringHelper
20: .tokenize(bValue, aDelim);
21: lResult.put(bKey, bValueArray);
22: }
23:
24: return lResult;
25: }//processMAPValues()
26:
27: public static ListMap invertMAP(final Map aMap) {
28: ListMap lResult = new ListMap();
29:
30: Iterator lIterator = aMap.keySet().iterator();
31: while (lIterator.hasNext()) {
32: Object bKey = lIterator.next();
33: lResult.put(aMap.get(bKey), bKey);
34: }
35:
36: return lResult;
37: }//invertMAP()
38:
39: public static ListMap invertArrayValueMAP(final Map aMap) {
40: ListMap lResult = new ListMap();
41:
42: Iterator lIterator = aMap.keySet().iterator();
43: while (lIterator.hasNext()) {
44: Object bKey = lIterator.next();
45: Object[] bValue = (Object[]) aMap.get(bKey);
46:
47: for (int i = 0; i < bValue.length; i++) {
48: lResult.put(bValue[i], bKey);
49: }
50: }
51:
52: return lResult;
53: }//invertArrayValueMAP()
54: }//class CollectionHelper
|