View Javadoc

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 java.util.List;
22  import java.util.Map;
23  
24  import net.wotonomy.foundation.NSDictionary;
25  import net.wotonomy.foundation.NSKeyValueCodingAdditions;
26  
27  /***
28  * EOKeyValueCodingAdditions defines an interface for classes
29  * that need to have more control over the wotonomy's bulk 
30  * property copying and cloning facilities.  <br><br>
31  *
32  * @author michael@mpowers.net
33  * @author $Author: cgruber $
34  * @version $Revision: 894 $
35  */
36  public interface EOKeyValueCodingAdditions extends EOKeyValueCoding, NSKeyValueCodingAdditions
37  {
38      
39      /***
40      * Static utilities methods that
41      * call the appropriate method if the object implements
42      * NSKeyValueCodingAdditions, otherwise calls the method
43      * on DefaultImplementation.
44      */
45      public class Utility extends NSKeyValueCodingAdditions.Utility
46      {
47          /***
48          * Calls the appropriate method if the object implements
49          * NSKeyValueCodingAdditions, otherwise calls the method
50          * on DefaultImplementation.
51          */
52          public static void takeValuesFromDictionary(
53              Object object, Map dictionary)
54          {
55              if (object instanceof NSKeyValueCodingAdditions) {
56                  ((NSKeyValueCodingAdditions)object).takeValuesFromDictionary(dictionary);
57              } else {
58                  DefaultImplementation.takeValuesFromDictionary(object, dictionary);
59              }
60           }
61              
62          /***
63          * Calls the appropriate method if the object implements
64          * NSKeyValueCodingAdditions, otherwise calls the method
65          * on DefaultImplementation.
66          */
67  /*        
68          public static void takeValuesFromDictionaryWithMapping(
69              Object object, NSDictionary dictionary, NSDictionary mapping)
70          {
71              if (object instanceof NSKeyValueCodingAdditions) {
72                  ((NSKeyValueCodingAdditions)object).takeValuesFromDictionaryWithMapping(dictionary, mapping);
73              } else {
74                  DefaultImplementation.takeValuesFromDictionaryWithMapping(object, dictionary, mapping);
75              }
76          }
77  */        
78          
79          /***
80          * Calls the appropriate method if the object implements
81          * NSKeyValueCodingAdditions, otherwise calls the method
82          * on DefaultImplementation.
83          */
84          public static NSDictionary valuesForKeys(
85              Object object, List keys)
86          {
87              if (object instanceof NSKeyValueCodingAdditions) {
88                  return ((NSKeyValueCodingAdditions)object).valuesForKeys(keys);
89              } else {
90                  return DefaultImplementation.valuesForKeys(object, keys);
91              }
92          }
93          
94          /***
95          * Calls the appropriate method if the object implements
96          * NSKeyValueCodingAdditions, otherwise calls the method
97          * on DefaultImplementation.
98          */
99  /*        
100         public static NSDictionary valuesForKeysWithMapping(
101             Object object, NSDictionary mapping)
102         {
103             if (object instanceof NSKeyValueCodingAdditions) {
104                 return ((NSKeyValueCodingAdditions)object).valuesForKeysWithMapping(mapping);
105             } else {
106                 return DefaultImplementation.valuesForKeysWithMapping(object, mapping);
107             }
108         }
109 */        
110     }
111     
112     /***
113     * Provides a reflection-based implementation for classes that
114     * don't implement NSKeyValueCodingAdditions.
115     */
116     public class DefaultImplementation extends NSKeyValueCodingAdditions.DefaultImplementation
117     {
118         public static void takeValuesFromDictionary(
119             Object object, NSDictionary dictionary)
120         {
121             throw new RuntimeException( "Not implemented yet." );
122         }
123             
124         public static void takeValuesFromDictionaryWithMapping(
125             Object object, NSDictionary dictionary, NSDictionary mapping)
126         {
127             throw new RuntimeException( "Not implemented yet." );
128         }
129         
130         public static NSDictionary valuesForKeys(
131             Object object, List keys)
132         {
133             throw new RuntimeException( "Not implemented yet." );
134         }
135         
136         public static NSDictionary valuesForKeysWithMapping(
137             Object object, Map mapping)
138         {
139             throw new RuntimeException( "Not implemented yet." );
140         }
141     }
142 }
143 
144 /*
145  * $Log$
146  * Revision 1.2  2006/02/16 16:47:14  cgruber
147  * Move some classes in to "internal" packages and re-work imports, etc.
148  *
149  * Also use UnsupportedOperationExceptions where appropriate, instead of WotonomyExceptions.
150  *
151  * Revision 1.1  2006/02/16 13:19:57  cgruber
152  * Check in all sources in eclipse-friendly maven-enabled packages.
153  *
154  * Revision 1.4  2003/01/16 22:47:30  mpowers
155  * Compatibility changes to support compiling woextensions source.
156  * (34 out of 56 classes compile!)
157  *
158  * Revision 1.3  2001/12/10 15:25:11  mpowers
159  * Now properly extending EOKeyValueCoding.
160  *
161  * Revision 1.2  2001/04/28 14:12:23  mpowers
162  * Refactored cloning/copying into KeyValueCodingUtilities.
163  *
164  * Revision 1.1  2001/03/29 03:29:49  mpowers
165  * Now using KeyValueCoding and Support instead of Introspector.
166  *
167  * Revision 1.2  2001/03/28 16:12:30  mpowers
168  * Documented interface.
169  *
170  * Revision 1.1  2001/03/27 23:25:05  mpowers
171  * Contributing interface, no docs yet.
172  *
173  *
174  */
175     
176