Coverage Report - net.wotonomy.foundation.NSCoding
 
Classes in this File Line Coverage Branch Coverage Complexity
NSCoding
0% 
0% 
1.932
 
 1  
 /*
 2  
 Wotonomy: OpenStep design patterns for pure Java applications.
 3  
 Copyright (C) 2002 Israfil consulting Services 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  
 $Id: NSCoding.java 892 2006-02-16 12:47:16 +0000 (Thu, 16 Feb 2006) cgruber $
 19  
 
 20  
 */
 21  
 
 22  
 package net.wotonomy.foundation;
 23  
 
 24  
 import java.math.BigInteger;
 25  
 
 26  
 /**
 27  
 * A helper interface supporting the NSCoder APIs.  At present it 
 28  
 * very confusing to me how this even works from a structural
 29  
 * perspective, but to be consistent with WebObjects APIs, this will
 30  
 * have to be properly implemented.
 31  
 *
 32  
 * @author cgruber@israfil.net
 33  
 * @author $Author: cgruber $
 34  
 * @version $Revision: 892 $
 35  
 */
 36  
 
 37  
 public interface NSCoding {
 38  
 
 39  
         /** Not yet implemented */
 40  
         public static class _BigDecimalSupport extends _BigIntegerSupport {
 41  
 
 42  
                 /** Not yet implemented */
 43  
                 public void encodeWithCoder(Object obj, NSCoder nscoder) {
 44  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 45  
                 }
 46  
 
 47  
                 /** Not yet implemented */
 48  
                 public Object decodeObject(NSCoder nscoder) {
 49  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 50  
                 }
 51  
 
 52  
                 /** Not yet implemented */
 53  0
                 public _BigDecimalSupport() {
 54  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 55  
                 }
 56  
         }
 57  
 
 58  
         /** Not yet implemented */
 59  
         public static class _BigIntegerSupport extends Support {
 60  
 
 61  
                 /** Not yet implemented */
 62  
                 public void encodeWithCoder(Object obj, NSCoder nscoder) {
 63  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 64  
                 }
 65  
 
 66  
                 /** Not yet implemented */
 67  
                 public Object decodeObject(NSCoder nscoder) {
 68  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 69  
                 }
 70  
 
 71  
                 /** Not yet implemented */
 72  
                 protected static void _encodeBigInteger(
 73  
                         NSCoder nscoder,
 74  
                         BigInteger biginteger) {
 75  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 76  
                 }
 77  
 
 78  
                 /** Not yet implemented */
 79  
                 protected static BigInteger _decodeBigInteger(NSCoder nscoder, int i) {
 80  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 81  
                 }
 82  
 
 83  
                 /** Not yet implemented */
 84  0
                 public _BigIntegerSupport() {
 85  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 86  
                 }
 87  
         }
 88  
 
 89  
         /** Not yet implemented */
 90  
         public static class _DoubleSupport extends _NumberSupport {
 91  
 
 92  
                 /** Not yet implemented */
 93  
                 public void encodeWithCoder(Object obj, NSCoder nscoder) {
 94  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 95  
                 }
 96  
 
 97  
                 /** Not yet implemented */
 98  0
                 public _DoubleSupport() {
 99  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 100  
                 }
 101  
         }
 102  
 
 103  
         /** Not yet implemented */
 104  
         public static class _FloatSupport extends _NumberSupport {
 105  
 
 106  
                 /** Not yet implemented */
 107  
                 public void encodeWithCoder(Object obj, NSCoder nscoder) {
 108  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 109  
                 }
 110  
 
 111  
                 /** Not yet implemented */
 112  0
                 public _FloatSupport() {
 113  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 114  
                 }
 115  
         }
 116  
 
 117  
         /** Not yet implemented */
 118  
         public static class _LongSupport extends _NumberSupport {
 119  
 
 120  
                 /** Not yet implemented */
 121  
                 public void encodeWithCoder(Object obj, NSCoder nscoder) {
 122  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 123  
                 }
 124  
 
 125  
                 /** Not yet implemented */
 126  0
                 public _LongSupport() {
 127  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 128  
                 }
 129  
         }
 130  
 
 131  
         /** Not yet implemented */
 132  
         public static class _IntegerSupport extends _NumberSupport {
 133  
 
 134  
                 /** Not yet implemented */
 135  
                 public void encodeWithCoder(Object obj, NSCoder nscoder) {
 136  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 137  
                 }
 138  
 
 139  
                 /** Not yet implemented */
 140  0
                 public _IntegerSupport() {
 141  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 142  
                 }
 143  
         }
 144  
 
 145  
         /** Not yet implemented */
 146  
         public static class _ShortSupport extends _NumberSupport {
 147  
 
 148  
                 /** Not yet implemented */
 149  
                 public void encodeWithCoder(Object obj, NSCoder nscoder) {
 150  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 151  
                 }
 152  
 
 153  
                 /** Not yet implemented */
 154  0
                 public _ShortSupport() {
 155  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 156  
                 }
 157  
         }
 158  
 
 159  
         /** Not yet implemented */
 160  
         public static class _ByteSupport extends _NumberSupport {
 161  
 
 162  
                 /** Not yet implemented */
 163  
                 public void encodeWithCoder(Object obj, NSCoder nscoder) {
 164  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 165  
                 }
 166  
 
 167  
                 /** Not yet implemented */
 168  0
                 public _ByteSupport() {
 169  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 170  
                 }
 171  
         }
 172  
 
 173  
         /** Not yet implemented */
 174  
         public static class _NumberSupport extends Support {
 175  
 
 176  
                 /** Not yet implemented */
 177  
                 public Class classForCoder(Object obj) {
 178  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 179  
                 }
 180  
 
 181  
                 /** Not yet implemented */
 182  
                 public void encodeWithCoder(Object obj, NSCoder nscoder) {
 183  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 184  
                 }
 185  
 
 186  
                 /** Not yet implemented */
 187  
                 public Object decodeObject(NSCoder nscoder) {
 188  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 189  
                 }
 190  
 
 191  
                 /** Not yet implemented */
 192  0
                 public _NumberSupport() {
 193  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 194  
                 }
 195  
         }
 196  
 
 197  
         /** Not yet implemented */
 198  
         public static class _CharacterSupport extends Support {
 199  
 
 200  
                 /** Not yet implemented */
 201  
                 public void encodeWithCoder(Object obj, NSCoder nscoder) {
 202  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 203  
                 }
 204  
 
 205  
                 /** Not yet implemented */
 206  
                 public Object decodeObject(NSCoder nscoder) {
 207  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 208  
                 }
 209  
 
 210  
                 /** Not yet implemented */
 211  0
                 public _CharacterSupport() {
 212  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 213  
                 }
 214  
         }
 215  
 
 216  
         /** Not yet implemented */
 217  
         public static class _DateSupport extends Support {
 218  
 
 219  
                 /** Not yet implemented */
 220  
                 public void encodeWithCoder(Object obj, NSCoder nscoder) {
 221  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 222  
                 }
 223  
 
 224  
                 /** Not yet implemented */
 225  
                 public Object decodeObject(NSCoder nscoder) {
 226  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 227  
                 }
 228  
 
 229  
                 /** Not yet implemented */
 230  0
                 public _DateSupport() {
 231  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 232  
                 }
 233  
         }
 234  
 
 235  
         /** Not yet implemented */
 236  
         public static class _StringSupport extends Support {
 237  
 
 238  
                 /** Not yet implemented */
 239  
                 public void encodeWithCoder(Object obj, NSCoder nscoder) {
 240  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 241  
                 }
 242  
 
 243  
                 /** Not yet implemented */
 244  
                 public Object decodeObject(NSCoder nscoder) {
 245  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 246  
                 }
 247  
 
 248  
                 /** Not yet implemented */
 249  0
                 public _StringSupport() {
 250  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 251  
                 }
 252  
         }
 253  
 
 254  
         /** Not yet implemented */
 255  
         public static class _BooleanSupport extends Support {
 256  
 
 257  
                 /** Not yet implemented */
 258  
                 public void encodeWithCoder(Object obj, NSCoder nscoder) {
 259  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 260  
                 }
 261  
 
 262  
                 /** Not yet implemented */
 263  
                 public Object decodeObject(NSCoder nscoder) {
 264  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 265  
                 }
 266  
 
 267  
                 /** Not yet implemented */
 268  0
                 public _BooleanSupport() {
 269  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 270  
                 }
 271  
         }
 272  
 
 273  
         /** Helper class for NSCoding. */
 274  0
         public static abstract class Support {
 275  
 
 276  0
                 private static NSMutableDictionary classSupportMap =
 277  0
                         new NSMutableDictionary(16);
 278  
 
 279  
                 public static Support supportForClass(Class aClass) {
 280  0
                         Support support = null;
 281  0
                         Class realClass = aClass;
 282  0
                         while (support == null && realClass != null) {
 283  0
                                 support = (Support) classSupportMap.objectForKey(realClass);
 284  0
                                 if (support == null)
 285  0
                                         realClass.getSuperclass();
 286  
                                 // Cache if we had to look to a superclass.
 287  0
                                 else if (aClass != realClass)
 288  0
                                         classSupportMap.setObjectForKey(support, aClass);
 289  
                         }
 290  0
                         return support;
 291  
                 }
 292  
 
 293  
                 public static void setSupportForClass(Support support, Class class1) {
 294  0
                         classSupportMap.setObjectForKey(support, class1);
 295  0
                 }
 296  
 
 297  
                 /** Return the class of a given object. It boggles the mind
 298  
                  *  as to why this is not a static, but in the original, it's
 299  
                  *  not. <sigh>
 300  
                  */
 301  
                 public Class classForCoder(Object obj) {
 302  0
                         return obj.getClass();
 303  
                 }
 304  
 
 305  
                 public abstract void encodeWithCoder(Object obj, NSCoder nscoder);
 306  
 
 307  
                 public abstract Object decodeObject(NSCoder nscoder);
 308  
 
 309  
                 protected static void _encodeUTF8(String s, NSCoder nscoder) {
 310  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 311  
                 }
 312  
 
 313  
                 protected static String _decodeUTF8(NSCoder nscoder) {
 314  0
                         throw new UnsupportedOperationException("Not Yet Implemented");
 315  
                 }
 316  
 
 317  
                 static {
 318  0
                         setSupportForClass(new _StringSupport(), java.lang.String.class);
 319  0
                         setSupportForClass(new _BooleanSupport(), java.lang.Boolean.class);
 320  0
                         setSupportForClass(new _NumberSupport(), null);
 321  0
                         setSupportForClass(new _ByteSupport(), java.lang.Byte.class);
 322  0
                         setSupportForClass(new _ShortSupport(), java.lang.Short.class);
 323  0
                         setSupportForClass(new _IntegerSupport(), java.lang.Integer.class);
 324  0
                         setSupportForClass(new _LongSupport(), java.lang.Long.class);
 325  0
                         setSupportForClass(new _FloatSupport(), java.lang.Float.class);
 326  0
                         setSupportForClass(new _DoubleSupport(), java.lang.Double.class);
 327  0
                         setSupportForClass(
 328  0
                                 new _BigIntegerSupport(),
 329  0
                                 java.math.BigInteger.class);
 330  0
                         setSupportForClass(
 331  0
                                 new _BigDecimalSupport(),
 332  0
                                 java.math.BigDecimal.class);
 333  0
                         setSupportForClass(new _DateSupport(), java.util.Date.class);
 334  0
                         setSupportForClass(
 335  0
                                 new _CharacterSupport(),
 336  0
                                 java.lang.Character.class);
 337  0
                 }
 338  
 
 339  0
                 public Support() {
 340  0
                 }
 341  
         }
 342  
 
 343  
     //CEG: I'm not sure why these are here, since NSCoding is an interface.
 344  
     //     It doesn't seem to even be used anywhere.
 345  
     //CEG: I'm not even sure why this compiles!!
 346  
         //public abstract Class classForCoder();
 347  
 
 348  
     //CEG: I'm not sure why these are here, since NSCoding is an interface.
 349  
     //     It doesn't seem to even be used anywhere.
 350  
     //CEG: I'm not even sure why this compiles!!
 351  
         //public abstract void encodeWithCoder(NSCoder nscoder);
 352  
 
 353  
 }
 354  
 /*
 355  
  * $Log$
 356  
  * Revision 1.1  2006/02/16 12:47:16  cgruber
 357  
  * Check in all sources in eclipse-friendly maven-enabled packages.
 358  
  *
 359  
  * Revision 1.2  2003/08/06 23:07:52  chochos
 360  
  * general code cleanup (mostly, removing unused imports)
 361  
  *
 362  
  * Revision 1.1  2002/07/14 21:56:16  mpowers
 363  
  * Contributions from cgruber.
 364  
  *
 365  
  * Revision 1.2  2002/06/25 19:03:02  cgruber
 366  
  * Internal documentation fixes.
 367  
  *
 368  
  * Revision 1.1  2002/06/25 07:52:56  cgruber
 369  
  * Add quite a few abstract classes, interfaces, and classes.  All API consistent with WebObjects, but with no implementation, nor any private or package access members from the original.
 370  
  *
 371  
  */