Source Code Cross Referenced for GenericElementNode.java in  » 6.0-JDK-Modules » j2me » com » sun » perseus » model » 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 » 6.0 JDK Modules » j2me » com.sun.perseus.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *
003:         *
004:         * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation.
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt).
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions.
025:         */
026:        package com.sun.perseus.model;
027:
028:        import com.sun.perseus.util.SVGConstants;
029:
030:        import org.w3c.dom.DOMException;
031:
032:        /**
033:         * A <code>GenericElementNode</code> is used to model elements which are either
034:         * unknown to Perseus or have no special behavior or attributes.
035:         *
036:         * Note that <code>GenericElementNode</code> is needed because we want to avoid
037:         * storing a namespaceURI and localName references for nodes which always return
038:         * constants for these values. Another option was to have namespaceURI and
039:         * localName be attributes of <code>ElementNode</code>, but that would have
040:         * forced us to carry two extra references on all nodes, which is superfluous.
041:         *
042:         * @version $Id: GenericElementNode.java,v 1.3 2006/04/21 06:37:21 st125089 Exp $
043:         */
044:        public class GenericElementNode extends ElementNode {
045:            /**
046:             * The element's namespace URI.
047:             */
048:            protected String namespaceURI;
049:
050:            /**
051:             * The element's local name.
052:             */
053:            protected String localName;
054:
055:            /**
056:             * The text content
057:             */
058:            protected String content;
059:
060:            /**
061:             * Constructor, providing the element's namespace and local name
062:             *
063:             * @param namespaceURI the element's namespace. May be null.
064:             * @param localName the element's localName. Should not be null.
065:             * @param doc the <code>DocumentNode</code> this node belongs to. Should
066:             *        not be null.
067:             * @throws IllegalArgumentException if one of the arguments is null.
068:             */
069:            public GenericElementNode(final String namespaceURI,
070:                    final String localName, final DocumentNode doc) {
071:                super (doc);
072:
073:                if (localName == null) {
074:                    throw new IllegalArgumentException();
075:                }
076:
077:                this .namespaceURI = namespaceURI;
078:                this .localName = localName;
079:            }
080:
081:            /**
082:             * @return the namespaceURI provided in the constructor.
083:             */
084:            public String getNamespaceURI() {
085:                return namespaceURI;
086:            }
087:
088:            /**
089:             * @return the localName provided in the constructor.
090:             */
091:
092:            public String getLocalName() {
093:                return localName;
094:            }
095:
096:            /**
097:             * Used by <code>DocumentNode</code> to create a new instance from
098:             * a prototype <code>GenericElementNode</code>.
099:             *
100:             * @param doc the <code>DocumentNode</code> for which a new node is
101:             *        should be created.
102:             * @return a new <code>GenericElementNode</code> for the requested document.
103:             */
104:            public ElementNode newInstance(final DocumentNode doc) {
105:                return new GenericElementNode(namespaceURI, localName, doc);
106:            }
107:
108:            /**
109:             * @param text the text to append to this node's content.
110:             *        If text is null or empty, this does nothing.
111:             */
112:            public void appendTextChild(final String text) {
113:                if (text == null || text.length() == 0) {
114:                    return;
115:                }
116:
117:                if (content == null) {
118:                    setContent(text);
119:                } else {
120:                    setContent(content + text);
121:                }
122:            }
123:
124:            /**
125:             * @param newContent this node's new content string
126:             */
127:            public void setContent(final String newContent) {
128:                if (equal(newContent, content)) {
129:                    return;
130:                }
131:                modifyingNode();
132:                this .content = newContent;
133:                modifiedNode();
134:            }
135:
136:            /**
137:             * @return this node's text content as a string
138:             */
139:            public String getContent() {
140:                return content;
141:            }
142:
143:            /**
144:             * Handles #text traits.
145:             *
146:             * @param name the requested trait's name (e.g., "#text")
147:             * @return the requested trait's string value (e.g., "Hello SVG Text")
148:             *
149:             * @throws DOMException with error code NOT_SUPPORTED_ERROR if the requested
150:             * trait is not supported on this element or null.
151:             * @throws DOMException with error code TYPE_MISMATCH_ERR if requested
152:             * trait's computed value cannot be converted to a String (SVG Tiny only).
153:             */
154:            public String getTraitImpl(final String name) throws DOMException {
155:                if (SVGConstants.SVG_TEXT_PSEUDO_ATTRIBUTE == name) {
156:                    if (content == null) {
157:                        return "";
158:                    }
159:                    return getContent();
160:                } else {
161:                    return super .getTraitImpl(name);
162:                }
163:            }
164:
165:            /**
166:             * @param traitName the trait name.
167:             */
168:            TraitAnim createTraitAnimImpl(final String traitName) {
169:                if (SVGConstants.SVG_TEXT_PSEUDO_ATTRIBUTE == traitName) {
170:                    return new StringTraitAnim(this , NULL_NS, traitName);
171:                } else {
172:                    return super .createTraitAnimImpl(traitName);
173:                }
174:            }
175:
176:            /**
177:             * Handles the #text traits.
178:             *
179:             * @param name the trait's name (e.g., "#text")
180:             * @param value the trait's value (e.g, "Hello SVG Text")
181:             *
182:             * @throws DOMException with error code NOT_SUPPORTED_ERROR if the requested
183:             * trait is not supported on this element or null.
184:             * @throws DOMException with error code TYPE_MISMATCH_ERR if the requested
185:             * trait's value cannot be specified as a String
186:             * @throws DOMException with error code INVALID_ACCESS_ERR if the input
187:             * value is an invalid value for the given trait or null.
188:             * @throws DOMException with error code NO_MODIFICATION_ALLOWED_ERR: if
189:             * attempt is made to change readonly trait.
190:             */
191:            public void setTraitImpl(final String name, final String value)
192:                    throws DOMException {
193:                if (SVGConstants.SVG_TEXT_PSEUDO_ATTRIBUTE == name) {
194:                    if (value == null) {
195:                        throw illegalTraitValue(name, value);
196:                    }
197:                    setContent(value);
198:                } else {
199:                    super.setTraitImpl(name, value);
200:                }
201:            }
202:
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.