01: //$Id: Status.java 9194 2006-02-01 19:59:07Z steveebersole $
02: package org.hibernate.engine;
03:
04: import java.io.Serializable;
05: import java.io.ObjectStreamException;
06: import java.io.InvalidObjectException;
07:
08: /**
09: * Represents the status of an entity with respect to
10: * this session. These statuses are for internal
11: * book-keeping only and are not intended to represent
12: * any notion that is visible to the _application_.
13: */
14: public final class Status implements Serializable {
15:
16: public static final Status MANAGED = new Status("MANAGED");
17: public static final Status READ_ONLY = new Status("READ_ONLY");
18: public static final Status DELETED = new Status("DELETED");
19: public static final Status GONE = new Status("GONE");
20: public static final Status LOADING = new Status("LOADING");
21: public static final Status SAVING = new Status("SAVING");
22:
23: private String name;
24:
25: private Status(String name) {
26: this .name = name;
27: }
28:
29: public String toString() {
30: return name;
31: }
32:
33: private Object readResolve() throws ObjectStreamException {
34: return parse(name);
35: }
36:
37: public static Status parse(String name)
38: throws InvalidObjectException {
39: if (name.equals(MANAGED.name))
40: return MANAGED;
41: if (name.equals(READ_ONLY.name))
42: return READ_ONLY;
43: if (name.equals(DELETED.name))
44: return DELETED;
45: if (name.equals(GONE.name))
46: return GONE;
47: if (name.equals(LOADING.name))
48: return LOADING;
49: if (name.equals(SAVING.name))
50: return SAVING;
51: throw new InvalidObjectException("invalid Status");
52: }
53: }
|