org.odftoolkit.simple.text.list
Class List

java.lang.Object
  extended by org.odftoolkit.simple.text.list.List

public class List
extends Object

This class represents a list. It can contain list header, followed by list items.

Since:
0.4

Constructor Summary
List(ListContainer container)
          Constructor with ListContainer only.
List(ListContainer container, ListDecorator decorator)
          Constructor with ListContainer and ListDecorator.
List(ListContainer container, String header, boolean isContinueNumbering, ListDecorator decorator)
          Constructor with ListContainer, ListDecorator, header and numbering setting.
List(ListContainer container, String header, ListDecorator decorator)
          Constructor with ListContainer, ListDecorator and header.
List(ListContainer container, String header, List continueList, ListDecorator decorator)
          Constructor with ListContainer, ListDecorator, header and continued list
 
Method Summary
 ListItem addItem(int location, ListItem item)
          Insert a ListItem at the specified location.
 ListItem addItem(int location, String itemContent)
          Insert the specified ListItem at the specified location.
 ListItem addItem(ListItem item)
          Add the specified list item in ListItem object.
 ListItem addItem(String itemContent)
          Add a list item by specifying a string value.
 List<ListItem> addItems(int location, ListItem[] items)
          Insert the list items at the certain location by specifying an array of ListItem.
 List<ListItem> addItems(int location, String[] items)
          Insert the list items at the specified location in this List by giving an array of string values.
 List<ListItem> addItems(ListItem[] items)
          Add list items by specifying an array of ListItem.
 List<ListItem> addItems(String[] items)
          Add list items by specifying an array of string values.
 void clear()
          Remove all items from this List.
 List getContinueList()
          Get the preceding list whose numbering is continued by this list.
 String getHeader()
          Get the header of this list.
 ListItem getItem(int location)
          Return the item at the specified location in this List.
 List<ListItem> getItems()
          Get all of the list items.
 int getLevel()
          Get the level of this list.
 TextListElement getOdfElement()
          Get the instance of TextListElement which represents this list.
 ListDecorator.ListType getType()
          Get the type of this list.
 boolean isContinueNumbering()
          Return whether the numbering of this list is continuing, or whether the numbering of the preceding list is continued or not.
 void remove()
          Remove this list from its container.
 boolean removeItem(int location)
          Remove the item at the specified location from this List.
 boolean removeItem(ListItem item)
          Remove the specified item from this List.
 boolean removeItems(List<ListItem> items)
          Remove all the items in the collection from this list
 ListItem set(int location, ListItem item)
          Replace the item at the specified location in this List with the specified item.
 ListItem set(int location, String itemContent)
          Replace the item at the specified location in this List with the specified item content.
 void setContinueList(List continueList)
          Set the list whose numbering is continued by this list.
 void setContinueNumbering(boolean isContinueNumbering)
          Set whether the numbering of the preceding list is continued or not.
 void setDecorator(ListDecorator decorator)
          Set the ListDecorator of this list.
 void setHeader(String header)
          Set the header of this list.
 int size()
          Return the number of direct child items in this List.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

List

public List(ListContainer container)
Constructor with ListContainer only. A bullet list with default style will be created.

Parameters:
container - the container in where this list will be appended.

List

public List(ListContainer container,
            ListDecorator decorator)
Constructor with ListContainer and ListDecorator.

Parameters:
container - the container in where this list will be appended.
decorator - the ListDecorator of this list.

List

public List(ListContainer container,
            String header,
            ListDecorator decorator)
Constructor with ListContainer, ListDecorator and header.

Parameters:
container - the container in where this list will be appended.
decorator - the ListDecorator of this list.
header - the header of this list.

List

public List(ListContainer container,
            String header,
            boolean isContinueNumbering,
            ListDecorator decorator)
Constructor with ListContainer, ListDecorator, header and numbering setting.

Parameters:
container - the container in where this list will be appended.
decorator - the ListDecorator of this list.
isContinueNumbering - If isContinueNumbering is true, the numbering of this list is continuing, otherwise the numbering of this list starts from the beginning.
header - the header of this list.

List

public List(ListContainer container,
            String header,
            List continueList,
            ListDecorator decorator)
Constructor with ListContainer, ListDecorator, header and continued list

Parameters:
container - the container in where this list will be appended.
decorator - the ListDecorator of this list.
continueList - the continued list of this list.
header - the header of this list.
Method Detail

getType

public ListDecorator.ListType getType()
Get the type of this list. The list type can be BULLET, NUMBER and IMAGE.

Returns:
the list type.

getHeader

public String getHeader()
Get the header of this list.

Returns:
the header of this list.

setHeader

public void setHeader(String header)
Set the header of this list. The exist header will be replaced.

Parameters:
header - the header to be set.

setDecorator

public void setDecorator(ListDecorator decorator)
Set the ListDecorator of this list. The current ListDecorator will be replaced.

This is a useful method which can change the list type and style, even though it has been created.

Parameters:
decorator - the ListDecorator to be used.

addItem

public ListItem addItem(String itemContent)
Add a list item by specifying a string value.

Parameters:
itemContent - the list item content to be added.
Returns:
the added ListItem.

addItem

public ListItem addItem(int location,
                        String itemContent)
Insert the specified ListItem at the specified location. The ListItem is inserted before the ListItem at the specified location.

Parameters:
location - the index to insert. The start number is 0.
itemContent - the list item content to be added.
Returns:
the added ListItem.
Throws:
IndexOutOfBoundsException - when the location is out of the List range.

addItem

public ListItem addItem(ListItem item)
Add the specified list item in ListItem object.

Parameters:
item - the list item to be added.
Returns:
the added ListItem.

addItem

public ListItem addItem(int location,
                        ListItem item)
Insert a ListItem at the specified location. The ListItem is inserted before the ListItem at the specified location.

Parameters:
location - the index to insert.
item - the list item to add.
Returns:
the added ListItem.
Throws:
IndexOutOfBoundsException - when the location is out of the List range.

addItems

public List<ListItem> addItems(String[] items)
Add list items by specifying an array of string values.

Parameters:
items - the list items to be added.
Returns:
the added items.

addItems

public List<ListItem> addItems(int location,
                               String[] items)
Insert the list items at the specified location in this List by giving an array of string values.

Parameters:
location - the index to insert.
items - the collection of list item contents.
Returns:
the added items.
Throws:
IndexOutOfBoundsException - when the location is out of the List range.

addItems

public List<ListItem> addItems(ListItem[] items)
Add list items by specifying an array of ListItem.

Parameters:
items - the list items to be added.

addItems

public List<ListItem> addItems(int location,
                               ListItem[] items)
Insert the list items at the certain location by specifying an array of ListItem.

Parameters:
location - the index to insert.
items - the collection of items.
Returns:
the added items
Throws:
IndexOutOfBoundsException - when the location is out of the List range.

getItem

public ListItem getItem(int location)
Return the item at the specified location in this List.

Parameters:
location - the index of the element to be returned.
Returns:
the element at the specified location.
Throws:
IndexOutOfBoundsException - when the location is out of the List range.

getItems

public List<ListItem> getItems()
Get all of the list items.

Returns:
all of list items.

size

public int size()
Return the number of direct child items in this List.

Returns:
the number of direct child items in this List.

set

public ListItem set(int location,
                    ListItem item)
Replace the item at the specified location in this List with the specified item.

Parameters:
location - the index to put the specified item.
item - the new item to be added.
Returns:
the previous element at the index.
Throws:
IndexOutOfBoundsException - when the location is out of the List range.

set

public ListItem set(int location,
                    String itemContent)
Replace the item at the specified location in this List with the specified item content.

Parameters:
location - the index to insert. The start number is 0.
itemContent - the list item content to be added.
Returns:
the previous element at the index.
Throws:
IndexOutOfBoundsException - when the location is out of the List range.

removeItem

public boolean removeItem(int location)
Remove the item at the specified location from this List.

Parameters:
location - the index of the item to be removed.
Returns:
true if this List is modified, false otherwise.
Throws:
IndexOutOfBoundsException - when the location is out of the List range.

removeItem

public boolean removeItem(ListItem item)
Remove the specified item from this List.

Parameters:
item - the item to be removed.
Returns:
true if this List is modified, false otherwise.

removeItems

public boolean removeItems(List<ListItem> items)
Remove all the items in the collection from this list

Parameters:
items - the collection of items to be removed.
Returns:
true if this List is modified, false otherwise.

clear

public void clear()
Remove all items from this List.


remove

public void remove()
Remove this list from its container.


isContinueNumbering

public boolean isContinueNumbering()
Return whether the numbering of this list is continuing, or whether the numbering of the preceding list is continued or not.

Returns:
true if the numbering of this list is continuing, false if not.

setContinueNumbering

public void setContinueNumbering(boolean isContinueNumbering)
Set whether the numbering of the preceding list is continued or not. This method will set the attribute "text:continue-numbering" of list element. As ODF specification describes, this attribute is ignored, if attribute is present, the user can call setContinueList(List) to set this attribute. This method is a easy way to set a list continue numbering, while setContinueList(List) is an advance way to set a list numbering. For example, there are three lists ListA, ListB and ListC in order. If the user call set ListC.setContinueNumbering, the first list item in ListC is the number of the last item in ListB incremented by one. It easy, no need to get the reference of ListB. While if the user need the first list item in ListC is the number of the last item in ListA incremented by one, he must use ListC.setContinueList(ListA).

Parameters:
isContinueNumbering - If isContinueNumbering is true, and text:continue-list attribute is not present and the numbering style of the preceding list is the same as the current list, the number of the first list item in the current list is the number of the last item in the preceding list incremented by one.the list is continue numbering, otherwise if the text:continue-list attribute is not present, the numbering of the preceding list is not continued.
See Also:
setContinueList(List)

getContinueList

public List getContinueList()
Get the preceding list whose numbering is continued by this list.

Now only support to get the continued list reference in the same ListContainer and the same Level.

Returns:
the continued list of this list. If the list has no continued list, it will return null.

setContinueList

public void setContinueList(List continueList)
Set the list whose numbering is continued by this list. This is an advance way to set a list numbering. For example, there are three lists ListA, ListB and ListC in order. If the user needs the first list item in ListC is the number of the last item in ListA incremented by one, he must use ListC.setContinueList(ListA).

Parameters:
continueList - the continued list of this list.
See Also:
setContinueNumbering(boolean)

getLevel

public int getLevel()
Get the level of this list.

Every list has a list level. If a list is not contained in another list, its list level is 1. If a list is contained within another list, the list level of the contained list is the list level of the list in which it is contained incremented by one. If a list is contained in a table cell or text box, its list level returns to 1, even though the table or text box may be nested in another list. Every list with a list level of 1 defines a list and the counter domain for its list items and any sub list of that list. Each sub list starts a counter for its list items and any sub list it may contain.

Returns:
list level.

getOdfElement

public TextListElement getOdfElement()
Get the instance of TextListElement which represents this list.

Returns:
the instance of TextListElement.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010-2011 The Apache Software Foundation. All Rights Reserved.