org.apache.fop.fo

Class FOText

Implemented Interfaces:
Cloneable

public class FOText
extends FONode

A text node (PCDATA) in the formatting object tree. Unfortunately the BufferManager implementatation holds onto references to the character data in this object longer than the lifetime of the object itself, causing excessive memory consumption and OOM errors.

Nested Class Summary

Nested classes/interfaces inherited from class org.apache.fop.fo.FONode

FONode.FONodeIterator

Field Summary

char[]
ca
the character array containing the text
int
endIndex
The ending valid index of the ca array to be processed.
int
startIndex
The starting valid index of the ca array to be processed.

Fields inherited from class org.apache.fop.fo.FONode

FOX_URI, FO_URI, locator, log, parent, siblings

Constructor Summary

FOText(FONode parent)
Creates a now FO text node.

Method Summary

protected void
addCharacters(char[] data, int start, int end, PropertyList list, Locator locator)
void
bind(PropertyList pList)
CharIterator
charIterator()
FONode
clone(FONode parent, boolean removeChildren)
protected void
createBlockPointers(Block ancestorBlock)
This method is run as part of the ancestor Block's flushText(), to create xref pointers to the previous FOText objects within the same Block
protected void
endOfNode()
protected String
gatherContextInfo()
Block
getAncestorBlock()
Length
getBaseLineShift()
Color
getColor()
CommonFont
getCommonFont()
CommonHyphenation
getCommonHyphenation()
KeepProperty
getKeepTogether()
Property
getLetterSpacing()
SpaceProperty
getLineHeight()
String
getLocalName()
FOText
getNextFOTextThisBlock()
String
getNormalNamespacePrefix()
FOText
getPrevFOTextThisBlock()
CommonTextDecoration
getTextDecoration()
int
getWhitespaceTreatment()
Property
getWordSpacing()
int
getWrapOption()
static int
isWordChar(char inputChar)
Determines whether the input char should be considered part of a "word".
String
toString()
boolean
willCreateArea()
Check if this text node will create an area.

Methods inherited from class org.apache.fop.fo.FONode

addCharacters, addChildNode, attachSiblings, attributeError, attributeWarning, bind, canHaveMarkers, charIterator, clone, clone, createPropertyList, decorateWithContextInfo, endOfNode, errorText, gatherContextInfo, getChildNodes, getChildNodes, getContentHandlerFactory, getContextInfo, getExtensionAttachment, getFOEventHandler, getLocalName, getLocator, getLocatorString, getLogger, getName, getName, getNameId, getNamespaceURI, getNodeString, getNormalNamespacePrefix, getParent, getRoot, getUserAgent, inMarker, invalidChildError, invalidChildError, missingChildElementError, missingPropertyError, nodesOutOfOrderError, processNode, removeChild, setLocator, startOfNode, tooManyNodesError, tooManyNodesError, validateChildNode, validateChildNode, warningText

Field Details

ca

public char[] ca
the character array containing the text

endIndex

public int endIndex
The ending valid index of the ca array to be processed. This value is originally equal to ca.length, but becomes decremented during between-word whitespace removal by the XMLWhiteSpaceHandler via the TextCharIterator.remove() method below.

startIndex

public int startIndex
The starting valid index of the ca array to be processed. This value is originally equal to 0, but becomes incremented during leading whitespace removal by the flow.Block class, via the TextCharIterator.remove() method below.

Constructor Details

FOText

public FOText(FONode parent)
Creates a now FO text node.
Parameters:
parent - FONode that is the parent of this object

Method Details

addCharacters

protected void addCharacters(char[] data,
                             int start,
                             int end,
                             PropertyList list,
                             Locator locator)
            throws FOPException
Overrides:
addCharacters in interface FONode

bind

public void bind(PropertyList pList)
            throws FOPException
Overrides:
bind in interface FONode

charIterator

public CharIterator charIterator()
Overrides:
charIterator in interface FONode
Returns:
a new TextCharIterator

clone

public FONode clone(FONode parent,
                    boolean removeChildren)
            throws FOPException
Overrides:
clone in interface FONode

createBlockPointers

protected void createBlockPointers(Block ancestorBlock)
This method is run as part of the ancestor Block's flushText(), to create xref pointers to the previous FOText objects within the same Block

endOfNode

protected void endOfNode()
            throws FOPException
Overrides:
endOfNode in interface FONode

gatherContextInfo

protected String gatherContextInfo()
Overrides:
gatherContextInfo in interface FONode

getAncestorBlock

public Block getAncestorBlock()
Returns:
The nearest ancestor block object which contains this FOText.

getBaseLineShift

public Length getBaseLineShift()
Returns:
the baseline-shift property

getColor

public Color getColor()
Returns:
the "color" property.

getCommonFont

public CommonFont getCommonFont()
Returns:
the Common Font Properties.

getCommonHyphenation

public CommonHyphenation getCommonHyphenation()
Returns:
the Common Hyphenation Properties.

getKeepTogether

public KeepProperty getKeepTogether()
Returns:
the "keep-together" property.

getLetterSpacing

public Property getLetterSpacing()
Returns:
the "letter-spacing" property.

getLineHeight

public SpaceProperty getLineHeight()
Returns:
the "line-height" property.

getLocalName

public String getLocalName()
Overrides:
getLocalName in interface FONode

getNextFOTextThisBlock

public FOText getNextFOTextThisBlock()
Returns:
The next FOText node in this Block; null if this is the last FOText in this Block; null if subsequent FOText nodes have not yet been processed.

getNormalNamespacePrefix

public String getNormalNamespacePrefix()
Overrides:
getNormalNamespacePrefix in interface FONode

getPrevFOTextThisBlock

public FOText getPrevFOTextThisBlock()
Returns:
The previous FOText node in this Block; null, if this is the first FOText in this Block.

getTextDecoration

public CommonTextDecoration getTextDecoration()
Returns:
the "text-decoration" property.

getWhitespaceTreatment

public int getWhitespaceTreatment()
Returns:
the "white-space-treatment" property

getWordSpacing

public Property getWordSpacing()
Returns:
the "word-spacing" property.

getWrapOption

public int getWrapOption()
Returns:
the "wrap-option" property.

isWordChar

public static int isWordChar(char inputChar)
Determines whether the input char should be considered part of a "word". This is used primarily to determine whether the character immediately following starts a new word, but may have other uses. We have not found a definition of "word" in the standard (1.0), so the logic used here is based on the programmer's best guess.
Parameters:
inputChar - the character to be tested.
Returns:
int IS_WORD_CHAR_TRUE, IS_WORD_CHAR_FALSE, or IS_WORD_CHAR_MAYBE, depending on whether the character should be considered part of a word or not.

toString

public String toString()

willCreateArea

public boolean willCreateArea()
Check if this text node will create an area. This means either there is non-whitespace or it is preserved whitespace. Maybe this just needs to check length > 0, since char iterators handle whitespace.
Returns:
true if this will create an area in the output

Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.