org.odftoolkit.simple.text
Class Span

java.lang.Object
  extended by org.odftoolkit.simple.Component
      extended by org.odftoolkit.simple.text.Span
All Implemented Interfaces:
TextHyperlinkContainer

public class Span
extends Component
implements TextHyperlinkContainer

This class represents the application of a style to the character data of a portion of text.

It provides convenient methods to create a span and manipulate attributes of a span.

Since:
0.5.5

Method Summary
 TextHyperlink appendHyperlink(String text, URI linkto)
          Append a hyperlink at the end of the container
 void appendTextContent(String content)
          Append the text content at the end of this span.
 void appendTextContent(String content, boolean isStyleInherited)
          Append the text content at the end of this span.
 TextHyperlink applyHyperlink(URI linkto)
          Hyperlink support
 Iterator<TextHyperlink> getHyperlinkIterator()
          Get the iterator of hyperlinks within this container element
static Span getInstanceof(TextSpanElement sElement)
          Get a span instance by an instance of TextSpanElement.
 TextSpanElement getOdfElement()
          Return the instance of "text:span" element
 Document getOwnerDocument()
          Get the owner document of this span
 DefaultStyleHandler getStyleHandler()
          Get the style handler of this span.
 String getTextContent()
          Return the text content of this span.
static Span newSpan(TextSelection textSelection)
          Create a span instance with a text selection
 void removeHyperlinks()
          Remove all the hyperlinks in this container element.
 void removeTextContent()
          Remove the text content of this span.
 void setTextContent(String content)
          Set the text content of this span.
 
Methods inherited from class org.odftoolkit.simple.Component
getComponentByElement, registerComponent, unregisterComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstanceof

public static Span getInstanceof(TextSpanElement sElement)
Get a span instance by an instance of TextSpanElement.

Parameters:
sElement - - the instance of TextSpanElement
Returns:
an instance of span

newSpan

public static Span newSpan(TextSelection textSelection)
Create a span instance with a text selection

Parameters:
textSelection - the TextSelection which the span is applied to.
Returns:
an instance of span
See Also:
TextSelection

getStyleHandler

public DefaultStyleHandler getStyleHandler()
Get the style handler of this span.

The style handler is an instance of DefaultStyleHandler

Returns:
an instance of DefaultStyleHandler
See Also:
DefaultStyleHandler

getOwnerDocument

public Document getOwnerDocument()
Get the owner document of this span

Overrides:
getOwnerDocument in class Component
Returns:
the document who owns this span

getOdfElement

public TextSpanElement getOdfElement()
Return the instance of "text:span" element

Specified by:
getOdfElement in class Component
Returns:
the instance of "text:span" element

removeTextContent

public void removeTextContent()
Remove the text content of this span.


setTextContent

public void setTextContent(String content)
Set the text content of this span.

All the existing text content of this paragraph would be removed, and then new text content would be set.

Parameters:
content - - the text content

getTextContent

public String getTextContent()
Return the text content of this span.

The other child elements except text content will not be returned.

Returns:
- the text content of this span

appendTextContent

public void appendTextContent(String content)
Append the text content at the end of this span.

The appended text would follow the style of the last character.

Parameters:
content - - the text content

appendTextContent

public void appendTextContent(String content,
                              boolean isStyleInherited)
Append the text content at the end of this span.

The appended text would follow the style of the last character if the second parameter is set to true; Or else, the appended text would follow the default style of this paragraph.

Parameters:
content - - the text content
isStyleInherited - - whether the hyperlink style would be inherited by the appended text

applyHyperlink

public TextHyperlink applyHyperlink(URI linkto)
Hyperlink support

Specified by:
applyHyperlink in interface TextHyperlinkContainer
Parameters:
linkto - the hyperlink
Returns:
an instance of TextHyperlink

getHyperlinkIterator

public Iterator<TextHyperlink> getHyperlinkIterator()
Description copied from interface: TextHyperlinkContainer
Get the iterator of hyperlinks within this container element

Specified by:
getHyperlinkIterator in interface TextHyperlinkContainer
Returns:
the iterator of hyperlinks within this container element

removeHyperlinks

public void removeHyperlinks()
Description copied from interface: TextHyperlinkContainer
Remove all the hyperlinks in this container element.

Specified by:
removeHyperlinks in interface TextHyperlinkContainer

appendHyperlink

public TextHyperlink appendHyperlink(String text,
                                     URI linkto)
Description copied from interface: TextHyperlinkContainer
Append a hyperlink at the end of the container

Specified by:
appendHyperlink in interface TextHyperlinkContainer
Parameters:
text - - the text content
linkto - - the URI of this hyperlink
Returns:
an instance of TextHyperlink


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