se.biltmore.tools.odttoapt.maven.plugin.models
Class APTParagraph

java.lang.Object
  extended by se.biltmore.tools.odttoapt.maven.plugin.models.APT
      extended by se.biltmore.tools.odttoapt.maven.plugin.models.APTParent
          extended by se.biltmore.tools.odttoapt.maven.plugin.models.APTParagraph
Direct Known Subclasses:
APTComment, APTPreformatted

public class APTParagraph
extends APTParent

This represents a paragraph in a APT document. This is created for each <text:p ...> in the odt file.

A paragraph is just one block of text, but parts of it can have different formatting like bold, italic, etc. The odt XML format in content.xml handles this by <text:span text:style-name="APT-Text-Bold"> child elements. There can be plain text both before, in-between, and after these.

This was easiest handled by letting APTParagraph be a parent and accept different subclasses of APTText as children. This will receive setValue(...) calls for the text in the <text:p> element. This can come multiple times for the same block of text that gets delivered in parts. So we add all received text to a StringBuilder. When a <test:span> element occurs an APTText subclass will be added as a child. Before the child is added we convert the StringBuilder to a string and create an APTText instance and add the text to it, and add it as a child before the received child. To catch the last pieces of text we also override done() and take any new text and put in a new APTText and add as a child.


Field Summary
private  StringBuilder localValue
          This collets received values.
 
Constructor Summary
APTParagraph()
          Creates a new APTParagraph instance.
 
Method Summary
 void addChild(APT child)
          Adds a child text part to this paragraph.
 void done()
          This gets called when this APT object has received all data.
protected  String getValue()
          Returns the value.
protected  String getValue(String formatPrefix)
          Returns the formatted value.
 void setValue(String value)
          Sets the value for this APT.
 
Methods inherited from class se.biltmore.tools.odttoapt.maven.plugin.models.APTParent
getChildren, getLastChild, getUnformattedValue, hasChildren
 
Methods inherited from class se.biltmore.tools.odttoapt.maven.plugin.models.APT
formatText, getParent, hasValue, isAllowFormat, isLink, setAllowFormat, setLink, setParent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

localValue

private StringBuilder localValue
This collets received values.

Constructor Detail

APTParagraph

public APTParagraph()
Creates a new APTParagraph instance.

Method Detail

setValue

public void setValue(String value)
Sets the value for this APT.

Overrides:
setValue in class APT
Parameters:
value - The value to set.

addChild

public void addChild(APT child)
Adds a child text part to this paragraph.

Overrides:
addChild in class APTParent
Parameters:
child - The text part to add.

done

public void done()
This gets called when this APT object has received all data.

Overrides:
done in class APT

getValue

protected String getValue()
Returns the value.

Overrides:
getValue in class APT

getValue

protected String getValue(String formatPrefix)
Returns the formatted value. This version if for reuse by subclasses.

Parameters:
formatPrefix - The prefix to use for the format.


Copyright © 2009-2010 Biltmore Group AB. All Rights Reserved.