org.odftoolkit.simple.text
Class Section

java.lang.Object
  extended by org.odftoolkit.simple.Component
      extended by org.odftoolkit.simple.text.Section
All Implemented Interfaces:
ParagraphContainer

public class Section
extends Component
implements ParagraphContainer

This class represents section definition in text document. It provides methods to manipulate section in text document, such as getting/setting section name, moving section and so on.

Since:
0.4

Method Summary
 Paragraph addParagraph(String textContent)
          Add paragraph at the end of the container with specified text content.
 boolean equals(Object obj)
           
static Section getInstance(TextSectionElement element)
          Get a section instance by an object of TextSectionElement.
 String getName()
          Return the name of this section
 TextSectionElement getOdfElement()
          Return an instance of TextSectionElement which represents this section.
 Document getOwnerDocument()
          Return the ODF document which this section belongs to.
 Paragraph getParagraphByIndex(int index, boolean isEmptyParagraphSkipped)
          Return a paragraph with a given index.
 Paragraph getParagraphByReverseIndex(int reverseIndex, boolean isEmptyParagraphSkipped)
          Return a paragraph with a given index.
 OdfElement getParagraphContainerElement()
          Get the ODF element which can have as child element directly.
 Iterator<Paragraph> getParagraphIterator()
          Return an Iterator of the paragraph in this container.
 void remove()
          Remove this section from the document.
 boolean removeParagraph(Paragraph para)
          Remove paragraph from the container
 void setName(String name)
          Set the value of this section name
 
Methods inherited from class org.odftoolkit.simple.Component
getComponentByElement, registerComponent, unregisterComponent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Section getInstance(TextSectionElement element)
Get a section instance by an object of TextSectionElement.

Parameters:
element - - an object of TextSectionElement
Returns:
an instance of Section that can represent TextSectionElement

getOwnerDocument

public Document getOwnerDocument()
Return the ODF document which this section belongs to.

Overrides:
getOwnerDocument in class Component
Returns:
- the ODF document which this section belongs to.

getName

public String getName()
Return the name of this section

Returns:
- the name of this section

setName

public void setName(String name)
Set the value of this section name

Parameters:
name - - the value of name to be set

remove

public void remove()
Remove this section from the document.

All the linked resources which are only linked to this section will be removed too.


getOdfElement

public TextSectionElement getOdfElement()
Return an instance of TextSectionElement which represents this section.

Specified by:
getOdfElement in class Component
Returns:
- an instance of TextSectionElement which represents this section

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

addParagraph

public Paragraph addParagraph(String textContent)
Description copied from interface: ParagraphContainer
Add paragraph at the end of the container with specified text content.

Specified by:
addParagraph in interface ParagraphContainer
Parameters:
textContent - - the text content
Returns:
an instance of paragraph

getParagraphContainerElement

public OdfElement getParagraphContainerElement()
Description copied from interface: ParagraphContainer
Get the ODF element which can have as child element directly.

Specified by:
getParagraphContainerElement in interface ParagraphContainer
Returns:
- an ODF element which can have paragraph as child

removeParagraph

public boolean removeParagraph(Paragraph para)
Description copied from interface: ParagraphContainer
Remove paragraph from the container

Specified by:
removeParagraph in interface ParagraphContainer
Parameters:
para - - the instance of paragraph
Returns:
true if the paragraph is removed successfully, false if errors happen.

getParagraphByIndex

public Paragraph getParagraphByIndex(int index,
                                     boolean isEmptyParagraphSkipped)
Description copied from interface: ParagraphContainer
Return a paragraph with a given index.

An index of zero represents the first paragraph.

If empty paragraph is skipped, the empty paragraph won't be counted.

Specified by:
getParagraphByIndex in interface ParagraphContainer
Parameters:
index - - the index started from 0.
isEmptyParagraphSkipped - - whether the empty paragraph is skipped or not
Returns:
the paragraph with a given index

getParagraphByReverseIndex

public Paragraph getParagraphByReverseIndex(int reverseIndex,
                                            boolean isEmptyParagraphSkipped)
Description copied from interface: ParagraphContainer
Return a paragraph with a given index. The index is in reverse order.

An index of zero represents the last paragraph.

If empty paragraph is skipped, the empty paragraph won't be counted.

Specified by:
getParagraphByReverseIndex in interface ParagraphContainer
Parameters:
reverseIndex - - the index started from 0 in reverse order.
isEmptyParagraphSkipped - - whether the empty paragraph is skipped or not
Returns:
the paragraph with a given index

getParagraphIterator

public Iterator<Paragraph> getParagraphIterator()
Description copied from interface: ParagraphContainer
Return an Iterator of the paragraph in this container.

Specified by:
getParagraphIterator in interface ParagraphContainer
Returns:
an Iterator of the paragraph in this container


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