1 29 30 package com.caucho.jcr.base; 31 32 import com.caucho.util.L10N; 33 34 import javax.jcr.Node; 35 import javax.jcr.Property; 36 import javax.jcr.RepositoryException; 37 import javax.jcr.Value; 38 import javax.jcr.ValueFactory; 39 import javax.jcr.ValueFormatException; 40 import javax.jcr.lock.LockException; 41 import javax.jcr.nodetype.ConstraintViolationException; 42 import javax.jcr.nodetype.PropertyDefinition; 43 import javax.jcr.version.VersionException; 44 import java.io.InputStream ; 45 import java.util.Calendar ; 46 47 50 public class BaseProperty extends BaseItem implements Property { 51 private static final L10N L = new L10N(BaseProperty.class); 52 53 private ValueFactory _factory = BaseValueFactory.FACTORY; 54 55 private Value _value; 57 protected BaseProperty(Value value) 58 { 59 _value = value; 60 } 61 62 65 public void setValue(Value value) 66 throws ValueFormatException, 67 VersionException, 68 LockException, 69 ConstraintViolationException, 70 RepositoryException 71 { 72 _value = value; 73 } 74 75 78 public void setValue(Value[] values) 79 throws ValueFormatException, 80 VersionException, 81 LockException, 82 ConstraintViolationException, 83 RepositoryException 84 { 85 throw new UnsupportedOperationException (getClass().getName()); 86 } 87 88 91 public void setValue(String value) 92 throws ValueFormatException, 93 VersionException, 94 LockException, 95 ConstraintViolationException, 96 RepositoryException 97 { 98 setValue(_factory.createValue(value)); 99 } 100 101 104 public void setValue(String [] values) 105 throws ValueFormatException, 106 VersionException, 107 LockException, 108 ConstraintViolationException, 109 RepositoryException 110 { 111 throw new UnsupportedOperationException (); 112 } 113 114 117 public void setValue(InputStream value) 118 throws ValueFormatException, 119 VersionException, 120 LockException, 121 ConstraintViolationException, 122 RepositoryException 123 { 124 setValue(_factory.createValue(value)); 125 } 126 127 130 public void setValue(long value) 131 throws ValueFormatException, 132 VersionException, 133 LockException, 134 ConstraintViolationException, 135 RepositoryException 136 { 137 setValue(_factory.createValue(value)); 138 } 139 140 143 public void setValue(double value) 144 throws ValueFormatException, 145 VersionException, 146 LockException, 147 ConstraintViolationException, 148 RepositoryException 149 { 150 setValue(_factory.createValue(value)); 151 } 152 153 156 public void setValue(Calendar value) 157 throws ValueFormatException, 158 VersionException, 159 LockException, 160 ConstraintViolationException, 161 RepositoryException 162 { 163 setValue(_factory.createValue(value)); 164 } 165 166 169 public void setValue(boolean value) 170 throws ValueFormatException, 171 VersionException, 172 LockException, 173 ConstraintViolationException, 174 RepositoryException 175 { 176 setValue(_factory.createValue(value)); 177 } 178 179 182 public void setValue(Node value) 183 throws ValueFormatException, 184 VersionException, 185 LockException, 186 ConstraintViolationException, 187 RepositoryException 188 { 189 setValue(_factory.createValue(value)); 190 } 191 192 195 public Value getValue() 196 throws ValueFormatException, 197 RepositoryException 198 { 199 return _value; 200 } 201 202 205 public Value[] getValues() 206 throws ValueFormatException, 207 RepositoryException 208 { 209 throw new UnsupportedOperationException (getClass().getName()); 210 } 211 212 215 public String getString() 216 throws ValueFormatException, 217 RepositoryException 218 { 219 return getValue().getString(); 220 } 221 222 225 public InputStream getStream() 226 throws ValueFormatException, 227 RepositoryException 228 { 229 return getValue().getStream(); 230 } 231 232 235 public long getLong() 236 throws ValueFormatException, 237 RepositoryException 238 { 239 return getValue().getLong(); 240 } 241 242 245 public double getDouble() 246 throws ValueFormatException, 247 RepositoryException 248 { 249 return getValue().getDouble(); 250 } 251 252 255 public Calendar getDate() 256 throws ValueFormatException, 257 RepositoryException 258 { 259 return getValue().getDate(); 260 } 261 262 265 public boolean getBoolean() 266 throws ValueFormatException, 267 RepositoryException 268 { 269 return getValue().getBoolean(); 270 } 271 272 275 public Node getNode() 276 throws ValueFormatException, 277 RepositoryException 278 { 279 throw new UnsupportedOperationException (); 280 } 281 282 285 public long getLength() 286 throws ValueFormatException, 287 RepositoryException 288 { 289 return 0; 290 } 291 292 295 public long[] getLengths() 296 throws ValueFormatException, 297 RepositoryException 298 { 299 return new long[0]; 300 } 301 302 305 public PropertyDefinition getDefinition() 306 throws RepositoryException 307 { 308 throw new UnsupportedOperationException (); 309 } 310 311 314 public int getType() 315 throws RepositoryException 316 { 317 return getDefinition().getRequiredType(); 318 } 319 } 320 | Popular Tags |