/** * {@inheritDoc} */ @Override public Object clone() { EffectiveNodeTypeCacheImpl clone = new EffectiveNodeTypeCacheImpl(); clone.sortedKeys.addAll(sortedKeys); clone.aggregates.putAll(aggregates); return clone; }
/** * {@inheritDoc} */ public void invalidate(Name name) { // remove all affected effective node types from aggregates cache // (copy keys first to prevent ConcurrentModificationException) ArrayList<Key> keys = new ArrayList<Key>(sortedKeys); for (Iterator<Key> keysIter = keys.iterator(); keysIter.hasNext();) { Key k = keysIter.next(); EffectiveNodeType ent = get(k); if (ent.includesNodeType(name)) { remove(k); } } }
/** * {@inheritDoc} */ public void put(EffectiveNodeType ent) { // we define the weight as the total number of included node types // (through aggregation and inheritance) int weight = ent.getMergedNodeTypes().length; // the effective node type is identified by the list of merged // (i.e. aggregated) node types WeightedKey k = new WeightedKey(ent.getMergedNodeTypes(), weight); put(k, ent); }
/** * {@inheritDoc} */ public Key findBest(Key key) { // quick check for already cached key if (contains(key)) { return key; } Iterator<Key> iter = sortedKeys.iterator(); while (iter.hasNext()) { Key k = iter.next(); // check if the existing aggregate is a 'subset' of the one we're // looking for if (key.contains(k)) { return k; } } return null; }
/** * {@inheritDoc} */ public void put(EffectiveNodeType ent) { // we define the weight as the total number of included node types // (through aggregation and inheritance) int weight = ent.getMergedNodeTypes().length; // the effective node type is identified by the list of merged // (i.e. aggregated) node types WeightedKey k = new WeightedKey(ent.getMergedNodeTypes(), weight); put(k, ent); }
/** * {@inheritDoc} */ public Key findBest(Key key) { // quick check for already cached key if (contains(key)) { return key; } Iterator<Key> iter = sortedKeys.iterator(); while (iter.hasNext()) { Key k = iter.next(); // check if the existing aggregate is a 'subset' of the one we're // looking for if (key.contains(k)) { return k; } } return null; }
/** * {@inheritDoc} */ public void invalidate(Name name) { // remove all affected effective node types from aggregates cache // (copy keys first to prevent ConcurrentModificationException) ArrayList<Key> keys = new ArrayList<Key>(sortedKeys); for (Iterator<Key> keysIter = keys.iterator(); keysIter.hasNext();) { Key k = keysIter.next(); EffectiveNodeType ent = get(k); if (ent.includesNodeType(name)) { remove(k); } } }
/** * {@inheritDoc} */ @Override public Object clone() { EffectiveNodeTypeCacheImpl clone = new EffectiveNodeTypeCacheImpl(); clone.sortedKeys.addAll(sortedKeys); clone.aggregates.putAll(aggregates); return clone; }