1 29 30 package com.caucho.jcr.base; 31 32 import com.caucho.util.L10N; 33 34 import javax.jcr.PropertyType; 35 import javax.jcr.RepositoryException; 36 import javax.jcr.Value; 37 import javax.jcr.ValueFormatException; 38 import java.io.InputStream ; 39 import java.util.Calendar ; 40 41 44 abstract public class BaseValue implements Value { 45 private static final L10N L = new L10N(BaseValue.class); 46 47 abstract public String getString() 48 throws ValueFormatException, 49 IllegalStateException , 50 RepositoryException; 51 52 public InputStream getStream() 53 throws IllegalStateException , 54 RepositoryException 55 { 56 throw new IllegalStateException (getClass().getName()); 57 } 58 59 public long getLong() 60 throws ValueFormatException, 61 IllegalStateException , 62 RepositoryException 63 { 64 return Long.parseLong(getString()); 65 } 66 67 public double getDouble() 68 throws ValueFormatException, 69 IllegalStateException , 70 RepositoryException 71 { 72 return Double.parseDouble(getString()); 73 } 74 75 public Calendar getDate() 76 throws ValueFormatException, 77 IllegalStateException , 78 RepositoryException 79 { 80 throw new UnsupportedOperationException (getClass().getName()); 81 } 82 83 public boolean getBoolean() 84 throws ValueFormatException, 85 IllegalStateException , 86 RepositoryException 87 { 88 return ! "false".equals(getString()); 89 } 90 91 public int getType() 92 { 93 return PropertyType.STRING; 94 } 95 } 96 | Popular Tags |