Source Code Cross Referenced for SimpleStringOperatorNode.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.SimpleStringOperatorNode
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.sql.compile.C_NodeTypes;
025:
026:        import org.apache.derby.iapi.error.StandardException;
027:
028:        import org.apache.derby.iapi.sql.dictionary.DataDictionary;
029:
030:        import org.apache.derby.iapi.types.TypeId;
031:        import org.apache.derby.iapi.types.DataTypeDescriptor;
032:
033:        import org.apache.derby.iapi.types.StringDataValue;
034:
035:        import org.apache.derby.iapi.reference.SQLState;
036:        import org.apache.derby.iapi.reference.ClassName;
037:
038:        import java.sql.Types;
039:
040:        import java.util.Vector;
041:
042:        /**
043:         * This node represents a unary upper or lower operator
044:         *
045:         * @author Jerry
046:         */
047:
048:        public class SimpleStringOperatorNode extends UnaryOperatorNode {
049:            /**
050:             * Initializer for a SimpleOperatorNode
051:             *
052:             * @param operand		The operand
053:             * @param methodName	The method name
054:             */
055:
056:            public void init(Object operand, Object methodName) {
057:                super .init(operand, methodName, methodName);
058:            }
059:
060:            /**
061:             * Bind this operator
062:             *
063:             * @param fromList			The query's FROM list
064:             * @param subqueryList		The subquery list being built as we find SubqueryNodes
065:             * @param aggregateVector	The aggregate vector being built as we find AggregateNodes
066:             *
067:             * @return	The new top of the expression tree.
068:             *
069:             * @exception StandardException		Thrown on error
070:             */
071:
072:            public ValueNode bindExpression(FromList fromList,
073:                    SubqueryList subqueryList, Vector aggregateVector)
074:                    throws StandardException {
075:                TypeId operandType;
076:
077:                super .bindExpression(fromList, subqueryList, aggregateVector);
078:
079:                /*
080:                 ** Check the type of the operand - this function is allowed only on
081:                 ** string value (char and bit) types.
082:                 */
083:                operandType = operand.getTypeId();
084:
085:                switch (operandType.getJDBCTypeId()) {
086:                case Types.CHAR:
087:                case Types.VARCHAR:
088:                case Types.LONGVARCHAR:
089:                case Types.CLOB:
090:                    break;
091:                case org.apache.derby.iapi.reference.JDBC20Translation.SQL_TYPES_JAVA_OBJECT:
092:                case Types.OTHER: {
093:                    throw StandardException.newException(
094:                            SQLState.LANG_UNARY_FUNCTION_BAD_TYPE, methodName,
095:                            operandType.getSQLTypeName());
096:                }
097:
098:                default:
099:                    operand = (ValueNode) getNodeFactory()
100:                            .getNode(
101:                                    C_NodeTypes.CAST_NODE,
102:                                    operand,
103:                                    DataTypeDescriptor
104:                                            .getBuiltInDataTypeDescriptor(
105:                                                    Types.VARCHAR,
106:                                                    true,
107:                                                    operand
108:                                                            .getTypeCompiler()
109:                                                            .getCastToCharWidth(
110:                                                                    operand
111:                                                                            .getTypeServices())),
112:                                    getContextManager());
113:                    ((CastNode) operand).bindCastNodeOnly();
114:                    operandType = operand.getTypeId();
115:                }
116:
117:                /*
118:                 ** The result type of upper()/lower() is the type of the operand.
119:                 */
120:
121:                setType(new DataTypeDescriptor(operandType, operand
122:                        .getTypeServices().isNullable(), operand
123:                        .getTypeCompiler().getCastToCharWidth(
124:                                operand.getTypeServices())));
125:
126:                return this ;
127:            }
128:
129:            /**
130:             * Bind a ? parameter operand of the upper/lower function.
131:             *
132:             * @exception StandardException		Thrown on error
133:             */
134:
135:            void bindParameter() throws StandardException {
136:                /*
137:                 ** According to the SQL standard, if bit_length has a ? operand,
138:                 ** its type is bit varying with the implementation-defined maximum length
139:                 ** for a bit.
140:                 */
141:
142:                operand.setType(DataTypeDescriptor
143:                        .getBuiltInDataTypeDescriptor(Types.VARCHAR));
144:            }
145:
146:            /**
147:             * This is a length operator node.  Overrides this method
148:             * in UnaryOperatorNode for code generation purposes.
149:             */
150:            public String getReceiverInterfaceName() {
151:                return ClassName.StringDataValue;
152:            }
153:
154:            /**
155:             * @see ValueNode#requiresTypeFromContext
156:             */
157:            public boolean requiresTypeFromContext() {
158:                //should return false because lower(?)/upper(?) are bound to varchar and hence don't
159:                //require their type to be set from the context. 
160:                return false;
161:            }
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.