4 * Copyright 2004-2007 MTBJ, Inc.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 package com
.dtrules
.interpreter
;
21 import com
.dtrules
.infrastructure
.RulesException
;
23 public class RNull
extends ARObject
{
26 * returns 0 if both are equal. -1 Otherwise. A Null is considered
27 * less than anything else. We do this just so sorting arrays were
28 * some values are null doesn't blow up.
30 public int compare(IRObject irObject
) throws RulesException
{
31 if(irObject
.equals(this))return 0; // A Null is equal to other nulls.
32 return -1; // A Null is less than anything else.
37 static RNull theNullObject
= new RNull();
39 * Nobody needs the constructor.
45 * Returns the RNull object. There is no need for more than
46 * one of these objects.
49 public static RNull
getRNull(){ return theNullObject
; }
52 * A Null is only equal to the null object
54 public boolean equals(IRObject o
) {
55 return o
.type()==iNull
;
58 public String
stringValue() {
63 * A Null is only equal to the null object, i.e. any
64 * Null object. They are all equal.
66 public boolean equals(Object arg0
) {
67 return arg0
.getClass().equals(this.getClass());
71 * We override toString() to simply return "null".
72 * Because we do this, we override hashcode() as well.
74 public String
toString() {
78 public int hashCode() {