KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xpath > internal > objects > XNull


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 /*
17  * $Id: XNull.java,v 1.13 2004/02/17 04:34:38 minchau Exp $
18  */

19 package com.sun.org.apache.xpath.internal.objects;
20
21 import com.sun.org.apache.xml.internal.dtm.DTM;
22 import com.sun.org.apache.xpath.internal.XPathContext;
23
24 /**
25  * This class represents an XPath null object, and is capable of
26  * converting the null to other types, such as a string.
27  * @xsl.usage general
28  */

29 public class XNull extends XNodeSet
30 {
31
32   /**
33    * Create an XObject.
34    */

35   public XNull()
36   {
37     super();
38   }
39
40   /**
41    * Tell what kind of class this is.
42    *
43    * @return type CLASS_NULL
44    */

45   public int getType()
46   {
47     return CLASS_NULL;
48   }
49
50   /**
51    * Given a request type, return the equivalent string.
52    * For diagnostic purposes.
53    *
54    * @return type string "#CLASS_NULL"
55    */

56   public String JavaDoc getTypeString()
57   {
58     return "#CLASS_NULL";
59   }
60
61   /**
62    * Cast result object to a number.
63    *
64    * @return 0.0
65    */

66
67   public double num()
68   {
69     return 0.0;
70   }
71
72   /**
73    * Cast result object to a boolean.
74    *
75    * @return false
76    */

77   public boolean bool()
78   {
79     return false;
80   }
81
82   /**
83    * Cast result object to a string.
84    *
85    * @return empty string ""
86    */

87   public String JavaDoc str()
88   {
89     return "";
90   }
91
92   /**
93    * Cast result object to a result tree fragment.
94    *
95    * @param support XPath context to use for the conversion
96    *
97    * @return The object as a result tree fragment.
98    */

99   public int rtf(XPathContext support)
100   {
101     // DTM frag = support.createDocumentFragment();
102
// %REVIEW%
103
return DTM.NULL;
104   }
105
106 // /**
107
// * Cast result object to a nodelist.
108
// *
109
// * @return null
110
// */
111
// public DTMIterator iter()
112
// {
113
// return null;
114
// }
115

116   /**
117    * Tell if two objects are functionally equal.
118    *
119    * @param obj2 Object to compare this to
120    *
121    * @return True if the given object is of type CLASS_NULL
122    */

123   public boolean equals(XObject obj2)
124   {
125     return obj2.getType() == CLASS_NULL;
126   }
127 }
128
Popular Tags