1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jdo.model.jdo;
19
20 /***
21 * This interface provides constants denoting the identity type
22 * of a persistence-capable class.
23 *
24 * @author Michael Bouschen
25 */
26 public class JDOIdentityType
27 {
28 /*** Constant representing an unspecified jdo identity */
29 public static final int UNSPECIFIED = 0;
30
31 /*** Constant representing jdo identity managed by the database. */
32 public static final int DATASTORE = 1;
33
34 /*** Constant representing jdo identity managed by the application. */
35 public static final int APPLICATION = 2;
36
37 /*** Constant representing unmanaged jdo identity. */
38 public static final int NONDURABLE = 4;
39
40 /***
41 * Returns a string representation of the specified identity type constant.
42 * @param jdoIdentityType the JDO identity type, one of
43 * {@link #APPLICATION}, {@link #DATASTORE}, or {@link #NONDURABLE}
44 * @return the string representation of the JDOIdentityType constant
45 */
46 public static String toString(int jdoIdentityType) {
47 switch ( jdoIdentityType) {
48 case DATASTORE :
49 return "datastore";
50 case APPLICATION :
51 return "application";
52 case NONDURABLE:
53 return "nondurable";
54 default:
55 return "UNSPECIFIED";
56 }
57 }
58
59 /***
60 * Returns the JDOIdentityType constant, one of {@link #APPLICATION},
61 * {@link #DATASTORE}, or {@link #NONDURABLE} for the specified string.
62 * @param jdoIdentityType the string representation of the
63 * JDO identity type
64 * @return the JDO identity type
65 **/
66 public static int toJDOIdentityType(String jdoIdentityType)
67 {
68 if ((jdoIdentityType == null) || (jdoIdentityType.length() == 0))
69 return UNSPECIFIED;
70
71 if ("datastore".equals(jdoIdentityType))
72 return DATASTORE;
73 else if ("application".equals(jdoIdentityType))
74 return APPLICATION;
75 else if ("nondurable".equals(jdoIdentityType))
76 return NONDURABLE;
77 else
78 return UNSPECIFIED;
79 }
80 }