Coverage Report - net.wotonomy.foundation.NSNull
 
Classes in this File Line Coverage Branch Coverage Complexity
NSNull
0% 
N/A 
1
 
 1  
 /*
 2  
 Wotonomy: OpenStep design patterns for pure Java applications.
 3  
 Copyright (C) 2001 Intersect Software Corporation
 4  
 
 5  
 This library is free software; you can redistribute it and/or
 6  
 modify it under the terms of the GNU Lesser General Public
 7  
 License as published by the Free Software Foundation; either
 8  
 version 2.1 of the License, or (at your option) any later version.
 9  
 
 10  
 This library is distributed in the hope that it will be useful,
 11  
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
 Lesser General Public License for more details.
 14  
 
 15  
 You should have received a copy of the GNU Lesser General Public
 16  
 License along with this library; if not, see http://www.gnu.org
 17  
 */
 18  
 
 19  
 package net.wotonomy.foundation;
 20  
 
 21  
 import java.io.Serializable;
 22  
 
 23  
 /**
 24  
 * NSNull is used to represent null in Collections classes
 25  
 * because List and Map do not specify whether null values
 26  
 * are allowed and because NSArray and NSDictionary explicitly
 27  
 * do not allow null values. <br><br>
 28  
 *
 29  
 * Use of the static singleton method nullValue() is required 
 30  
 * by this implementation because Java cannot return a singleton
 31  
 * instance from a constructor.  Even then, more than one instance
 32  
 * may exist in the application due to object serialization.  
 33  
 * Be sure to compare with equals().
 34  
 *
 35  
 * @author michael@mpowers.net
 36  
 * @author $Author: cgruber $
 37  
 * @version $Revision: 892 $
 38  
 */
 39  0
 public class NSNull implements Serializable
 40  
 {
 41  0
     private static final NSNull instance = new NSNull();
 42  
     
 43  
     /**
 44  
     * Create a new instance of NSNull.
 45  
     */
 46  0
     private NSNull ()
 47  0
     {
 48  0
     }
 49  
 
 50  
     /**
 51  
     * Returns the static instance of nullValue.
 52  
     * Note that serialization may mean that more than
 53  
     * one instance of NSNull exists, so be sure to 
 54  
     * compare with equals().
 55  
     */
 56  
     public static NSNull nullValue ()
 57  
     {        
 58  0
         return instance; 
 59  
     }
 60  
 
 61  
     /**
 62  
     * Returns a human-readable string representation.
 63  
     */
 64  
     public String toString()
 65  
     {
 66  0
         return "[null]";
 67  
     }
 68  
     
 69  
     /**
 70  
     * Hashcode of all instances is zero.
 71  
     */
 72  
     public int hashCode()
 73  
     {
 74  0
         return 0;   
 75  
     }
 76  
     
 77  
     /**
 78  
     * Implemented to return true for any instance of NSNull.
 79  
     */
 80  
     public boolean equals( Object anObject )
 81  
     {
 82  0
         return ( anObject instanceof NSNull );   
 83  
     }
 84  
 }
 85  
 
 86  
 /*
 87  
  * $Log$
 88  
  * Revision 1.1  2006/02/16 12:47:16  cgruber
 89  
  * Check in all sources in eclipse-friendly maven-enabled packages.
 90  
  *
 91  
  * Revision 1.3  2003/08/06 23:07:52  chochos
 92  
  * general code cleanup (mostly, removing unused imports)
 93  
  *
 94  
  * Revision 1.2  2001/03/01 20:36:09  mpowers
 95  
  * Implemented equals, hashcode, and serializable.
 96  
  *
 97  
  * Revision 1.1  2001/02/26 22:41:51  mpowers
 98  
  * Implemented null placeholder classes.
 99  
  * Duplicator now uses NSNull.
 100  
  * No longer catching base exception class.
 101  
  *
 102  
  *
 103  
  */
 104