org.codehaus.groovy.runtime
Class NullObject

java.lang.Object
  extended by groovy.lang.GroovyObjectSupport
      extended by org.codehaus.groovy.runtime.NullObject
All Implemented Interfaces:
GroovyObject

public class NullObject
extends GroovyObjectSupport


Method Summary
 Object asType(Class c)
          Type conversion method for null.
 Object clone()
          Since this is implemented as a singleton, we should avoid the use of the clone method
 boolean equals(Object to)
          null is only equal to null
static NullObject getNullObject()
          get the NullObject reference
 Object getProperty(String property)
          Tries to get a property on null, which will always fail
 int hashCode()
           
 Object invokeMethod(String name, Object args)
          Tries to invoke a method on null, which will always fail
 boolean is(Object other)
          The method "is" is used to test for equal references.
 Iterator iterator()
          iterator() method to be able to iterate on null.
 Object plus(String s)
          Allows to add a String to null.
 void setProperty(String property, Object newValue)
          Tries to set a property on null, which will always fail
 String toString()
           
 
Methods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, setMetaClass
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getNullObject

public static NullObject getNullObject()
get the NullObject reference

Returns:
the null object

clone

public Object clone()
Since this is implemented as a singleton, we should avoid the use of the clone method

Overrides:
clone in class Object

getProperty

public Object getProperty(String property)
Tries to get a property on null, which will always fail

Specified by:
getProperty in interface GroovyObject
Overrides:
getProperty in class GroovyObjectSupport
Parameters:
property - - the property to get
Returns:
a NPE

setProperty

public void setProperty(String property,
                        Object newValue)
Tries to set a property on null, which will always fail

Specified by:
setProperty in interface GroovyObject
Overrides:
setProperty in class GroovyObjectSupport
Parameters:
property - - the proprty to set
newValue - - the new value of the property

invokeMethod

public Object invokeMethod(String name,
                           Object args)
Tries to invoke a method on null, which will always fail

Specified by:
invokeMethod in interface GroovyObject
Overrides:
invokeMethod in class GroovyObjectSupport
Parameters:
name - the name of the method to invoke
args - - arguments to the method
Returns:
a NPE

equals

public boolean equals(Object to)
null is only equal to null

Overrides:
equals in class Object
Parameters:
to - - the reference object with which to compare
Returns:
- true if this object is the same as the to argument

iterator

public Iterator iterator()
iterator() method to be able to iterate on null. Note: this part is from Invoker

Returns:
an iterator for an empty list

plus

public Object plus(String s)
Allows to add a String to null. The result is concatenated String of the result of calling toString() on this object and the String in the parameter.

Parameters:
s - - the String to concatenate
Returns:
the concatenated string

is

public boolean is(Object other)
The method "is" is used to test for equal references. This method will return true only if the given parameter is null

Parameters:
other - - the object to test
Returns:
true if other is null

asType

public Object asType(Class c)
Type conversion method for null.

Parameters:
c - - the class to convert to
Returns:
always null

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

Copyright © 2003-2010 The Codehaus. All rights reserved.