- }\r
- \r
- @SuppressWarnings("unchecked")\r
- @Override\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
- // Assert end > from\r
- if (keyBinding.compare(from, end)>0) return 0;\r
- \r
- try {\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
- HashMap<Object, Object> m = ((HashMap<Object, Object>)src);\r
- int i = 0;\r
- for (Entry<Object, Object> e : m.entrySet()) {\r
- if (limit>=0 && i>=limit) break;\r
- Object k = e.getKey();\r
- int fk = keyBinding.compare(from, k);\r
- int ek = keyBinding.compare(k, end);\r
- boolean fromMatches = fromInclusive ? fk<=0 : fk<0;\r
- boolean endMatches = endInclusive ? ek<=0 : ek <0; \r
- if ( fromMatches && endMatches ) {\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
- }\r
- return i;\r
- } catch (AdapterConstructionException e) {\r
- throw new BindingException( e );\r
- } catch (AdaptException e) {\r
- throw new BindingException( e );\r
- }\r
- }\r
- \r
- @SuppressWarnings("unchecked")\r
- @Override\r
- public int count(Object src, Object from, boolean fromInclusive,\r
- Object end, boolean endInclusive) throws BindingException {\r
- // Assert end > from\r
- if (keyBinding.compare(from, end)>0) return 0;\r
- \r
- int result = 0;\r
- HashMap<Object, Object> m = ((HashMap<Object, Object>)src);\r
- for (Object k : m.keySet()) {\r
- int fk = keyBinding.compare(from, k);\r
- int ek = keyBinding.compare(k, end);\r
- boolean fromMatches = fromInclusive ? fk<=0 : fk<0;\r
- boolean endMatches = endInclusive ? ek<=0 : ek <0; \r
- if ( fromMatches && endMatches ) result++;\r
- } \r
- return result;\r
- }\r
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ 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 {
+ // Assert end > from
+ if (keyBinding.compare(from, end)>0) return 0;
+
+ try {
+ int dkc = dstKeyArrayBinding.size(dstKeyArray);
+ int dvc = dstValueArrayBinding.size(dstValueArray);
+ Adapter ka = Bindings.getTypeAdapter(keyBinding, dstKeyArrayBinding.getComponentBinding());
+ Adapter va = Bindings.getTypeAdapter(valueBinding, dstValueArrayBinding.getComponentBinding());
+ HashMap<Object, Object> m = ((HashMap<Object, Object>)src);
+ int i = 0;
+ for (Entry<Object, Object> e : m.entrySet()) {
+ if (limit>=0 && i>=limit) break;
+ Object k = e.getKey();
+ int fk = keyBinding.compare(from, k);
+ int ek = keyBinding.compare(k, end);
+ boolean fromMatches = fromInclusive ? fk<=0 : fk<0;
+ boolean endMatches = endInclusive ? ek<=0 : ek <0;
+ if ( fromMatches && endMatches ) {
+ 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")
+ @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;
+
+ int result = 0;
+ HashMap<Object, Object> m = ((HashMap<Object, Object>)src);
+ for (Object k : m.keySet()) {
+ int fk = keyBinding.compare(from, k);
+ int ek = keyBinding.compare(k, end);
+ boolean fromMatches = fromInclusive ? fk<=0 : fk<0;
+ boolean endMatches = endInclusive ? ek<=0 : ek <0;
+ if ( fromMatches && endMatches ) result++;
+ }
+ return result;
+ }