private IService<CdmBase> service = null; \r
\r
public MapWrapper(IService<CdmBase> service){\r
- if (service == null){\r
- internalMap = new HashMap<Integer, CdmBase>();\r
- }else{\r
- this.service = service;\r
- internalMap = new HashMap<Integer, UUID>();\r
- }\r
+ makeNewMap(service);\r
}\r
\r
public void put(Object id, T cdmBase){\r
}\r
\r
/**\r
- * Returns all values that are either stored in the wrapper or the the database.\r
+ * Returns all values that are either stored in the wrapper or the database.\r
* If <code>service</code> is null then only the elements stored in the wrapper are returned. \r
* @return\r
*/\r
return result;\r
}\r
\r
- public boolean containsId(Integer id){\r
+ public boolean containsId(Object id){\r
return internalMap.containsKey(id);\r
}\r
\r
}\r
}\r
\r
+ public boolean makeEmpty(){\r
+ return makeNewMap(service);\r
+ }\r
+ \r
+ public boolean makeNewMap(IService<CdmBase> service){\r
+ if (service == null){\r
+ internalMap = new HashMap<Integer, CdmBase>();\r
+ }else{\r
+ this.service = service;\r
+ internalMap = new HashMap<Integer, UUID>();\r
+ }\r
+ return true;\r
+ }\r
+ \r
+ public int size() {\r
+ return internalMap.size();\r
+ }\r
+ \r
+ public Collection<T> objects(int start, int limit) {\r
+ \r
+ Map internalPartMap = new HashMap<Integer, CdmBase>();\r
+ int index = 0;\r
+ \r
+ for (int i = 0; i < limit; i++) {\r
+// for (int i = start; i < limit; i++) {\r
+ \r
+ int j = start + i;\r
+ \r
+ Object object = internalMap.get(j);\r
+ if(object != null) {\r
+ internalPartMap.put(index, internalMap.get(j));\r
+ index++;\r
+ } else {\r
+ if (logger.isDebugEnabled()) { logger.debug("Object (" + j + ") is null"); }\r
+ }\r
+ }\r
+// return (Collection<T>)internalMap.values();\r
+ return (Collection<T>)internalPartMap.values();\r
+ }\r
+ \r
+ \r
+ public Collection<T> removeObjects(int start, int limit) {\r
+ \r
+ for (int i = start; i < start + limit; i++) {\r
+ internalMap.remove(i);\r
+ if (logger.isDebugEnabled()) { logger.debug("Object (" + i + ") removed"); }\r
+ }\r
+ return (Collection<T>)internalMap.values();\r
+ }\r
+\r
+ \r
+ public Set<Integer> keySet() {\r
+ return internalMap.keySet();\r
+ }\r
+ \r
}\r