Coverage Report - net.wotonomy.control.EOGenericRecord
 
Classes in this File Line Coverage Branch Coverage Complexity
EOGenericRecord
0% 
0% 
1.222
 
 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.control;
 20  
 
 21  
 import net.wotonomy.foundation.NSMutableDictionary;
 22  
 import net.wotonomy.foundation.NSNull;
 23  
 
 24  
 /**
 25  
 * EOGenericRecord extends EOCustomObject to provide a 
 26  
 * general-purpose implementation, relying entirely on the
 27  
 * class description for entity-specific behavior, and 
 28  
 * storing data in a dictionary.
 29  
 *
 30  
 * @author michael@mpowers.net
 31  
 * @author $Author: cgruber $
 32  
 * @version $Revision: 894 $
 33  
 */
 34  
 public class EOGenericRecord extends EOCustomObject
 35  
 {
 36  
     private EOClassDescription classDescription;
 37  
     private NSMutableDictionary dataDictionary;
 38  
     
 39  
     /**
 40  
     * Default constructor.
 41  
     */
 42  0
     protected EOGenericRecord()
 43  0
     {
 44  0
         classDescription = null;
 45  0
         dataDictionary = new NSMutableDictionary();
 46  0
     }
 47  
     
 48  
     /**
 49  
     * Preferred constructor.
 50  
     */
 51  
     public EOGenericRecord( EOClassDescription aDescription )
 52  
     {
 53  0
         this();
 54  0
         classDescription = aDescription;
 55  0
     }
 56  
     
 57  
     /**
 58  
     * Overridden to return true so that deferred faults are used. 
 59  
     */
 60  
     public static boolean usesDeferredFaultCreation()
 61  
     {
 62  0
         return true;
 63  
     }
 64  
     
 65  
     /**
 66  
     * Compatibility constructor: aContext and anID are ignored.
 67  
     */
 68  
     public EOGenericRecord( 
 69  
         EOEditingContext aContext, EOClassDescription aDescription, EOGlobalID anID )
 70  
     {
 71  0
         this( aDescription );
 72  0
     }
 73  
     
 74  
     /**
 75  
     * Returns a class description for this object.
 76  
     * Overridden to return the class description passed
 77  
     * into the constructor.
 78  
     */
 79  
     public EOClassDescription classDescription()
 80  
     {
 81  0
         return classDescription;
 82  
     }
 83  
     
 84  
     // interface EOKeyValueCoding
 85  
     
 86  
     /**
 87  
     * Calls storedValueForKey.
 88  
     */
 89  
     public Object valueForKey( String aKey )
 90  
     {
 91  0
         return storedValueForKey( aKey );
 92  
     }
 93  
 
 94  
     /**
 95  
     * Calls willChange and then calls takeStoredValueForKey.
 96  
     */
 97  
     public void takeValueForKey( Object aValue, String aKey )
 98  
     {
 99  0
         willChange();
 100  0
         takeStoredValueForKey( aValue, aKey );
 101  0
     }
 102  
 
 103  
     /**
 104  
     * Calls willRead for the specified key,
 105  
     * and returns the corresponding value from
 106  
     * the data dictionary.  Keys that do not
 107  
     * exist will return null.
 108  
     */
 109  
     public Object storedValueForKey( String aKey )
 110  
     {
 111  0
         willRead( aKey );
 112  0
         Object result = dataDictionary.objectForKey( aKey );
 113  0
         if ( NSNull.nullValue().equals( result ) ) result = null;
 114  0
         return result;
 115  
     }
 116  
 
 117  
     /**
 118  
     * Writes the specified value into the data dictionary 
 119  
     * for the specified key.  Nulls are stored as NSNulls 
 120  
     * in the dictionary.
 121  
     * No checking is performed to determine whether the
 122  
     * key is a valid attribute key.
 123  
     */
 124  
     public void takeStoredValueForKey( Object aValue, String aKey )
 125  
     {
 126  0
         if ( aValue == null ) aValue = NSNull.nullValue();
 127  0
         dataDictionary.setObjectForKey( aValue, aKey );
 128  0
     }
 129  
 
 130  
 }
 131  
 
 132  
 /*
 133  
  * $Log$
 134  
  * Revision 1.2  2006/02/16 16:47:14  cgruber
 135  
  * Move some classes in to "internal" packages and re-work imports, etc.
 136  
  *
 137  
  * Also use UnsupportedOperationExceptions where appropriate, instead of WotonomyExceptions.
 138  
  *
 139  
  * Revision 1.1  2006/02/16 13:19:57  cgruber
 140  
  * Check in all sources in eclipse-friendly maven-enabled packages.
 141  
  *
 142  
  * Revision 1.2  2003/08/06 23:07:52  chochos
 143  
  * general code cleanup (mostly, removing unused imports)
 144  
  *
 145  
  * Revision 1.1  2001/11/18 18:57:10  mpowers
 146  
  * Implemented EOGenericRecord.
 147  
  *
 148  
  *
 149  
  */
 150  
     
 151