KickJava   Java API By Example, From Geeks To Geeks.

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


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: TransientDirty.java,v 1.1 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 TransientDirty extends LifeCycleState
18 {
19     protected TransientDirty()
20     {
21         isPersistent = false;
22         isTransactional = true;
23         isDirty = true;
24         isNew = false;
25         isDeleted = false;
26
27         stateType = T_DIRTY;
28     }
29
30     public LifeCycleState transitionMakePersistent(StateManagerImpl sm, Transaction tx)
31     {
32         return changeState(sm, P_NEW);
33     }
34
35     public LifeCycleState transitionDeletePersistent(StateManagerImpl sm, Transaction tx)
36     {
37         throw new JDOUserException("Cannot delete, object is not persistent", sm.getObject());
38     }
39
40     public LifeCycleState transitionMakeNontransactional(StateManagerImpl sm)
41     {
42         throw new JDOUserException("Cannot make object non-transactional: object is dirty", sm.getObject());
43     }
44
45     public LifeCycleState transitionCommit(StateManagerImpl sm, Transaction tx)
46     {
47         sm.discardSavedFields();
48         sm.evictFromTransaction();
49         return changeState(sm, T_CLEAN);
50     }
51
52     public LifeCycleState transitionRollback(StateManagerImpl sm, Transaction tx)
53     {
54         sm.restoreFields();
55         sm.replaceSCOFields();
56         sm.evictFromTransaction();
57         return changeState(sm, T_CLEAN);
58     }
59
60     public String JavaDoc toString()
61     {
62         return "T_DIRTY";
63     }
64 }
65
Popular Tags