com.pepper.platform.program
Class PageList

java.lang.Object
  extended by java.util.AbstractCollection
      extended by java.util.AbstractList
          extended by java.util.ArrayList
              extended by com.pepper.platform.program.PageList
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, List, RandomAccess

public class PageList
extends ArrayList

Linked list of Pages. Note - code iterating and/or modifying instances of this class must externally synchronize on the instance lock. eg. PageList pages = section.getPages(); synchronized(pages) { for (int i = 0; i < pages.size(); i++) { Page = pages.getPage(x); ... } }

See Also:
Section, Serialized Form

Field Summary
static int DEFAULT_CAPACITY
          Default Capacity
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
PageList(com.pepper.platform.program.PageIndex pageIndex)
          Creates a new PageList instance.
 
Method Summary
 int add(int index, Page page, Section section)
          insert the item in the list and return the actual position where it was inserted (will be same as index passed in unless index was too big, in which case it will be added to the end of the list)
 boolean add(Object obj)
          Adds an orphan page (ie doesn't belong to a section) to the end of the PageList and to the PageIndex.
 boolean add(Page page, Section section)
          Adds a page to end of the PageList and to the PageIndex with the specified section.
 boolean contains(Object obj)
          Override to only check the page id.
 Page getPage(int index)
          Returns the page specified by the given index.
 Page getPage(String pageId)
          Returns the page specified by the given id.
 int getPageIndex(String pageId)
          Returns the page index specified by the given id.
 List getPageListAsXml()
          Returns all of the pages in this instance as List of JDOM XML Element instances.
 Object remove(int index)
          Removes the specified page from the PageList and PageIndex.
 Object remove(int index, boolean clearPageIndex)
           
 boolean remove(Object obj)
          Removes the specified page from the PageList and PageIndex.
 int remove(String pageId)
          Delete based on the pageId of the page
 void setPageIndex(com.pepper.platform.program.PageIndex pageIndex)
          Sets the PageIndex instance of this list.
 String toString()
          Debug method to dump contents of a PageList as a String.
 
Methods inherited from class java.util.ArrayList
add, addAll, addAll, clear, clone, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Field Detail

DEFAULT_CAPACITY

public static final int DEFAULT_CAPACITY
Default Capacity

See Also:
Constant Field Values
Constructor Detail

PageList

public PageList(com.pepper.platform.program.PageIndex pageIndex)
Creates a new PageList instance.

Method Detail

contains

public boolean contains(Object obj)
Override to only check the page id.

Specified by:
contains in interface Collection
Specified by:
contains in interface List
Overrides:
contains in class ArrayList
Parameters:
obj - an Object instance.
Returns:
a boolean value.

setPageIndex

public void setPageIndex(com.pepper.platform.program.PageIndex pageIndex)
Sets the PageIndex instance of this list.

Parameters:
pageIndex - a PageIndex instance.

getPage

public Page getPage(int index)
Returns the page specified by the given index.

Parameters:
index - an int value containing the page's index.
Returns:
The requested Page instance.

getPage

public Page getPage(String pageId)
Returns the page specified by the given id.

Parameters:
pageId - an String value containing the page's id.
Returns:
The requested Page instance.

getPageIndex

public int getPageIndex(String pageId)
Returns the page index specified by the given id.

Parameters:
pageId - an String value containing the page's id.
Returns:
The index of the page.

add

public boolean add(Object obj)
Adds an orphan page (ie doesn't belong to a section) to the end of the PageList and to the PageIndex.

Specified by:
add in interface Collection
Specified by:
add in interface List
Overrides:
add in class ArrayList
Parameters:
obj - an Object value
Returns:
true (as per the general contract of Collection.add).

add

public boolean add(Page page,
                   Section section)
Adds a page to end of the PageList and to the PageIndex with the specified section.

Parameters:
page - a Page value.
section - the owning Section.
Returns:
true (as per the general contract of Collection.add).

add

public int add(int index,
               Page page,
               Section section)
insert the item in the list and return the actual position where it was inserted (will be same as index passed in unless index was too big, in which case it will be added to the end of the list)

Parameters:
index - an int value
page - a Page value
section - a Section value
Returns:
an int value

remove

public int remove(String pageId)
Delete based on the pageId of the page

Parameters:
pageId - a String value
Returns:
a boolean value

remove

public Object remove(int index)
Removes the specified page from the PageList and PageIndex.

Specified by:
remove in interface List
Overrides:
remove in class ArrayList
Parameters:
index - an int value specifying the page's index.
Returns:
An Object instance containing the removed Page.

remove

public Object remove(int index,
                     boolean clearPageIndex)

remove

public boolean remove(Object obj)
Removes the specified page from the PageList and PageIndex.

Specified by:
remove in interface Collection
Specified by:
remove in interface List
Overrides:
remove in class ArrayList
Parameters:
obj - an Object instance containing the Page instance to be removed.
Returns:
a boolean value indicating whether or not the Page was successfully removed.

getPageListAsXml

public List getPageListAsXml()
Returns all of the pages in this instance as List of JDOM XML Element instances.

Returns:
A List of JDOM Elements.

toString

public String toString()
Debug method to dump contents of a PageList as a String.

Overrides:
toString in class AbstractCollection


Copyright © 2006-2007 Pepper Computer, Inc. All Rights Reserved.