Class AbstractObjectList

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable
    Direct Known Subclasses:
    BooleanList, ObjectList, PaintList, ShapeList, StrokeList

    public class AbstractObjectList
    extends java.lang.Object
    implements java.lang.Cloneable, java.io.Serializable
    A list of objects that can grow as required.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_INITIAL_CAPACITY
      The default initial capacity of the list.
      private int increment
      The default increment.
      private java.lang.Object[] objects
      Storage for the objects.
      private static long serialVersionUID
      For serialization.
      private int size
      The current list size.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractObjectList()
      Creates a new list with the default initial capacity.
      protected AbstractObjectList​(int initialCapacity)
      Creates a new list.
      protected AbstractObjectList​(int initialCapacity, int increment)
      Creates a new list.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clears the list.
      java.lang.Object clone()
      Clones the list of objects.
      boolean equals​(java.lang.Object obj)
      Tests this list for equality with another object.
      protected java.lang.Object get​(int index)
      Returns the object at the specified index, if there is one, or null.
      int hashCode()
      Returns a hash code value for the object.
      protected int indexOf​(java.lang.Object object)
      Returns the index of the specified object, or -1 if the object is not in the list.
      private void readObject​(java.io.ObjectInputStream stream)
      Provides serialization support.
      protected void set​(int index, java.lang.Object object)
      Sets an object reference (overwriting any existing object).
      int size()
      Returns the size of the list.
      private void writeObject​(java.io.ObjectOutputStream stream)
      Provides serialization support.
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        For serialization.
        See Also:
        Constant Field Values
      • DEFAULT_INITIAL_CAPACITY

        public static final int DEFAULT_INITIAL_CAPACITY
        The default initial capacity of the list.
        See Also:
        Constant Field Values
      • objects

        private transient java.lang.Object[] objects
        Storage for the objects.
      • size

        private int size
        The current list size.
      • increment

        private int increment
        The default increment.
    • Constructor Detail

      • AbstractObjectList

        protected AbstractObjectList()
        Creates a new list with the default initial capacity.
      • AbstractObjectList

        protected AbstractObjectList​(int initialCapacity)
        Creates a new list.
        Parameters:
        initialCapacity - the initial capacity.
      • AbstractObjectList

        protected AbstractObjectList​(int initialCapacity,
                                     int increment)
        Creates a new list.
        Parameters:
        initialCapacity - the initial capacity.
        increment - the increment.
    • Method Detail

      • get

        protected java.lang.Object get​(int index)
        Returns the object at the specified index, if there is one, or null.
        Parameters:
        index - the object index.
        Returns:
        The object or null.
      • set

        protected void set​(int index,
                           java.lang.Object object)
        Sets an object reference (overwriting any existing object).
        Parameters:
        index - the object index.
        object - the object (null permitted).
      • clear

        public void clear()
        Clears the list.
      • size

        public int size()
        Returns the size of the list.
        Returns:
        The size of the list.
      • indexOf

        protected int indexOf​(java.lang.Object object)
        Returns the index of the specified object, or -1 if the object is not in the list.
        Parameters:
        object - the object.
        Returns:
        The index or -1.
      • equals

        public boolean equals​(java.lang.Object obj)
        Tests this list for equality with another object.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the object to test.
        Returns:
        A boolean.
      • hashCode

        public int hashCode()
        Returns a hash code value for the object.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hashcode
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Clones the list of objects. The objects in the list are not cloned, so this is method makes a 'shallow' copy of the list.
        Overrides:
        clone in class java.lang.Object
        Returns:
        A clone.
        Throws:
        java.lang.CloneNotSupportedException - if an item in the list does not support cloning.
      • writeObject

        private void writeObject​(java.io.ObjectOutputStream stream)
                          throws java.io.IOException
        Provides serialization support.
        Parameters:
        stream - the output stream.
        Throws:
        java.io.IOException - if there is an I/O error.
      • readObject

        private void readObject​(java.io.ObjectInputStream stream)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
        Provides serialization support.
        Parameters:
        stream - the input stream.
        Throws:
        java.io.IOException - if there is an I/O error.
        java.lang.ClassNotFoundException - if there is a classpath problem.