Source Code Cross Referenced for XMLTypeCompiler.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » sql » compile » 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 DBMS » db derby 10.2 » org.apache.derby.impl.sql.compile 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.sql.compile.XMLTypeCompiler
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.impl.sql.compile;
023:
024:        import org.apache.derby.iapi.services.loader.ClassFactory;
025:        import org.apache.derby.iapi.services.sanity.SanityManager;
026:        import org.apache.derby.iapi.services.io.StoredFormatIds;
027:        import org.apache.derby.iapi.sql.compile.TypeCompiler;
028:
029:        import org.apache.derby.iapi.error.StandardException;
030:
031:        import org.apache.derby.iapi.types.TypeId;
032:        import org.apache.derby.iapi.types.DataTypeDescriptor;
033:
034:        import org.apache.derby.iapi.reference.ClassName;
035:
036:        /**
037:         * This class implements TypeCompiler for the XML type.
038:         */
039:
040:        public class XMLTypeCompiler extends BaseTypeCompiler {
041:            /**
042:             * Tell whether this type (XML) can be compared to the given type.
043:             * Says SQL/XML[2003] spec:
044:             *
045:             * 4.2.2 XML comparison and assignment
046:             * "XML values are not comparable."
047:             *
048:             * @param otherType The TypeId of the other type.
049:             */
050:            public boolean comparable(TypeId otherType, boolean forEquals,
051:                    ClassFactory cs) {
052:                // An XML value cannot be compared to any type--
053:                // not even to other XML values.
054:                return false;
055:            }
056:
057:            /**
058:             * Tell whether this type (XML) can be converted to the given type.
059:             *
060:             * An XML value can't be converted to any other type, per
061:             * SQL/XML[2003] 6.3 <cast specification>
062:             *
063:             * @see TypeCompiler#convertible
064:             */
065:            public boolean convertible(TypeId otherType,
066:                    boolean forDataTypeFunction) {
067:                // An XML value cannot be converted to any non-XML type.  If
068:                // user wants to convert an XML value to a string, then
069:                // s/he must use the provided SQL/XML serialization operator
070:                // (namely, XMLSERIALIZE).
071:                return otherType.isXMLTypeId();
072:            }
073:
074:            /**
075:             * Tell whether this type (XML) is compatible with the given type.
076:             *
077:             * @param otherType The TypeId of the other type.
078:             */
079:            public boolean compatible(TypeId otherType) {
080:                // An XML value is not compatible (i.e. cannot be "coalesced")
081:                // into any non-XML type.
082:                return otherType.isXMLTypeId();
083:            }
084:
085:            /**
086:             * Tell whether this type (XML) can be stored into from the given type.
087:             * Only XML values can be stored into an XML type, per SQL/XML spec:
088:             *
089:             * 4.2.2 XML comparison and assignment
090:             * Values of XML type are assignable to sites of XML type.
091:             *
092:             * @param otherType The TypeId of the other type.
093:             * @param cf A ClassFactory
094:             */
095:            public boolean storable(TypeId otherType, ClassFactory cf) {
096:                // The only type of value that can be stored as XML
097:                // is an XML value.  Strings are not allowed.  If
098:                // the user wants to store a string value as XML,
099:                // s/he must use the provided XML parse operator
100:                // (namely, XMLPARSE) to parse the string into
101:                // XML.
102:                return otherType.isXMLTypeId();
103:            }
104:
105:            /**
106:             * @see TypeCompiler#interfaceName
107:             */
108:            public String interfaceName() {
109:                return ClassName.XMLDataValue;
110:            }
111:
112:            /**
113:             * @see TypeCompiler#getCorrespondingPrimitiveTypeName
114:             */
115:            public String getCorrespondingPrimitiveTypeName() {
116:                int formatId = getStoredFormatIdFromTypeId();
117:                if (formatId == StoredFormatIds.XML_TYPE_ID)
118:                    return "org.apache.derby.iapi.types.XML";
119:
120:                if (SanityManager.DEBUG) {
121:                    SanityManager
122:                            .THROWASSERT("unexpected formatId in getCorrespondingPrimitiveTypeName(): "
123:                                    + formatId);
124:                }
125:
126:                return null;
127:            }
128:
129:            /**
130:             * @see TypeCompiler#getCastToCharWidth
131:             *
132:             * While it is true XML values can't be cast to char, this method
133:             * can get called before we finish type checking--so we return a dummy
134:             * value here and let the type check throw the appropriate error.
135:             */
136:            public int getCastToCharWidth(DataTypeDescriptor dts) {
137:                return -1;
138:            }
139:
140:            /**
141:             * @see BaseTypeCompiler#nullMethodName
142:             */
143:            protected String nullMethodName() {
144:                int formatId = getStoredFormatIdFromTypeId();
145:                if (formatId == StoredFormatIds.XML_TYPE_ID)
146:                    return "getNullXML";
147:
148:                if (SanityManager.DEBUG) {
149:                    SanityManager
150:                            .THROWASSERT("unexpected formatId in nullMethodName(): "
151:                                    + formatId);
152:                }
153:
154:                return null;
155:            }
156:
157:            /**
158:             * @see BaseTypeCompiler#dataValueMethodName
159:             */
160:            protected String dataValueMethodName() {
161:                int formatId = getStoredFormatIdFromTypeId();
162:                if (formatId == StoredFormatIds.XML_TYPE_ID)
163:                    return "getXMLDataValue";
164:
165:                if (SanityManager.DEBUG) {
166:                    SanityManager
167:                            .THROWASSERT("unexpected formatId in dataValueMethodName() - "
168:                                    + formatId);
169:                }
170:
171:                return null;
172:            }
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.