/** Creates a Map with entries from specified scope. */ public Map<String, Serializable> getScopeValues(ScopeType scopeType) { Map<String, Serializable> defMap = new HashMap<String, Serializable>(); final String defaultScopePrefix = scopeType.getScopePrefix(); final int prefixLen = defaultScopePrefix.length(); for (Map.Entry<String, Serializable> entry : entrySet()) { String key = entry.getKey(); if (key.startsWith(defaultScopePrefix)) { defMap.put(key.substring(prefixLen), entry.getValue()); } } return defMap; }
/** Removes all mappings for given scope. */ public void clearScope(ScopeType scopeType) { if (scopeType == null) { log.error("Cannot clear map, specified scope is null"); } else { String prefix = scopeType.getScopePrefix(); List<String> toRemove = new ArrayList<String>(); for (Map.Entry<String, Serializable> entry : entrySet()) { String key = entry.getKey(); if (key.startsWith(prefix)) { toRemove.add(key); } } for (String key : toRemove) { remove(key); } } }