Source Code Cross Referenced for ValidatedInfo.java in  » XML » xerces-2_9_1 » org » apache » xerces » impl » dv » 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.dv 
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.dv;
019:
020:        import org.apache.xerces.xs.ShortList;
021:        import org.apache.xerces.xs.XSConstants;
022:
023:        /**
024:         * Class to get the information back after content is validated. This info
025:         * would be filled by validate().
026:         * 
027:         * @xerces.internal 
028:         *
029:         * @author Neeraj Bajaj, Sun Microsystems, inc.
030:         *
031:         * @version $Id: ValidatedInfo.java 446751 2006-09-15 21:54:06Z mrglavas $
032:         */
033:        public class ValidatedInfo {
034:
035:            /**
036:             * The normalized value of a string value
037:             */
038:            public String normalizedValue;
039:
040:            /**
041:             * The actual value from a string value (QName, Boolean, etc.)
042:             * An array of Objects if the type is a list.
043:             */
044:            public Object actualValue;
045:
046:            /**
047:             * The type of the actual value. It's one of the _DT constants
048:             * defined in XSConstants.java. The value is used to indicate
049:             * the most specific built-in type.
050:             * (i.e. short instead of decimal or integer).
051:             */
052:            public short actualValueType;
053:
054:            /**
055:             * If the type is a union type, then the member type which
056:             * actually validated the string value.
057:             */
058:            public XSSimpleType memberType;
059:
060:            /**
061:             * If
062:             * 1. the type is a union type where one of the member types is a list, or
063:             *    if the type is a list; and
064:             * 2. the item type of the list is a union type
065:             * then an array of member types used to validate the values.
066:             */
067:            public XSSimpleType[] memberTypes;
068:
069:            /**
070:             * In the case the value is a list or a list of unions, this value
071:             * indicates the type(s) of the items in the list.
072:             * For a normal list, the length of the array is 1; for list of unions,
073:             * the length of the array is the same as the length of the list.
074:             */
075:            public ShortList itemValueTypes;
076:
077:            /**
078:             * reset the state of this object
079:             */
080:            public void reset() {
081:                this .normalizedValue = null;
082:                this .actualValue = null;
083:                this .memberType = null;
084:                this .memberTypes = null;
085:            }
086:
087:            /**
088:             * Return a string representation of the value. If there is an actual
089:             * value, use toString; otherwise, use the normalized value.
090:             */
091:            public String stringValue() {
092:                if (actualValue == null)
093:                    return normalizedValue;
094:                else
095:                    return actualValue.toString();
096:            }
097:
098:            /**
099:             * Returns true if the two ValidatedInfo objects can be compared in the same
100:             * value space.
101:             */
102:            public static boolean isComparable(ValidatedInfo info1,
103:                    ValidatedInfo info2) {
104:                final short primitiveType1 = convertToPrimitiveKind(info1.actualValueType);
105:                final short primitiveType2 = convertToPrimitiveKind(info2.actualValueType);
106:                if (primitiveType1 != primitiveType2) {
107:                    return (primitiveType1 == XSConstants.ANYSIMPLETYPE_DT
108:                            && primitiveType2 == XSConstants.STRING_DT || primitiveType1 == XSConstants.STRING_DT
109:                            && primitiveType2 == XSConstants.ANYSIMPLETYPE_DT);
110:                } else if (primitiveType1 == XSConstants.LIST_DT
111:                        || primitiveType1 == XSConstants.LISTOFUNION_DT) {
112:                    final ShortList typeList1 = info1.itemValueTypes;
113:                    final ShortList typeList2 = info2.itemValueTypes;
114:                    final int typeList1Length = typeList1 != null ? typeList1
115:                            .getLength() : 0;
116:                    final int typeList2Length = typeList2 != null ? typeList2
117:                            .getLength() : 0;
118:                    if (typeList1Length != typeList2Length) {
119:                        return false;
120:                    }
121:                    for (int i = 0; i < typeList1Length; ++i) {
122:                        final short primitiveItem1 = convertToPrimitiveKind(typeList1
123:                                .item(i));
124:                        final short primitiveItem2 = convertToPrimitiveKind(typeList2
125:                                .item(i));
126:                        if (primitiveItem1 != primitiveItem2) {
127:                            if (primitiveItem1 == XSConstants.ANYSIMPLETYPE_DT
128:                                    && primitiveItem2 == XSConstants.STRING_DT
129:                                    || primitiveItem1 == XSConstants.STRING_DT
130:                                    && primitiveItem2 == XSConstants.ANYSIMPLETYPE_DT) {
131:                                continue;
132:                            }
133:                            return false;
134:                        }
135:                    }
136:                }
137:                return true;
138:            }
139:
140:            /**
141:             * Returns the primitive type of the given type.
142:             * @param valueType A value type as defined in XSConstants.
143:             * @return The primitive type from which valueType was derived.
144:             */
145:            private static short convertToPrimitiveKind(short valueType) {
146:                /** Primitive datatypes. */
147:                if (valueType <= XSConstants.NOTATION_DT) {
148:                    return valueType;
149:                }
150:                /** Types derived from string. */
151:                if (valueType <= XSConstants.ENTITY_DT) {
152:                    return XSConstants.STRING_DT;
153:                }
154:                /** Types derived from decimal. */
155:                if (valueType <= XSConstants.POSITIVEINTEGER_DT) {
156:                    return XSConstants.DECIMAL_DT;
157:                }
158:                /** Other types. */
159:                return valueType;
160:            }
161:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.