/* * Copyright (c) Johannes Brodwall , 2006 * * Licensed under Creative Commons Deed 2.5 * * You are free: * to copy, distribute, display, and perform the work * to make derivative works * to make commercial use of the work * * Under the following conditions: * Attribution. You must attribute the work in the manner specified by the author or licensor. * * For any reuse or distribution, you must make clear to others the license terms of this work. * Any of these conditions can be waived if you get permission from the copyright holder. * * Your fair use and other rights are in no way affected by the above. * * For full license text see: http://creativecommons.org/licenses/by/2.5/ */ package com.brodwall.insanejava.lazyload.space; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import net.sf.cglib.proxy.Enhancer; import net.sf.cglib.proxy.LazyLoader; import com.brodwall.insanejava.lazyload.Category; import com.brodwall.insanejava.lazyload.CategoryDao; import com.brodwall.insanejava.lazyload.lazy.PagedLazyCollection; public class SpaceCategoryDao implements CategoryDao { private Map idToTuples = new HashMap(); private Map parentIdToIdList = new HashMap(); private long nextId = 1; private Map sessionCache = new HashMap(); public void clearSessionCache() { sessionCache.clear(); } public void unloadFromSessionCache(Collection categories) { for (Iterator iter = categories.iterator(); iter.hasNext();) { Category element = (Category) iter.next(); sessionCache.remove(element.getId()); } } public boolean isLoaded(Long id) { return sessionCache.containsKey(id); } public Collection findByParentId(Long parentId, int offset, int length) { ArrayList result = new ArrayList(); Iterator iter = getChildIdListFor(parentId).iterator(); for (int i=0; i