org.abstracthorizon.mercury.imap.util
Class SimpleSequence

java.lang.Object
  extended by org.abstracthorizon.mercury.imap.util.SimpleSequence
All Implemented Interfaces:
Comparable<Sequence>, Sequence

public class SimpleSequence
extends Object
implements Sequence

A class representing simple implementation of Sequence. It has min and max, and maintains current pointer.

Author:
Daniel Sendula

Field Summary
protected  int max
          Default minimum value
protected  int min
          Default maximum value
protected  int ptr
          Current pointer
 
Constructor Summary
SimpleSequence()
          Constructor
 
Method Summary
 int compareTo(Sequence o)
          Compares two sequences
 boolean equals(Object o)
          Returns true if two sequences are equal
 void first()
          Resets internal iterator
 int getMax()
          Maximum element in the sequence
 int getMin()
          Minimum element in the sequence
 int hashCode()
          Returns sum of min and max
 boolean more()
          Returns true if there are more elements in internal interator
 int next()
          Returns next element from the internal interator
 void setLowerLimit(int lower)
          Sets the lower limit
 void setMax(int max)
          Sets maximum element in the sequence
 void setMin(int min)
          Sets minimum element in the sequence
 void setUpperLimit(int upper)
          Sets upper limit
 String toString()
          Returns sequence as string
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

min

protected int min
Default maximum value


max

protected int max
Default minimum value


ptr

protected int ptr
Current pointer

Constructor Detail

SimpleSequence

public SimpleSequence()
Constructor

Method Detail

getMin

public int getMin()
Minimum element in the sequence

Specified by:
getMin in interface Sequence
Returns:
minimum element in the sequence

setMin

public void setMin(int min)
Sets minimum element in the sequence

Parameters:
min - minimum element in the sequence

getMax

public int getMax()
Maximum element in the sequence

Specified by:
getMax in interface Sequence
Returns:
maximum element in the sequence

setMax

public void setMax(int max)
Sets maximum element in the sequence

Parameters:
max - maximum element in the sequence

setLowerLimit

public void setLowerLimit(int lower)
Sets the lower limit

Specified by:
setLowerLimit in interface Sequence
Parameters:
lower - lower limit

setUpperLimit

public void setUpperLimit(int upper)
Sets upper limit

Specified by:
setUpperLimit in interface Sequence
Parameters:
upper - upper limit

first

public void first()
Resets internal iterator

Specified by:
first in interface Sequence

more

public boolean more()
Returns true if there are more elements in internal interator

Specified by:
more in interface Sequence
Returns:
true if there are more elements in internal interator

next

public int next()
Returns next element from the internal interator

Specified by:
next in interface Sequence
Returns:
next element from the internal interator

equals

public boolean equals(Object o)
Returns true if two sequences are equal

Overrides:
equals in class Object
Parameters:
o - other sequence
Returns:
true if two sequences are equal

hashCode

public int hashCode()
Returns sum of min and max

Overrides:
hashCode in class Object
Returns:
sum of min and max

compareTo

public int compareTo(Sequence o)
Compares two sequences

Specified by:
compareTo in interface Comparable<Sequence>
Parameters:
o - other sequence
Returns:
-1, 0 and 1

toString

public String toString()
Returns sequence as string

Overrides:
toString in class Object
Returns:
sequence as string


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.