1 24 package javax.jcr; 25 26 import java.util.Calendar ; 27 28 35 public class ReferenceValue extends BaseValue { 36 37 public static final int TYPE = PropertyType.REFERENCE; 38 39 private final String uuid; 40 41 49 public ReferenceValue(Node target) throws RepositoryException { 50 super(TYPE); 51 try { 52 this.uuid = target.getUUID(); 53 } catch (UnsupportedRepositoryOperationException ure) { 54 throw new IllegalArgumentException ("target is nonreferenceable."); 55 } 56 } 57 58 64 public ReferenceValue(String uuid) { 65 super(TYPE); 66 this.uuid = uuid; 68 } 69 70 81 public boolean equals(Object obj) { 82 if (this == obj) { 83 return true; 84 } 85 if (obj instanceof ReferenceValue) { 86 ReferenceValue other = (ReferenceValue) obj; 87 if (uuid == other.uuid) { 88 return true; 89 } else if (uuid != null && other.uuid != null) { 90 return uuid.equals(other.uuid); 91 } 92 } 93 return false; 94 } 95 96 100 public Calendar getDate() throws ValueFormatException, IllegalStateException , RepositoryException { 101 setValueConsumed(); 102 103 throw new ValueFormatException("conversion to date failed: inconvertible types"); 104 } 105 106 109 public long getLong() throws ValueFormatException, IllegalStateException , RepositoryException { 110 setValueConsumed(); 111 112 throw new ValueFormatException("conversion to long failed: inconvertible types"); 113 } 114 115 118 public boolean getBoolean() throws ValueFormatException, IllegalStateException , RepositoryException { 119 setValueConsumed(); 120 121 throw new ValueFormatException("conversion to boolean failed: inconvertible types"); 122 } 123 124 127 public double getDouble() throws ValueFormatException, IllegalStateException , RepositoryException { 128 setValueConsumed(); 129 130 throw new ValueFormatException("conversion to double failed: inconvertible types"); 131 } 132 133 136 public String getString() throws ValueFormatException, IllegalStateException , RepositoryException { 137 setValueConsumed(); 138 139 if (uuid != null) { 140 return uuid; 141 } else { 142 throw new ValueFormatException("empty value"); 143 } 144 } 145 } 146 | Popular Tags |