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:
TableContainer, ListContainer, ParagraphContainer

public class Section
extends Component
implements ParagraphContainer, TableContainer, ListContainer

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
 List addList()
          Add a new List to this container.
 List addList(ListDecorator decorator)
          Add a List with specified ListDecorator to this container.
 Paragraph addParagraph(String textContent)
          Add paragraph at the end of the container with specified text content.
 Table addTable()
          Add a new Table to this container.
 Table addTable(int numRows, int numCols)
          Add a new Table to this container with a specified row number and column number.
 void clearList()
          Remove all Lists from this container.
 boolean equals(Object obj)
           
 ProtectionKeyDigestProvider getDefaultProtectionKeyDigestProvider()
          Get the default provider which use SHA-1 standard as the protection key digest algorithm.
 Section getEmbeddedSectionByName(String chdSecName)
          Looks for an embedded section with a given name.
static Section getInstance(TextSectionElement element)
          Get a section instance by an object of TextSectionElement.
 OdfElement getListContainerElement()
          Get the ODF element which can have as child element directly according to ODF specification.
 Iterator<List> getListIterator()
          Return an Iterator of the Lists in this ListContainer.
 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.
 String getProtectedPassword()
          Get the protection key of this section.
 String getProtectionKeyDigestAlgorithm()
          Get the protection key digest algorithm.
 ProtectionKeyDigestProvider getProtectionKeyDigestProvier()
          Get current used provider which provides corresponding protection key digest algorithm.
 Table.TableBuilder getTableBuilder()
          Return the table builder of this document.
 Table getTableByName(String name)
          Return an instance of table feature with the specific table name.
 OdfElement getTableContainerElement()
          Get the ODF element which can have as child element directly according to ODF specification.
protected  TableContainer getTableContainerImpl()
           
 List<Table> getTableList()
          Return a list of table features in this document.
 boolean isProtected()
          Return the value of section which specifies whether the section is protected.
 void remove()
          Remove this section from the document.
 boolean removeList(List list)
          Remove the existing List from this container.
 boolean removeParagraph(Paragraph para)
          Remove paragraph from the container
 void setName(String name)
          Set the value of this section name
 void setProtected(boolean isProtected)
          Set the value to specify whether the section is protected.
 void setProtectedWithPassword(String key)
          Set the password which specifies that an authorization is required for removing the protection of this section.
 void setProtectionKeyDigestProvider(ProtectionKeyDigestProvider provider)
          Set the provider which provides corresponding protection key digest algorithm.
 
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

setProtected

public void setProtected(boolean isProtected)
Set the value to specify whether the section is protected.

If this value is set to false, the existing password will be removed at the same.

Parameters:
isProtected - - "true" represents the section cannot be edited through a user interface. "false" represents the section is allowed to be edited.

isProtected

public boolean isProtected()
Return the value of section which specifies whether the section is protected.

Returns:
whether the section is protected.

setProtectedWithPassword

public void setProtectedWithPassword(String key)
Set the password which specifies that an authorization is required for removing the protection of this section.

If key is empty or null, the attribute of text:protection-key and text:protection-key-digest-algorithm will be removed.

The authentication procedure can be customized by setProtectionKeyDigestProvider(ProtectionKeyDigestProvider) . The default digest algorighom of the protection key is SHA-1: http://www.w3.org/2000/09/xmldsig#sha1.

Parameters:
key - -the value of the password.

getProtectedPassword

public String getProtectedPassword()
Get the protection key of this section.

Returns:
the protection key of this section

getProtectionKeyDigestAlgorithm

public String getProtectionKeyDigestAlgorithm()
Get the protection key digest algorithm.

The default value is http://www.w3.org/2000/09/xmldsig#sha1, if no value specified.

Returns:
an IRI that identifies an authentication procedure for removing a protection.

setProtectionKeyDigestProvider

public void setProtectionKeyDigestProvider(ProtectionKeyDigestProvider provider)
Set the provider which provides corresponding protection key digest algorithm.

Parameters:
provider - - an instance of a protection key digest algorithm provider

getProtectionKeyDigestProvier

public ProtectionKeyDigestProvider getProtectionKeyDigestProvier()
Get current used provider which provides corresponding protection key digest algorithm.

Returns:
the current used provider.

getDefaultProtectionKeyDigestProvider

public ProtectionKeyDigestProvider getDefaultProtectionKeyDigestProvider()
Get the default provider which use SHA-1 standard as the protection key digest algorithm.

Returns:
the default protection key digest algorithm.

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

getTableContainerImpl

protected TableContainer getTableContainerImpl()

addTable

public Table addTable()
Description copied from interface: TableContainer
Add a new Table to this container.

Specified by:
addTable in interface TableContainer
Returns:
added table.

addTable

public Table addTable(int numRows,
                      int numCols)
Description copied from interface: TableContainer
Add a new Table to this container with a specified row number and column number.

The table will be inserted at the end of the tableContainer. An unique table name will be given, you may set a custom table name using the setTableName method.

Specified by:
addTable in interface TableContainer
Parameters:
numRows - the row number
numCols - the column number
Returns:
a new instance of Table

getTableBuilder

public Table.TableBuilder getTableBuilder()
Description copied from interface: TableContainer
Return the table builder of this document. Every document has a table builder, which supplies all of the table creation realization, for example newTable().

Specified by:
getTableBuilder in interface TableContainer
Returns:
the table builder of this document.

getTableByName

public Table getTableByName(String name)
Description copied from interface: TableContainer
Return an instance of table feature with the specific table name.

Specified by:
getTableByName in interface TableContainer
Parameters:
name - of the table being searched for.
Returns:
an instance of table feature with the specific table name.

getTableContainerElement

public OdfElement getTableContainerElement()
Description copied from interface: TableContainer
Get the ODF element which can have as child element directly according to ODF specification. This Element will help to find the position to insert a new Table. For example, element is usable with element, so TextDocument will return OfficeTextElement. While Presentation Notes is an indirectly TableContainer, which holds Table with the help of its grand-child element , so for Notes, DrawTextBoxElement should be return.

Specified by:
getTableContainerElement in interface TableContainer
Returns:
container element which can hold .

getTableList

public List<Table> getTableList()
Description copied from interface: TableContainer
Return a list of table features in this document.

Specified by:
getTableList in interface TableContainer
Returns:
a list of table features in this document.

addList

public List addList()
Description copied from interface: ListContainer
Add a new List to this container.

Specified by:
addList in interface ListContainer
Returns:
added list.

addList

public List addList(ListDecorator decorator)
Description copied from interface: ListContainer
Add a List with specified ListDecorator to this container.

Specified by:
addList in interface ListContainer
Parameters:
decorator - the specified ListDecorator
Returns:
added list.

clearList

public void clearList()
Description copied from interface: ListContainer
Remove all Lists from this container.

Specified by:
clearList in interface ListContainer

getListContainerElement

public OdfElement getListContainerElement()
Description copied from interface: ListContainer
Get the ODF element which can have as child element directly according to ODF specification. This Element will help to find the position to insert a new List. For example, element is usable with element, so TextDocument will return OfficeTextElement. While Presentation Notes is an indirectly ListContainer, which holds List with the help of its grand-child element , so for Notes, DrawTextBoxElement should be return.

Specified by:
getListContainerElement in interface ListContainer
Returns:
container element which can hold .

getListIterator

public Iterator<List> getListIterator()
Description copied from interface: ListContainer
Return an Iterator of the Lists in this ListContainer. The Lists are iterated in the same order that they occur in the ListContainer.

Specified by:
getListIterator in interface ListContainer
Returns:
an Iterator of the Lists in this ListContainer
See Also:
Iterator

removeList

public boolean removeList(List list)
Description copied from interface: ListContainer
Remove the existing List from this container.

Specified by:
removeList in interface ListContainer
Returns:
true, if the container contains this List.

getEmbeddedSectionByName

public Section getEmbeddedSectionByName(String chdSecName)
Looks for an embedded section with a given name.

Parameters:
chdSecName - Section name looked for
Returns:
TextSectionElement with the given name or null


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