Source Code Cross Referenced for ENTITYDatatypeValidator.java in  » Web-Server » Rimfaxe-Web-Server » org » apache » xerces » validators » datatype » 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 » Web Server » Rimfaxe Web Server » org.apache.xerces.validators.datatype 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The Apache Software License, Version 1.1
003:         *
004:         *
005:         * Copyright (c) 1999, 2000 The Apache Software Foundation.  All rights
006:         * reserved.
007:         *
008:         * Redistribution and use in source and binary forms, with or without
009:         * modification, are permitted provided that the following conditions
010:         * are met:
011:         *
012:         * 1. Redistributions of source code must retain the above copyright
013:         *    notice, this list of conditions and the following disclaimer.
014:         *
015:         * 2. Redistributions in binary form must reproduce the above copyright
016:         *    notice, this list of conditions and the following disclaimer in
017:         *    the documentation and/or other materials provided with the
018:         *    distribution.
019:         *
020:         * 3. The end-user documentation included with the redistribution,
021:         *    if any, must include the following acknowledgment:
022:         *       "This product includes software developed by the
023:         *        Apache Software Foundation (http://www.apache.org/)."
024:         *    Alternately, this acknowledgment may appear in the software itself,
025:         *    if and wherever such third-party acknowledgments normally appear.
026:         *
027:         * 4. The names "Xerces" and "Apache Software Foundation" must
028:         *    not be used to endorse or promote products derived from this
029:         *    software without prior written permission. For written
030:         *    permission, please contact apache@apache.org.
031:         *
032:         * 5. Products derived from this software may not be called "Apache",
033:         *    nor may "Apache" appear in their name, without prior written
034:         *    permission of the Apache Software Foundation.
035:         *
036:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
037:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
038:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
039:         * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
040:         * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
042:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
043:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
044:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
045:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
046:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
047:         * SUCH DAMAGE.
048:         * ====================================================================
049:         *
050:         * This software consists of voluntary contributions made by many
051:         * individuals on behalf of the Apache Software Foundation and was
052:         * originally based on software copyright (c) 1999, International
053:         * Business Machines, Inc., http://www.apache.org.  For more
054:         * information on the Apache Software Foundation, please see
055:         * <http://www.apache.org/>.
056:         */
057:
058:        package org.apache.xerces.validators.datatype;
059:
060:        import java.util.Hashtable;
061:        import java.util.Vector;
062:        import org.apache.xerces.readers.DefaultEntityHandler;
063:        import org.apache.xerces.utils.XMLMessages;
064:        import org.apache.xerces.utils.StringPool;
065:        import org.apache.xerces.validators.schema.SchemaSymbols;
066:
067:        /**
068:         * ENTITYDatatypeValidator implements the
069:         * DatattypeValidator interface.
070:         * This validator embodies the ENTITY attribute type
071:         * from XML1.0 recommendation.
072:         * The Value space of ENTITY is the set of all strings
073:         * that match the NCName production and have been
074:         * declared as an unparsed entity in a document
075:         * type definition.
076:         * The Lexical space of Entity is the set of all
077:         * strings that match the NCName production.
078:         * The value space of ENTITY is scoped to a specific
079:         * instance document.
080:         *
081:         * Some caveats:
082:         *
083:         * Because of the Xerces Architecture, where all
084:         * symbols are stored in a StringPool and Strings
085:         * are referenced by int then this datatype needs
086:         * to know about StringPool.
087:         * The first time that this datatype is invoked
088:         * we pass a message containing 2 references needed
089:         * by this validator:
090:         * - a reference to the DefaultEntityHandler  used
091:         * by the XMLValidator.
092:         * - a reference to the StringPool.
093:         *
094:         *
095:         * This validator extends also the XML1.0 validation
096:         * provided in DTD by providing "only on Schemas"
097:         * facet validation.
098:         * This validator also embodies the Derived datatype
099:         * ENTITIES which is an ENTITY derived by list.
100:         *
101:         * These validators can be supplied by the application writer and may be useful as
102:         * standalone code as well as plugins to the validator architecture.
103:         *
104:         * @author Jeffrey Rodriguez-
105:         * @author Mark Swinkles - List Validation refactoring
106:         * @version $Id: ENTITYDatatypeValidator.java,v 1.15 2001/06/20 18:37:39 sandygao Exp $
107:         * @see org.apache.xerces.validators.datatype.DatatypeValidator
108:         * @see org.apache.xerces.validators.datatype.DatatypeValidatorFactoryImpl
109:         * @see org.apache.xerces.validators.datatype.DatatypeValidatorFactory
110:         * @see org.apache.xerces.validators.common.XMLValidator
111:         */
112:        public class ENTITYDatatypeValidator extends StringDatatypeValidator {
113:
114:            public static final int ENTITY_VALIDATE = 0;
115:
116:            public ENTITYDatatypeValidator()
117:                    throws InvalidDatatypeFacetException {
118:                this (null, null, false); // Native, No Facets defined, Restriction
119:            }
120:
121:            public ENTITYDatatypeValidator(DatatypeValidator base,
122:                    Hashtable facets, boolean derivedByList)
123:                    throws InvalidDatatypeFacetException {
124:
125:                // all facets are handled in StringDatatypeValidator
126:                super (base, facets, derivedByList);
127:
128:                // list types are handled by ListDatatypeValidator, we do nothing here.
129:                if (derivedByList)
130:                    return;
131:
132:                setTokenType(SPECIAL_TOKEN_ENTITY);
133:            }
134:
135:            /**
136:             * return value of whiteSpace facet
137:             */
138:            public short getWSFacet() {
139:                return COLLAPSE;
140:            }
141:
142:            /**
143:             * Checks that "content" string is valid
144:             * datatype.
145:             * If invalid a Datatype validation exception is thrown.
146:             *
147:             * @param content A string containing the content to be validated
148:             * @param derivedBylist
149:             *                Flag which is true when type
150:             *                is derived by list otherwise it
151:             *                it is derived by extension.
152:             *
153:             * @exception throws InvalidDatatypeException if the content is
154:             *                   invalid according to the rules for the validators
155:             * @exception InvalidDatatypeValueException
156:             * @see         org.apache.xerces.validators.datatype.InvalidDatatypeValueException
157:             */
158:            public Object validate(String content, Object state)
159:                    throws InvalidDatatypeValueException {
160:                // use StringDatatypeValidator to validate content against facets
161:                super .validate(content, state);
162:
163:                StateMessageDatatype message = (StateMessageDatatype) state;
164:                if (message != null
165:                        && message.getDatatypeState() == ENTITY_VALIDATE) {
166:                    Object[] params = (Object[]) message.getDatatypeObject();
167:                    DefaultEntityHandler entityHandler = (DefaultEntityHandler) params[0];
168:                    StringPool stringPool = (StringPool) params[1];
169:
170:                    int attValueHandle = stringPool.addSymbol(content);
171:                    if (!entityHandler.isUnparsedEntity(attValueHandle)) {
172:                        InvalidDatatypeValueException error = new InvalidDatatypeValueException(
173:                                "ENTITY '" + content + "' is not valid");
174:                        error.setMinorCode(XMLMessages.MSG_ENTITY_INVALID);
175:                        error.setMajorCode(XMLMessages.VC_ENTITY_DECLARED);
176:                        throw error;
177:                    }
178:                }
179:
180:                return null;
181:            }
182:
183:            /**
184:             * REVISIT
185:             * Compares two Datatype for order
186:             *
187:             * @return
188:             */
189:            public int compare(String content1, String content2) {
190:                // TO BE DONE!!!
191:                return content1.equals(content2) ? 0 : -1;
192:            }
193:
194:            // Private methods start here
195:
196:            /**
197:             * Returns a copy of this object.
198:             */
199:            public Object clone() throws CloneNotSupportedException {
200:                throw new CloneNotSupportedException(
201:                        "clone() is not supported in "
202:                                + this.getClass().getName());
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.