summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2006-09-19 07:14:05 +0000
committerBrian S. O'Neill <bronee@gmail.com>2006-09-19 07:14:05 +0000
commitc08e8a086133809df5526420c7d4cf40bb8cad3c (patch)
tree04d6a3caa19fa995fde7040762601c42a66593bd
parentea82ae6b0e50c6d1c2928518245bf4b3407867d0 (diff)
Make toStringKeyOnly also include alternate keys.
-rw-r--r--src/main/java/com/amazon/carbonado/Storable.java4
-rw-r--r--src/main/java/com/amazon/carbonado/spi/StorableGenerator.java36
2 files changed, 38 insertions, 2 deletions
diff --git a/src/main/java/com/amazon/carbonado/Storable.java b/src/main/java/com/amazon/carbonado/Storable.java
index f5c2248..20c7ab7 100644
--- a/src/main/java/com/amazon/carbonado/Storable.java
+++ b/src/main/java/com/amazon/carbonado/Storable.java
@@ -416,8 +416,8 @@ public interface Storable<S extends Storable<S>> {
String toString();
/**
- * Returns a string for debugging purposes that contains only supported
- * primary key property names and values for this object. Unsupported
+ * Returns a string for debugging purposes that contains supported
+ * key property names and values for this object. Unsupported
* {@link Independent independent} properties are not included.
*/
String toStringKeyOnly();
diff --git a/src/main/java/com/amazon/carbonado/spi/StorableGenerator.java b/src/main/java/com/amazon/carbonado/spi/StorableGenerator.java
index f63a260..ecd344d 100644
--- a/src/main/java/com/amazon/carbonado/spi/StorableGenerator.java
+++ b/src/main/java/com/amazon/carbonado/spi/StorableGenerator.java
@@ -3138,6 +3138,42 @@ public final class StorableGenerator<S extends Storable> {
b.loadConstant('}');
invokeAppend(b, charParam);
+
+ // For key string, also show all the alternate keys. This makes the
+ // FetchNoneException message more helpful.
+ if (keyOnly) {
+ int altKeyCount = mInfo.getAlternateKeyCount();
+ for (int i=0; i<altKeyCount; i++) {
+ b.loadConstant(", {");
+ invokeAppend(b, stringParam);
+
+ StorableKey<S> key = mInfo.getAlternateKey(i);
+
+ ordinal = 0;
+ for (OrderedProperty<S> op : key.getProperties()) {
+ StorableProperty<S> property = op.getChainedProperty().getPrimeProperty();
+
+ Label skipPrint = b.createLabel();
+
+ // Check if independent property is supported, and skip if not.
+ if (property.isIndependent()) {
+ addSkipIndependent(b, null, property, skipPrint);
+ }
+
+ if (ordinal++ > 0) {
+ b.loadConstant(", ");
+ invokeAppend(b, stringParam);
+ }
+ addPropertyAppendCall(b, property, stringParam, charParam);
+
+ skipPrint.setLocation();
+ }
+
+ b.loadConstant('}');
+ invokeAppend(b, charParam);
+ }
+ }
+
b.invokeVirtual(stringBuilder, TO_STRING_METHOD_NAME, TypeDesc.STRING, null);
b.returnValue(TypeDesc.STRING);
}