Source Code Cross Referenced for XMLDPChannel.java in  » Portal » Open-Portal » com » sun » portal » desktop » dp » xml » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.desktop.dp.xml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved. 
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms. 
004:         */
005:        package com.sun.portal.desktop.dp.xml;
006:
007:        import org.w3c.dom.*;
008:
009:        import com.sun.portal.desktop.context.DPContext;
010:        import com.sun.portal.desktop.dp.DPError;
011:        import com.sun.portal.desktop.dp.DPChannel;
012:        import com.sun.portal.desktop.dp.DPTypes;
013:        import com.sun.portal.desktop.dp.DPRoot;
014:        import com.sun.portal.desktop.dp.DPNode;
015:        import com.sun.portal.desktop.dp.DPProvider;
016:
017:        public class XMLDPChannel extends XMLDPNode implements  DPChannel,
018:                DPTypes, XMLDPTags {
019:
020:            static long ccount = 0;
021:
022:            XMLDPChannel(DPContext dpc, DPRoot r, Element e) {
023:                super (dpc, r, e);
024:            }
025:
026:            /**
027:             * Construct a DP channel with empty properties.
028:             */
029:
030:            XMLDPChannel(DPContext dpc, DPRoot r, Document d, String name,
031:                    String providerName) {
032:                this (dpc, r, createElement(dpc, d, name, providerName,
033:                        XMLDPProperties.createElement(dpc, d)));
034:            }
035:
036:            public void checkType() {
037:                if ((!getElement().getTagName().equals(getTag()))
038:                        && (!getElement().getTagName().equals(CONTAINER_TAG))) {
039:                    throw new DPError(
040:                            "XMLDPChannel.checkType(): invalid type tagName="
041:                                    + getElement().getTagName());
042:                }
043:            }
044:
045:            public String getTag() {
046:                return CHANNEL_TAG;
047:            }
048:
049:            public short getType() {
050:                return CHANNEL_DP;
051:            }
052:
053:            //
054:            // FIXME(susu): getName() gets called quite frequently and it makes
055:            // sense to cache this value.  however, we first need to figure out
056:            // how this value should get refreshed.  i.e. when the channel gets added
057:            // to a node, the name should be converted to a fully-qualified name.
058:            //
059:            public String getName() {
060:                StringBuffer name = new StringBuffer(super .getName());
061:
062:                DPNode parentNode = getParentNode();
063:                if (parentNode != null && parentNode.getType() != ROOT_DP) {
064:                    name.insert(0, CHANNEL_NAME_SEPARATOR);
065:                    name.insert(0, parentNode.getName());
066:                }
067:                return name.toString();
068:            }
069:
070:            public String getChannelName() {
071:                return super .getName();
072:            }
073:
074:            public String getProviderName() {
075:                String providerName = null;
076:                boolean locked = false;
077:
078:                // See whether the channel is locked, if so return
079:                // the provider class from the locked node.
080:                for (int i = 0; i < getMergers().size(); i++) {
081:                    DPChannel dpc = (DPChannel) getMergers().get(i);
082:                    String pn = dpc.getProviderName();
083:                    if (pn != null && pn.length() > 0) {
084:                        providerName = pn;
085:                    }
086:
087:                    if (dpc.isLocked()) {
088:                        locked = true;
089:                        if (dpc.isRemove()) {
090:                            providerName = null;
091:                        }
092:                        break;
093:                    }
094:                }
095:
096:                // if it is a not a dummy, and not locked, return set to 
097:                // the name from this
098:                if (!locked && !isDummy()) {
099:                    String pn = getProviderNameFromThis();
100:                    if (pn != null && pn.length() > 0) {
101:                        providerName = pn;
102:                    }
103:                }
104:
105:                return providerName;
106:            }
107:
108:            protected String getProviderNameFromThis() {
109:                return getElement().getAttribute("provider");
110:            }
111:
112:            public void setProviderName(String providerName) {
113:                getElement().setAttribute("provider", providerName);
114:                setDirty(true);
115:            }
116:
117:            //
118:            // TBD(jtb): declared all well-known dp attribute keys via string
119:            // constants ... here and throughout the rest of the DP code.
120:            //
121:
122:            public DPProvider getProvider() {
123:                String name = getProviderName();
124:                return getProvider(name);
125:            }
126:
127:            public DPProvider getProvider(String name) {
128:                DPRoot root = getRoot();
129:                return root.getProvider(name);
130:            }
131:
132:            public DPChannel getChannel(String name) {
133:                //
134:                // a channel cannot contain channels.
135:                // only containers do.
136:                //
137:                if (getType() != CONTAINER_DP) {
138:                    return null;
139:                } else {
140:                    return super .getChannel(name);
141:                }
142:            }
143:
144:            public DPChannel copy(DPRoot dpr, boolean deep) {
145:                return copy(dpr, deep, null);
146:            }
147:
148:            public DPChannel copy(DPRoot dpr, boolean deep, String newName) {
149:                XMLDPRoot xmldpr = (XMLDPRoot) dpr;
150:
151:                Document ownerDocument = xmldpr.getElement().getOwnerDocument();
152:                Element copyElement = (Element) ownerDocument.importNode(
153:                        getElement(), deep);
154:
155:                if (!deep) {
156:                    //
157:                    // we're not copying deep, so copy empty versions of the
158:                    // required sub elements
159:                    //
160:                    copyElement.appendChild(ownerDocument
161:                            .importNode(getChildElement(getElement(),
162:                                    PROPERTIES_TAG, null), false));
163:                }
164:
165:                if (newName != null) {
166:                    setName(copyElement, newName);
167:                }
168:
169:                return XMLDPFactory.getInstance().getChannel(getContext(), dpr,
170:                        copyElement);
171:            }
172:
173:            DPChannel createDummy(DPRoot dpr) {
174:                DPChannel dpc = copy(dpr, false);
175:
176:                dpc.setDummy(true);
177:                dpc.setDefaults();
178:
179:                return dpc;
180:            }
181:
182:            protected Element getMergedElement() {
183:                XMLDPProperties xp = (XMLDPProperties) getProperties();
184:                Element e = createElement(getContext(), getDocument(), super 
185:                        .getName(), getProviderName(), xp.getMergedElement());
186:                return e;
187:            }
188:
189:            static Element createElement(DPContext dpc, Document d,
190:                    String name, String providerName, Element propertiesElement) {
191:                Element e = createElement(dpc, d, CHANNEL_TAG, name);
192:                e.setAttribute("provider", providerName);
193:
194:                e.appendChild(propertiesElement);
195:
196:                setDefaultsElement(e);
197:
198:                return e;
199:            }
200:
201:            protected void appendProviderAttr(StringBuffer b) {
202:                String toSet = null;
203:                String fromMergers = null;
204:                boolean locked = false;
205:
206:                for (int i = 0; i < getMergers().size(); i++) {
207:                    DPChannel dpc = (DPChannel) getMergers().get(i);
208:                    fromMergers = dpc.getProviderName();
209:
210:                    if (dpc.isLocked()) {
211:                        locked = true;
212:                        if (dpc.isRemove()) {
213:                            fromMergers = null;
214:                        }
215:                        break;
216:                    }
217:                }
218:
219:                if (locked) {
220:                    toSet = fromMergers;
221:                } else {
222:                    String fromThis = getProviderNameFromThis();
223:
224:                    if (fromMergers == null) {
225:                        toSet = fromThis;
226:                    } else if (fromThis != null && fromThis.length() > 0
227:                            && !fromThis.equals(fromMergers)) {
228:                        toSet = fromThis;
229:                    }
230:                }
231:
232:                if (toSet != null && toSet.length() > 0) {
233:                    b.append(" " + PROVIDER_KEY + "=\"");
234:                    b.append(toSet);
235:                    b.append("\"");
236:                }
237:            }
238:
239:            public void toXML(StringBuffer b, int indent) {
240:                if (isDummy()) {
241:                    return;
242:                }
243:                indentBuffer(b, indent);
244:
245:                appendStartTag(b);
246:
247:                b.append(" " + NAME_KEY + "=\"").append(getChannelName())
248:                        .append("\"");
249:
250:                appendProviderAttr(b);
251:                appendMergeAttr(b);
252:                appendLockAttr(b);
253:                appendAdvancedAttr(b);
254:
255:                b.append(">\n");
256:
257:                getPropertiesFromThis().toXML(b, indent + 1);
258:
259:                indentBuffer(b, indent);
260:                appendEndTag(b);
261:            }
262:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.