KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.compile.XMLConstantNode
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.error.StandardException;
25 import org.apache.derby.iapi.services.compiler.MethodBuilder;
26 import org.apache.derby.iapi.services.io.StoredFormatIds;
27 import org.apache.derby.iapi.services.sanity.SanityManager;
28 import org.apache.derby.iapi.types.TypeId;
29
30 import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
31
32 import org.apache.derby.iapi.util.ReuseFactory;
33
34 public final class XMLConstantNode extends ConstantNode
35 {
36     /**
37      * Initializer for an XMLConstantNode.
38      *
39      * @param arg1 The TypeId for the type of the node
40      *
41      * @exception StandardException
42      */

43     public void init(
44                     Object JavaDoc arg1)
45         throws StandardException
46     {
47         super.init(
48                     arg1,
49                     Boolean.TRUE,
50                     ReuseFactory.getInteger(0));
51     }
52
53     /**
54      * Return the value from this XMLConstantNode as a string.
55      *
56      * @return The value of this XMLConstantNode as a string.
57      *
58      * @exception StandardException Thrown on error
59      */

60     public String JavaDoc getString() throws StandardException
61     {
62         return value.getString();
63     }
64
65     /**
66      * Return an Object representing the bind time value of this
67      * expression tree. If the expression tree does not evaluate to
68      * a constant at bind time then we return null.
69      *
70      * @return An Object representing the bind time value of this
71      * expression tree (null if not a bind time constant).
72      *
73      * @exception StandardException Thrown on error
74      */

75     Object JavaDoc getConstantValueAsObject() throws StandardException
76     {
77         return value.getObject();
78     }
79
80     /**
81      * This generates the proper constant. For an XML value,
82      * this constant value is simply the XML string (which is
83      * just null because null values are the only types of
84      * XML constants we can have).
85      *
86      * @param acb The ExpressionClassBuilder for the class being built
87      * @param mb The method the code to place the code
88      *
89      * @exception StandardException Thrown on error
90      */

91     void generateConstant(ExpressionClassBuilder acb, MethodBuilder mb)
92         throws StandardException
93     {
94         // The generated java is the expression:
95
// "#getString()"
96
mb.push(getString());
97     }
98 }
99
Popular Tags