Source Code Cross Referenced for XMLDPContainerChannel.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 java.util.Iterator;
010:        import java.util.List;
011:        import java.util.Set;
012:
013:        import com.sun.portal.desktop.context.DPContext;
014:
015:        import com.sun.portal.desktop.dp.DPContainerChannel;
016:        import com.sun.portal.desktop.dp.DPChannel;
017:        import com.sun.portal.desktop.dp.DPAvailable;
018:        import com.sun.portal.desktop.dp.DPSelected;
019:        import com.sun.portal.desktop.dp.DPTypes;
020:        import com.sun.portal.desktop.dp.DPRoot;
021:        import com.sun.portal.desktop.dp.DPError;
022:
023:        public class XMLDPContainerChannel extends XMLDPChannel implements 
024:                DPContainerChannel, DPTypes, XMLDPTags {
025:
026:            private Element selectedElement = null;
027:            private Element availableElement = null;
028:
029:            XMLDPContainerChannel(DPContext dpc, DPRoot r, Document d,
030:                    String name, String providerName) {
031:                this (dpc, r, createElement(dpc, d, name, providerName,
032:                        XMLDPProperties.createElement(dpc, d)));
033:            }
034:
035:            XMLDPContainerChannel(DPContext dpc, DPRoot r, Element e) {
036:                super (dpc, r, e);
037:            }
038:
039:            public short getType() {
040:                return CONTAINER_DP;
041:            }
042:
043:            public String getTag() {
044:                return CONTAINER_TAG;
045:            }
046:
047:            public DPChannel copy(DPRoot dpr, boolean deep) {
048:                return copy(dpr, deep, null);
049:            }
050:
051:            public DPChannel copy(DPRoot dpr, boolean deep, String newName) {
052:                XMLDPRoot xmldpr = (XMLDPRoot) dpr;
053:
054:                Document ownerDocument = xmldpr.getElement().getOwnerDocument();
055:                Element copyElement = (Element) ownerDocument.importNode(
056:                        getElement(), deep);
057:
058:                if (!deep) {
059:                    //
060:                    // we're not copying deep, so copy empty versions of the
061:                    // required sub elements
062:                    //
063:                    copyElement.appendChild(ownerDocument
064:                            .importNode(getChildElement(getElement(),
065:                                    PROPERTIES_TAG, null), false));
066:                    copyElement.appendChild(ownerDocument.importNode(
067:                            getChildElement(getElement(), AVAILABLE_TAG, null),
068:                            false));
069:                    copyElement.appendChild(ownerDocument.importNode(
070:                            getChildElement(getElement(), SELECTED_TAG, null),
071:                            false));
072:                    copyElement.appendChild(ownerDocument.importNode(
073:                            getChildElement(getElement(), CHANNELS_TAG, null),
074:                            false));
075:                }
076:
077:                if (newName != null) {
078:                    setName(copyElement, newName);
079:                }
080:
081:                return XMLDPFactory.getInstance().getChannel(getContext(), dpr,
082:                        copyElement);
083:            }
084:
085:            Element getAvailableElement() {
086:                if (availableElement == null) {
087:                    availableElement = getChildElement(getElement(),
088:                            AVAILABLE_TAG, null);
089:                    if (availableElement == null) {
090:                        throw new DPError(
091:                                "XMLDPContainerChannel.getAvailableElement(): no "
092:                                        + AVAILABLE_TAG + " child found");
093:                    }
094:                }
095:
096:                return availableElement;
097:            }
098:
099:            public DPAvailable getAvailableFromThis() {
100:                Element a = getAvailableElement();
101:                DPAvailable dpAvailable = (DPAvailable) getObject(a);
102:                if (dpAvailable == null) {
103:                    dpAvailable = XMLDPFactory.getInstance().getAvailable(
104:                            getContext(), getRoot(), a);
105:                    putObject(dpAvailable);
106:                }
107:
108:                return dpAvailable;
109:            }
110:
111:            protected DPAvailable getAvailableFromThis(Element a) {
112:                DPAvailable dpAvailable = null;
113:
114:                if (a == null) {
115:                    throw new DPError(
116:                            "XMLDPContainerChannel.getAvailableFromThis(): no "
117:                                    + AVAILABLE_TAG + " child found");
118:                }
119:
120:                dpAvailable = XMLDPFactory.getInstance().getAvailable(
121:                        getContext(), getRoot(), a);
122:                return dpAvailable;
123:            }
124:
125:            public DPSelected getSelectedFromThis() {
126:                Element s = getSelectedElement();
127:                DPSelected dpSelected = (DPSelected) getObject(s);
128:                if (dpSelected == null) {
129:                    dpSelected = XMLDPFactory.getInstance().getSelected(
130:                            getContext(), getRoot(), s);
131:                    putObject(dpSelected);
132:                }
133:
134:                return dpSelected;
135:            }
136:
137:            Element getSelectedElement() {
138:                if (selectedElement == null) {
139:                    selectedElement = getChildElement(getElement(),
140:                            SELECTED_TAG, null);
141:                    if (selectedElement == null) {
142:                        throw new DPError(
143:                                "XMLDPContainerChannel.getSelectedElement(): no "
144:                                        + SELECTED_TAG + " child found");
145:                    }
146:                }
147:
148:                return selectedElement;
149:            }
150:
151:            public DPAvailable getAvailable() {
152:                DPAvailable dpAvailable = getAvailableFromThis();
153:
154:                if (dpAvailable != null && dpAvailable.isMerged()) {
155:                    // nothing
156:                } else {
157:                    for (int i = 0; i < getMergers().size(); i++) {
158:                        DPContainerChannel dpcc = (DPContainerChannel) getMergers()
159:                                .get(i);
160:                        DPAvailable dpa = ((XMLDPContainerChannel) dpcc)
161:                                .getAvailableFromThis();
162:
163:                        dpAvailable.addMerger(dpa);
164:                    }
165:                }
166:
167:                return dpAvailable;
168:            }
169:
170:            public void setAvailable(List avail) {
171:                getAvailable().setCollectionValue(avail);
172:            }
173:
174:            public DPSelected getSelected() {
175:                DPSelected dpSelected = getSelectedFromThis();
176:
177:                if (dpSelected != null && dpSelected.isMerged()) {
178:                    // nothing
179:                } else {
180:                    for (int i = 0; i < getMergers().size(); i++) {
181:                        DPContainerChannel dpcc = (DPContainerChannel) getMergers()
182:                                .get(i);
183:                        DPSelected dps = ((XMLDPContainerChannel) dpcc)
184:                                .getSelectedFromThis();
185:
186:                        dpSelected.addMerger(dps);
187:                    }
188:                }
189:
190:                return dpSelected;
191:            }
192:
193:            public void setSelected(List set) {
194:                getSelected().setCollectionValue(set);
195:            }
196:
197:            DPChannel createDummy(DPRoot dpr) {
198:                DPContainerChannel dpc = (DPContainerChannel) super 
199:                        .createDummy(dpr);
200:
201:                dpc.setDefaults();
202:
203:                return dpc;
204:            }
205:
206:            protected Element getMergedElement() {
207:                XMLDPProperties xp = (XMLDPProperties) getProperties();
208:                Element e = createElement(getContext(), getDocument(),
209:                        getName(), getProviderName(), xp.getMergedElement());
210:                //
211:                // add available
212:                //
213:                Element ae = getChildElement(e, AVAILABLE_TAG);
214:                XMLDPAvailable xa = (XMLDPAvailable) getAvailable();
215:                e.replaceChild(xa.getMergedElement(), ae);
216:
217:                //
218:                // add selected
219:                //
220:                Element se = getChildElement(e, SELECTED_TAG);
221:                XMLDPSelected xs = (XMLDPSelected) getSelected();
222:                e.replaceChild(xs.getMergedElement(), se);
223:
224:                //
225:                // add channels
226:                //
227:                Element cse = getChildElement(e, CHANNELS_TAG);
228:                Set names = getChannelNames();
229:                for (Iterator i = names.iterator(); i.hasNext();) {
230:                    String name = (String) i.next();
231:                    XMLDPChannel xc = (XMLDPChannel) getChannel(name);
232:                    Element ce = xc.getMergedElement();
233:                    cse.appendChild(ce);
234:                }
235:
236:                return e;
237:            }
238:
239:            static Element createElement(DPContext dpc, Document d,
240:                    String name, String providerName, Element propertiesElement) {
241:                Element e = createElement(dpc, d, CONTAINER_TAG, name);
242:                e.setAttribute("provider", providerName);
243:
244:                //
245:                // set empty properties
246:                //
247:                e.appendChild(propertiesElement);
248:
249:                //
250:                // add available
251:                //
252:                Element ae = XMLDPAvailable.createElement(dpc, d);
253:                e.appendChild(ae);
254:
255:                //
256:                // add selected
257:                //
258:                Element se = XMLDPSelected.createElement(dpc, d);
259:                e.appendChild(se);
260:
261:                //
262:                // add "channels" bag
263:                //
264:                Element channelsElement = d.createElement(CHANNELS_TAG);
265:                e.appendChild(channelsElement);
266:
267:                setDefaultsElement(e);
268:
269:                return e;
270:            }
271:
272:            public void setMergeDefaults() {
273:                setMergeDefaultsElement(getElement());
274:            }
275:
276:            public void setDefaults() {
277:                setDefaultsElement(getElement());
278:            }
279:
280:            static void setMergeDefaultsElement(Element e) {
281:                setMergeTypeElement(e, staticGetDefaultMergeType());
282:                e.setAttribute(LOCK_KEY, FALSE_ATTR);
283:
284:                Element pe = getChildElement(e, PROPERTIES_TAG, null);
285:                XMLDPProperties.setMergeDefaultsElement(pe);
286:                Element ae = getChildElement(e, AVAILABLE_TAG, null);
287:                XMLDPAvailable.setMergeDefaultsElement(ae);
288:                Element se = getChildElement(e, SELECTED_TAG, null);
289:                XMLDPSelected.setMergeDefaultsElement(se);
290:            }
291:
292:            static void setDefaultsElement(Element e) {
293:                setMergeDefaultsElement(e);
294:                e.setAttribute(ADVANCED_KEY, FALSE_ATTR);
295:
296:                Element pe = getChildElement(e, PROPERTIES_TAG, null);
297:                XMLDPProperties.setDefaultsElement(pe);
298:                Element ae = getChildElement(e, AVAILABLE_TAG, null);
299:                XMLDPAvailable.setDefaultsElement(ae);
300:                Element se = getChildElement(e, SELECTED_TAG, null);
301:                XMLDPSelected.setDefaultsElement(se);
302:            }
303:
304:            public void toXML(StringBuffer b, int indent) {
305:                if (isDummy()) {
306:                    return;
307:                }
308:
309:                indentBuffer(b, indent);
310:                appendStartTag(b);
311:                b.append(" " + NAME_KEY + "=\"").append(getChannelName())
312:                        .append("\"");
313:
314:                appendProviderAttr(b);
315:                appendMergeAttr(b);
316:                appendLockAttr(b);
317:                appendAdvancedAttr(b);
318:                b.append(">\n");
319:
320:                getPropertiesFromThis().toXML(b, indent + 1);
321:                getAvailableFromThis().toXML(b, indent + 1);
322:                getSelectedFromThis().toXML(b, indent + 1);
323:
324:                // Add Channels
325:                indentBuffer(b, indent + 1);
326:
327:                appendChannels(b, indent);
328:
329:                indentBuffer(b, indent);
330:                appendEndTag(b);
331:            }
332:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.