KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > compile > UntypedNullConstantNode


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.compile.UntypedNullConstantNode
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.sql.compile;
23
24 import org.apache.derby.iapi.services.compiler.MethodBuilder;
25
26 import org.apache.derby.iapi.services.sanity.SanityManager;
27
28 import org.apache.derby.iapi.error.StandardException;
29
30 import org.apache.derby.iapi.types.DataValueDescriptor;
31 import org.apache.derby.iapi.types.DataTypeDescriptor;
32
33 import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
34
35 import java.util.Vector JavaDoc;
36 /**
37  * An UntypedNullConstantNode represents a SQL NULL before it has
38  * been bound. The bind() operation will replace the UntypedNullConstantNodes
39  * with typed ConstantNodes.
40  */

41
42 public final class UntypedNullConstantNode extends ConstantNode
43 {
44     /**
45      * Constructor for an UntypedNullConstantNode. Untyped constants
46      * contain no state (not too surprising).
47      */

48
49     public UntypedNullConstantNode()
50     {
51         super();
52     }
53
54     /**
55      * Return the length
56      *
57      * @return The length of the value this node represents
58      *
59      */

60
61     //public int getLength()
62
//{
63
// if (SanityManager.DEBUG)
64
// SanityManager.ASSERT(false,
65
// "Unimplemented method - should not be called on UntypedNullConstantNode");
66
// return 0;
67
//}
68

69     /**
70      * Should never be called for UntypedNullConstantNode because
71      * we shouldn't make it to generate
72      *
73      * @param acb The ExpressionClassBuilder for the class being built
74      * @param mb The method the expression will go into
75      */

76     void generateConstant(ExpressionClassBuilder acb, MethodBuilder mb)
77     {
78         if (SanityManager.DEBUG)
79         {
80             SanityManager.THROWASSERT("generateConstant() not expected to be called for UntypedNullConstantNode because we have implemented our own generateExpression().");
81         }
82     }
83
84     /**
85      * Translate a Default node into a default value, given a type descriptor.
86      *
87      * @param typeDescriptor A description of the required data type.
88      *
89      */

90     public DataValueDescriptor convertDefaultNode(DataTypeDescriptor typeDescriptor)
91     {
92         /*
93         ** The default value is null, so set nullability to TRUE
94         */

95         return typeDescriptor.getNull();
96     }
97     
98     /** @see ValueNode#bindExpression(FromList, SubqueryList, Vector)
99      * @see ResultColumnList#bindUntypedNullsToResultColumns
100      * This does nothing-- the node is actually bound when
101      * bindUntypedNullsToResultColumns is called.
102      */

103     public ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, Vector JavaDoc aggregateVector)
104     {
105         return this;
106     }
107 }
108
Popular Tags