Source Code Cross Referenced for Wildcard.java in  » Database-ORM » castor » org » exolab » castor » xml » schema » 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.schema 
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 2001 (C) Intalio, Inc. All Rights Reserved.
042:         *
043:         * $Id: Wildcard.java 6230 2006-09-19 07:56:07Z wguttmn $
044:         * Date         Author          Changes
045:         * 04/02/2001   Arnaud Blandin  Created
046:         */package org.exolab.castor.xml.schema;
047:
048:        import java.util.Enumeration;
049:        import java.util.Vector;
050:        import org.exolab.castor.xml.ValidationException;
051:
052:        /**
053:         * A class that represents an XML Schema Wildcard.
054:         * A wilcard is represented by the XML elements {@literal <any>} and
055:         * {@literal <anyAttribute>} and can be hold in a complexType or in
056:         * a ModelGroup (<group>).
057:         *
058:         * @author <a href="mailto:blandin@intalio.com">Arnaud Blandin</a>
059:         */
060:        public class Wildcard extends Particle {
061:            /** SerialVersionUID */
062:            private static final long serialVersionUID = -2747251897459951684L;
063:
064:            /**
065:             * The vector where we store the list of namespaces
066:             */
067:            //don't use ArrayList to keep compatibility with jdk1.1
068:            private Vector _namespaces;
069:
070:            /**
071:             * A boolean that indicates if this wildcard represents
072:             * {@literal <anyAttribute>}.
073:             * By default a wildcard represents {@literal <any>}
074:             */
075:            private boolean _attribute = false;
076:
077:            /**
078:             * The complexType that holds this wildcard.
079:             */
080:            private ComplexType _complexType;
081:
082:            /**
083:             * The Group (<sequence> or <choice>) that holds this wildcard.
084:             */
085:            private Group _group;
086:
087:            /**
088:             * The Attribute Group that holds the wildcard
089:             */
090:            private AttributeGroup _attGroup;
091:
092:            /**
093:             * the processContent of this wildcard.
094:             * (strict by default)
095:             */
096:            private String _processContents;
097:
098:            /**
099:             * The wildcard is embedded in a complexType
100:             * @param complexType the complexType that contains this wildcard
101:             */
102:            public Wildcard(ComplexType complexType) {
103:                _complexType = complexType;
104:                init();
105:            }
106:
107:            /**
108:             * The wildcard is embedded in a ModelGroup (<group>)
109:             * @param group the ModelGoup that contains this wildcard
110:             */
111:            public Wildcard(Group group) {
112:                _group = group;
113:                init();
114:            }
115:
116:            /**
117:             * The wildcard is embedded in an AttributeGroup.
118:             * @param attGroup the AttributeGroup that contains this wildcard
119:             */
120:            public Wildcard(AttributeGroup attGroup) {
121:                _attGroup = attGroup;
122:                init();
123:            }
124:
125:            private void init() {
126:                //in general not more than one namespace
127:                _namespaces = new Vector(1);
128:                setMaxOccurs(1);
129:                setMinOccurs(1);
130:                try {
131:                    setProcessContents(SchemaNames.STRICT);
132:                } catch (SchemaException e) {
133:                    //nothing to do since we are
134:                    //not 'out of bounds' by using an hard coded value
135:                }
136:            }
137:
138:            /**
139:             * add a namespace
140:             * @param Namespace the namespace to add
141:             */
142:            public void addNamespace(String Namespace) {
143:                _namespaces.addElement(Namespace);
144:            }
145:
146:            /**
147:             * Removes the given namespace from the namespace collection
148:             * @param namespace the namespace to remove.
149:             */
150:            public boolean removeNamespace(String namespace) {
151:                if (namespace == null)
152:                    return false;
153:                int position = _namespaces.indexOf(namespace);
154:                if (position >= 0) {
155:                    _namespaces.removeElementAt(position);
156:                    return true;
157:                }
158:                return false;
159:            }
160:
161:            /**
162:             * Returns the complexType that contains this wildcard, can return null.
163:             * @return the complexType that contains this wildcard (can be null).
164:             */
165:            public ComplexType getComplexType() {
166:                return _complexType;
167:            }
168:
169:            /**
170:             * Returns the model group that contains this wildcard, can return null.
171:             * @return the model group that contains this wildcard (can be null).
172:             */
173:            public Group getModelGroup() {
174:                return _group;
175:            }
176:
177:            /**
178:             * Returns the AttributeGroup that contains this wilcard (can return null)
179:             * @return the AttributeGroup that contains this wilcard (can return null)
180:             */
181:            public AttributeGroup getAttributeGroup() {
182:                return _attGroup;
183:            }
184:
185:            /**
186:             * Returns the parent schema in which this wildcard is located.
187:             *
188:             * @return the schema that contains the parent structure of this wildcard.
189:             */
190:            public Schema getSchema() {
191:                if (_complexType != null)
192:                    return _complexType.getSchema();
193:                else if (_attGroup != null) {
194:                    if (_attGroup instanceof  AttributeGroupDecl)
195:                        return ((AttributeGroupDecl) _attGroup).getSchema();
196:                    else if (_attGroup instanceof  AttributeGroupReference) {
197:                        AttributeGroup tempRef = ((AttributeGroupReference) _attGroup)
198:                                .resolveReference();
199:                        if (tempRef instanceof  AttributeGroupDecl)
200:                            return ((AttributeGroupDecl) tempRef).getSchema();
201:                        tempRef = null;
202:                        return null;
203:                    }
204:                }
205:                if (_group == null)
206:                    return null;
207:
208:                Structure parent = _group.getParent();
209:                if (parent == null)
210:                    return null;
211:
212:                Schema result = null;
213:                while (result == null) {
214:                    switch (parent.getStructureType()) {
215:                    case Structure.COMPLEX_TYPE:
216:                        result = ((ComplexType) parent).getSchema();
217:                        break;
218:                    case Structure.MODELGROUP:
219:                        result = ((ModelGroup) parent).getSchema();
220:                        break;
221:                    case Structure.GROUP:
222:                        parent = ((Group) parent).getParent();
223:                        break;
224:                    default:
225:                        String err = "A group can only be child of a complexType";
226:                        err += " or a ModelGroup or a group.";
227:                        throw new IllegalStateException(err);
228:                    }
229:                }
230:                return result;
231:            }
232:
233:            /**
234:             * Returns an enumeration that contains the different namespaces
235:             * of this wildcard
236:             * @return an enumeration that contains the different namespaces
237:             * of this wildcard
238:             */
239:            public Enumeration getNamespaces() {
240:                return _namespaces.elements();
241:            }
242:
243:            /**
244:             * Returns the processContent of this wildcard
245:             * @return the processContent of this wildcard
246:             */
247:            public String getProcessContent() {
248:                return _processContents;
249:            }
250:
251:            /**
252:             * Returns true if this wildcard represents {@literal <anyAttribute>} otherwise false
253:             * @return true if this wildcard represents {@literal <anyAttribute>} otherwise false
254:             */
255:            public boolean isAttributeWildcard() {
256:                return _attribute;
257:            }
258:
259:            /**
260:             * Sets this wildcard to represent {@literal <anyAttribute>}
261:             */
262:            public void setAttributeWildcard() {
263:                _attribute = true;
264:            }
265:
266:            /**
267:             * Sets the ID for this Group
268:             * @param id the ID for this Group
269:             */
270:            public void setId(final String id) {
271:            }
272:
273:            /**
274:             * Sets the processContent of the wildCard
275:             * @param process the process content to set
276:             * @exception SchemaException thrown when the processContent is not valid
277:             */
278:            public void setProcessContents(String process)
279:                    throws SchemaException {
280:                if (!SchemaNames.isProcessName(process))
281:                    throw new SchemaException(
282:                            "processContents attribute not valid:" + process);
283:                _processContents = process;
284:            }
285:
286:            public void validate() throws ValidationException {
287:                //only do the validation on the namespace
288:            }
289:
290:            /**
291:             * Returns the type of this Schema Structure
292:             * @return the type of this Schema Structure
293:             **/
294:            public short getStructureType() {
295:                return Structure.WILDCARD;
296:            }
297:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.