javawebparts.servlet
Class Items

java.lang.Object
  |
  +--javawebparts.servlet.Items
All Implemented Interfaces:
java.io.Serializable

public class Items
extends java.lang.Object
implements java.io.Serializable

This class holds the items from a configuration file. It is a simple list of String items. This class is used by the TextReturnerServlet and the ImageReturnerServlet.

See Also:
Serialized Form

Field Summary
private  java.util.ArrayList items
          Our actual list of items as read in from the file.
private  java.lang.String order
          What order items are retrieved in.
private static java.lang.String ORDER_FORWARD
          Constant used when the order is "forward".
private static java.lang.String ORDER_RANDOM
          Constant used when the order is "random".
private static java.lang.String ORDER_REVERSE
          Constant used when the order is "reverse".
private  int[] orderArray
          The array that will store the order to return the items in.
private  int orderArrayIndex
          Current index into the orderArray array.
 
Constructor Summary
Items()
           
 
Method Summary
 java.lang.String getItem()
          Returns the next item in the list.
 void setItem(java.lang.String item)
          Adds an item to the collection.
 void setOrder(java.lang.String inOrder)
          This method is called AFTER the items have been populated by Digester.
 java.lang.String toString()
          Overriden toString method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ORDER_RANDOM

private static final java.lang.String ORDER_RANDOM
Constant used when the order is "random".

See Also:
Constant Field Values

ORDER_FORWARD

private static final java.lang.String ORDER_FORWARD
Constant used when the order is "forward".

See Also:
Constant Field Values

ORDER_REVERSE

private static final java.lang.String ORDER_REVERSE
Constant used when the order is "reverse".

See Also:
Constant Field Values

orderArray

private int[] orderArray
The array that will store the order to return the items in.


orderArrayIndex

private int orderArrayIndex
Current index into the orderArray array.


items

private java.util.ArrayList items
Our actual list of items as read in from the file.


order

private java.lang.String order
What order items are retrieved in.

Constructor Detail

Items

public Items()
Method Detail

setOrder

public void setOrder(java.lang.String inOrder)
This method is called AFTER the items have been populated by Digester. It's job is to populate the orderArray with the list of index values in the order the items will be retrieved. So, later on when the servlet does its thing, all it has to do is call getItem() on this object and it will get the next item in the correct order.

Parameters:
inOrder - What the order will be ("random", "forward" or "reverse").

setItem

public void setItem(java.lang.String item)
Adds an item to the collection.

Parameters:
item - The item to add.

getItem

public java.lang.String getItem()
Returns the next item in the list. When the end of orderArray is reached, we start from the beginning again. So, it is true that random is really on psuedo-random, but we'll live with that!

Returns:
The next item.

toString

public java.lang.String toString()
Overriden toString method.

Overrides:
toString in class java.lang.Object
Returns:
A reflexively-built string representation of this bean.


Copyright © 2005 Frank W. Zammetti