KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > triactive > jdo > state > PersistentDeleted


1 /*
2  * Copyright 2004 (C) TJDO.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the TJDO License version 1.0.
6  * See the terms of the TJDO License in the documentation provided with this software.
7  *
8  * $Id: PersistentDeleted.java,v 1.6 2004/01/18 03:01:06 jackknifebarber Exp $
9  */

10
11 package com.triactive.jdo.state;
12
13 import javax.jdo.JDOUserException;
14 import javax.jdo.Transaction;
15
16
17 class PersistentDeleted extends LifeCycleState
18 {
19     protected PersistentDeleted()
20     {
21         isPersistent = true;
22         isTransactional = true;
23         isDirty = true;
24         isNew = false;
25         isDeleted = true;
26
27         stateType = P_DELETED;
28     }
29
30     public LifeCycleState transitionMakeNontransactional(StateManagerImpl sm)
31     {
32         throw new JDOUserException("Cannot make object non-transactional: object has been deleted", sm.getObject());
33     }
34
35     public LifeCycleState transitionMakeTransient(StateManagerImpl sm)
36     {
37         throw new JDOUserException("Cannot make object transient: object has been deleted", sm.getObject());
38     }
39
40     public LifeCycleState transitionCommit(StateManagerImpl sm, Transaction tx)
41     {
42         sm.clearPersistentFields();
43         sm.evictFromTransaction();
44         sm.disconnect();
45         return changeState(sm, TRANSIENT);
46     }
47
48     public LifeCycleState transitionRollback(StateManagerImpl sm, Transaction tx)
49     {
50         if (tx.getRestoreValues())
51         {
52             sm.restoreFields();
53             sm.replaceSCOFields();
54             sm.evictFromTransaction();
55             return changeState(sm, P_NONTRANS);
56         }
57         else
58         {
59             sm.clearPersistentFields();
60             sm.discardSavedFields();
61             sm.evictFromTransaction();
62             return changeState(sm, HOLLOW);
63         }
64
65     }
66
67     public LifeCycleState transitionReadField(StateManagerImpl sm, Transaction tx)
68     {
69         throw new JDOUserException("Cannot read fields from a deleted object", sm.getObject());
70     }
71
72     public LifeCycleState transitionWriteField(StateManagerImpl sm, Transaction tx)
73     {
74         throw new JDOUserException("Cannot write fields to a deleted object", sm.getObject());
75     }
76
77     public String JavaDoc toString()
78     {
79         return "P_DELETED";
80     }
81 }
82
Popular Tags