KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jcorporate > expresso > core > dataobjects > DataField


1 /* ====================================================================
2  * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
3  *
4  * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * 3. The end-user documentation included with the redistribution,
19  * if any, must include the following acknowledgment:
20  * "This product includes software developed by Jcorporate Ltd.
21  * (http://www.jcorporate.com/)."
22  * Alternately, this acknowledgment may appear in the software itself,
23  * if and wherever such third-party acknowledgments normally appear.
24  *
25  * 4. "Jcorporate" and product names such as "Expresso" must
26  * not be used to endorse or promote products derived from this
27  * software without prior written permission. For written permission,
28  * please contact info@jcorporate.com.
29  *
30  * 5. Products derived from this software may not be called "Expresso",
31  * or other Jcorporate product names; nor may "Expresso" or other
32  * Jcorporate product names appear in their name, without prior
33  * written permission of Jcorporate Ltd.
34  *
35  * 6. No product derived from this software may compete in the same
36  * market space, i.e. framework, without prior written permission
37  * of Jcorporate Ltd. For written permission, please contact
38  * partners@jcorporate.com.
39  *
40  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
41  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
42  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
43  * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
44  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
45  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
46  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
47  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
48  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
49  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
50  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51  * SUCH DAMAGE.
52  * ====================================================================
53  *
54  * This software consists of voluntary contributions made by many
55  * individuals on behalf of the Jcorporate Ltd. Contributions back
56  * to the project(s) are encouraged when you make modifications.
57  * Please send them to support@jcorporate.com. For more information
58  * on Jcorporate Ltd. and its products, please see
59  * <http://www.jcorporate.com/>.
60  *
61  * Portions of this software are based upon other open source
62  * products and are subject to their respective licenses.
63  */

64
65 package com.jcorporate.expresso.core.dataobjects;
66
67 import java.io.InputStream JavaDoc;
68 import java.math.BigDecimal JavaDoc;
69 import java.util.Date JavaDoc;
70 import java.util.Map JavaDoc;
71
72 /**
73  * This class represents a single field of data that is stored within the
74  * data object. It will provide basic manipulations such as it's original
75  * value, and attribute holdings.
76  *
77  * @author Michael Rimov
78  * @since Expresso 5.0.1
79  */

80
81 public interface DataField {
82
83     /**
84      * Retrieves the wrapped object for the Data Field
85      *
86      * @return java.lang.Object or null
87      */

88     public Object JavaDoc getValue();
89
90     /**
91      * Retrieves the wrapped object as a String
92      *
93      * @return java.lang.String
94      */

95     public String JavaDoc asString();
96
97
98     /**
99      * Retrieve the boolean object value.
100      *
101      * @return java.lang.Boolean
102      */

103     public Boolean JavaDoc asBoolean();
104
105     /**
106      * Retrieves the wrapped object as an <code>Integer</code> or zero if it's an invalid format.
107      *
108      * @return a java.lang.Integer object, or null if the object is null.
109      */

110     public Integer JavaDoc asInteger();
111
112     /**
113      * Retrieve the wrapped object as a <code>Date</code> object or possibly null if we
114      * can't convert it or the object is null.
115      *
116      * @return a properly instantiated <code>Date</code> Object if we're able to convert it.
117      */

118     public Date JavaDoc asDate();
119
120     /**
121      * Retrieve the wrapped object as a <code>BigDecimal</code> object or zero if we're unable
122      * to convert it.
123      *
124      * @return a properly instantiated <code>BigDecimal</code> Object if we're able to convert it.
125      */

126     public BigDecimal JavaDoc asBigDecimal();
127
128     /**
129      * Retrieve the wrapped object as a <code>Double</code> object or zero if we
130      * can't convert i
131      *
132      * @return a properly instantiated <code>Double</code> Object if we're able to convert it.
133      */

134     public Double JavaDoc asDouble();
135
136     /**
137      * @return the original object or null
138      * @deprecated 8/04 v.5.5 do not expose this cache
139      * Retrieve the last original value if the data has changed. Will return
140      * null if isChanged() is false
141      */

142     public Object JavaDoc getOriginalValue();
143
144
145     /**
146      * Allows for retrieval of BLOB database types.
147      *
148      * @return java.io.InputStream
149      */

150     public InputStream JavaDoc asStream();
151
152     /**
153      * Used for change logging.
154      *
155      * @return true if the field has changed since the last reset
156      */

157     public boolean isChanged();
158
159     /**
160      * Used for change logging.
161      *
162      * @return true if the field has been set since the last reset
163      */

164     public boolean isValueSet();
165
166     /**
167      * Make sure the value of the field is valid.
168      *
169      * @throws DataException if the field value is not valid
170      */

171     public void checkValue() throws DataException;
172
173     /**
174      * Resets the changed flag and sets the original value field to null
175      */

176     public void resetChanged();
177
178     /**
179      * Sets the wrapped object for the data field
180      *
181      * @param newValue a new Object to set the value to
182      */

183     public void setValue(Object JavaDoc newValue);
184
185     /**
186      * Returns true if the object is null.
187      *
188      * @return true if the object is null
189      */

190     public boolean isNull();
191
192     /**
193      * Sets an attribute for this particular instance of the Data field
194      *
195      * @param attributeName the name of the attribute to set
196      * @param value the value to set it to
197      */

198     public void setAttribute(String JavaDoc attributeName, Object JavaDoc value);
199
200     /**
201      * Retrieves any user defined attributes for this field.
202      *
203      * @param attributeName the name of the attribute to retrieve
204      * @return an object or null if the attribute doesn't exist
205      */

206     public Object JavaDoc getAttribute(String JavaDoc attributeName);
207
208
209     /**
210      * Returns a Read Only <code>Map</code> of all attributes in name-value pairs. If there are no
211      * attributes then getAllAttributes will return a null map.
212      *
213      * @return java.util.map
214      */

215     public Map JavaDoc getAllAttributes();
216
217     /**
218      * Returns a handle to the DataObject that is the container for this
219      * Data Field
220      *
221      * @return DataObject the containing data object.
222      */

223     public DataObject getOwner();
224
225     /**
226      * Sets the owner of a given DataObject
227      *
228      * @param newOwner The new parent object.
229      */

230     public void setOwner(DataObject newOwner);
231
232
233     /**
234      * Returns a handle to the Field MetaData object.
235      *
236      * @return DataFieldMetaData
237      */

238     public DataFieldMetaData getFieldMetaData();
239
240     /**
241      * Sets the metadata object for this field.
242      *
243      * @param newMetadata the new Field Meta data object... for example <code>DBField</code>
244      */

245     public void setFieldMetaData(DataFieldMetaData newMetadata);
246
247     /**
248      * call after add() or update(). The currentValue of data fields should be considered the baseline, the 'original value' for purposes of determining 'isChanged'
249      */

250     public void cacheIsChangedComparison();
251 }
252
Popular Tags