Source Code Cross Referenced for DOMElementImpl.java in  » HTML-Parser » JTidy » org » w3c » tidy » 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 » HTML Parser » JTidy » org.w3c.tidy 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Java HTML Tidy - JTidy
003:         *  HTML parser and pretty printer
004:         *
005:         *  Copyright (c) 1998-2000 World Wide Web Consortium (Massachusetts
006:         *  Institute of Technology, Institut National de Recherche en
007:         *  Informatique et en Automatique, Keio University). All Rights
008:         *  Reserved.
009:         *
010:         *  Contributing Author(s):
011:         *
012:         *     Dave Raggett <dsr@w3.org>
013:         *     Andy Quick <ac.quick@sympatico.ca> (translation to Java)
014:         *     Gary L Peskin <garyp@firstech.com> (Java development)
015:         *     Sami Lempinen <sami@lempinen.net> (release management)
016:         *     Fabrizio Giustina <fgiust at users.sourceforge.net>
017:         *
018:         *  The contributing author(s) would like to thank all those who
019:         *  helped with testing, bug fixes, and patience.  This wouldn't
020:         *  have been possible without all of you.
021:         *
022:         *  COPYRIGHT NOTICE:
023:         * 
024:         *  This software and documentation is provided "as is," and
025:         *  the copyright holders and contributing author(s) make no
026:         *  representations or warranties, express or implied, including
027:         *  but not limited to, warranties of merchantability or fitness
028:         *  for any particular purpose or that the use of the software or
029:         *  documentation will not infringe any third party patents,
030:         *  copyrights, trademarks or other rights. 
031:         *
032:         *  The copyright holders and contributing author(s) will not be
033:         *  liable for any direct, indirect, special or consequential damages
034:         *  arising out of any use of the software or documentation, even if
035:         *  advised of the possibility of such damage.
036:         *
037:         *  Permission is hereby granted to use, copy, modify, and distribute
038:         *  this source code, or portions hereof, documentation and executables,
039:         *  for any purpose, without fee, subject to the following restrictions:
040:         *
041:         *  1. The origin of this source code must not be misrepresented.
042:         *  2. Altered versions must be plainly marked as such and must
043:         *     not be misrepresented as being the original source.
044:         *  3. This Copyright notice may not be removed or altered from any
045:         *     source or altered source distribution.
046:         * 
047:         *  The copyright holders and contributing author(s) specifically
048:         *  permit, without fee, and encourage the use of this source code
049:         *  as a component for supporting the Hypertext Markup Language in
050:         *  commercial products. If you use this source code in a product,
051:         *  acknowledgment is not required but would be appreciated.
052:         *
053:         */
054:        package org.w3c.tidy;
055:
056:        import org.w3c.dom.Attr;
057:        import org.w3c.dom.DOMException;
058:        import org.w3c.dom.TypeInfo;
059:
060:        /**
061:         * DOMElementImpl.
062:         * @author Dave Raggett <a href="mailto:dsr@w3.org">dsr@w3.org </a>
063:         * @author Andy Quick <a href="mailto:ac.quick@sympatico.ca">ac.quick@sympatico.ca </a> (translation to Java)
064:         * @author Fabrizio Giustina
065:         * @version $Revision: 1.9 $ ($Author: fgiust $)
066:         */
067:        public class DOMElementImpl extends DOMNodeImpl implements 
068:                org.w3c.dom.Element {
069:
070:            /**
071:             * Instantiates a new DOM element.
072:             * @param adaptee Tidy Node.
073:             */
074:            protected DOMElementImpl(Node adaptee) {
075:                super (adaptee);
076:            }
077:
078:            /**
079:             * @see org.w3c.dom.Node#getNodeType
080:             */
081:            public short getNodeType() {
082:                return org.w3c.dom.Node.ELEMENT_NODE;
083:            }
084:
085:            /**
086:             * @see org.w3c.dom.Element#getTagName
087:             */
088:            public String getTagName() {
089:                return super .getNodeName();
090:            }
091:
092:            /**
093:             * @see org.w3c.dom.Element#getAttribute(java.lang.String)
094:             */
095:            public String getAttribute(String name) {
096:                if (this .adaptee == null) {
097:                    return null;
098:                }
099:
100:                AttVal att = this .adaptee.attributes;
101:                while (att != null) {
102:                    if (att.attribute.equals(name)) {
103:                        break;
104:                    }
105:                    att = att.next;
106:                }
107:                if (att != null) {
108:                    return att.value;
109:                }
110:
111:                return "";
112:            }
113:
114:            /**
115:             * @see org.w3c.dom.Element#setAttribute(java.lang.String, java.lang.String)
116:             */
117:            public void setAttribute(String name, String value)
118:                    throws DOMException {
119:                if (this .adaptee == null) {
120:                    return;
121:                }
122:
123:                AttVal att = this .adaptee.attributes;
124:                while (att != null) {
125:                    if (att.attribute.equals(name)) {
126:                        break;
127:                    }
128:                    att = att.next;
129:                }
130:                if (att != null) {
131:                    att.value = value;
132:                } else {
133:                    att = new AttVal(null, null, '"', name, value);
134:                    att.dict = AttributeTable.getDefaultAttributeTable()
135:                            .findAttribute(att);
136:                    if (this .adaptee.attributes == null) {
137:                        this .adaptee.attributes = att;
138:                    } else {
139:                        att.next = this .adaptee.attributes;
140:                        this .adaptee.attributes = att;
141:                    }
142:                }
143:            }
144:
145:            /**
146:             * @see org.w3c.dom.Element#removeAttribute(java.lang.String)
147:             */
148:            public void removeAttribute(String name) throws DOMException {
149:                if (this .adaptee == null) {
150:                    return;
151:                }
152:
153:                AttVal att = this .adaptee.attributes;
154:                AttVal pre = null;
155:                while (att != null) {
156:                    if (att.attribute.equals(name)) {
157:                        break;
158:                    }
159:                    pre = att;
160:                    att = att.next;
161:                }
162:                if (att != null) {
163:                    if (pre == null) {
164:                        this .adaptee.attributes = att.next;
165:                    } else {
166:                        pre.next = att.next;
167:                    }
168:                }
169:            }
170:
171:            /**
172:             * @see org.w3c.dom.Element#getAttributeNode(java.lang.String)
173:             */
174:            public org.w3c.dom.Attr getAttributeNode(String name) {
175:                if (this .adaptee == null) {
176:                    return null;
177:                }
178:
179:                AttVal att = this .adaptee.attributes;
180:                while (att != null) {
181:                    if (att.attribute.equals(name)) {
182:                        break;
183:                    }
184:                    att = att.next;
185:                }
186:                if (att != null) {
187:                    return att.getAdapter();
188:                }
189:
190:                return null;
191:            }
192:
193:            /**
194:             * @see org.w3c.dom.Element#setAttributeNode(org.w3c.dom.Attr)
195:             */
196:            public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr)
197:                    throws DOMException {
198:                if (newAttr == null) {
199:                    return null;
200:                }
201:                if (!(newAttr instanceof  DOMAttrImpl)) {
202:                    throw new DOMException(DOMException.WRONG_DOCUMENT_ERR,
203:                            "newAttr not instanceof DOMAttrImpl");
204:                }
205:
206:                DOMAttrImpl newatt = (DOMAttrImpl) newAttr;
207:                String name = newatt.avAdaptee.attribute;
208:                org.w3c.dom.Attr result = null;
209:
210:                AttVal att = this .adaptee.attributes;
211:                while (att != null) {
212:                    if (att.attribute.equals(name)) {
213:                        break;
214:                    }
215:                    att = att.next;
216:                }
217:                if (att != null) {
218:                    result = att.getAdapter();
219:                    att.adapter = newAttr;
220:                } else {
221:                    if (this .adaptee.attributes == null) {
222:                        this .adaptee.attributes = newatt.avAdaptee;
223:                    } else {
224:                        newatt.avAdaptee.next = this .adaptee.attributes;
225:                        this .adaptee.attributes = newatt.avAdaptee;
226:                    }
227:                }
228:                return result;
229:            }
230:
231:            /**
232:             * @see org.w3c.dom.Element#removeAttributeNode(org.w3c.dom.Attr)
233:             */
234:            public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr)
235:                    throws DOMException {
236:                if (oldAttr == null) {
237:                    return null;
238:                }
239:
240:                org.w3c.dom.Attr result = null;
241:                AttVal att = this .adaptee.attributes;
242:                AttVal pre = null;
243:                while (att != null) {
244:                    if (att.getAdapter() == oldAttr) {
245:                        break;
246:                    }
247:                    pre = att;
248:                    att = att.next;
249:                }
250:                if (att != null) {
251:                    if (pre == null) {
252:                        this .adaptee.attributes = att.next;
253:                    } else {
254:                        pre.next = att.next;
255:                    }
256:                    result = oldAttr;
257:                } else {
258:                    throw new DOMException(DOMException.NOT_FOUND_ERR,
259:                            "oldAttr not found");
260:                }
261:                return result;
262:            }
263:
264:            /**
265:             * @see org.w3c.dom.Element#getElementsByTagName(java.lang.String)
266:             */
267:            public org.w3c.dom.NodeList getElementsByTagName(String name) {
268:                return new DOMNodeListByTagNameImpl(this .adaptee, name);
269:            }
270:
271:            /**
272:             * @todo DOM level 2 getOwnerDocument() Not supported. Do nothing.
273:             * @see org.w3c.dom.Element#normalize
274:             */
275:            public void normalize() {
276:                // do nothing
277:            }
278:
279:            /**
280:             * @todo DOM level 2 getAttributeNS() Not supported. Throws NOT_SUPPORTED_ERR.
281:             * @see org.w3c.dom.Element#getAttributeNS(java.lang.String, java.lang.String)
282:             */
283:            public String getAttributeNS(String namespaceURI, String localName) {
284:                // DOMException - NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature "XML" and
285:                // the language exposed through the Document does not support XML Namespaces (such as HTML 4.01).
286:                throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
287:                        "DOM method not supported");
288:            }
289:
290:            /**
291:             * @todo DOM level 2 setAttributeNS() Not supported. Throws NOT_SUPPORTED_ERR.
292:             * @see org.w3c.dom.Element#setAttributeNS(java.lang.String, java.lang.String, java.lang.String)
293:             */
294:            public void setAttributeNS(String namespaceURI,
295:                    String qualifiedName, String value)
296:                    throws org.w3c.dom.DOMException {
297:                throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
298:                        "DOM method not supported");
299:            }
300:
301:            /**
302:             * @todo DOM level 2 removeAttributeNS() Not supported. Throws NOT_SUPPORTED_ERR.
303:             * @see org.w3c.dom.Element#removeAttributeNS(java.lang.String, java.lang.String)
304:             */
305:            public void removeAttributeNS(String namespaceURI, String localName)
306:                    throws org.w3c.dom.DOMException {
307:                throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
308:                        "DOM method not supported");
309:            }
310:
311:            /**
312:             * @todo DOM level 2 getAttributeNodeNS() Not supported. Throws NOT_SUPPORTED_ERR.
313:             * @see org.w3c.dom.Element#getAttributeNodeNS(java.lang.String, java.lang.String)
314:             */
315:            public org.w3c.dom.Attr getAttributeNodeNS(String namespaceURI,
316:                    String localName) {
317:                throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
318:                        "DOM method not supported");
319:            }
320:
321:            /**
322:             * @todo DOM level 2 setAttributeNodeNS() Not supported. Throws NOT_SUPPORTED_ERR.
323:             * @see org.w3c.dom.Element#setAttributeNodeNS(org.w3c.dom.Attr)
324:             */
325:            public org.w3c.dom.Attr setAttributeNodeNS(org.w3c.dom.Attr newAttr)
326:                    throws org.w3c.dom.DOMException {
327:                throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
328:                        "DOM method not supported");
329:            }
330:
331:            /**
332:             * @todo DOM level 2 getElementsByTagNameNS() Not supported. Throws NOT_SUPPORTED_ERR.
333:             * @see org.w3c.dom.Element#getElementsByTagNameNS(java.lang.String, java.lang.String)
334:             */
335:            public org.w3c.dom.NodeList getElementsByTagNameNS(
336:                    String namespaceURI, String localName) {
337:                throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
338:                        "DOM method not supported");
339:            }
340:
341:            /**
342:             * @todo DOM level 2 hasAttribute() Not supported. Returns false.
343:             * @see org.w3c.dom.Element#hasAttribute(java.lang.String)
344:             */
345:            public boolean hasAttribute(String name) {
346:                return false;
347:            }
348:
349:            /**
350:             * @todo DOM level 2 hasAttribute() Not supported. Returns false.
351:             * @see org.w3c.dom.Element#hasAttributeNS(java.lang.String, java.lang.String)
352:             */
353:            public boolean hasAttributeNS(String namespaceURI, String localName) {
354:                return false;
355:            }
356:
357:            /**
358:             * @todo DOM level 3 getSchemaTypeInfo() Not supported. Returns null.
359:             * @see org.w3c.dom.Element#getSchemaTypeInfo()
360:             */
361:            public TypeInfo getSchemaTypeInfo() {
362:                return null;
363:            }
364:
365:            /**
366:             * @todo DOM level 3 setIdAttribute() Not supported. Throws NOT_SUPPORTED_ERR.
367:             * @see org.w3c.dom.Element#setIdAttribute(java.lang.String, boolean)
368:             */
369:            public void setIdAttribute(String name, boolean isId)
370:                    throws DOMException {
371:                throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
372:                        "DOM method not supported");
373:            }
374:
375:            /**
376:             * @todo DOM level 3 setIdAttributeNode() Not supported. Throws NOT_SUPPORTED_ERR.
377:             * @see org.w3c.dom.Element#setIdAttributeNode(org.w3c.dom.Attr, boolean)
378:             */
379:            public void setIdAttributeNode(Attr idAttr, boolean isId)
380:                    throws DOMException {
381:                throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
382:                        "DOM method not supported");
383:            }
384:
385:            /**
386:             * @todo DOM level 3 setIdAttributeNS() Not supported. Throws NOT_SUPPORTED_ERR.
387:             * @see org.w3c.dom.Element#setIdAttributeNS(java.lang.String, java.lang.String, boolean)
388:             */
389:            public void setIdAttributeNS(String namespaceURI, String localName,
390:                    boolean isId) throws DOMException {
391:                throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
392:                        "DOM method not supported");
393:            }
394:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.