01: package com.sun.portal.providers.util;
02:
03: import java.lang.Boolean;
04:
05: import java.util.Map;
06:
07: import com.sun.portal.providers.context.ProviderContext;
08:
09: /*
10: * Convenient methods to get the value from a dp map value
11: */
12: public class PropertyUtil {
13:
14: /*
15: * convenient method to get value out of a map, if not found
16: * give back the default value.
17: */
18: public static boolean getBooleanValueFromMap(Map map, String key,
19: boolean def) {
20: Boolean val = (Boolean) map.get(key);
21: boolean retVal = def;
22: if (val != null) {
23: retVal = val.booleanValue();
24: }
25:
26: return retVal;
27: }
28:
29: /*
30: * convenient method to get value out of a map, if not found
31: * give back the default value.
32: */
33: public static String getStringValueFromMap(Map map, String key,
34: String def) {
35: String val = def;
36: val = (String) map.get(key);
37:
38: if (val == null) {
39: val = def;
40: }
41:
42: return val;
43: }
44:
45: /*
46: * convenient method to return a channelName by replacing the
47: * characters shown below in the channelName. Used by the FrontProvider and
48: * the TableProvider to get a unique window name which is used while
49: * detaching a channel.
50: */
51: public static String replaceChannelName(String channelName) {
52:
53: StringBuffer newChannelName = new StringBuffer();
54: int newSize = 0;
55:
56: for (int i = 0; i < channelName.length(); i++) {
57: switch (channelName.charAt(i)) {
58: case '%':
59: newChannelName.insert(newSize++, '_');
60: break;
61: case '+':
62: newChannelName.insert(newSize++, '_');
63: newChannelName.insert(newSize++, '2');
64: newChannelName.insert(newSize++, 'B');
65: break;
66: case '.':
67: newChannelName.insert(newSize++, '_');
68: newChannelName.insert(newSize++, '2');
69: newChannelName.insert(newSize++, 'C');
70: break;
71: case '-':
72: newChannelName.insert(newSize++, '_');
73: newChannelName.insert(newSize++, '2');
74: newChannelName.insert(newSize++, 'D');
75: break;
76: case '*':
77: newChannelName.insert(newSize++, '_');
78: newChannelName.insert(newSize++, '2');
79: newChannelName.insert(newSize++, 'A');
80: break;
81: case '_':
82: newChannelName.insert(newSize++, '_');
83: newChannelName.insert(newSize++, '5');
84: newChannelName.insert(newSize++, 'F');
85: break;
86: default:
87: newChannelName.insert(newSize++, channelName.charAt(i));
88: break;
89: }
90: }
91: return newChannelName.toString();
92: }
93: }
|