Class SimpleListObj

  • All Implemented Interfaces:
    SimpleList

    public class SimpleListObj
    extends java.lang.Object
    implements SimpleList
    This class will allow the user to add, remove, and examine the objects in the given collection.
    Since:
    MicroStrategy Web 7.3.1 or earlier
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.Object element)
      Adds the given object to the collection.
      void addAll​(SimpleList simpleList)
      Adds all elements in another SimpleList into this list.
      void clear()
      Clears all items from the collection.
      java.util.Collection collection()  
      boolean contains​(java.lang.Object item)
      Returns whether a specific object is contained in the collection.
      java.util.Enumeration elements()
      Return the enumeration of the items inside this list.
      java.lang.Class getObjectTypeAllowed()
      Returns the object type allowed in the collection.
      boolean isEmpty()
      Returns true if the collection is empty, false otherwise.
      boolean isReadOnly()
      Returns true if the collection is read-only, false if it can be modified.
      java.lang.Object item​(int index)
      Returns the item in the list with the given index.
      void remove​(int index)
      Removes the item with the given index from the list.
      boolean remove​(java.lang.Object obj)
      Removes the specified object from the collection.
      void setObjectTypeAllowed​(java.lang.Class _typeAllowed)
      Sets the object type allowed in the collection.
      void setReadOnly​(boolean isReadOnly)
      Sets the collection as read-only.
      int size()
      Returns the current size of the list.
      void sort​(java.util.Comparator c)
      Sorts the collection using the specified Comparator.
      java.util.ArrayList toArrayList()
      Return the list as an array list.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • SimpleListObj

        public SimpleListObj()
      • SimpleListObj

        public SimpleListObj​(java.lang.Class objectAllowed)
    • Method Detail

      • add

        public void add​(java.lang.Object element)
                 throws java.lang.UnsupportedOperationException,
                        java.lang.ClassCastException
        Adds the given object to the collection. It will be added to the end of the list. Note that this could fail either because the object is read-only, or because the creating object has constrained the list to only hold a certain type of object.
        Specified by:
        add in interface SimpleList
        Parameters:
        element - The object to add to the collection.
        Throws:
        java.lang.UnsupportedOperationException - Thrown if the list is read-only.
        java.lang.ClassCastException - Thrown if the object given is of an inappropriate type.
      • addAll

        public void addAll​(SimpleList simpleList)
        Adds all elements in another SimpleList into this list.
        Specified by:
        addAll in interface SimpleList
        Parameters:
        simpleList - The list whose elements will be added into this list.
        Since:
        MicroStrategy Web 7.5.1
      • clear

        public void clear()
                   throws java.lang.UnsupportedOperationException
        Clears all items from the collection. Throws an UnsupportedOperationException if the object is read-only.
        Specified by:
        clear in interface SimpleList
        Throws:
        java.lang.UnsupportedOperationException - Thrown if the list is read-only.
      • size

        public int size()
        Returns the current size of the list.
        Specified by:
        size in interface SimpleList
        Returns:
        The number of items in the list.
      • item

        public java.lang.Object item​(int index)
                              throws java.lang.IndexOutOfBoundsException
        Returns the item in the list with the given index.
        Specified by:
        item in interface SimpleList
        Parameters:
        index - The index of the item in the collection to return.
        Returns:
        The object which is at the given index in the collection.
        Throws:
        java.lang.IndexOutOfBoundsException - Thrown if no item in the collection has the given index.
      • remove

        public void remove​(int index)
                    throws java.lang.UnsupportedOperationException,
                           java.lang.IndexOutOfBoundsException
        Removes the item with the given index from the list. This will cause a shifting of indices of items in the list which are after the removed item.
        Specified by:
        remove in interface SimpleList
        Parameters:
        index - The index of the item in the collection to remove.
        Throws:
        java.lang.IndexOutOfBoundsException - Thrown if no item in the collection has the given index.
        java.lang.UnsupportedOperationException - Thrown if the list is designated as read-only.
      • elements

        public java.util.Enumeration elements()
        Return the enumeration of the items inside this list.
        Specified by:
        elements in interface SimpleList
        Returns:
        An enumeration of the items inside this list.
      • collection

        public java.util.Collection collection()
        Since:
        MicroStrategy Web 9.0.0
      • setReadOnly

        public void setReadOnly​(boolean isReadOnly)
        Sets the collection as read-only.
        Parameters:
        isReadOnly - whether the collection will be read only or not.
      • isReadOnly

        public boolean isReadOnly()
        Returns true if the collection is read-only, false if it can be modified.
        Specified by:
        isReadOnly in interface SimpleList
        Returns:
        Whether the collection is read-only.
      • isEmpty

        public boolean isEmpty()
        Returns true if the collection is empty, false otherwise.
        Specified by:
        isEmpty in interface SimpleList
        Returns:
        Whether the collection is empty.
      • setObjectTypeAllowed

        public void setObjectTypeAllowed​(java.lang.Class _typeAllowed)
        Sets the object type allowed in the collection.
        Parameters:
        _typeAllowed - the object type allowed in the collection.
      • getObjectTypeAllowed

        public java.lang.Class getObjectTypeAllowed()
        Returns the object type allowed in the collection.
        Returns:
        The object type allowed in the collection.
      • contains

        public boolean contains​(java.lang.Object item)
        Returns whether a specific object is contained in the collection.
        Specified by:
        contains in interface SimpleList
        Parameters:
        item - The object we want to search in the collection.
        Returns:
        true when the item is contained in the collection. Otherwise, false will be returned.
      • sort

        public void sort​(java.util.Comparator c)
        Sorts the collection using the specified Comparator.
        Specified by:
        sort in interface SimpleList
        Parameters:
        c - The Comparator to be used in sorting.
        Since:
        MicroStrategy Web 7.5.1
      • remove

        public boolean remove​(java.lang.Object obj)
                       throws java.lang.UnsupportedOperationException
        Removes the specified object from the collection.
        Specified by:
        remove in interface SimpleList
        Parameters:
        obj - The object to be removed.
        Returns:
        true if the object has been successfully removed. Otherwise, false will be returned.
        Throws:
        java.lang.UnsupportedOperationException - Thrown when this collection is read-only.
        Since:
        MicroStrategy Web 7.5.2
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Since:
        MicroStrategy Web 8.0.0
      • toArrayList

        public java.util.ArrayList toArrayList()
        Description copied from interface: SimpleList
        Return the list as an array list.
        Specified by:
        toArrayList in interface SimpleList