net.sf.sail.core.entity
Interface ISock

All Superinterfaces:
java.lang.Iterable
All Known Implementing Classes:
MemorySock

public interface ISock
extends java.lang.Iterable

Subset of java.util.Collection plus a peek() from java.util.Stack

Author:
turadg

Method Summary
 boolean add(java.lang.Object o)
          Ensures that this collection contains the specified element (optional operation).
 boolean isEmpty()
          Returns true if this collection contains no elements.
 java.util.Iterator iterator()
          Returns an iterator over the elements in this collection.
 java.lang.Object peek()
          Looks at the most recent object in this sock.
 int size()
          Returns the number of elements in this collection.
 

Method Detail

size

int size()
Returns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:
the number of elements in this collection

isEmpty

boolean isEmpty()
Returns true if this collection contains no elements.

Returns:
true if this collection contains no elements

iterator

java.util.Iterator iterator()
Returns an iterator over the elements in this collection. There are no guarantees concerning the order in which the elements are returned (unless this collection is an instance of some class that provides a guarantee).

Specified by:
iterator in interface java.lang.Iterable
Returns:
an Iterator over the elements in this collection

add

boolean add(java.lang.Object o)
Ensures that this collection contains the specified element (optional operation). Returns true if this collection changed as a result of the call. (Returns false if this collection does not permit duplicates and already contains the specified element.)

Collections that support this operation may place limitations on what elements may be added to this collection. In particular, some collections will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. Collection classes should clearly specify in their documentation any restrictions on what elements may be added.

If a collection refuses to add a particular element for any reason other than that it already contains the element, it must throw an exception (rather than returning false). This preserves the invariant that a collection always contains the specified element after this call returns.

Parameters:
o - element whose presence in this collection is to be ensured.
Returns:
true if this collection changed as a result of the call
Throws:
java.lang.UnsupportedOperationException - add is not supported by this collection.
java.lang.ClassCastException - class of the specified element prevents it from being added to this collection.
java.lang.NullPointerException - if the specified element is null and this collection does not support null elements.
java.lang.IllegalArgumentException - some aspect of this element prevents it from being added to this collection.

peek

java.lang.Object peek()
Looks at the most recent object in this sock.

Returns:
the object most recently added to this sock
Throws:
java.util.EmptyStackException - if this sock is empty.


Copyright 2004-2004-2006 TELS Center. All Rights Reserved.