1 24 package javax.jcr; 25 26 43 public final class PropertyType { 44 47 public static final int STRING = 1; 48 public static final int BINARY = 2; 49 public static final int LONG = 3; 50 public static final int DOUBLE = 4; 51 public static final int DATE = 5; 52 public static final int BOOLEAN = 6; 53 public static final int SOFTLINK = 7; 54 public static final int REFERENCE = 8; 55 56 59 public static final int UNDEFINED = 0; 60 61 65 public static final String TYPENAME_STRING = "String"; 66 public static final String TYPENAME_BINARY = "Binary"; 67 public static final String TYPENAME_LONG = "Long"; 68 public static final String TYPENAME_DOUBLE = "Double"; 69 public static final String TYPENAME_DATE = "Date"; 70 public static final String TYPENAME_BOOLEAN = "Boolean"; 71 public static final String TYPENAME_SOFTLINK = "SoftLink"; 72 public static final String TYPENAME_REFERENCE = "Reference"; 73 74 83 public static String nameFromValue(int type) { 84 switch (type) { 85 case STRING: 86 return TYPENAME_STRING; 87 case BINARY: 88 return TYPENAME_BINARY; 89 case BOOLEAN: 90 return TYPENAME_BOOLEAN; 91 case LONG: 92 return TYPENAME_LONG; 93 case DOUBLE: 94 return TYPENAME_DOUBLE; 95 case DATE: 96 return TYPENAME_DATE; 97 case SOFTLINK: 98 return TYPENAME_SOFTLINK; 99 case REFERENCE: 100 return TYPENAME_REFERENCE; 101 default: 102 throw new IllegalArgumentException ("unknown type: " + type); 103 } 104 } 105 106 114 public static int valueFromName(String name) { 115 if (name.equals(TYPENAME_STRING)) { 116 return STRING; 117 } else if (name.equals(TYPENAME_BINARY)) { 118 return BINARY; 119 } else if (name.equals(TYPENAME_BOOLEAN)) { 120 return BOOLEAN; 121 } else if (name.equals(TYPENAME_LONG)) { 122 return LONG; 123 } else if (name.equals(TYPENAME_DOUBLE)) { 124 return DOUBLE; 125 } else if (name.equals(TYPENAME_DATE)) { 126 return DATE; 127 } else if (name.equals(TYPENAME_SOFTLINK)) { 128 return SOFTLINK; 129 } else if (name.equals(TYPENAME_REFERENCE)) { 130 return REFERENCE; 131 } else { 132 throw new IllegalArgumentException ("unknown type: " + name); 133 } 134 } 135 136 139 private PropertyType() { 140 } 141 } 142 143 | Popular Tags |