]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/src/org/simantics/databoard/binding/impl/TreeMapBinding.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / binding / impl / TreeMapBinding.java
index 54ae417e38bd1455ba1d838079806797fd013484..50a7ca5008e91576d672f31e49a018d3e50ba185 100644 (file)
@@ -1,38 +1,38 @@
-/*******************************************************************************\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.util.IdentityHashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Map.Entry;\r
-import java.util.Set;\r
-import java.util.TreeMap;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.databoard.adapter.AdaptException;\r
-import org.simantics.databoard.adapter.Adapter;\r
-import org.simantics.databoard.adapter.AdapterConstructionException;\r
-import org.simantics.databoard.binding.ArrayBinding;\r
-import org.simantics.databoard.binding.Binding;\r
-import org.simantics.databoard.binding.MapBinding;\r
-import org.simantics.databoard.binding.error.BindingException;\r
-import org.simantics.databoard.type.MapType;\r
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.databoard.adapter.AdaptException;
+import org.simantics.databoard.adapter.Adapter;
+import org.simantics.databoard.adapter.AdapterConstructionException;
+import org.simantics.databoard.binding.ArrayBinding;
+import org.simantics.databoard.binding.Binding;
+import org.simantics.databoard.binding.MapBinding;
+import org.simantics.databoard.binding.error.BindingException;
+import org.simantics.databoard.type.MapType;
 
 /**
  * Binds java.util.TreeMap to MapType
  * 
  * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
- */\r
+ */
 @SuppressWarnings("all")
 public class TreeMapBinding extends MapBinding {
 
@@ -94,7 +94,7 @@ public class TreeMapBinding extends MapBinding {
                TreeMap result = new TreeMap( getKeyBinding() );
                result.putAll(initialMap);
                return result;
-       }\r
+       }
        
        @SuppressWarnings("unchecked")
        @Override
@@ -139,69 +139,69 @@ public class TreeMapBinding extends MapBinding {
        public void getKeys(Object map, Set<Object> keys) throws BindingException {
                Map m = ((Map)map);
                keys.addAll(m.keySet());
-       }       \r
-       \r
-       /**\r
-        * Count the number of entries between two keyes\r
-        * @param from\r
-     * @param fromInclusive\r
-        * @param end \r
-     * @param endInclusive\r
-        * @throws BindingException\r
-        */\r
-       @SuppressWarnings("unchecked")\r
-       @Override\r
-       public int count(Object src, Object from, boolean fromInclusive, Object end, boolean endInclusive) throws BindingException {\r
-               // Assert end > from\r
-               if (keyBinding.compare(from, end)>0) return 0;\r
-               \r
-               TreeMap m = (TreeMap) src;\r
-               Map sm = m.subMap(from, fromInclusive, end, endInclusive);\r
-               return sm.size();\r
-       }\r
-       \r
-       /**\r
-        * Read a range of entries\r
-        * \r
-        * @param src\r
-        * @param from\r
-     * @param fromInclusive\r
-        * @param end \r
-     * @param endInclusive\r
-        * @param dstKeyArrayBinding\r
-        * @param dstKeyArray\r
-     * @param dstValueArrayBinding\r
-        * @param dstValueArray\r
-        * @throws BindingException\r
-        */\r
-       public int getEntries(Object src, Object from, boolean fromInclusive, Object end, boolean endInclusive, ArrayBinding dstKeyArrayBinding, Object dstKeyArray, ArrayBinding dstValueArrayBinding, Object dstValueArray, int limit) throws BindingException {\r
-               try {\r
-                       // Assert end > from\r
-                       if (keyBinding.compare(from, end)>0) return 0;\r
-\r
-                       TreeMap m = (TreeMap) src;\r
-                       Map sm = m.subMap(from, fromInclusive, end, endInclusive);\r
-                       int dkc = dstKeyArrayBinding.size( dstKeyArray );\r
-                       int dvc = dstValueArrayBinding.size( dstValueArray );\r
-                       Adapter ka = Bindings.getTypeAdapter(keyBinding, dstKeyArrayBinding.getComponentBinding());\r
-                       Adapter va = Bindings.getTypeAdapter(valueBinding, dstValueArrayBinding.getComponentBinding());\r
-                       int i = 0;\r
-                       Set<Map.Entry<Object, Object>> es = sm.entrySet();\r
-                       for (Entry<Object, Object> e : es) {\r
-                               if (limit>=0 && i>=limit) break;\r
-                               Object dk = ka.adapt( e.getKey() );\r
-                               Object dv = va.adapt( e.getValue() );\r
-                               if (i<dkc) dstKeyArrayBinding.set(dstKeyArray, i, dk); else dstKeyArrayBinding.add(dstKeyArray, dk);\r
-                               if (i<dvc) dstValueArrayBinding.set(dstValueArray, i, dv); else dstValueArrayBinding.add(dstValueArray, dv);\r
-                               i++;\r
-                       }\r
-                       return i;\r
-               } catch (AdapterConstructionException e) {\r
-                       throw new BindingException(e);\r
-               } catch (AdaptException e) {\r
-                       throw new BindingException(e);\r
-               }\r
-       }\r
+       }       
+       
+       /**
+        * Count the number of entries between two keyes
+        * @param from
+     * @param fromInclusive
+        * @param end 
+     * @param endInclusive
+        * @throws BindingException
+        */
+       @SuppressWarnings("unchecked")
+       @Override
+       public int count(Object src, Object from, boolean fromInclusive, Object end, boolean endInclusive) throws BindingException {
+               // Assert end > from
+               if (keyBinding.compare(from, end)>0) return 0;
+               
+               TreeMap m = (TreeMap) src;
+               Map sm = m.subMap(from, fromInclusive, end, endInclusive);
+               return sm.size();
+       }
+       
+       /**
+        * Read a range of entries
+        * 
+        * @param src
+        * @param from
+     * @param fromInclusive
+        * @param end 
+     * @param endInclusive
+        * @param dstKeyArrayBinding
+        * @param dstKeyArray
+     * @param dstValueArrayBinding
+        * @param dstValueArray
+        * @throws BindingException
+        */
+       public int getEntries(Object src, Object from, boolean fromInclusive, Object end, boolean endInclusive, ArrayBinding dstKeyArrayBinding, Object dstKeyArray, ArrayBinding dstValueArrayBinding, Object dstValueArray, int limit) throws BindingException {
+               try {
+                       // Assert end > from
+                       if (keyBinding.compare(from, end)>0) return 0;
+
+                       TreeMap m = (TreeMap) src;
+                       Map sm = m.subMap(from, fromInclusive, end, endInclusive);
+                       int dkc = dstKeyArrayBinding.size( dstKeyArray );
+                       int dvc = dstValueArrayBinding.size( dstValueArray );
+                       Adapter ka = Bindings.getTypeAdapter(keyBinding, dstKeyArrayBinding.getComponentBinding());
+                       Adapter va = Bindings.getTypeAdapter(valueBinding, dstValueArrayBinding.getComponentBinding());
+                       int i = 0;
+                       Set<Map.Entry<Object, Object>> es = sm.entrySet();
+                       for (Entry<Object, Object> e : es) {
+                               if (limit>=0 && i>=limit) break;
+                               Object dk = ka.adapt( e.getKey() );
+                               Object dv = va.adapt( e.getValue() );
+                               if (i<dkc) dstKeyArrayBinding.set(dstKeyArray, i, dk); else dstKeyArrayBinding.add(dstKeyArray, dk);
+                               if (i<dvc) dstValueArrayBinding.set(dstValueArray, i, dv); else dstValueArrayBinding.add(dstValueArray, dv);
+                               i++;
+                       }
+                       return i;
+               } catch (AdapterConstructionException e) {
+                       throw new BindingException(e);
+               } catch (AdaptException e) {
+                       throw new BindingException(e);
+               }
+       }
        
 
        @SuppressWarnings("unchecked")