KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
25  * <p>
26  * <b>Purpose</b>: To record the changes for an attribute that references a single Object
27  * @see RelatedClasses prototype.changeset.CollectionChangeRecord,prototype.changeset.SingleObjectChangeRecord
28  */

29 public class ObjectReferenceChangeRecord extends ChangeRecord implements oracle.toplink.essentials.changesets.ObjectReferenceChangeRecord {
30
31     /** This is the object change set that the attribute points to. */
32     protected ObjectChangeSet newValue;
33     
34     /** A reference to the old value must also be sotred. This is only required for the commit and must never be serialized. */
35     protected transient Object JavaDoc oldValue;
36
37     /**
38      * INTERNAL:
39      * This default constructor is reference internally by SDK XML project to mapp this class
40      */

41     public ObjectReferenceChangeRecord() {
42         super();
43     }
44
45     /**
46      * INTERNAL:
47      * This Constructor is used to create an ObjectReferenceChangeRecord With an owner
48      * @param owner prototype.changeset.ObjectChangeSet
49      */

50     public ObjectReferenceChangeRecord(ObjectChangeSet owner) {
51         this.owner = owner;
52     }
53
54     /**
55      * ADVANCED:
56      * Returns the new reference for this object
57      * @return prototype.changeset.ObjectChangeSet
58      */

59     public oracle.toplink.essentials.changesets.ObjectChangeSet getNewValue() {
60         return newValue;
61     }
62
63     /**
64      * INTERNAL:
65      * This method will be used to merge one record into another
66      */

67     public void mergeRecord(ChangeRecord mergeFromRecord, UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet) {
68         ObjectChangeSet localChangeSet = mergeToChangeSet.findOrIntegrateObjectChangeSet((ObjectChangeSet)((ObjectReferenceChangeRecord)mergeFromRecord).getNewValue(), mergeFromChangeSet);
69         this.newValue = localChangeSet;
70     }
71
72
73     /**
74      * This method sets the value of the change to be made.
75      * @param newValue prototype.changeset.ObjectChangeSet
76      */

77     public void setNewValue(oracle.toplink.essentials.changesets.ObjectChangeSet newValue) {
78         this.newValue = (ObjectChangeSet)newValue;
79     }
80
81     /**
82      * This method sets the value of the change to be made.
83      * @param newValue prototype.changeset.ObjectChangeSet
84      */

85     public void setNewValue(ObjectChangeSet newValue) {
86         this.newValue = newValue;
87     }
88     
89     /**
90      * Return the old value of the object reference.
91      * This is used during the commit for private-owned references.
92      */

93     public Object JavaDoc getOldValue() {
94         return oldValue;
95     }
96     
97     /**
98      * Set the old value of the object reference.
99      * This is used during the commit for private-owned references.
100      */

101     public void setOldValue(Object JavaDoc oldValue) {
102         this.oldValue = oldValue;
103     }
104
105     /**
106      * INTERNAL:
107      * This method will be used to update the objectsChangeSets references
108      */

109     public void updateReferences(UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet) {
110         this.setNewValue(mergeToChangeSet.findOrIntegrateObjectChangeSet((ObjectChangeSet)this.getNewValue(), mergeFromChangeSet));
111     }
112 }
113
Popular Tags