sam.entry
Class List

java.lang.Object
  |
  +--sam.entry.Enumerator
        |
        +--sam.entry.List
All Implemented Interfaces:
java.util.Enumeration

public class List
extends Enumerator

Static enumerator.

Can be reset.

See Also:
reset

Field Summary
 
Fields inherited from class sam.entry.Enumerator
EMPTY
 
Constructor Summary
  List(sam.entry.Entry[] entries)
          Makes a list from specified entries array.
protected List(sam.entry.Entry[] entries, int start, int end)
          Makes a list from specified entries array portion.
  List(java.io.InputStream input)
          Make a list from file names list read from an input stream.
  List(java.lang.String[] names)
          Make a list from file names list.
 
Method Summary
 sam.entry.Enumerator appendNewerFrom(sam.entry.List others)
          Appends all newer entries to this enumeration.
 void checkRead()
          Check all entries of this enumeration for reading.
 int count()
          Counts the total number of remaining entries in this enumeration.
 sam.entry.Enumerator exclude(sam.entry.Enumerator others)
          Excludes specified entries from current list.
 sam.entry.Enumerator getRemovedSince(sam.entry.Enumerator others)
          Returns the enumeration of all entries appearing in other but not in this.
 boolean hasMoreElements()
          Wether this Enumerator has more elements
 boolean isEmpty()
          Tests wether all included entries are of length 0, or if there is no more entry at all.
 sam.entry.Enumerator keepNewerThan(sam.entry.Enumerator others)
          Keeps only entries from this enumeration that are newer than in specified enumeration.
 sam.entry.Entry nextEntry()
          Gets next entry, or null if none
protected  sam.entry.List removeDuplicates(java.util.Comparator comparator)
          Removes duplicate entries from a sorted files list.
 sam.entry.List removeDuplicates(sam.entry.NameFilter filter)
          Removes duplicates file specification.
 void reset()
          Restarts the enumeration from the beginning
 long size()
          Computes the total size of all entries of this enumeration.
 sam.entry.List sort()
          Sorts this enumeration in lexicographical order.
 sam.entry.List sort(java.util.Comparator comparator)
          Sorts this enumeration.
 sam.entry.List sortAndRemoveDuplicates()
           
 sam.entry.List sortAndRemoveDuplicates(java.util.Comparator comparator)
          Sorts and remove duplicates in a sorted files list.
 boolean specifies(sam.entry.Entry entry)
          Tests this regular expression against specified entry
 boolean specifies(sam.entry.Entry entry, sam.entry.NameFilter filter)
          Tests this regular expression against specified entry
 java.lang.String toString()
           
 
Methods inherited from class sam.entry.Enumerator
filter, filter, load, nextElement, println, println, statify, store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

List

public List(java.io.InputStream input)
     throws java.io.IOException
Make a list from file names list read from an input stream.


List

public List(java.lang.String[] names)
Make a list from file names list.


List

public List(sam.entry.Entry[] entries)
Makes a list from specified entries array.


List

protected List(sam.entry.Entry[] entries,
               int start,
               int end)
Makes a list from specified entries array portion.

Method Detail

nextEntry

public sam.entry.Entry nextEntry()
Description copied from class: Enumerator
Gets next entry, or null if none

Specified by:
nextEntry in class Enumerator

hasMoreElements

public boolean hasMoreElements()
Description copied from class: Enumerator
Wether this Enumerator has more elements

Specified by:
hasMoreElements in interface java.util.Enumeration
Specified by:
hasMoreElements in class Enumerator

size

public long size()
Computes the total size of all entries of this enumeration.


count

public int count()
Counts the total number of remaining entries in this enumeration.


checkRead

public void checkRead()
               throws java.io.IOException
Check all entries of this enumeration for reading.

java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

reset

public void reset()
Restarts the enumeration from the beginning


isEmpty

public boolean isEmpty()
Tests wether all included entries are of length 0, or if there is no more entry at all.

Overrides:
isEmpty in class Enumerator

keepNewerThan

public sam.entry.Enumerator keepNewerThan(sam.entry.Enumerator others)
Keeps only entries from this enumeration that are newer than in specified enumeration.


exclude

public sam.entry.Enumerator exclude(sam.entry.Enumerator others)
Excludes specified entries from current list.


getRemovedSince

public sam.entry.Enumerator getRemovedSince(sam.entry.Enumerator others)
Returns the enumeration of all entries appearing in other but not in this.


appendNewerFrom

public sam.entry.Enumerator appendNewerFrom(sam.entry.List others)
Appends all newer entries to this enumeration.


sort

public sam.entry.List sort()
Sorts this enumeration in lexicographical order.

Returns:
this (Beware !)

sort

public sam.entry.List sort(java.util.Comparator comparator)
Sorts this enumeration.

Returns:
this (Beware !)

sortAndRemoveDuplicates

public sam.entry.List sortAndRemoveDuplicates()

sortAndRemoveDuplicates

public sam.entry.List sortAndRemoveDuplicates(java.util.Comparator comparator)
Sorts and remove duplicates in a sorted files list.

The complexity is that of sorting, i.e. n*ln(n).

Returns:
a new List instance with duplicates removed.

removeDuplicates

protected sam.entry.List removeDuplicates(java.util.Comparator comparator)
Removes duplicate entries from a sorted files list.

The complexity is linear, because any entry has to be compared to the only adjacent one for equality.

Parameters:
comparator - the files comparator to be used for ordering and equality testing.
Returns:
a new List instance with duplicates removed.
Throws:
java.lang.IllegalArgumentException - if this list is not sorted.
See Also:
NameFilter

removeDuplicates

public sam.entry.List removeDuplicates(sam.entry.NameFilter filter)
Removes duplicates file specification.

Reduces { "a*", "?", "*" } to { "*", "?" }

The complexity is quadratic, because any entry has to be compared to all others.

Parameters:
filter - the name filter to be used. Default is NameFilter.BASIC
Returns:
a new List instance with duplicates removed.
See Also:
NameFilter

specifies

public boolean specifies(sam.entry.Entry entry)
Tests this regular expression against specified entry

Returns:
true if, and only if at least one of these entries is a regular expression that expands to entry

specifies

public boolean specifies(sam.entry.Entry entry,
                         sam.entry.NameFilter filter)
Tests this regular expression against specified entry

Parameters:
filter - the name filtering rule to be used
Returns:
true if, and only if at least one of these entries is a regular expression that expands to entry