org.jutil.java.collections
Class Singleton

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--org.jutil.java.collections.Singleton
All Implemented Interfaces:
java.util.Collection, java.util.List, java.util.Set

public final class Singleton
extends java.util.AbstractList
implements java.util.Set


Inner Class Summary
 class Singleton.SingletonIterator
           
 
Inner classes inherited from class java.util.AbstractList
java.util.AbstractList.1
 
Field Summary
static java.lang.String CVS_REVISION
           
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
Singleton(java.lang.Object onlyElement)
          Initialize a new Singleton containing the given element.
 
Method Summary
 boolean add(java.lang.Object o)
          See superclass
 boolean addAll(java.util.Collection c)
          See superclass
 void clear()
          See superclass
 boolean contains(java.lang.Object o)
          See superclass
 java.lang.Object get(int index)
          See superclass
 java.lang.Object getOnlyElement()
          Return the only element in this Singleton.
 boolean isEmpty()
          See superclass
 java.util.Iterator iterator()
          See superclass
 boolean remove(java.lang.Object o)
          See superclass
 boolean removeAll(java.util.Collection c)
          See superclass
 boolean retainAll(java.util.Collection c)
          See superclass
 java.lang.Object set(int index, java.lang.Object object)
          See superclass
 int size()
          See superclass
 java.lang.Object[] toArray()
          See superclass
 java.lang.Object[] toArray(java.lang.Object[] a)
          See superclass
 
Methods inherited from class java.util.AbstractList
add, addAll, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
containsAll, equals, hashCode
 
Methods inherited from interface java.util.List
containsAll
 

Field Detail

CVS_REVISION

public static final java.lang.String CVS_REVISION
Constructor Detail

Singleton

public Singleton(java.lang.Object onlyElement)
Initialize a new Singleton containing the given element.

Parameters:
onlyElement - The only element of this Singleton.

Specifications:
public behavior
ensures getOnlyElement() == onlyElement;
Method Detail

getOnlyElement

public java.lang.Object getOnlyElement()
Return the only element in this Singleton.

size

public int size()
See superclass

Specifications:
     also
public behavior
ensures \result == 1;

isEmpty

public boolean isEmpty()
See superclass

Specifications:
     also
public behavior
ensures \result == false;

contains

public boolean contains(java.lang.Object o)
See superclass

Specifications:
     also
public behavior
ensures \result == ((getOnlyElement() == null)&&(o == null))||getOnlyElement().equals(o);

iterator

public java.util.Iterator iterator()
See superclass

Specifications:
     also
public behavior
ensures \result instanceof SingletonIterator;
ensures \result != null;

toArray

public java.lang.Object[] toArray()
See superclass

Specifications:
     also
public behavior
ensures \result .length == 1;
ensures \result [0] == getOnlyElement();

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
See superclass

Specifications:
     also
public behavior
ensures \result .getClass().getComponentType() == a.getClass().getComponentType();
ensures \result [0] == getOnlyElement();
ensures (a.length >= 1) ==> (\result == a);
ensures (a.length < 1) ==> (\result .length == 1);
signals (NullPointerException) a == null;
signals (ArrayStoreException) (getOnlyElement() != null)&&(!a.getClass().isInstance(getOnlyElement()));

get

public java.lang.Object get(int index)
See superclass

Specifications:
     also
public behavior
requires index == 1;
ensures \result == getOnlyElement();

add

public boolean add(java.lang.Object o)
            throws java.lang.UnsupportedOperationException
See superclass

Specifications:
     also
public behavior
ensures false;
signals (UnsupportedOperationException) true;

remove

public boolean remove(java.lang.Object o)
               throws java.lang.UnsupportedOperationException
See superclass

Specifications:
     also
public behavior
ensures false;
signals (UnsupportedOperationException) true;

addAll

public boolean addAll(java.util.Collection c)
               throws java.lang.UnsupportedOperationException
See superclass

Specifications:
     also
public behavior
ensures false;
signals (UnsupportedOperationException) true;

retainAll

public boolean retainAll(java.util.Collection c)
                  throws java.lang.UnsupportedOperationException
See superclass

Specifications:
     also
public behavior
ensures false;
signals (UnsupportedOperationException) true;

removeAll

public boolean removeAll(java.util.Collection c)
                  throws java.lang.UnsupportedOperationException
See superclass

Specifications:
     also
public behavior
ensures false;
signals (UnsupportedOperationException) true;

clear

public void clear()
           throws java.lang.UnsupportedOperationException
See superclass

Specifications:
     also
public behavior
ensures false;
signals (UnsupportedOperationException) true;

set

public java.lang.Object set(int index,
                            java.lang.Object object)
                     throws java.lang.UnsupportedOperationException
See superclass

Specifications:
     also
public behavior
ensures false;
signals (UnsupportedOperationException) true;