Source Code Cross Referenced for ValidationState.java in  » XML » xerces-2_9_1 » org » apache » xerces » impl » validation » 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.validation 
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.validation;
019:
020:        import org.apache.xerces.util.SymbolTable;
021:        import org.apache.xerces.impl.dv.ValidationContext;
022:
023:        import org.apache.xerces.xni.NamespaceContext;
024:        import java.util.Hashtable;
025:        import java.util.Enumeration;
026:
027:        /**
028:         * Implementation of ValidationContext inteface. Used to establish an
029:         * environment for simple type validation.
030:         * 
031:         * @xerces.internal
032:         *
033:         * @author Elena Litani, IBM
034:         * @version $Id: ValidationState.java 446719 2006-09-15 20:32:39Z mrglavas $
035:         */
036:        public class ValidationState implements  ValidationContext {
037:
038:            //
039:            // private data
040:            //
041:            private boolean fExtraChecking = true;
042:            private boolean fFacetChecking = true;
043:            private boolean fNormalize = true;
044:            private boolean fNamespaces = true;
045:
046:            private EntityState fEntityState = null;
047:            private NamespaceContext fNamespaceContext = null;
048:            private SymbolTable fSymbolTable = null;
049:
050:            //REVISIT: Should replace with a lighter structure.
051:            private final Hashtable fIdTable = new Hashtable();
052:            private final Hashtable fIdRefTable = new Hashtable();
053:            private final static Object fNullValue = new Object();
054:
055:            //
056:            // public methods
057:            //
058:            public void setExtraChecking(boolean newValue) {
059:                fExtraChecking = newValue;
060:            }
061:
062:            public void setFacetChecking(boolean newValue) {
063:                fFacetChecking = newValue;
064:            }
065:
066:            public void setNormalizationRequired(boolean newValue) {
067:                fNormalize = newValue;
068:            }
069:
070:            public void setUsingNamespaces(boolean newValue) {
071:                fNamespaces = newValue;
072:            }
073:
074:            public void setEntityState(EntityState state) {
075:                fEntityState = state;
076:            }
077:
078:            public void setNamespaceSupport(NamespaceContext namespace) {
079:                fNamespaceContext = namespace;
080:            }
081:
082:            public void setSymbolTable(SymbolTable sTable) {
083:                fSymbolTable = sTable;
084:            }
085:
086:            /**
087:             * return null if all IDREF values have a corresponding ID value;
088:             * otherwise return the first IDREF value without a matching ID value.
089:             */
090:            public String checkIDRefID() {
091:                Enumeration en = fIdRefTable.keys();
092:
093:                String key;
094:                while (en.hasMoreElements()) {
095:                    key = (String) en.nextElement();
096:                    if (!fIdTable.containsKey(key)) {
097:                        return key;
098:                    }
099:                }
100:                return null;
101:            }
102:
103:            public void reset() {
104:                fExtraChecking = true;
105:                fFacetChecking = true;
106:                fNamespaces = true;
107:                fIdTable.clear();
108:                fIdRefTable.clear();
109:                fEntityState = null;
110:                fNamespaceContext = null;
111:                fSymbolTable = null;
112:            }
113:
114:            /**
115:             * The same validation state can be used to validate more than one (schema)
116:             * validation roots. Entity/Namespace/Symbol are shared, but each validation
117:             * root needs its own id/idref tables. So we need this method to reset only
118:             * the two tables.
119:             */
120:            public void resetIDTables() {
121:                fIdTable.clear();
122:                fIdRefTable.clear();
123:            }
124:
125:            //
126:            // implementation of ValidationContext methods
127:            //
128:
129:            // whether to do extra id/idref/entity checking
130:            public boolean needExtraChecking() {
131:                return fExtraChecking;
132:            }
133:
134:            // whether to validate against facets
135:            public boolean needFacetChecking() {
136:                return fFacetChecking;
137:            }
138:
139:            public boolean needToNormalize() {
140:                return fNormalize;
141:            }
142:
143:            public boolean useNamespaces() {
144:                return fNamespaces;
145:            }
146:
147:            // entity
148:            public boolean isEntityDeclared(String name) {
149:                if (fEntityState != null) {
150:                    return fEntityState.isEntityDeclared(getSymbol(name));
151:                }
152:                return false;
153:            }
154:
155:            public boolean isEntityUnparsed(String name) {
156:                if (fEntityState != null) {
157:                    return fEntityState.isEntityUnparsed(getSymbol(name));
158:                }
159:                return false;
160:            }
161:
162:            // id
163:            public boolean isIdDeclared(String name) {
164:                return fIdTable.containsKey(name);
165:            }
166:
167:            public void addId(String name) {
168:                fIdTable.put(name, fNullValue);
169:            }
170:
171:            // idref
172:            public void addIdRef(String name) {
173:                fIdRefTable.put(name, fNullValue);
174:            }
175:
176:            // get symbols
177:
178:            public String getSymbol(String symbol) {
179:                if (fSymbolTable != null)
180:                    return fSymbolTable.addSymbol(symbol);
181:                // if there is no symbol table, we return java-internalized string,
182:                // because symbol table strings are also java-internalzied.
183:                // this guarantees that the returned string from this method can be
184:                // compared by reference with other symbol table string. -SG
185:                return symbol.intern();
186:            }
187:
188:            // qname, notation
189:            public String getURI(String prefix) {
190:                if (fNamespaceContext != null) {
191:                    return fNamespaceContext.getURI(prefix);
192:                }
193:                return null;
194:            }
195:
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.