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.ValueFormatException; 37 import java.io.IOException ; 38 import java.io.InputStream ; 39 40 43 abstract public class BinaryValue extends BaseValue { 44 private static final L10N L = new L10N(BaseValue.class); 45 46 public String getString() 47 throws ValueFormatException, 48 IllegalStateException , 49 RepositoryException 50 { 51 StringBuilder sb = new StringBuilder (); 52 53 try { 54 InputStream is = getStream(); 55 56 int ch; 58 59 while ((ch = is.read()) >= 0) { 60 sb.append((char) ch); 61 } 62 63 return sb.toString(); 64 } catch (IOException e) { 65 throw new ValueFormatException(e); 66 } 67 } 68 69 abstract public InputStream getStream() 70 throws IllegalStateException , 71 RepositoryException; 72 73 public int getType() 74 { 75 return PropertyType.STRING; 76 } 77 } 78 | Popular Tags |