<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FCollections%2FReference</id>
		<title>Java Tutorial/Collections/Reference - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FCollections%2FReference"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/Collections/Reference&amp;action=history"/>
		<updated>2026-04-07T13:13:53Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/Collections/Reference&amp;diff=4714&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/Collections/Reference&amp;diff=4714&amp;oldid=prev"/>
				<updated>2010-06-01T05:04:51Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 05:04, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/Collections/Reference&amp;diff=4713&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/Collections/Reference&amp;diff=4713&amp;oldid=prev"/>
				<updated>2010-05-31T17:44:27Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==  An implementation of Set that manages a map of soft references to the set values. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * JBoss, Home of Professional Open Source&lt;br /&gt;
 * Copyright 2005, JBoss Inc., and individual contributors as indicated&lt;br /&gt;
 * by the @authors tag. See the copyright.txt in the distribution for a&lt;br /&gt;
 * full listing of individual contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * This is free software; you can redistribute it and/or modify it&lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as&lt;br /&gt;
 * published by the Free Software Foundation; either version 2.1 of&lt;br /&gt;
 * the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU&lt;br /&gt;
 * Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this software; if not, write to the Free&lt;br /&gt;
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA&lt;br /&gt;
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.&lt;br /&gt;
 */&lt;br /&gt;
import java.lang.ref.ReferenceQueue;&lt;br /&gt;
import java.lang.ref.SoftReference;&lt;br /&gt;
import java.lang.reflect.Array;&lt;br /&gt;
import java.util.Collection;&lt;br /&gt;
import java.util.HashMap;&lt;br /&gt;
import java.util.Iterator;&lt;br /&gt;
import java.util.Set;&lt;br /&gt;
/**&lt;br /&gt;
 * An implementation of Set that manages a map of soft references to the set&lt;br /&gt;
 * values. The map is keyed by the value hashCode and so this is only useful for&lt;br /&gt;
 * value whose hashCode is a valid identity representation (String, primative&lt;br /&gt;
 * wrappers, etc).&lt;br /&gt;
 * &lt;br /&gt;
 * @author Scott.Stark@jboss.org&lt;br /&gt;
 * @version $Revision: 2787 $&lt;br /&gt;
 */&lt;br /&gt;
@SuppressWarnings(&amp;quot;unchecked&amp;quot;)&lt;br /&gt;
public class SoftSet implements Set {&lt;br /&gt;
  private HashMap map = new HashMap();&lt;br /&gt;
  /** The queue of garbage collected soft references */&lt;br /&gt;
  private ReferenceQueue gcqueue = new ReferenceQueue();&lt;br /&gt;
  static class ComparableSoftReference extends SoftReference {&lt;br /&gt;
    private Integer key;&lt;br /&gt;
    ComparableSoftReference(Integer key, Object o, ReferenceQueue q) {&lt;br /&gt;
      super(o, q);&lt;br /&gt;
      this.key = key;&lt;br /&gt;
    }&lt;br /&gt;
    Integer getKey() {&lt;br /&gt;
      return key;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  static class ComparableSoftReferenceIterator implements Iterator {&lt;br /&gt;
    Iterator theIter;&lt;br /&gt;
    ComparableSoftReferenceIterator(Iterator theIter) {&lt;br /&gt;
      this.theIter = theIter;&lt;br /&gt;
    }&lt;br /&gt;
    public boolean hasNext() {&lt;br /&gt;
      return theIter.hasNext();&lt;br /&gt;
    }&lt;br /&gt;
    public Object next() {&lt;br /&gt;
      ComparableSoftReference csr = (ComparableSoftReference) theIter.next();&lt;br /&gt;
      return csr.get();&lt;br /&gt;
    }&lt;br /&gt;
    public void remove() {&lt;br /&gt;
      theIter.remove();&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * &lt;br /&gt;
   */&lt;br /&gt;
  public SoftSet() {&lt;br /&gt;
  }&lt;br /&gt;
  public int size() {&lt;br /&gt;
    processQueue();&lt;br /&gt;
    return map.size();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean isEmpty() {&lt;br /&gt;
    processQueue();&lt;br /&gt;
    return map.isEmpty();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean contains(Object o) {&lt;br /&gt;
    processQueue();&lt;br /&gt;
    Integer key = new Integer(o.hashCode());&lt;br /&gt;
    boolean contains = map.containsKey(key);&lt;br /&gt;
    return contains;&lt;br /&gt;
  }&lt;br /&gt;
  public Iterator iterator() {&lt;br /&gt;
    processQueue();&lt;br /&gt;
    Iterator theIter = map.values().iterator();&lt;br /&gt;
    return new ComparableSoftReferenceIterator(theIter);&lt;br /&gt;
  }&lt;br /&gt;
  public Object[] toArray() {&lt;br /&gt;
    processQueue();&lt;br /&gt;
    return toArray(new Object[0]);&lt;br /&gt;
  }&lt;br /&gt;
  public Object[] toArray(Object[] a) {&lt;br /&gt;
    processQueue();&lt;br /&gt;
    int size = map.size();&lt;br /&gt;
    Object[] array = {};&lt;br /&gt;
    if (a.length &amp;gt;= size)&lt;br /&gt;
      array = a;&lt;br /&gt;
    Iterator iter = map.values().iterator();&lt;br /&gt;
    int index = 0;&lt;br /&gt;
    while (iter.hasNext()) {&lt;br /&gt;
      ComparableSoftReference csr = (ComparableSoftReference) iter.next();&lt;br /&gt;
      Object value = csr.get();&lt;br /&gt;
      // Create the correct array type&lt;br /&gt;
      if (array.length == 0) {&lt;br /&gt;
        if (value == null) {&lt;br /&gt;
          index++;&lt;br /&gt;
          continue;&lt;br /&gt;
        }&lt;br /&gt;
        Array.newInstance(value.getClass(), size);&lt;br /&gt;
      }&lt;br /&gt;
      array[index] = value;&lt;br /&gt;
      index++;&lt;br /&gt;
    }&lt;br /&gt;
    return array;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean add(Object o) {&lt;br /&gt;
    processQueue();&lt;br /&gt;
    Integer key = new Integer(o.hashCode());&lt;br /&gt;
    ComparableSoftReference sr = new ComparableSoftReference(key, o, gcqueue);&lt;br /&gt;
    return map.put(key, sr) == null;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean remove(Object o) {&lt;br /&gt;
    processQueue();&lt;br /&gt;
    Integer key = new Integer(o.hashCode());&lt;br /&gt;
    return map.remove(key) != null;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean containsAll(Collection c) {&lt;br /&gt;
    processQueue();&lt;br /&gt;
    Iterator iter = c.iterator();&lt;br /&gt;
    boolean contains = true;&lt;br /&gt;
    while (iter.hasNext()) {&lt;br /&gt;
      Object value = iter.next();&lt;br /&gt;
      Integer key = new Integer(value.hashCode());&lt;br /&gt;
      contains &amp;amp;= map.containsKey(key);&lt;br /&gt;
    }&lt;br /&gt;
    return contains;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean addAll(Collection c) {&lt;br /&gt;
    processQueue();&lt;br /&gt;
    Iterator iter = c.iterator();&lt;br /&gt;
    boolean added = false;&lt;br /&gt;
    while (iter.hasNext()) {&lt;br /&gt;
      Object value = iter.next();&lt;br /&gt;
      Integer key = new Integer(value.hashCode());&lt;br /&gt;
      ComparableSoftReference sr = new ComparableSoftReference(key, value, gcqueue);&lt;br /&gt;
      added |= map.put(key, sr) == null;&lt;br /&gt;
    }&lt;br /&gt;
    return added;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean retainAll(Collection c) {&lt;br /&gt;
    Iterator iter = iterator();&lt;br /&gt;
    boolean removed = false;&lt;br /&gt;
    while (iter.hasNext()) {&lt;br /&gt;
      Object value = iter.next();&lt;br /&gt;
      if (c.contains(value) == false) {&lt;br /&gt;
        iter.remove();&lt;br /&gt;
        removed = true;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return removed;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean removeAll(Collection c) {&lt;br /&gt;
    processQueue();&lt;br /&gt;
    Iterator iter = c.iterator();&lt;br /&gt;
    boolean removed = false;&lt;br /&gt;
    while (iter.hasNext()) {&lt;br /&gt;
      Object value = iter.next();&lt;br /&gt;
      removed |= remove(value);&lt;br /&gt;
    }&lt;br /&gt;
    return removed;&lt;br /&gt;
  }&lt;br /&gt;
  public void clear() {&lt;br /&gt;
    while (gcqueue.poll() != null)&lt;br /&gt;
      ;&lt;br /&gt;
    map.clear();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean equals(Object o) {&lt;br /&gt;
    return map.equals(o);&lt;br /&gt;
  }&lt;br /&gt;
  public int hashCode() {&lt;br /&gt;
    return map.hashCode();&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Iterate through the gcqueue for for any cleared reference, remove the&lt;br /&gt;
   * associated value from the underlying set.&lt;br /&gt;
   */&lt;br /&gt;
  private void processQueue() {&lt;br /&gt;
    ComparableSoftReference cr;&lt;br /&gt;
    while ((cr = (ComparableSoftReference) gcqueue.poll()) != null) {&lt;br /&gt;
      map.remove(cr.getKey());&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Cache based on SoftReference ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*   Copyright 2004 The Apache Software Foundation&lt;br /&gt;
 *&lt;br /&gt;
 *   Licensed under the Apache License, Version 2.0 (the &amp;quot;License&amp;quot;);&lt;br /&gt;
 *   you may not use this file except in compliance with the License.&lt;br /&gt;
 *   You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 *       http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 *   Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
 *   distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
 *   See the License for the specific language governing permissions and&lt;br /&gt;
 *  limitations under the License.&lt;br /&gt;
 */&lt;br /&gt;
// Revised from xmlbeans&lt;br /&gt;
import java.util.HashMap;&lt;br /&gt;
import java.lang.ref.SoftReference;&lt;br /&gt;
/**&lt;br /&gt;
 * @author Cezar Andrei (cezar.andrei at bea.ru)&lt;br /&gt;
 *         Date: Apr 26, 2005&lt;br /&gt;
 */&lt;br /&gt;
public class SoftCache&lt;br /&gt;
{&lt;br /&gt;
    private HashMap map = new HashMap();&lt;br /&gt;
    public Object get(Object key)&lt;br /&gt;
    {&lt;br /&gt;
        SoftReference softRef = (SoftReference)map.get(key);&lt;br /&gt;
        if (softRef==null)&lt;br /&gt;
            return null;&lt;br /&gt;
        return softRef.get();&lt;br /&gt;
    }&lt;br /&gt;
    public Object put(Object key, Object value)&lt;br /&gt;
    {&lt;br /&gt;
        SoftReference softRef = (SoftReference)map.put(key, new SoftReference(value));&lt;br /&gt;
        if (softRef==null)&lt;br /&gt;
            return null;&lt;br /&gt;
        Object oldValue = softRef.get();&lt;br /&gt;
        softRef.clear();&lt;br /&gt;
        return oldValue;&lt;br /&gt;
    }&lt;br /&gt;
    public Object remove(Object key)&lt;br /&gt;
    {&lt;br /&gt;
        SoftReference softRef = (SoftReference)map.remove(key);&lt;br /&gt;
        if (softRef==null)&lt;br /&gt;
            return null;&lt;br /&gt;
        Object oldValue = softRef.get();&lt;br /&gt;
        softRef.clear();&lt;br /&gt;
        return oldValue;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  WeakReference list uses java.lang.ref.WeakReferences to store its contents. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * &lt;br /&gt;
 * JFreeReport : a free Java reporting library&lt;br /&gt;
 * &lt;br /&gt;
 *&lt;br /&gt;
 * Project Info:  http://reporting.pentaho.org/&lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is free software; you can redistribute it and/or modify it under the terms&lt;br /&gt;
 * of the GNU Lesser General Public License as published by the Free Software Foundation;&lt;br /&gt;
 * either version 2.1 of the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;&lt;br /&gt;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&lt;br /&gt;
 * See the GNU Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public License along with this&lt;br /&gt;
 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,&lt;br /&gt;
 * Boston, MA 02111-1307, USA.&lt;br /&gt;
 *&lt;br /&gt;
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.&lt;br /&gt;
 * in the United States and other countries.]&lt;br /&gt;
 *&lt;br /&gt;
 * ------------&lt;br /&gt;
 * WeakReferenceList.java&lt;br /&gt;
 * ------------&lt;br /&gt;
 * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.ObjectInputStream;&lt;br /&gt;
import java.io.Serializable;&lt;br /&gt;
import java.lang.ref.Reference;&lt;br /&gt;
import java.lang.ref.WeakReference;&lt;br /&gt;
/**&lt;br /&gt;
 * The WeakReference list uses &amp;lt;code&amp;gt;java.lang.ref.WeakReference&amp;lt;/code&amp;gt;s to store its contents. In contrast to the&lt;br /&gt;
 * WeakHashtable, this list knows how to restore missing content, so that garbage collected elements can be restored&lt;br /&gt;
 * when they are accessed.&lt;br /&gt;
 * &amp;lt;p/&amp;gt;&lt;br /&gt;
 * By default this list can contain 25 elements, where the first element is stored using a strong reference, which is&lt;br /&gt;
 * not garbage collected.&lt;br /&gt;
 * &amp;lt;p/&amp;gt;&lt;br /&gt;
 * Restoring the elements is not implemented, concrete implementations will have to override the&lt;br /&gt;
 * &amp;lt;code&amp;gt;restoreChild(int)&amp;lt;/code&amp;gt; method. The &amp;lt;code&amp;gt;getMaxChildCount&amp;lt;/code&amp;gt; method defines the maxmimum number of&lt;br /&gt;
 * children in the list. When more than &amp;lt;code&amp;gt;maxChildCount&amp;lt;/code&amp;gt; elements are contained in this list, add will always&lt;br /&gt;
 * return false to indicate that adding the element failed.&lt;br /&gt;
 * &amp;lt;p/&amp;gt;&lt;br /&gt;
 * To customize the list, override createReference to create a different kind of reference.&lt;br /&gt;
 * &amp;lt;p/&amp;gt;&lt;br /&gt;
 * This list is able to add or replace elements, but inserting or removing of elements is not possible.&lt;br /&gt;
 *&lt;br /&gt;
 * @author Thomas Morgner&lt;br /&gt;
 */&lt;br /&gt;
public abstract class WeakReferenceList implements Serializable, Cloneable&lt;br /&gt;
{&lt;br /&gt;
  /**&lt;br /&gt;
   * The master element.&lt;br /&gt;
   */&lt;br /&gt;
  private Object master;&lt;br /&gt;
  /**&lt;br /&gt;
   * Storage for the references.&lt;br /&gt;
   */&lt;br /&gt;
  private transient Reference[] childs;&lt;br /&gt;
  /**&lt;br /&gt;
   * The current number of elements.&lt;br /&gt;
   */&lt;br /&gt;
  private int size;&lt;br /&gt;
  /**&lt;br /&gt;
   * The maximum number of elements.&lt;br /&gt;
   */&lt;br /&gt;
  private final int maxChilds;&lt;br /&gt;
  /**&lt;br /&gt;
   * Creates a new weak reference list. The storage of the list is limited to getMaxChildCount() elements.&lt;br /&gt;
   *&lt;br /&gt;
   * @param maxChildCount the maximum number of elements.&lt;br /&gt;
   */&lt;br /&gt;
  protected WeakReferenceList(final int maxChildCount)&lt;br /&gt;
  {&lt;br /&gt;
    this.maxChilds = maxChildCount;&lt;br /&gt;
    this.childs = new Reference[maxChildCount - 1];&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the maximum number of children in this list.&lt;br /&gt;
   *&lt;br /&gt;
   * @return the maximum number of elements in this list.&lt;br /&gt;
   */&lt;br /&gt;
  protected final int getMaxChildCount()&lt;br /&gt;
  {&lt;br /&gt;
    return maxChilds;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the master element of this list. The master element is the element stored by a strong reference and cannot&lt;br /&gt;
   * be garbage collected.&lt;br /&gt;
   *&lt;br /&gt;
   * @return the master element&lt;br /&gt;
   */&lt;br /&gt;
  protected Object getMaster()&lt;br /&gt;
  {&lt;br /&gt;
    return master;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Attempts to restore the child stored on the given index.&lt;br /&gt;
   *&lt;br /&gt;
   * @param index the index.&lt;br /&gt;
   * @return null if the child could not be restored or the restored child.&lt;br /&gt;
   */&lt;br /&gt;
  protected abstract Object restoreChild(int index);&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the child stored at the given index. If the child has been garbage collected, it gets restored using the&lt;br /&gt;
   * restoreChild function.&lt;br /&gt;
   *&lt;br /&gt;
   * @param index the index.&lt;br /&gt;
   * @return the object.&lt;br /&gt;
   */&lt;br /&gt;
  public Object get(final int index)&lt;br /&gt;
  {&lt;br /&gt;
    if (isMaster(index))&lt;br /&gt;
    {&lt;br /&gt;
      return master;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      final Reference ref = childs[getChildPos(index)];&lt;br /&gt;
      if (ref == null)&lt;br /&gt;
      {&lt;br /&gt;
        throw new IllegalStateException(&amp;quot;State: &amp;quot; + index);&lt;br /&gt;
      }&lt;br /&gt;
      Object ob = ref.get();&lt;br /&gt;
      if (ob == null)&lt;br /&gt;
      {&lt;br /&gt;
        ob = restoreChild(index);&lt;br /&gt;
        childs[getChildPos(index)] = createReference(ob);&lt;br /&gt;
      }&lt;br /&gt;
      return ob;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Replaces the child stored at the given index with the new child which can be null.&lt;br /&gt;
   *&lt;br /&gt;
   * @param report the object.&lt;br /&gt;
   * @param index  the index.&lt;br /&gt;
   */&lt;br /&gt;
  public void set(final Object report, final int index)&lt;br /&gt;
  {&lt;br /&gt;
    if (isMaster(index))&lt;br /&gt;
    {&lt;br /&gt;
      master = report;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      childs[getChildPos(index)] = createReference(report);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Creates a new reference for the given object.&lt;br /&gt;
   *&lt;br /&gt;
   * @param o the object.&lt;br /&gt;
   * @return a WeakReference for the object o without any ReferenceQueue attached.&lt;br /&gt;
   */&lt;br /&gt;
  private Reference createReference(final Object o)&lt;br /&gt;
  {&lt;br /&gt;
    return new WeakReference(o);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Adds the element to the list. If the maximum size of the list is exceeded, this function returns false to indicate&lt;br /&gt;
   * that adding failed.&lt;br /&gt;
   *&lt;br /&gt;
   * @param rs the object.&lt;br /&gt;
   * @return true, if the object was successfully added to the list, false otherwise&lt;br /&gt;
   */&lt;br /&gt;
  public boolean add(final Object rs)&lt;br /&gt;
  {&lt;br /&gt;
    if (size == 0)&lt;br /&gt;
    {&lt;br /&gt;
      master = rs;&lt;br /&gt;
      size = 1;&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      if (size &amp;lt; getMaxChildCount())&lt;br /&gt;
      {&lt;br /&gt;
        childs[size - 1] = createReference(rs);&lt;br /&gt;
        size++;&lt;br /&gt;
        return true;&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
        // was not able to add this to this list, maximum number of entries reached.&lt;br /&gt;
        return false;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns true, if the given index denotes a master index of this list.&lt;br /&gt;
   *&lt;br /&gt;
   * @param index the index.&lt;br /&gt;
   * @return true if the index is a master index.&lt;br /&gt;
   */&lt;br /&gt;
  protected boolean isMaster(final int index)&lt;br /&gt;
  {&lt;br /&gt;
    return index % getMaxChildCount() == 0;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the internal storage position for the child.&lt;br /&gt;
   *&lt;br /&gt;
   * @param index the index.&lt;br /&gt;
   * @return the internal storage index.&lt;br /&gt;
   */&lt;br /&gt;
  protected int getChildPos(final int index)&lt;br /&gt;
  {&lt;br /&gt;
    return index % getMaxChildCount() - 1;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Returns the size of the list.&lt;br /&gt;
   *&lt;br /&gt;
   * @return the size.&lt;br /&gt;
   */&lt;br /&gt;
  public int getSize()&lt;br /&gt;
  {&lt;br /&gt;
    return size;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Serialisation support. The transient child elements were not saved.&lt;br /&gt;
   *&lt;br /&gt;
   * @param in the input stream.&lt;br /&gt;
   * @throws IOException            if there is an I/O error.&lt;br /&gt;
   * @throws ClassNotFoundException if a serialized class is not defined on this system.&lt;br /&gt;
   */&lt;br /&gt;
  private void readObject(final ObjectInputStream in)&lt;br /&gt;
      throws IOException, ClassNotFoundException&lt;br /&gt;
  {&lt;br /&gt;
    in.defaultReadObject();&lt;br /&gt;
    childs = new Reference[getMaxChildCount() - 1];&lt;br /&gt;
    for (int i = 0; i &amp;lt; childs.length; i++)&lt;br /&gt;
    {&lt;br /&gt;
      childs[i] = createReference(null);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Creates and returns a copy of this object.  The precise meaning of &amp;quot;copy&amp;quot; may depend on the class of the object.&lt;br /&gt;
   * The general intent is that, for any object &amp;lt;tt&amp;gt;x&amp;lt;/tt&amp;gt;, the expression: &amp;lt;blockquote&amp;gt;&lt;br /&gt;
   * &amp;lt;pre&amp;gt;&lt;br /&gt;
   * x.clone() != x&amp;lt;/pre&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
   * will be true, and that the expression: &amp;lt;blockquote&amp;gt;&lt;br /&gt;
   * &amp;lt;pre&amp;gt;&lt;br /&gt;
   * x.clone().getClass() == x.getClass()&amp;lt;/pre&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
   * will be &amp;lt;tt&amp;gt;true&amp;lt;/tt&amp;gt;, but these are not absolute requirements. While it is typically the case that: &amp;lt;blockquote&amp;gt;&lt;br /&gt;
   * &amp;lt;pre&amp;gt;&lt;br /&gt;
   * x.clone().equals(x)&amp;lt;/pre&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
   * will be &amp;lt;tt&amp;gt;true&amp;lt;/tt&amp;gt;, this is not an absolute requirement.&lt;br /&gt;
   * &amp;lt;p/&amp;gt;&lt;br /&gt;
   * By convention, the returned object should be obtained by calling &amp;lt;tt&amp;gt;super.clone&amp;lt;/tt&amp;gt;.  If a class and all of its&lt;br /&gt;
   * superclasses (except &amp;lt;tt&amp;gt;Object&amp;lt;/tt&amp;gt;) obey this convention, it will be the case that &amp;lt;tt&amp;gt;x.clone().getClass() ==&lt;br /&gt;
   * x.getClass()&amp;lt;/tt&amp;gt;.&lt;br /&gt;
   * &amp;lt;p/&amp;gt;&lt;br /&gt;
   * By convention, the object returned by this method should be independent of this object (which is being cloned).  To&lt;br /&gt;
   * achieve this independence, it may be necessary to modify one or more fields of the object returned by&lt;br /&gt;
   * &amp;lt;tt&amp;gt;super.clone&amp;lt;/tt&amp;gt; before returning it.  Typically, this means copying any mutable objects that comprise the&lt;br /&gt;
   * internal &amp;quot;deep structure&amp;quot; of the object being cloned and replacing the references to these objects with references&lt;br /&gt;
   * to the copies.  If a class contains only primitive fields or references to immutable objects, then it is usually&lt;br /&gt;
   * the case that no fields in the object returned by &amp;lt;tt&amp;gt;super.clone&amp;lt;/tt&amp;gt; need to be modified.&lt;br /&gt;
   * &amp;lt;p/&amp;gt;&lt;br /&gt;
   * The method &amp;lt;tt&amp;gt;clone&amp;lt;/tt&amp;gt; for class &amp;lt;tt&amp;gt;Object&amp;lt;/tt&amp;gt; performs a specific cloning operation. First, if the class of&lt;br /&gt;
   * this object does not implement the interface &amp;lt;tt&amp;gt;Cloneable&amp;lt;/tt&amp;gt;, then a &amp;lt;tt&amp;gt;CloneNotSupportedException&amp;lt;/tt&amp;gt; is&lt;br /&gt;
   * thrown. Note that all arrays are considered to implement the interface &amp;lt;tt&amp;gt;Cloneable&amp;lt;/tt&amp;gt;. Otherwise, this method&lt;br /&gt;
   * creates a new instance of the class of this object and initializes all its fields with exactly the contents of the&lt;br /&gt;
   * corresponding fields of this object, as if by assignment; the contents of the fields are not themselves cloned.&lt;br /&gt;
   * Thus, this method performs a &amp;quot;shallow copy&amp;quot; of this object, not a &amp;quot;deep copy&amp;quot; operation.&lt;br /&gt;
   * &amp;lt;p/&amp;gt;&lt;br /&gt;
   * The class &amp;lt;tt&amp;gt;Object&amp;lt;/tt&amp;gt; does not itself implement the interface &amp;lt;tt&amp;gt;Cloneable&amp;lt;/tt&amp;gt;, so calling the &amp;lt;tt&amp;gt;clone&amp;lt;/tt&amp;gt;&lt;br /&gt;
   * method on an object whose class is &amp;lt;tt&amp;gt;Object&amp;lt;/tt&amp;gt; will result in throwing an exception at run time.&lt;br /&gt;
   *&lt;br /&gt;
   * @return a clone of this instance.&lt;br /&gt;
   * @throws CloneNotSupportedException if the object&amp;quot;s class does not support the &amp;lt;code&amp;gt;Cloneable&amp;lt;/code&amp;gt; interface.&lt;br /&gt;
   *                                    Subclasses that override the &amp;lt;code&amp;gt;clone&amp;lt;/code&amp;gt; method can also throw this&lt;br /&gt;
   *                                    exception to indicate that an instance cannot be cloned.&lt;br /&gt;
   * @see Cloneable&lt;br /&gt;
   */&lt;br /&gt;
  protected Object clone()&lt;br /&gt;
      throws CloneNotSupportedException&lt;br /&gt;
  {&lt;br /&gt;
    final WeakReferenceList list = (WeakReferenceList) super.clone();&lt;br /&gt;
    list.childs = (Reference[]) childs.clone();&lt;br /&gt;
    return list;&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>