diff options
Diffstat (limited to 'src/main/java/com/amazon/carbonado/lob')
8 files changed, 94 insertions, 0 deletions
diff --git a/src/main/java/com/amazon/carbonado/lob/AbstractBlob.java b/src/main/java/com/amazon/carbonado/lob/AbstractBlob.java index 6440978..1d331bc 100644 --- a/src/main/java/com/amazon/carbonado/lob/AbstractBlob.java +++ b/src/main/java/com/amazon/carbonado/lob/AbstractBlob.java @@ -196,4 +196,31 @@ public abstract class AbstractBlob implements Blob { }
}
}
+
+ @Override
+ public int hashCode() {
+ Object locator = getLocator();
+ return locator == null ? super.hashCode() : locator.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof AbstractBlob) {
+ Object locator = getLocator();
+ if (locator != null) {
+ AbstractBlob other = (AbstractBlob) obj;
+ return locator == other.getLocator();
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ Object locator = getLocator();
+ return locator == null ? super.toString() : ("Blob@" + locator);
+ }
}
diff --git a/src/main/java/com/amazon/carbonado/lob/AbstractClob.java b/src/main/java/com/amazon/carbonado/lob/AbstractClob.java index 6e4e273..8531ba4 100644 --- a/src/main/java/com/amazon/carbonado/lob/AbstractClob.java +++ b/src/main/java/com/amazon/carbonado/lob/AbstractClob.java @@ -165,4 +165,31 @@ public abstract class AbstractClob implements Clob { }
}
}
+
+ @Override
+ public int hashCode() {
+ Object locator = getLocator();
+ return locator == null ? super.hashCode() : locator.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof AbstractClob) {
+ Object locator = getLocator();
+ if (locator != null) {
+ AbstractClob other = (AbstractClob) obj;
+ return locator == other.getLocator();
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ Object locator = getLocator();
+ return locator == null ? super.toString() : ("Clob@" + locator);
+ }
}
diff --git a/src/main/java/com/amazon/carbonado/lob/BlobClob.java b/src/main/java/com/amazon/carbonado/lob/BlobClob.java index 9822171..107f422 100644 --- a/src/main/java/com/amazon/carbonado/lob/BlobClob.java +++ b/src/main/java/com/amazon/carbonado/lob/BlobClob.java @@ -96,6 +96,10 @@ public class BlobClob extends AbstractClob { mBlob.setLength(length << 1);
}
+ public Object getLocator() {
+ return mBlob.getLocator();
+ }
+
protected Blob getWrappedBlob() {
return mBlob;
}
diff --git a/src/main/java/com/amazon/carbonado/lob/ByteArrayBlob.java b/src/main/java/com/amazon/carbonado/lob/ByteArrayBlob.java index eadd8e1..028f575 100644 --- a/src/main/java/com/amazon/carbonado/lob/ByteArrayBlob.java +++ b/src/main/java/com/amazon/carbonado/lob/ByteArrayBlob.java @@ -305,6 +305,13 @@ public class ByteArrayBlob extends AbstractBlob { }
}
+ /**
+ * Always returns null.
+ */
+ public Object getLocator() {
+ return null;
+ }
+
private static class Input extends InputStream {
private final ByteArrayBlob mBlob;
private long mPos;
diff --git a/src/main/java/com/amazon/carbonado/lob/CharArrayClob.java b/src/main/java/com/amazon/carbonado/lob/CharArrayClob.java index ed6b5e9..1472da3 100644 --- a/src/main/java/com/amazon/carbonado/lob/CharArrayClob.java +++ b/src/main/java/com/amazon/carbonado/lob/CharArrayClob.java @@ -310,6 +310,13 @@ public class CharArrayClob extends AbstractClob { }
}
+ /**
+ * Always returns null.
+ */
+ public Object getLocator() {
+ return null;
+ }
+
private static class Input extends Reader {
private final CharArrayClob mClob;
private long mPos;
diff --git a/src/main/java/com/amazon/carbonado/lob/FileBlob.java b/src/main/java/com/amazon/carbonado/lob/FileBlob.java index c351361..eeba914 100644 --- a/src/main/java/com/amazon/carbonado/lob/FileBlob.java +++ b/src/main/java/com/amazon/carbonado/lob/FileBlob.java @@ -109,4 +109,11 @@ public class FileBlob extends AbstractBlob { throw new PersistException(e);
}
}
+
+ /**
+ * Always returns null.
+ */
+ public Object getLocator() {
+ return null;
+ }
}
diff --git a/src/main/java/com/amazon/carbonado/lob/Lob.java b/src/main/java/com/amazon/carbonado/lob/Lob.java index a09bfe0..404500f 100644 --- a/src/main/java/com/amazon/carbonado/lob/Lob.java +++ b/src/main/java/com/amazon/carbonado/lob/Lob.java @@ -25,6 +25,14 @@ package com.amazon.carbonado.lob; */
public interface Lob {
/**
+ * Returns an object which identifies the Lob data, which may be null if
+ * not supported.
+ *
+ * @since 1.2
+ */
+ Object getLocator();
+
+ /**
* Two Lobs are considered equal if the object instances are the same or if
* they point to the same content. Lob data is not compared, as that would
* be expensive or it may result in a fetch exception.
diff --git a/src/main/java/com/amazon/carbonado/lob/StringClob.java b/src/main/java/com/amazon/carbonado/lob/StringClob.java index f19d63d..fe9b05d 100644 --- a/src/main/java/com/amazon/carbonado/lob/StringClob.java +++ b/src/main/java/com/amazon/carbonado/lob/StringClob.java @@ -87,6 +87,13 @@ public class StringClob extends AbstractClob { denied();
}
+ /**
+ * Always returns null.
+ */
+ public Object getLocator() {
+ return null;
+ }
+
private PersistException denied() {
return new PersistDeniedException("Read-only");
}
|