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