01: /*
02: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.desktop.dp;
06:
07: import java.util.StringTokenizer;
08:
09: public class DPHelper {
10: public static FQCN getFQCN(DPRoot dpRoot, String channelName) {
11: StringBuffer result = new StringBuffer();
12: DPChannel dpChannel = dpRoot.getChannel(channelName);
13:
14: if (dpChannel == null) {
15: result.append("name=").append(channelName);
16: result.append(",class=NoChannelByThisName");
17: } else {
18: DPProperties dpProperties = dpChannel.getProperties();
19: DPString dpString = (dpProperties == null) ? null
20: : dpProperties.getString("id");
21: String id = (dpString == null) ? null : dpString
22: .getStringValue();
23:
24: DPProvider dpProvider = dpChannel.getProvider();
25: if (dpProvider == null) {
26: result.append("name=").append(channelName);
27: result.append(",class=NoProviderForThisChannel");
28: } else {
29: if (id == null) {
30: result.append("name=").append(dpChannel.getName());
31: result.append(",class=").append(
32: dpProvider.getClassName());
33: } else {
34: StringTokenizer tokenizer = new StringTokenizer(id,
35: "${}");
36: while (tokenizer.hasMoreTokens()) {
37: String token = tokenizer.nextToken();
38:
39: if (token.equals("name")) {
40: result.append(dpChannel.getName());
41: } else if (token.equals("class")) {
42: result.append(dpProvider.getClassName());
43: } else {
44: DPProperty dpProperty = dpProperties
45: .get(token);
46: if (dpProperty != null) {
47: result.append(dpProperty.getValue());
48: } else {
49: result.append(token);
50: }
51: }
52: }
53: }
54: }
55: }
56:
57: return new FQCN(result.toString());
58: }
59: }
|