Source Code Cross Referenced for Element.java in  » Database-ORM » castor » org » exolab » castor » xml » dtd » 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 » Database ORM » castor » org.exolab.castor.xml.dtd 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Redistribution and use of this software and associated documentation
003:         * ("Software"), with or without modification, are permitted provided
004:         * that the following conditions are met:
005:         *
006:         * 1. Redistributions of source code must retain copyright
007:         *    statements and notices.  Redistributions must also contain a
008:         *    copy of this document.
009:         *
010:         * 2. Redistributions in binary form must reproduce the
011:         *    above copyright notice, this list of conditions and the
012:         *    following disclaimer in the documentation and/or other
013:         *    materials provided with the distribution.
014:         *
015:         * 3. The name "Exolab" must not be used to endorse or promote
016:         *    products derived from this Software without prior written
017:         *    permission of Intalio, Inc.  For written permission,
018:         *    please contact info@exolab.org.
019:         *
020:         * 4. Products derived from this Software may not be called "Exolab"
021:         *    nor may "Exolab" appear in their names without prior written
022:         *    permission of Intalio, Inc. Exolab is a registered
023:         *    trademark of Intalio, Inc.
024:         *
025:         * 5. Due credit should be given to the Exolab Project
026:         *    (http://www.exolab.org/).
027:         *
028:         * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS
029:         * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
030:         * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
031:         * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
032:         * INTALIO, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
033:         * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
034:         * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
035:         * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
036:         * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
037:         * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
038:         * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
039:         * OF THE POSSIBILITY OF SUCH DAMAGE.
040:         *
041:         * Copyright 2000 (C) Intalio Inc. All Rights Reserved.
042:         *
043:         * $Id: Element.java 5951 2006-05-30 22:18:48Z bsnyder $
044:         */package org.exolab.castor.xml.dtd;
045:
046:        import java.util.HashSet;
047:        import java.util.Hashtable;
048:        import java.util.Iterator;
049:        import java.util.Enumeration;
050:
051:        /**
052:         * Implementation of DTD Element declaration specification.
053:         * @author <a href="mailto:totok@intalio.com">Alexander Totok</a>
054:         * @version $Revision: 5951 $ $Date: 2006-04-25 15:08:23 -0600 (Tue, 25 Apr 2006) $
055:         */
056:        public class Element {
057:
058:            private static final short ANY = 0;
059:            private static final short EMPTY = 1;
060:            private static final short MIXED = 2;
061:            private static final short ELEMENTS_ONLY = 3;
062:
063:            /**
064:             * Name of the element.
065:             */
066:            private String name;
067:
068:            /**
069:             * DTD document owning this element
070:             */
071:            private DTDdocument document;
072:
073:            /**
074:             * Content type of the element. Value may be {@link #ANY ANY}, {@link #EMPTY EMPTY},
075:             * {@link #MIXED MIXED}, {@link #ELEMENTS_ONLY ELEMENTS_ONLY} or
076:             * -1, if unspecified.
077:             */
078:            private short contentType = -1;
079:
080:            /**
081:             * Set of names of children of the element,
082:             * if the element has <tt>MIXED</tt> content.
083:             */
084:            private HashSet mixedChildren = null;
085:
086:            /**
087:             * Content Particle representing content of the element, if the element has
088:             * <tt>ELEMENTS_ONLY</tt> content.
089:             */
090:            private ContentParticle content = null;
091:
092:            /**
093:             * Attributes of the element.
094:             */
095:            private Hashtable attributes;
096:
097:            /**
098:             * Constructor, setting the name of the element and owning DTD document.
099:             * @param document must not be null.
100:             */
101:            public Element(DTDdocument document, String name) {
102:
103:                if (document == null) {
104:                    String err = "Element constructor: document must not be null.";
105:                    throw new IllegalArgumentException(err);
106:                }
107:
108:                this .name = name;
109:                this .document = document;
110:                attributes = new Hashtable();
111:            } //-- Element
112:
113:            /**
114:             * Constructor, setting owning DTD document of the element.
115:             * @param document must not be null.
116:             */
117:            public Element(DTDdocument document) {
118:                this (document, null);
119:            } //-- Element
120:
121:            /**
122:             * Returns the name of the element.
123:             */
124:            public String getName() {
125:                return name;
126:            } //-- getName
127:
128:            /**
129:             * Returns DTD document owning this element.
130:             */
131:            public DTDdocument getDocument() {
132:                return document;
133:            } //-- getDocument
134:
135:            /**
136:             * Returns {@link java.util.Iterator iterator} of the set of mixed children,
137:             * if of <tt>MIXED</tt> content, <tt>null</tt> otherwise.
138:             */
139:            public Iterator getMixedContentChildren() {
140:                if (isMixedContent())
141:                    return mixedChildren.iterator();
142:                return null;
143:            } //-- getMixedContentChildren
144:
145:            /**
146:             * Returns enumeration of the attributes of the element.
147:             */
148:            public Enumeration getAttributes() {
149:                return attributes.elements();
150:            } //-- getAttributes
151:
152:            /**
153:             * Returns {@link org.exolab.castor.xml.dtd.ContentParticle Content Particle},
154:             * representing the content of the element, if has <tt>ELEMENTS_ONLY</tt>
155:             * content, <tt>null</tt> otherwise.
156:             */
157:            public ContentParticle getContent() {
158:                if (isElemOnlyContent())
159:                    return content;
160:                return null;
161:            } //-- getContent
162:
163:            /**
164:             * Sets the name of the element.
165:             */
166:            public void setName(String name) {
167:                this .name = name;
168:            } //-- setName
169:
170:            /**
171:             * Sets the content type of the element to <tt>ANY</tt>.
172:             */
173:            public void setAnyContent() {
174:                contentType = ANY;
175:            } //-- setAnyContent
176:
177:            /**
178:             * <b>True</b> if the element is of <tt>ANY</tt> content type,
179:             * <b>false</b> otherwise.
180:             */
181:            public boolean isAnyContent() {
182:                return contentType == ANY;
183:            } //-- isAnyContent
184:
185:            /**
186:             * Sets the content type of the element to <tt>EMPTY</tt>.
187:             */
188:            public void setEmptyContent() {
189:                contentType = EMPTY;
190:            } //-- setEmptyContent
191:
192:            /**
193:             * <b>True</b> if the element is of <tt>EMPTY</tt> content type, <b>false</b> otherwise.
194:             */
195:            public boolean isEmptyContent() {
196:                return contentType == EMPTY;
197:            } //-- isEmptyContent
198:
199:            /**
200:             * Sets the content type of the element to <tt>MIXED</tt>.
201:             */
202:            public void setMixedContent() {
203:                contentType = MIXED;
204:                mixedChildren = new HashSet();
205:            } //-- setMixedContent
206:
207:            /**
208:             * <b>True</b> if the element is of <tt>MIXED</tt> content type, <b>false</b> otherwise.
209:             */
210:            public boolean isMixedContent() {
211:                return contentType == MIXED;
212:            } //-- isMixedContent
213:
214:            /**
215:             * Sets the content type of the element to <tt>ELEMENTS_ONLY</tt>.
216:             * @param cp Content Particle representing content of the element.
217:             */
218:            public void setElemOnlyContent(ContentParticle cp) {
219:                contentType = ELEMENTS_ONLY;
220:                content = cp;
221:            } //-- setChildrenContent
222:
223:            /**
224:             * <b>True</b> if the element is of <tt>ELEMENTS_ONLY</tt> content type,
225:             * <b>false</b> otherwise.
226:             */
227:            public boolean isElemOnlyContent() {
228:                return contentType == ELEMENTS_ONLY;
229:            } //-- isChildrenContent
230:
231:            /**
232:             * Adds name of a <tt>child</tt> to the set of children's names.
233:             * @throws DTDException if there already exists the child with the same name.
234:             */
235:            public synchronized void addMixedContentChild(String child)
236:                    throws DTDException {
237:                if (mixedChildren.contains(child)) {
238:                    String err = "Element \"" + name
239:                            + "\" already contains child element ";
240:                    err += "\"" + child + "\".";
241:                    throw new DTDException(err);
242:                }
243:                mixedChildren.add(child);
244:            } //-- addChild
245:
246:            /**
247:             * Adds attribute to the element. If the element already has the attribute
248:             * with the same name, does nothing.
249:             */
250:            public synchronized void addAttribute(Attribute attribute) {
251:                String name = attribute.getName();
252:                if (!attributes.containsKey(name))
253:                    attributes.put(name, attribute);
254:            } //-- addAttribute
255:
256:        } //-- Element
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.