public Object[] toArray(Object[] array) { // Extend the array if needed if (array.length < size) { Class componentType = array.getClass().getComponentType(); array = (Object[]) Array.newInstance(componentType, size); } // Copy the values into the array int i = 0; for (Node node = header.next; node != header; node = node.next, i++) { array[i] = node.getValue(); } // Set the value after the last value to null if (array.length > size) { array[size] = null; } return array; }
/** * Adds a node to the cache, if the cache isn't full. * The node's contents are cleared to so they can be garbage collected. * * @param node the node to add to the cache */ protected void addNodeToCache(Node node) { if (isCacheFull()) { // don't cache the node. return; } // clear the node's contents and add it to the cache. Node nextCachedNode = firstCachedNode; node.previous = null; node.next = nextCachedNode; node.setValue(null); firstCachedNode = node; cacheSize++; }
/** * Adds a node to the cache, if the cache isn't full. * The node's contents are cleared to so they can be garbage collected. * * @param node the node to add to the cache */ protected void addNodeToCache(Node node) { if (isCacheFull()) { // don't cache the node. return; } // clear the node's contents and add it to the cache. Node nextCachedNode = firstCachedNode; node.previous = null; node.next = nextCachedNode; node.setValue(null); firstCachedNode = node; cacheSize++; }
@Override protected Object getValue() { Object val = super.getValue(); NodeEntry ne; if (val == null) { ne = null; } else if (val instanceof Reference) { ne = (NodeEntry) ((Reference) val).get(); } else { ne = (NodeEntry) val; } // if the nodeEntry has been g-collected in the mean time // create a new NodeEntry in order to avoid returning null. if (ne == null && this != header) { ne = factory.createNodeEntry(parent, qName, null); super.setValue(new SoftReference<NodeEntry>(ne)); } return ne; }
/** * Adds a node to the cache, if the cache isn't full. * The node's contents are cleared to so they can be garbage collected. * * @param node the node to add to the cache */ protected void addNodeToCache(Node node) { if (isCacheFull()) { // don't cache the node. return; } // clear the node's contents and add it to the cache. Node nextCachedNode = firstCachedNode; node.previous = null; node.next = nextCachedNode; node.setValue(null); firstCachedNode = node; cacheSize++; }
@Override protected Object getValue() { Object val = super.getValue(); NodeEntry ne; if (val == null) { ne = null; } else if (val instanceof Reference) { ne = (NodeEntry) ((Reference) val).get(); } else { ne = (NodeEntry) val; } // if the nodeEntry has been g-collected in the mean time // create a new NodeEntry in order to avoid returning null. if (ne == null && this != header) { ne = factory.createNodeEntry(parent, qName, null); super.setValue(new SoftReference<NodeEntry>(ne)); } return ne; }
/** * Adds a node to the cache, if the cache isn't full. * The node's contents are cleared to so they can be garbage collected. * * @param node the node to add to the cache */ protected void addNodeToCache(Node node) { if (isCacheFull()) { // don't cache the node. return; } // clear the node's contents and add it to the cache. Node nextCachedNode = firstCachedNode; node.previous = null; node.next = nextCachedNode; node.setValue(null); firstCachedNode = node; cacheSize++; }
/** * Adds a node to the cache, if the cache isn't full. * The node's contents are cleared to so they can be garbage collected. * * @param node the node to add to the cache */ protected void addNodeToCache(Node node) { if (isCacheFull()) { // don't cache the node. return; } // clear the node's contents and add it to the cache. Node nextCachedNode = firstCachedNode; node.previous = null; node.next = nextCachedNode; node.setValue(null); firstCachedNode = node; cacheSize++; }
/** * Creates a new node, either by reusing one from the cache or creating * a new one. * * @param value value of the new node * @return the newly created node */ protected Node createNode(Object value) { Node cachedNode = getNodeFromCache(); if (cachedNode == null) { return super.createNode(value); } else { cachedNode.setValue(value); return cachedNode; } }
/** * Creates a new node, either by reusing one from the cache or creating * a new one. * * @param value value of the new node * @return the newly created node */ protected Node createNode(Object value) { Node cachedNode = getNodeFromCache(); if (cachedNode == null) { return super.createNode(value); } else { cachedNode.setValue(value); return cachedNode; } }
/** * Creates a new node, either by reusing one from the cache or creating * a new one. * * @param value value of the new node * @return the newly created node */ protected Node createNode(Object value) { Node cachedNode = getNodeFromCache(); if (cachedNode == null) { return super.createNode(value); } else { cachedNode.setValue(value); return cachedNode; } }
/** * Creates a new node, either by reusing one from the cache or creating * a new one. * * @param value value of the new node * @return the newly created node */ protected Node createNode(Object value) { Node cachedNode = getNodeFromCache(); if (cachedNode == null) { return super.createNode(value); } else { cachedNode.setValue(value); return cachedNode; } }
/** * Creates a new node, either by reusing one from the cache or creating * a new one. * * @param value value of the new node * @return the newly created node */ protected Node createNode(Object value) { Node cachedNode = getNodeFromCache(); if (cachedNode == null) { return super.createNode(value); } else { cachedNode.setValue(value); return cachedNode; } }
public void set(Object obj) { checkModCount(); getLastNodeReturned().setValue(obj); }
public void set(Object obj) { checkModCount(); getLastNodeReturned().setValue(obj); }
public void set(Object obj) { checkModCount(); getLastNodeReturned().setValue(obj); }
public void set(Object obj) { checkModCount(); getLastNodeReturned().setValue(obj); }
/** * Updates the node with a new value. * This implementation sets the value on the node. * Subclasses can override this to record the change. * * @param node node to update * @param value new value of the node */ protected void updateNode(Node node, Object value) { node.setValue(value); }
/** * Creates a new node with previous, next and element all set to null. * This implementation creates a new empty Node. * Subclasses can override this to create a different class. * * @return newly created node */ protected Node createHeaderNode() { return new Node(); }
/** * @return the next LinkNode. */ public LinkedEntries.LinkNode getPreviousLinkNode() { return (LinkedEntries.LinkNode) super.getPreviousNode(); } }