01: /*
02: * Created by IntelliJ IDEA.
03: * User: sanjib.ghosh@sun.com
04: * Date: Dec 24, 2001
05: * Time: $TME$
06: */
07: //package com.sun.portal.remote.common;
08: package com.sun.portal.proxylet.util;
09:
10: import java.util.*;
11:
12: public class AttributeExtractor {
13:
14: public static String getString(Map source, String name,
15: String defaultValue) {
16: Set set = (Set) source.get(name);
17: if (null == set) {
18: return defaultValue;
19: }
20: Iterator it = set.iterator();
21: return (it.hasNext()) ? (String) it.next() : defaultValue;
22: }
23:
24: public static int getInt(Map source, String name, int defaultValue) {
25: Set set = (Set) source.get(name);
26: if (null == set) {
27: return defaultValue;
28: }
29: Iterator it = set.iterator();
30: return (it.hasNext()) ? Integer.parseInt((String) it.next())
31: : defaultValue;
32: }
33:
34: public static boolean getBoolean(Map source, String name,
35: boolean defaultValue) {
36: Set set = (Set) source.get(name);
37: if (null == set) {
38: return defaultValue;
39: }
40: Iterator it = set.iterator();
41: return (it.hasNext()) ? new Boolean((String) it.next())
42: .booleanValue() : defaultValue;
43: }
44:
45: public static List getStringList(Map source, String name) {
46: Set set = (Set) source.get(name);
47: if (null == set) {
48: return new ArrayList();
49: }
50: List ret = new ArrayList(set.size());
51: for (Iterator it = set.iterator(); it.hasNext();) {
52: ret.add((String) it.next());
53: }
54: return ret;
55: }
56:
57: }
|