KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > sessions > ChangeRecord


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.internal.sessions;
23
24 import oracle.toplink.essentials.mappings.*;
25 import oracle.toplink.essentials.internal.sessions.AbstractSession;
26 import java.io.Serializable JavaDoc;
27
28 /**
29  * <p>
30  * <b>Purpose</b>: This class was designed as a superclass to all possible Change Record types.
31  * These Change Records holds the changes made to the objects
32  * <p>
33  *
34  * @see KnownSubclasses prototype.changeset.CollectionChangeRecord,prototype.changeset.DirectToFieldChangeRecord,prototype.changeset.SingleObjectChangeRecord
35  */

36 public abstract class ChangeRecord implements Serializable JavaDoc, oracle.toplink.essentials.changesets.ChangeRecord {
37
38     /**
39      * This is the attribute name that this change record represents
40      */

41     protected String JavaDoc attribute;
42
43     /**
44      * This attribute stores the mapping allong with the attribute so that the mapping does not need to be looked up
45      */

46     protected transient DatabaseMapping mapping;
47
48     /** This is the object change set that holds this record **/
49     protected ObjectChangeSet owner;
50
51     /**
52      * ADVANCED:
53      * Returns the name of the attribute this ChangeRecord Represents
54      * @return java.lang.String
55      */

56     public String JavaDoc getAttribute() {
57         return attribute;
58     }
59
60     /**
61      * ADVANCED:
62      * Returns the mapping for the attribute this ChangeRecord Represents
63      */

64     public DatabaseMapping getMapping() {
65         return mapping;
66     }
67
68     /**
69      * Insert the method's description here.
70      * Creation date: (5/30/00 3:42:14 PM)
71      * @return prototype.changeset.ObjectChangeSet
72      */

73     public oracle.toplink.essentials.changesets.ObjectChangeSet getOwner() {
74         return (oracle.toplink.essentials.changesets.ObjectChangeSet)owner;
75     }
76
77     /**
78      * INTERNAL:
79      * This method will be used to merge one record into another
80      */

81     public abstract void mergeRecord(ChangeRecord mergeFromRecord, UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet);
82
83     /**
84      * INTERNAL:
85      * Ensure this change record is ready to by sent remotely for cache synchronization
86      * In general, this means setting the CacheSynchronizationType on any ObjectChangeSets
87      * associated with this ChangeRecord
88      */

89     public void prepareForSynchronization(AbstractSession session) {
90     }
91
92     /**
93      * Sets the name of the attribute that this Record represents
94      * @param newValue java.lang.String
95      */

96     public void setAttribute(String JavaDoc newValue) {
97         this.attribute = newValue;
98     }
99
100     /**
101      * Sets the mapping for the attribute that this Record represents
102      */

103     public void setMapping(DatabaseMapping mapping) {
104         this.mapping = mapping;
105     }
106
107     /**
108      * INTERNAL:
109      * This method is used to set the ObjectChangeSet that uses this Record in that Record
110      * @param newOwner prototype.changeset.ObjectChangeSet The changeSet that uses this record
111      */

112     public void setOwner(ObjectChangeSet newOwner) {
113         owner = newOwner;
114     }
115
116     public String JavaDoc toString() {
117         return this.getClass().getName() + "(" + getAttribute() + ")";
118     }
119
120     /**
121      * INTERNAL:
122      * used by the record to update the new value ignores the value in the default implementation
123      */

124     public void updateChangeRecordWithNewValue(Object JavaDoc newValue) {
125         //no op
126
}
127
128     /**
129      * INTERNAL:
130      * This method will be used to update the objectsChangeSets references
131      */

132     public abstract void updateReferences(UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet);
133 }
134
Popular Tags