- } \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);
+ }
+ }