]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/src/org/simantics/databoard/binding/OptionalBinding.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / binding / OptionalBinding.java
index b94a5fb7674b03c70fb297899d2c790fb5f3ff02..0c45ef01a734c742a05bede7b8a4b43fe1184353 100644 (file)
@@ -1,31 +1,31 @@
-/*******************************************************************************\r
- *  Copyright (c) 2010 Association for Decentralized Information Management in\r
- *  Industry THTH ry.\r
- *  All rights reserved. This program and the accompanying materials\r
- *  are made available under the terms of the Eclipse Public License v1.0\r
- *  which accompanies this distribution, and is available at\r
- *  http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- *  Contributors:\r
- *      VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
+/*******************************************************************************
+ *  Copyright (c) 2010 Association for Decentralized Information Management in
+ *  Industry THTH ry.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ *
+ *  Contributors:
+ *      VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
 package org.simantics.databoard.binding;
 
-import java.util.IdentityHashMap;\r
-import java.util.Set;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.databoard.accessor.reference.ChildReference;\r
-import org.simantics.databoard.accessor.reference.IndexReference;\r
-import org.simantics.databoard.accessor.reference.KeyReference;\r
-import org.simantics.databoard.accessor.reference.LabelReference;\r
-import org.simantics.databoard.accessor.reference.NameReference;\r
-import org.simantics.databoard.adapter.AdaptException;\r
-import org.simantics.databoard.binding.error.BindingException;\r
-import org.simantics.databoard.binding.error.RuntimeBindingException;\r
-import org.simantics.databoard.binding.impl.BindingPrintContext;\r
-import org.simantics.databoard.type.OptionalType;\r
-import org.simantics.databoard.util.IdentityPair;\r
+import java.util.IdentityHashMap;
+import java.util.Set;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.databoard.accessor.reference.ChildReference;
+import org.simantics.databoard.accessor.reference.IndexReference;
+import org.simantics.databoard.accessor.reference.KeyReference;
+import org.simantics.databoard.accessor.reference.LabelReference;
+import org.simantics.databoard.accessor.reference.NameReference;
+import org.simantics.databoard.adapter.AdaptException;
+import org.simantics.databoard.binding.error.BindingException;
+import org.simantics.databoard.binding.error.RuntimeBindingException;
+import org.simantics.databoard.binding.impl.BindingPrintContext;
+import org.simantics.databoard.type.OptionalType;
+import org.simantics.databoard.util.IdentityPair;
 
 
 /**
@@ -96,32 +96,32 @@ public abstract class OptionalBinding extends Binding {
     public Binding getComponentBinding() {
         return componentBinding;
     }
-       \r
-       @Override\r
-       public void readFrom(Binding srcBinding, Object src, Object dst)\r
-                       throws BindingException {\r
-               OptionalBinding sb = (OptionalBinding) srcBinding;\r
-               if (sb.hasValue(src)) {\r
-                       Binding dcb = getComponentBinding();\r
-                       Binding scb = sb.getComponentBinding();\r
-                       Object scv = sb.getValue(src);\r
-                       if (dcb.isImmutable() || !hasValue(dst)) {\r
-                               try {\r
-                                       Object v = Bindings.clone(scv, scb, dcb);\r
-                                       v = dcb.readFromTry(scb, scv, v);\r
-                                       setValue(dst, v);\r
-                               } catch (AdaptException e) {\r
-                                       throw new BindingException(e);\r
-                               }\r
-                       } else {\r
-                               Object v = getValue(src);\r
-                               v = dcb.readFromTry(scb, scv, v);\r
-                               setValue(dst, v);\r
-                       }\r
-               } else {\r
-                       setNoValue(dst);\r
-               }\r
-       }\r
+       
+       @Override
+       public void readFrom(Binding srcBinding, Object src, Object dst)
+                       throws BindingException {
+               OptionalBinding sb = (OptionalBinding) srcBinding;
+               if (sb.hasValue(src)) {
+                       Binding dcb = getComponentBinding();
+                       Binding scb = sb.getComponentBinding();
+                       Object scv = sb.getValue(src);
+                       if (dcb.isImmutable() || !hasValue(dst)) {
+                               try {
+                                       Object v = Bindings.clone(scv, scb, dcb);
+                                       v = dcb.readFromTry(scb, scv, v);
+                                       setValue(dst, v);
+                               } catch (AdaptException e) {
+                                       throw new BindingException(e);
+                               }
+                       } else {
+                               Object v = getValue(src);
+                               v = dcb.readFromTry(scb, scv, v);
+                               setValue(dst, v);
+                       }
+               } else {
+                       setNoValue(dst);
+               }
+       }
     
     @Override
     public void accept(Visitor1 v, Object obj) {
@@ -150,7 +150,7 @@ public abstract class OptionalBinding extends Binding {
        }
        
        @Override
-       public int deepCompare(Object o1, Object o2, Set<IdentityPair<Object, Object>> compareHistory) throws BindingException \r
+       public int deepCompare(Object o1, Object o2, Set<IdentityPair<Object, Object>> compareHistory) throws BindingException 
        {
                Boolean h1 = hasValue(o1);
                Boolean h2 = hasValue(o2);
@@ -188,45 +188,45 @@ public abstract class OptionalBinding extends Binding {
                        throw new RuntimeBindingException(e);
                }
     }
-\r
-    @Override\r
-       protected void toString(Object value, BindingPrintContext ctx) throws BindingException {\r
-       if(hasValue(value)) {\r
-               getComponentBinding().toString(getValue(value), ctx);\r
-       } else {\r
-               ctx.b.append("null");\r
-       }\r
-    }\r
-    \r
-    @Override\r
-    public Binding getComponentBinding(ChildReference path) {\r
-       if (path==null) return this;\r
-       if (path instanceof KeyReference) throw new IllegalArgumentException("KeyReference is not supported in OptionalType"); \r
-       if (path instanceof NameReference) throw new IllegalArgumentException("NameReference is not supported in OptionalType"); \r
-       if (path instanceof IndexReference && ((IndexReference) path).index!=0) throw new IllegalArgumentException("Index out of bounds");\r
-       if (path instanceof LabelReference && !((LabelReference) path).label.equals("v")) throw new IllegalArgumentException("Unknown label");\r
-       return componentBinding.getComponentBinding(path.childReference);\r
-    }    \r
-    \r
-    @Override\r
-    public int getComponentCount() {\r
-       return 1;\r
-    }\r
-    \r
-    @Override\r
-    public Binding getComponentBinding(int index) {\r
-       if (index==0) return componentBinding;\r
-       throw new IllegalArgumentException();\r
-    }\r
-\r
-    @Override\r
-    protected boolean deepEquals(Object obj,\r
-               Set<IdentityPair<Binding, Binding>> compareHistory) {\r
-       return super.deepEquals( obj, compareHistory ) && componentBinding.equals(((OptionalBinding) obj).componentBinding, compareHistory);\r
-    }\r
-    \r
-    @Override\r
-    public int deepHashCode(IdentityHashMap<Object, Object> hashedObjects) {\r
-       return super.deepHashCode( hashedObjects ) + componentBinding.hashCode(hashedObjects);\r
+
+    @Override
+       protected void toString(Object value, BindingPrintContext ctx) throws BindingException {
+       if(hasValue(value)) {
+               getComponentBinding().toString(getValue(value), ctx);
+       } else {
+               ctx.b.append("null");
+       }
+    }
+    
+    @Override
+    public Binding getComponentBinding(ChildReference path) {
+       if (path==null) return this;
+       if (path instanceof KeyReference) throw new IllegalArgumentException("KeyReference is not supported in OptionalType"); 
+       if (path instanceof NameReference) throw new IllegalArgumentException("NameReference is not supported in OptionalType"); 
+       if (path instanceof IndexReference && ((IndexReference) path).index!=0) throw new IllegalArgumentException("Index out of bounds");
+       if (path instanceof LabelReference && !((LabelReference) path).label.equals("v")) throw new IllegalArgumentException("Unknown label");
+       return componentBinding.getComponentBinding(path.childReference);
+    }    
+    
+    @Override
+    public int getComponentCount() {
+       return 1;
+    }
+    
+    @Override
+    public Binding getComponentBinding(int index) {
+       if (index==0) return componentBinding;
+       throw new IllegalArgumentException();
+    }
+
+    @Override
+    protected boolean deepEquals(Object obj,
+               Set<IdentityPair<Binding, Binding>> compareHistory) {
+       return super.deepEquals( obj, compareHistory ) && componentBinding.equals(((OptionalBinding) obj).componentBinding, compareHistory);
+    }
+    
+    @Override
+    public int deepHashCode(IdentityHashMap<Object, Object> hashedObjects) {
+       return super.deepHashCode( hashedObjects ) + componentBinding.hashCode(hashedObjects);
     }
 }