Source Code Cross Referenced for HTMLElementImpl.java in  » Web-Server » Rimfaxe-Web-Server » org » apache » html » dom » 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 » Web Server » Rimfaxe Web Server » org.apache.html.dom 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The Apache Software License, Version 1.1
003:         *
004:         *
005:         * Copyright (c) 1999,2000 The Apache Software Foundation.  All rights 
006:         * reserved.
007:         *
008:         * Redistribution and use in source and binary forms, with or without
009:         * modification, are permitted provided that the following conditions
010:         * are met:
011:         *
012:         * 1. Redistributions of source code must retain the above copyright
013:         *    notice, this list of conditions and the following disclaimer. 
014:         *
015:         * 2. Redistributions in binary form must reproduce the above copyright
016:         *    notice, this list of conditions and the following disclaimer in
017:         *    the documentation and/or other materials provided with the
018:         *    distribution.
019:         *
020:         * 3. The end-user documentation included with the redistribution,
021:         *    if any, must include the following acknowledgment:  
022:         *       "This product includes software developed by the
023:         *        Apache Software Foundation (http://www.apache.org/)."
024:         *    Alternately, this acknowledgment may appear in the software itself,
025:         *    if and wherever such third-party acknowledgments normally appear.
026:         *
027:         * 4. The names "Xerces" and "Apache Software Foundation" must
028:         *    not be used to endorse or promote products derived from this
029:         *    software without prior written permission. For written 
030:         *    permission, please contact apache@apache.org.
031:         *
032:         * 5. Products derived from this software may not be called "Apache",
033:         *    nor may "Apache" appear in their name, without prior written
034:         *    permission of the Apache Software Foundation.
035:         *
036:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
037:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
038:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
039:         * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
040:         * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
042:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
043:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
044:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
045:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
046:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
047:         * SUCH DAMAGE.
048:         * ====================================================================
049:         *
050:         * This software consists of voluntary contributions made by many
051:         * individuals on behalf of the Apache Software Foundation and was
052:         * originally based on software copyright (c) 1999, International
053:         * Business Machines, Inc., http://www.apache.org.  For more
054:         * information on the Apache Software Foundation, please see
055:         * <http://www.apache.org/>.
056:         */
057:        package org.apache.html.dom;
058:
059:        import org.w3c.dom.*;
060:        import org.w3c.dom.html.*;
061:        import org.apache.xerces.dom.ElementImpl;
062:
063:        /**
064:         * Implements an HTML-specific element, an {@link org.w3c.dom.Element} that
065:         * will only appear inside HTML documents. This element extends {@link
066:         * org.apache.xerces.dom.ElementImpl} by adding methods for directly
067:         * manipulating HTML-specific attributes. All HTML elements gain access to
068:         * the <code>id</code>, <code>title</code>, <code>lang</code>,
069:         * <code>dir</code> and <code>class</code> attributes. Other elements
070:         * add their own specific attributes.
071:         * 
072:         * 
073:         * @version $Revision: 1.4 $ $Date: 2000/12/21 00:33:40 $
074:         * @author <a href="mailto:arkin@exoffice.com">Assaf Arkin</a>
075:         * @see org.w3c.dom.html.HTMLElement
076:         */
077:        public class HTMLElementImpl extends ElementImpl implements  HTMLElement {
078:
079:            /**
080:             * Constructor required owner document and element tag name. Will be called
081:             * by the constructor of specific element types but with a known tag name.
082:             * Assures that the owner document is an HTML element.
083:             * 
084:             * @param owner The owner HTML document
085:             * @param tagName The element's tag name
086:             */
087:            HTMLElementImpl(HTMLDocumentImpl owner, String tagName) {
088:                super (owner, tagName.toUpperCase());
089:            }
090:
091:            public String getId() {
092:                return getAttribute("id");
093:            }
094:
095:            public void setId(String id) {
096:                setAttribute("id", id);
097:            }
098:
099:            public String getTitle() {
100:                return getAttribute("title");
101:            }
102:
103:            public void setTitle(String title) {
104:                setAttribute("title", title);
105:            }
106:
107:            public String getLang() {
108:                return getAttribute("lang");
109:            }
110:
111:            public void setLang(String lang) {
112:                setAttribute("lang", lang);
113:            }
114:
115:            public String getDir() {
116:                return getAttribute("dir");
117:            }
118:
119:            public void setDir(String dir) {
120:                setAttribute("dir", dir);
121:            }
122:
123:            public String getClassName() {
124:                return getAttribute("class");
125:            }
126:
127:            public void setClassName(String className) {
128:                setAttribute("class", className);
129:            }
130:
131:            /**
132:             * Convenience method used to translate an attribute value into an integer
133:             * value. Returns the integer value or zero if the attribute is not a
134:             * valid numeric string.
135:             * 
136:             * @param value The value of the attribute
137:             * @return The integer value, or zero if not a valid numeric string
138:             */
139:            int getInteger(String value) {
140:                try {
141:                    return Integer.parseInt(value);
142:                } catch (NumberFormatException except) {
143:                    return 0;
144:                }
145:            }
146:
147:            /**
148:             * Convenience method used to translate an attribute value into a boolean
149:             * value. If the attribute has an associated value (even an empty string),
150:             * it is set and true is returned. If the attribute does not exist, false
151:             * is returend.
152:             * 
153:             * @param value The value of the attribute
154:             * @return True or false depending on whether the attribute has been set
155:             */
156:            boolean getBinary(String name) {
157:                return (getAttributeNode(name) != null);
158:            }
159:
160:            /**
161:             * Convenience method used to set a boolean attribute. If the value is true,
162:             * the attribute is set to an empty string. If the value is false, the attribute
163:             * is removed. HTML 4.0 understands empty strings as set attributes.
164:             * 
165:             * @param name The name of the attribute
166:             * @param value The value of the attribute
167:             */
168:            void setAttribute(String name, boolean value) {
169:                if (value)
170:                    setAttribute(name, name);
171:                else
172:                    removeAttribute(name);
173:            }
174:
175:            public Attr getAttributeNode(String attrName) {
176:                return super .getAttributeNode(attrName.toLowerCase());
177:            }
178:
179:            public Attr getAttributeNodeNS(String namespaceURI, String localName) {
180:                if (namespaceURI != null && namespaceURI.length() > 0)
181:                    return super .getAttributeNodeNS(namespaceURI, localName);
182:                else
183:                    return super .getAttributeNode(localName.toLowerCase());
184:            }
185:
186:            public String getAttribute(String attrName) {
187:                return super .getAttribute(attrName.toLowerCase());
188:            }
189:
190:            public String getAttributeNS(String namespaceURI, String localName) {
191:                if (namespaceURI != null && namespaceURI.length() > 0)
192:                    return super .getAttributeNS(namespaceURI, localName);
193:                else
194:                    return super .getAttribute(localName.toLowerCase());
195:            }
196:
197:            public final NodeList getElementsByTagName(String tagName) {
198:                return super .getElementsByTagName(tagName.toUpperCase());
199:            }
200:
201:            public final NodeList getElementsByTagNameNS(String namespaceURI,
202:                    String localName) {
203:                if (namespaceURI != null && namespaceURI.length() > 0)
204:                    return super .getElementsByTagNameNS(namespaceURI, localName
205:                            .toUpperCase());
206:                else
207:                    return super .getElementsByTagName(localName.toUpperCase());
208:            }
209:
210:            /**
211:             * Convenience method used to capitalize a one-off attribute value before it
212:             * is returned. For example, the align values "LEFT" and "left" will both
213:             * return as "Left".
214:             * 
215:             * @param value The value of the attribute
216:             * @return The capitalized value
217:             */
218:            String capitalize(String value) {
219:                char[] chars;
220:                int i;
221:
222:                // Convert string to charactares. Convert the first one to upper case,
223:                // the other characters to lower case, and return the converted string.
224:                chars = value.toCharArray();
225:                if (chars.length > 0) {
226:                    chars[0] = Character.toUpperCase(chars[0]);
227:                    for (i = 1; i < chars.length; ++i)
228:                        chars[i] = Character.toLowerCase(chars[i]);
229:                    return String.valueOf(chars);
230:                }
231:                return value;
232:            }
233:
234:            /**
235:             * Convenience method used to capitalize a one-off attribute value before it
236:             * is returned. For example, the align values "LEFT" and "left" will both
237:             * return as "Left".
238:             * 
239:             * @param name The name of the attribute
240:             * @return The capitalized value
241:             */
242:            String getCapitalized(String name) {
243:                String value;
244:                char[] chars;
245:                int i;
246:
247:                value = getAttribute(name);
248:                if (value != null) {
249:                    // Convert string to charactares. Convert the first one to upper case,
250:                    // the other characters to lower case, and return the converted string.
251:                    chars = value.toCharArray();
252:                    if (chars.length > 0) {
253:                        chars[0] = Character.toUpperCase(chars[0]);
254:                        for (i = 1; i < chars.length; ++i)
255:                            chars[i] = Character.toLowerCase(chars[i]);
256:                        return String.valueOf(chars);
257:                    }
258:                }
259:                return value;
260:            }
261:
262:            /**
263:             * Convenience method returns the form in which this form element is contained.
264:             * This method is exposed for form elements through the DOM API, but other
265:             * elements have no access to it through the API.
266:             */
267:            public HTMLFormElement getForm() {
268:                Node parent;
269:
270:                parent = getParentNode();
271:                while (parent != null) {
272:                    if (parent instanceof  HTMLFormElement)
273:                        return (HTMLFormElement) parent;
274:                    parent = parent.getParentNode();
275:                }
276:                return null;
277:            }
278:
279:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.