Source Code Cross Referenced for XMLDPAtomic.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.Element;
008:        import org.w3c.dom.Document;
009:        import org.w3c.dom.Text;
010:
011:        import com.sun.portal.desktop.context.DPContext;
012:        import com.sun.portal.desktop.encode.Encoder;
013:        import com.sun.portal.desktop.dp.DPAtomic;
014:        import com.sun.portal.desktop.dp.DPProperty;
015:        import com.sun.portal.desktop.dp.DPRoot;
016:
017:        abstract class XMLDPAtomic extends XMLDPProperty implements  DPAtomic,
018:                XMLDPAttrs {
019:            XMLDPAtomic(DPContext dpc, DPRoot r, Element e) {
020:                super (dpc, r, e);
021:            }
022:
023:            public Object getValue() {
024:                //
025:                // here, the case where this is remove, or were the merger is locked
026:                // and is remove should be handled by the object that created us.
027:                // such an object should not give an instance of a DP object
028:                // if the merger is remove.
029:                //
030:                // namely, our merge == replace, and the merger's merge (if there's
031:                // a merger) is also replace.
032:
033:                //
034:                // if there's no mergers, all we can do is get from this
035:                //
036:                if (getMergers().size() == 0) {
037:                    return getValueFromThis();
038:                }
039:
040:                // Iterate through the dp docs at different node and check
041:                // for lock and remove condition
042:                for (int i = 0; i < getMergers().size(); i++) {
043:                    DPProperty dpc = (DPProperty) getMergers().get(i);
044:                    // If the property is locked at a higher level, handle that
045:                    if (dpc.isLocked()) {
046:                        // Property is to be removed, return null
047:                        if (dpc.isRemove()) {
048:                            return null;
049:                        }
050:                        // Locked at a higher level, hence don't consider other dp
051:                        // docs leave the method with what you have.
052:                        return ((XMLDPAtomic) dpc).getValueFromThis();
053:                    }
054:                }
055:
056:                //if it is a dummy, return the last merger
057:                if (isDummy()) {
058:                    return ((XMLDPAtomic) getLastMerger()).getValueFromThis();
059:                }
060:
061:                //
062:                // else, merge type was replace, so return the user value
063:                //
064:
065:                return getValueFromThis();
066:            }
067:
068:            /**
069:             * Make a copy of the DP property object.
070:             *
071:             */
072:            public DPProperty copy(DPRoot dpr, boolean deep) {
073:                //
074:                // we must copy atomic properties deeply, to get their body content
075:                // value if it exists.
076:                //
077:                return super .copy(dpr, true);
078:            }
079:
080:            protected Object getValueFromThis() {
081:
082:                if (isValueBodyContent()) {
083:                    return getValueFromThisBodyContent();
084:                } else {
085:                    return getValueFromThisAttribute();
086:                }
087:
088:            }
089:
090:            protected boolean isValueBodyContent() {
091:                boolean bodyContent = false;
092:
093:                if (getTextNode(getElement()) != null) {
094:                    bodyContent = true;
095:                }
096:
097:                return bodyContent;
098:            }
099:
100:            protected Object getValueFromThisBodyContent() {
101:                return getTextNode(getElement()).getData();
102:            }
103:
104:            protected Object getValueFromThisAttribute() {
105:                return getElement().getAttribute("value");
106:            }
107:
108:            public Object setValue(Object val) {
109:                Object old = getValue();
110:
111:                Text textNode = getTextNode(getElement());
112:
113:                if (textNode == null) {
114:                    getElement().setAttribute("value", val.toString());
115:                } else {
116:                    textNode.setData(val.toString());
117:                }
118:
119:                setDummy(false);
120:
121:                return old;
122:            }
123:
124:            protected Element getMergedElement() {
125:                Element e = createElement(getContext(), getDocument(),
126:                        getTag(), getName(), (String) getValue());
127:                return e;
128:            }
129:
130:            static Element createElement(DPContext dpc, Document d,
131:                    String tagName, String val) {
132:                Element e = createElement(dpc, d, tagName, null, val);
133:                return e;
134:            }
135:
136:            static Element createElement(DPContext dpc, Document d,
137:                    String tagName, String name, String val) {
138:                Element e = XMLDPObject.createElement(dpc, d, tagName, name);
139:
140:                //
141:                // TBD(jtb): must change this to allow the value to be set
142:                // in the body content, not just as an attr
143:                //
144:                e.setAttribute(VALUE_KEY, val);
145:                setDefaultsElement(e);
146:
147:                return e;
148:            }
149:
150:            public int getDefaultMergeType() {
151:                return staticGetDefaultMergeType();
152:            }
153:
154:            static int staticGetDefaultMergeType() {
155:                return MERGE_REPLACE;
156:            }
157:
158:            public void setMergeDefaults() {
159:                setMergeDefaultsElement(getElement());
160:            }
161:
162:            public void setDefaults() {
163:                setDefaultsElement(getElement());
164:            }
165:
166:            static void setMergeDefaultsElement(Element e) {
167:                setMergeTypeElement(e, staticGetDefaultMergeType());
168:                e.setAttribute(LOCK_KEY, FALSE_ATTR);
169:            }
170:
171:            static void setDefaultsElement(Element e) {
172:                setMergeDefaultsElement(e);
173:                e.setAttribute(PROPAGATE_KEY, TRUE_ATTR);
174:                e.setAttribute(ADVANCED_KEY, FALSE_ATTR);
175:            }
176:
177:            public void appendTagValue(StringBuffer b) {
178:
179:                appendStartTag(b);
180:
181:                if (isNamed()) {
182:                    b.append(" " + NAME_KEY + "=\"").append(
183:                            Encoder.XML_ENCODER.encode(getName())).append("\"");
184:                }
185:                b.append(" " + VALUE_KEY + "=\"")
186:                        .append(
187:                                Encoder.XML_ENCODER
188:                                        .encode((String) getValueFromThis()))
189:                        .append("\"");
190:            }
191:
192:            public void toXML(StringBuffer b, int indent) {
193:                if (isDummy()) {
194:                    return;
195:                }
196:                boolean bodyContent = isValueBodyContent();
197:                indentBuffer(b, indent);
198:
199:                if (bodyContent) {
200:                    appendStartTag(b);
201:                } else {
202:                    appendTagValue(b);
203:                }
204:                appendMergeAttr(b);
205:                appendLockAttr(b);
206:                appendAdvancedAttr(b);
207:                appendPropagateAttr(b);
208:                if (bodyContent) {
209:                    b.append(">").append(
210:                            Encoder.XML_ENCODER
211:                                    .encode((String) getValueFromThis()));
212:                    appendEndTag(b);
213:                } else {
214:                    b.append("/>\n");
215:                }
216:
217:            }
218:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.