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

java.lang.Object
  extended by se.biltmore.tools.odttoapt.maven.plugin.models.APT
Direct Known Subclasses:
APTDocumentAttribute, APTImageCaption, APTImageHRef, APTParent, APTSectionTitle, APTText

public abstract class APT
extends Object

This is a base class for all APT models.


Field Summary
private  boolean allowFormat
          Determines if the APT object is allowed to be formatted.
private  boolean link
          If link is set to true parsed XML elements resulting in multiple consecutive identical APT objects are linked togheter into one.
private  APTParent parent
          If this object is added to a parent, this will contain that parent.
private  String value
          A possible value for this APT object.
 
Constructor Summary
protected APT()
          Creates a new ATP subclass instance since this class is abstract.
 
Method Summary
 void done()
          This is called when the object is done.
protected  String formatText(String text, String indent, int width)
          Formats a string of text splitting it into several lines breaking at a specified width and prefixing with a specified indent.
protected  APTParent getParent()
          Returns the parent of this object if any or null otherwise.
protected  String getUnformattedValue()
          This should always returns the unformatted value as it is stored.
protected  String getValue()
          Returns the value or null if not set.
protected  boolean hasValue()
          Returns true if there is a value available.
 boolean isAllowFormat()
          Returns true if this APT object is allowed to be formatted.
 boolean isLink()
          Returns true if this should be linked with previous consecutive identical.
protected  void setAllowFormat(boolean allowFormat)
          Sets if formatting is allowed.
protected  void setLink(boolean link)
          Sets if multiple consecutive identical APT objects should be linked.
 void setParent(APTParent parent)
          Sets the parent of this object.
 void setValue(String value)
          Sets the value for this APT.
 String toString()
          Returns a String representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value

private String value
A possible value for this APT object.


allowFormat

private boolean allowFormat
Determines if the APT object is allowed to be formatted. All parents that format their children must not format those children that does not allow it. For example an image in a paragraph cannot be formatted while the rest of the paragraph can and should.


link

private boolean link
If link is set to true parsed XML elements resulting in multiple consecutive identical APT objects are linked togheter into one. That is the first creates the object, and consecutive calls setValue() on the same object. For this to work setValue() will actually have to append instead.


parent

private APTParent parent
If this object is added to a parent, this will contain that parent.

Constructor Detail

APT

protected APT()
Creates a new ATP subclass instance since this class is abstract.

Method Detail

setAllowFormat

protected void setAllowFormat(boolean allowFormat)
Sets if formatting is allowed.

Parameters:
allowFormat - true or false.

isAllowFormat

public boolean isAllowFormat()
Returns true if this APT object is allowed to be formatted.


setLink

protected void setLink(boolean link)
Sets if multiple consecutive identical APT objects should be linked.

Parameters:
link - true or false.

isLink

public boolean isLink()
Returns true if this should be linked with previous consecutive identical.


setParent

public void setParent(APTParent parent)
Sets the parent of this object.

Parameters:
parent - The parent to set.

getParent

protected APTParent getParent()
Returns the parent of this object if any or null otherwise.


setValue

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

Please note that this gets called every time the SAXParser calls characters(...) in OdtSAXHandler. Depending on the element text this sometimes gets called more than once before the element content is complete. Entity references are usually received in a separate call for example. Therefore we append each set value. That means calling this with a value and then again with another value will not replace the first value, but append to it.

Values should never ever be stored formatted in this object!! The only place were formatting should occur is in getValue().

Parameters:
value - The value to set.

getValue

protected String getValue()
Returns the value or null if not set. This method should always return a value that is formatted according to the requirements of the subclass. It is OK to returns it as is if the subclass does not require any formatting.


getUnformattedValue

protected String getUnformattedValue()
This should always returns the unformatted value as it is stored.


hasValue

protected boolean hasValue()
Returns true if there is a value available.


done

public void done()
This is called when the object is done. When this is called, all values have been received.


formatText

protected String formatText(String text,
                            String indent,
                            int width)
Formats a string of text splitting it into several lines breaking at a specified width and prefixing with a specified indent.

This method shamelessly stolen from OptionsManager (http://optionsmanager.sf.net), but that is ok since it is also made by me, and also open source.

Parameters:
text - The text to format.
indent - The indent to use.
width - The width to break at.

toString

public String toString()
Returns a String representation of this object.

Overrides:
toString in class Object


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