]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/src/org/simantics/databoard/binding/impl/IntArrayBinding.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / binding / impl / IntArrayBinding.java
index 6ba82f10df877b991d7fde6c0ab401b86b95df79..c6ee534f37a76bc4b990c79f53945eec3f28f92e 100644 (file)
@@ -1,44 +1,44 @@
-/*******************************************************************************\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.impl;
 
-import java.lang.reflect.Array;\r
-import java.util.IdentityHashMap;\r
-import java.util.Iterator;\r
-import java.util.Set;\r
-\r
-import org.simantics.databoard.binding.ArrayBinding;\r
-import org.simantics.databoard.binding.Binding;\r
-import org.simantics.databoard.binding.IntegerBinding;\r
-import org.simantics.databoard.binding.error.BindingException;\r
-import org.simantics.databoard.binding.error.UnsupportedOperationException;\r
-import org.simantics.databoard.type.ArrayType;\r
-import org.simantics.databoard.type.IntegerType;\r
-import org.simantics.databoard.type.NumberType;\r
-import org.simantics.databoard.util.IdentityPair;\r
+import java.lang.reflect.Array;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.simantics.databoard.binding.ArrayBinding;
+import org.simantics.databoard.binding.Binding;
+import org.simantics.databoard.binding.IntegerBinding;
+import org.simantics.databoard.binding.error.BindingException;
+import org.simantics.databoard.binding.error.UnsupportedOperationException;
+import org.simantics.databoard.type.ArrayType;
+import org.simantics.databoard.type.IntegerType;
+import org.simantics.databoard.type.NumberType;
+import org.simantics.databoard.util.IdentityPair;
 
 /**
  * Binds Integer[] Type to int[] Class.
  */
 public final class IntArrayBinding extends ArrayBinding {
        
-       public static IntArrayBinding createFrom(ArrayType type) {\r
-               return new IntArrayBinding(type, new IntegerBindingDefault((IntegerType) type.componentType));\r
-       }\r
-\r
-       public IntArrayBinding(ArrayType type, Binding componentBinding) {\r
-               super(type, componentBinding);\r
-       }\r
-\r
+       public static IntArrayBinding createFrom(ArrayType type) {
+               return new IntArrayBinding(type, new IntegerBindingDefault((IntegerType) type.componentType));
+       }
+
+       public IntArrayBinding(ArrayType type, Binding componentBinding) {
+               super(type, componentBinding);
+       }
+
        @Override
        public Object create() {
                return new int[0];
@@ -68,54 +68,54 @@ public final class IntArrayBinding extends ArrayBinding {
         */
        public Object create(int[] array) {
                return array;
-       }\r
-       \r
-       @Override\r
-    public Object createDefault()\r
-    throws BindingException\r
-    {\r
-               NumberType nt = (NumberType) type().componentType;\r
-               if (nt.getRange() == null) {\r
-               return new int[ type().minLength() ];\r
-               }\r
-               return super.createDefault();\r
-    }  \r
+       }
+       
+       @Override
+    public Object createDefault()
+    throws BindingException
+    {
+               NumberType nt = (NumberType) type().componentType;
+               if (nt.getRange() == null) {
+               return new int[ type().minLength() ];
+               }
+               return super.createDefault();
+    }  
+       
+
+       @Override
+       public void readFrom(Binding srcBinding, Object src, Object dst)
+                       throws BindingException {
+               // Src Binding
+               ArrayBinding sb = (ArrayBinding) srcBinding;
+               // Src Component Binding
+               IntegerBinding scb = (IntegerBinding) sb.getComponentBinding();
+               
+               int[] d = (int[]) dst;
+               if (d.length != sb.size(src)) throw new BindingException("int[] is length immutable");
+               
+               for (int i=0; i<d.length; i++) {
+                       d[i] = scb.getValue_( sb.get(src, i) );
+               }
+       }       
        
-\r
-       @Override\r
-       public void readFrom(Binding srcBinding, Object src, Object dst)\r
-                       throws BindingException {\r
-               // Src Binding\r
-               ArrayBinding sb = (ArrayBinding) srcBinding;\r
-               // Src Component Binding\r
-               IntegerBinding scb = (IntegerBinding) sb.getComponentBinding();\r
-               \r
-               int[] d = (int[]) dst;\r
-               if (d.length != sb.size(src)) throw new BindingException("int[] is length immutable");\r
-               \r
-               for (int i=0; i<d.length; i++) {\r
-                       d[i] = scb.getValue_( sb.get(src, i) );\r
-               }\r
-       }       \r
-       \r
-\r
-       @Override\r
-       public Object readFromTry(Binding srcBinding, Object src, Object dst)\r
-                       throws BindingException {\r
-               // Src Binding\r
-               ArrayBinding sb = (ArrayBinding) srcBinding;\r
-               // Src Component Binding\r
-               IntegerBinding scb = (IntegerBinding) sb.getComponentBinding();\r
-               \r
-               int[] d = (int[]) dst;\r
-               int srcSize = sb.size(src);\r
-               if (d.length != srcSize) d = new int[ srcSize ];\r
-               \r
-               for (int i=0; i<d.length; i++) {\r
-                       d[i] = scb.getValue_( sb.get(src, i) );\r
-               }\r
-               return d;\r
-       }               \r
+
+       @Override
+       public Object readFromTry(Binding srcBinding, Object src, Object dst)
+                       throws BindingException {
+               // Src Binding
+               ArrayBinding sb = (ArrayBinding) srcBinding;
+               // Src Component Binding
+               IntegerBinding scb = (IntegerBinding) sb.getComponentBinding();
+               
+               int[] d = (int[]) dst;
+               int srcSize = sb.size(src);
+               if (d.length != srcSize) d = new int[ srcSize ];
+               
+               for (int i=0; i<d.length; i++) {
+                       d[i] = scb.getValue_( sb.get(src, i) );
+               }
+               return d;
+       }               
        
        @Override
        public Object get(Object array, int index) throws BindingException {
@@ -198,18 +198,18 @@ public final class IntArrayBinding extends ArrayBinding {
        @Override
        public void remove(Object array, int index, int count) throws BindingException {
        throw new UnsupportedOperationException();
-       }\r
-\r
-       @Override\r
-       public void setSize(Object array, int newSize) throws BindingException {\r
-               int oldSize = Array.getLength(array);\r
-               if (oldSize==newSize) return;\r
-               throw new BindingException("int[] is length immutable");\r
-       }       \r
+       }
 
-       @Override\r
-       public boolean isResizable() {\r
-               return false;\r
-       }\r
+       @Override
+       public void setSize(Object array, int newSize) throws BindingException {
+               int oldSize = Array.getLength(array);
+               if (oldSize==newSize) return;
+               throw new BindingException("int[] is length immutable");
+       }       
+
+       @Override
+       public boolean isResizable() {
+               return false;
+       }
     
 }