- \r
- @Override\r
- protected void toString(Object value, BindingPrintContext ctx) throws BindingException {\r
- Binding keyBinding = getKeyBinding();\r
- Binding valueBinding = getValueBinding();\r
- ctx.b.append("{ ");\r
- boolean first = true;\r
- for(Object key : getKeys(value)) {\r
- if(first)\r
- first = false;\r
- else {\r
- ctx.b.append(", ");\r
- if ( !ctx.singleLine ) ctx.b.append('\n');\r
- }\r
- keyBinding.toString(key, ctx);\r
- ctx.b.append(" = ");\r
- valueBinding.toString(get(value, key), ctx);\r
- }\r
- ctx.b.append(" }");\r
- }\r
-\r
- @Override\r
- public Binding getComponentBinding(ChildReference path) {\r
- if (path==null) return this;\r
- if (path instanceof IndexReference) {\r
- IndexReference ir = (IndexReference) path;\r
- if (ir.index==0) return keyBinding.getComponentBinding(path.childReference);\r
- if (ir.index==1) return valueBinding.getComponentBinding(path.childReference);\r
- }\r
- if (path instanceof LabelReference) {\r
- LabelReference lr = (LabelReference) path;\r
- if (lr.label.equals("0") || lr.label.equals("key")) return keyBinding.getComponentBinding(path.childReference);\r
- if (lr.label.equals("1") || lr.label.equals("value")) return valueBinding.getComponentBinding(path.childReference);\r
- }\r
- if (path instanceof NameReference) {\r
- NameReference nr = (NameReference) path;\r
- if (nr.name.equals("key")) return keyBinding.getComponentBinding(path.childReference);\r
- if (nr.name.equals("value")) return valueBinding.getComponentBinding(path.childReference);\r
- }\r
- throw new IllegalArgumentException();\r
- } \r
-\r
- \r
- @Override\r
- public int getComponentCount() {\r
- return 2;\r
- }\r
- \r
- @Override\r
- public Binding getComponentBinding(int index) {\r
- if (index==0) return keyBinding;\r
- if (index==1) return valueBinding;\r
- throw new IllegalArgumentException();\r
- } \r
-\r
- @Override\r
- protected boolean deepEquals(Object obj,\r
- Set<IdentityPair<Binding, Binding>> compareHistory) {\r
- MapBinding o = (MapBinding)obj;\r
- return super.deepEquals( obj, compareHistory ) && keyBinding.equals(o.keyBinding, compareHistory) && valueBinding.equals(o.valueBinding, compareHistory);\r
- }\r
- \r
- @Override\r
- public int deepHashCode(IdentityHashMap<Object, Object> hashedObjects) {\r
- return super.deepHashCode(hashedObjects) + 13 * keyBinding.hashCode(hashedObjects) + 17 * valueBinding.hashCode(hashedObjects);\r
+
+ @Override
+ protected void toString(Object value, BindingPrintContext ctx) throws BindingException {
+ Binding keyBinding = getKeyBinding();
+ Binding valueBinding = getValueBinding();
+ ctx.b.append("{ ");
+ boolean first = true;
+ for(Object key : getKeys(value)) {
+ if(first)
+ first = false;
+ else {
+ ctx.b.append(", ");
+ if ( !ctx.singleLine ) ctx.b.append('\n');
+ }
+ keyBinding.toString(key, ctx);
+ ctx.b.append(" = ");
+ valueBinding.toString(get(value, key), ctx);
+ }
+ ctx.b.append(" }");
+ }
+
+ @Override
+ public Binding getComponentBinding(ChildReference path) {
+ if (path==null) return this;
+ if (path instanceof IndexReference) {
+ IndexReference ir = (IndexReference) path;
+ if (ir.index==0) return keyBinding.getComponentBinding(path.childReference);
+ if (ir.index==1) return valueBinding.getComponentBinding(path.childReference);
+ }
+ if (path instanceof LabelReference) {
+ LabelReference lr = (LabelReference) path;
+ if (lr.label.equals("0") || lr.label.equals("key")) return keyBinding.getComponentBinding(path.childReference);
+ if (lr.label.equals("1") || lr.label.equals("value")) return valueBinding.getComponentBinding(path.childReference);
+ }
+ if (path instanceof NameReference) {
+ NameReference nr = (NameReference) path;
+ if (nr.name.equals("key")) return keyBinding.getComponentBinding(path.childReference);
+ if (nr.name.equals("value")) return valueBinding.getComponentBinding(path.childReference);
+ }
+ throw new IllegalArgumentException();
+ }
+
+
+ @Override
+ public int getComponentCount() {
+ return 2;
+ }
+
+ @Override
+ public Binding getComponentBinding(int index) {
+ if (index==0) return keyBinding;
+ if (index==1) return valueBinding;
+ throw new IllegalArgumentException();
+ }
+
+ @Override
+ protected boolean deepEquals(Object obj,
+ Set<IdentityPair<Binding, Binding>> compareHistory) {
+ MapBinding o = (MapBinding)obj;
+ return super.deepEquals( obj, compareHistory ) && keyBinding.equals(o.keyBinding, compareHistory) && valueBinding.equals(o.valueBinding, compareHistory);
+ }
+
+ @Override
+ public int deepHashCode(IdentityHashMap<Object, Object> hashedObjects) {
+ return super.deepHashCode(hashedObjects) + 13 * keyBinding.hashCode(hashedObjects) + 17 * valueBinding.hashCode(hashedObjects);