Source Code Cross Referenced for IdentityConstraint.java in  » XML » xerces-2_9_1 » org » apache » xerces » impl » xs » identity » 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 » XML » xerces 2_9_1 » org.apache.xerces.impl.xs.identity 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.xerces.impl.xs.identity;
019:
020:        import org.apache.xerces.xs.XSIDCDefinition;
021:        import org.apache.xerces.xs.StringList;
022:        import org.apache.xerces.xs.XSNamespaceItem;
023:        import org.apache.xerces.xs.XSObjectList;
024:        import org.apache.xerces.xs.XSConstants;
025:        import org.apache.xerces.impl.xs.util.StringListImpl;
026:        import org.apache.xerces.impl.xs.util.XSObjectListImpl;
027:        import org.apache.xerces.impl.xs.XSAnnotationImpl;
028:
029:        /**
030:         * Base class of Schema identity constraint.
031:         *
032:         * @xerces.internal 
033:         *
034:         * @author Andy Clark, IBM
035:         * @version $Id: IdentityConstraint.java 572110 2007-09-02 19:04:44Z mrglavas $
036:         */
037:        public abstract class IdentityConstraint implements  XSIDCDefinition {
038:
039:            //
040:            // Data
041:            //
042:
043:            /** type */
044:            protected short type;
045:
046:            /** target namespace */
047:            protected final String fNamespace;
048:
049:            /** Identity constraint name. */
050:            protected final String fIdentityConstraintName;
051:
052:            /** name of owning element */
053:            protected final String fElementName;
054:
055:            /** Selector. */
056:            protected Selector fSelector;
057:
058:            /** Field count. */
059:            protected int fFieldCount;
060:
061:            /** Fields. */
062:            protected Field[] fFields;
063:
064:            // optional annotations
065:            protected XSAnnotationImpl[] fAnnotations = null;
066:
067:            // number of annotations in this identity constraint
068:            protected int fNumAnnotations;
069:
070:            //
071:            // Constructors
072:            //
073:
074:            /** Default constructor. */
075:            protected IdentityConstraint(String namespace,
076:                    String identityConstraintName, String elemName) {
077:                fNamespace = namespace;
078:                fIdentityConstraintName = identityConstraintName;
079:                fElementName = elemName;
080:            } // <init>(String,String)
081:
082:            //
083:            // Public methods
084:            //
085:
086:            /** Returns the identity constraint name. */
087:            public String getIdentityConstraintName() {
088:                return fIdentityConstraintName;
089:            } // getIdentityConstraintName():String
090:
091:            /** Sets the selector. */
092:            public void setSelector(Selector selector) {
093:                fSelector = selector;
094:            } // setSelector(Selector)
095:
096:            /** Returns the selector. */
097:            public Selector getSelector() {
098:                return fSelector;
099:            } // getSelector():Selector
100:
101:            /** Adds a field. */
102:            public void addField(Field field) {
103:                if (fFields == null)
104:                    fFields = new Field[4];
105:                else if (fFieldCount == fFields.length)
106:                    fFields = resize(fFields, fFieldCount * 2);
107:                fFields[fFieldCount++] = field;
108:            } // addField(Field)
109:
110:            /** Returns the field count. */
111:            public int getFieldCount() {
112:                return fFieldCount;
113:            } // getFieldCount():int
114:
115:            /** Returns the field at the specified index. */
116:            public Field getFieldAt(int index) {
117:                return fFields[index];
118:            } // getFieldAt(int):Field
119:
120:            // get the name of the owning element
121:            public String getElementName() {
122:                return fElementName;
123:            } // getElementName(): String
124:
125:            //
126:            // Object methods
127:            //
128:
129:            /** Returns a string representation of this object. */
130:            public String toString() {
131:                String s = super .toString();
132:                int index1 = s.lastIndexOf('$');
133:                if (index1 != -1) {
134:                    return s.substring(index1 + 1);
135:                }
136:                int index2 = s.lastIndexOf('.');
137:                if (index2 != -1) {
138:                    return s.substring(index2 + 1);
139:                }
140:                return s;
141:            } // toString():String
142:
143:            // equals:  returns true if and only if the String
144:            // representations of all members of both objects (except for
145:            // the elenemtName field) are equal.
146:            public boolean equals(IdentityConstraint id) {
147:                boolean areEqual = fIdentityConstraintName
148:                        .equals(id.fIdentityConstraintName);
149:                if (!areEqual)
150:                    return false;
151:                areEqual = fSelector.toString().equals(id.fSelector.toString());
152:                if (!areEqual)
153:                    return false;
154:                areEqual = (fFieldCount == id.fFieldCount);
155:                if (!areEqual)
156:                    return false;
157:                for (int i = 0; i < fFieldCount; i++)
158:                    if (!fFields[i].toString().equals(id.fFields[i].toString()))
159:                        return false;
160:                return true;
161:            } // equals
162:
163:            static final Field[] resize(Field[] oldArray, int newSize) {
164:                Field[] newArray = new Field[newSize];
165:                System.arraycopy(oldArray, 0, newArray, 0, oldArray.length);
166:                return newArray;
167:            }
168:
169:            /**
170:             * Get the type of the object, i.e ELEMENT_DECLARATION.
171:             */
172:            public short getType() {
173:                return XSConstants.IDENTITY_CONSTRAINT;
174:            }
175:
176:            /**
177:             * The <code>name</code> of this <code>XSObject</code> depending on the
178:             * <code>XSObject</code> type.
179:             */
180:            public String getName() {
181:                return fIdentityConstraintName;
182:            }
183:
184:            /**
185:             * The namespace URI of this node, or <code>null</code> if it is
186:             * unspecified.  defines how a namespace URI is attached to schema
187:             * components.
188:             */
189:            public String getNamespace() {
190:                return fNamespace;
191:            }
192:
193:            /**
194:             * {identity-constraint category} One of key, keyref or unique.
195:             */
196:            public short getCategory() {
197:                return type;
198:            }
199:
200:            /**
201:             * {selector} A restricted XPath ([XPath]) expression
202:             */
203:            public String getSelectorStr() {
204:                return (fSelector != null) ? fSelector.toString() : null;
205:            }
206:
207:            /**
208:             * {fields} A non-empty list of restricted XPath ([XPath]) expressions.
209:             */
210:            public StringList getFieldStrs() {
211:                String[] strs = new String[fFieldCount];
212:                for (int i = 0; i < fFieldCount; i++)
213:                    strs[i] = fFields[i].toString();
214:                return new StringListImpl(strs, fFieldCount);
215:            }
216:
217:            /**
218:             * {referenced key} Required if {identity-constraint category} is keyref,
219:             * forbidden otherwise. An identity-constraint definition with
220:             * {identity-constraint category} equal to key or unique.
221:             */
222:            public XSIDCDefinition getRefKey() {
223:                return null;
224:            }
225:
226:            /**
227:             * Optional. Annotation.
228:             */
229:            public XSObjectList getAnnotations() {
230:                return new XSObjectListImpl(fAnnotations, fNumAnnotations);
231:            }
232:
233:            /**
234:             * @see org.apache.xerces.xs.XSObject#getNamespaceItem()
235:             */
236:            public XSNamespaceItem getNamespaceItem() {
237:                // REVISIT: implement
238:                return null;
239:            }
240:
241:            public void addAnnotation(XSAnnotationImpl annotation) {
242:                if (annotation == null)
243:                    return;
244:                if (fAnnotations == null) {
245:                    fAnnotations = new XSAnnotationImpl[2];
246:                } else if (fNumAnnotations == fAnnotations.length) {
247:                    XSAnnotationImpl[] newArray = new XSAnnotationImpl[fNumAnnotations << 1];
248:                    System.arraycopy(fAnnotations, 0, newArray, 0,
249:                            fNumAnnotations);
250:                    fAnnotations = newArray;
251:                }
252:                fAnnotations[fNumAnnotations++] = annotation;
253:            }
254:
255:        } // class IdentityConstraint
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.