summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/spi
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 /src/main/java/com/amazon/carbonado/spi
parentea82ae6b0e50c6d1c2928518245bf4b3407867d0 (diff)
Make toStringKeyOnly also include alternate keys.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/spi')
-rw-r--r--src/main/java/com/amazon/carbonado/spi/StorableGenerator.java36
1 files changed, 36 insertions, 0 deletions
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);
}