net.sf.sail.core.entity
Interface ISock<T>

All Superinterfaces:
java.lang.Iterable<T>
All Known Implementing Classes:
MemorySock

public interface ISock<T>
extends java.lang.Iterable<T>

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

Author:
turadg

Method Summary
 boolean add(T o)
          The same as add(T o, false).
 boolean add(T o, boolean replace)
          Ensures that this collection contains the specified element (optional operation).
 java.util.Iterator<ISockEntry<T>> entryIterator()
          Return an iterator of the sock entries in this sock.
 ISockEntry<T> entryPeek()
          Return the most recent ISockEntry in this sock.
 boolean isEmpty()
          Returns true if this collection contains no elements.
 java.util.Iterator<T> iterator()
          Returns an iterator over the elements in this collection.
 T 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<T> 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<T>
Returns:
an Iterator over the elements in this collection

add

boolean add(T o)
The same as add(T o, false). See add(T o, boolean replace).

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.

add

boolean add(T o,
            boolean replace)
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.
replace - false -- creates and adds a new SockEntry for this object true -- replaces the timestamp and value of the most recent SockEntry with the current timestamp and this object
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

T 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.

entryPeek

ISockEntry<T> entryPeek()
Return the most recent ISockEntry in this sock. This can be used to get the Date when an object was added to the sock.

Returns:

entryIterator

java.util.Iterator<ISockEntry<T>> entryIterator()
Return an iterator of the sock entries in this sock.

Returns:


Copyright © 2004-2008 TELS Center. All Rights Reserved.