fop 1.1

org.apache.fop.fo
Class FOText

java.lang.Object
  extended by org.apache.fop.fo.FONode
      extended by org.apache.fop.fo.FOText
All Implemented Interfaces:
java.lang.CharSequence, java.lang.Cloneable

public class FOText
extends FONode
implements java.lang.CharSequence

A text node (PCDATA) in the formatting object tree.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.fop.fo.FONode
FONode.FONodeIterator, FONode.GatherContextInfoFunction
 
Field Summary
 
Fields inherited from class org.apache.fop.fo.FONode
FO_URI, FOX_URI, locator, log, parent, siblings
 
Constructor Summary
FOText(FONode parent)
          Creates a new FO text node.
 
Method Summary
 void addMapping(int start, int end, java.lang.CharSequence mappedChars)
          Add characters mapped by script substitution processing.
 int bidiLevelAt(int position)
          Obtain bidirectional level of character at specified position, which must be a non-negative integer less than the length of this FO.
 void bind(PropertyList pList)
          Bind the given PropertyList to this node Does nothing by default.
protected  void characters(char[] data, int start, int length, PropertyList list, org.xml.sax.Locator locator)
          Adds characters.
 char charAt(int position)
          
 CharIterator charIterator()
          Return a CharIterator over all characters in this node
 FONode clone(FONode parent, boolean removeChildren)
          Performs a shallow cloning operation, sets the clone's parent, and optionally cleans the list of child nodes
protected  java.util.Stack collectDelimitedTextRanges(java.util.Stack ranges, DelimitedTextRange currentRange)
          Collect the sequence of delimited text ranges, where each new range is pushed onto RANGES, where default implementation collects ranges of child nodes.
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()
          Primarily used for making final content model validation checks and/or informing the FOEventHandler that the end of this FO has been reached.
 void finalizeNode()
          Finalize this node.
protected  java.lang.String gatherContextInfo()
          Gathers context information for the getContextInfo() method.
 Length getBaseLineShift()
           
 int[] getBidiLevels()
          Obtain bidirectional level of each character represented by this FOText.
 int[] getBidiLevels(int start, int end)
          Obtain bidirectional level of each character over interval [start,end).
 java.lang.CharSequence getCharSequence()
          Return the array of characters for this instance.
 java.awt.Color getColor()
           
 CommonFont getCommonFont()
           
 CommonHyphenation getCommonHyphenation()
           
 java.lang.String getCountry()
           
 KeepProperty getKeepTogether()
           
 java.lang.String getLanguage()
           
 Property getLetterSpacing()
           
 SpaceProperty getLineHeight()
           
 java.lang.String getLocalName()
          Returns the local name (i.e.
 java.lang.String getMapping(int start, int end)
          Obtain mapping of characters over specific interval.
 int[] getMappingBidiLevels(int start, int end)
          Obtain bidirectional levels of mapping of characters over specific interval.
 int getMappingLength(int start, int end)
          Obtain length of mapping of characters over specific interval.
 java.lang.String getNormalNamespacePrefix()
          Returns the normally used namespace prefix for this node
 java.lang.String getScript()
           
 StructureTreeElement getStructureTreeElement()
           
 CommonTextDecoration getTextDecoration()
           
 int getWhitespaceTreatment()
           
 Property getWordSpacing()
           
 int getWrapOption()
           
 boolean hasMapping(int start, int end)
          Determine if characters over specific interval have a mapping.
 boolean isDelimitedTextRangeBoundary(int boundary)
          Determine if node has a delimited text range boundary.
 int length()
          
 void resetBuffer()
          Resets the backing java.nio.CharBuffer
 void setBidiLevel(int level, int start, int end)
          Set bidirectional level over interval [start,end).
 void setStructureTreeElement(StructureTreeElement structureTreeElement)
          Sets the structure tree element.
 java.lang.CharSequence subSequence(int start, int end)
          
 java.lang.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, canHaveMarkers, clone, collectDelimitedTextRanges, createPropertyList, decorateWithContextInfo, errorText, getBuilderContext, getChildNodes, getChildNodes, getContentHandlerFactory, getContextInfo, getContextInfoAlt, getExtensionAttachment, getFOEventHandler, getFOValidationEventProducer, getLocator, getLocatorString, getLogger, getName, getName, getNameId, getNamespaceURI, getNodePrefix, getNodeString, getParent, getRoot, getUserAgent, inMarker, invalidChildError, invalidChildError, isBidiRangeBlockItem, missingChildElementError, missingChildElementError, missingPropertyError, nodesOutOfOrderError, nodesOutOfOrderError, processNode, removeChild, setLocator, startOfNode, tooManyNodesError, tooManyNodesError, tooManyNodesError, validateChildNode, validateChildNode, warningText
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FOText

public FOText(FONode parent)
Creates a new FO text node.

Parameters:
parent - FONode that is the parent of this object
Method Detail

characters

protected void characters(char[] data,
                          int start,
                          int length,
                          PropertyList list,
                          org.xml.sax.Locator locator)
                   throws FOPException
Adds characters. Does nothing by default. To be overridden in subclasses that allow #PCDATA content.

Overrides:
characters in class FONode
Parameters:
data - array of characters containing text to be added
start - starting array element to add
length - number of elements to add
list - currently applicable PropertyList
locator - location in the XSL-FO source file.
Throws:
FOPException - if there's a problem during processing

getCharSequence

public java.lang.CharSequence getCharSequence()
Return the array of characters for this instance.

Returns:
a char sequence containing the text

clone

public FONode clone(FONode parent,
                    boolean removeChildren)
             throws FOPException
Performs a shallow cloning operation, sets the clone's parent, and optionally cleans the list of child nodes

Overrides:
clone in class FONode
Parameters:
parent - the intended parent of the clone
removeChildren - if true, clean the list of child nodes
Returns:
the cloned FO node
Throws:
FOPException - if there's a problem while cloning the node

bind

public void bind(PropertyList pList)
          throws FOPException
Bind the given PropertyList to this node Does nothing by default. Subclasses should override this method in case they want to use the properties available on the PropertyList.

Overrides:
bind in class FONode
Parameters:
pList - the PropertyList
Throws:
FOPException - if there was an error when processing the PropertyList

endOfNode

protected void endOfNode()
                  throws FOPException
Primarily used for making final content model validation checks and/or informing the FOEventHandler that the end of this FO has been reached. The default implementation simply calls FONode.finalizeNode(), without sending any event to the FOEventHandler.
Note: the recommended way to override this method in subclasses is

super.endOfNode(); // invoke finalizeNode()
getFOEventHandler().endXXX(); // send endOfNode() notification

Overrides:
endOfNode in class FONode
Throws:
FOPException - if there's a problem during processing

finalizeNode

public void finalizeNode()
Finalize this node. This method can be overridden by subclasses to perform finishing tasks (cleanup, validation checks, ...) without triggering endXXX() events in the FOEventHandler. The method is called by the default FONode.endOfNode() implementation.

Overrides:
finalizeNode in class FONode

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

charIterator

public CharIterator charIterator()
Description copied from class: FONode
Return a CharIterator over all characters in this node

Overrides:
charIterator in class FONode
Returns:
a new TextCharIterator

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

Parameters:
ancestorBlock - the ancestor fo:block

getCommonFont

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

getCommonHyphenation

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

getColor

public java.awt.Color getColor()
Returns:
the "color" trait.

getKeepTogether

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

getLetterSpacing

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

getLineHeight

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

getWhitespaceTreatment

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

getWordSpacing

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

getWrapOption

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

getTextDecoration

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

getBaseLineShift

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

getCountry

public java.lang.String getCountry()
Returns:
the country trait

getLanguage

public java.lang.String getLanguage()
Returns:
the language trait

getScript

public java.lang.String getScript()
Returns:
the script trait

toString

public java.lang.String toString()

Specified by:
toString in interface java.lang.CharSequence
Overrides:
toString in class java.lang.Object

getLocalName

public java.lang.String getLocalName()
Returns the local name (i.e. without namespace prefix) of the node

Specified by:
getLocalName in class FONode
Returns:
the local name of this node

getNormalNamespacePrefix

public java.lang.String getNormalNamespacePrefix()
Returns the normally used namespace prefix for this node

Specified by:
getNormalNamespacePrefix in class FONode
Returns:
the normally used namespace prefix for this kind of node (ex. "fo" for XSL-FO)

gatherContextInfo

protected java.lang.String gatherContextInfo()
Gathers context information for the getContextInfo() method.

Overrides:
gatherContextInfo in class FONode
Returns:
the collected context information or null, if none is available

charAt

public char charAt(int position)

Specified by:
charAt in interface java.lang.CharSequence

subSequence

public java.lang.CharSequence subSequence(int start,
                                          int end)

Specified by:
subSequence in interface java.lang.CharSequence

length

public int length()

Specified by:
length in interface java.lang.CharSequence

resetBuffer

public void resetBuffer()
Resets the backing java.nio.CharBuffer


isDelimitedTextRangeBoundary

public boolean isDelimitedTextRangeBoundary(int boundary)
Description copied from class: FONode
Determine if node has a delimited text range boundary. N.B. that we report this to be true by default, while specific subclasses override this method to report false.

Overrides:
isDelimitedTextRangeBoundary in class FONode
Parameters:
boundary - one of {EN_BEFORE, EN_AFTER, or EN_BOTH} enumeration constants
Returns:
true if indicated boundary (or boundaries) constitute a delimited text range boundary.

setStructureTreeElement

public void setStructureTreeElement(StructureTreeElement structureTreeElement)
Description copied from class: FONode
Sets the structure tree element.

Overrides:
setStructureTreeElement in class FONode
Parameters:
structureTreeElement - set.

getStructureTreeElement

public StructureTreeElement getStructureTreeElement()
Returns:
the structure tree element.

setBidiLevel

public void setBidiLevel(int level,
                         int start,
                         int end)
Set bidirectional level over interval [start,end).

Parameters:
level - the resolved level
start - the starting index of interval
end - the ending index of interval

getBidiLevels

public int[] getBidiLevels()
Obtain bidirectional level of each character represented by this FOText.

Returns:
a (possibly empty) array of bidi levels or null in case no bidi levels have been assigned

getBidiLevels

public int[] getBidiLevels(int start,
                           int end)
Obtain bidirectional level of each character over interval [start,end).

Parameters:
start - the starting index of interval
end - the ending index of interval
Returns:
a (possibly empty) array of bidi levels or null in case no bidi levels have been assigned

bidiLevelAt

public int bidiLevelAt(int position)
                throws java.lang.IndexOutOfBoundsException
Obtain bidirectional level of character at specified position, which must be a non-negative integer less than the length of this FO.

Parameters:
position - an offset position into FO's characters
Returns:
a resolved bidi level or -1 if default
Throws:
java.lang.IndexOutOfBoundsException - if position is not non-negative integer or is greater than or equal to length

addMapping

public void addMapping(int start,
                       int end,
                       java.lang.CharSequence mappedChars)
Add characters mapped by script substitution processing.

Parameters:
start - index in character buffer
end - index in character buffer
mappedChars - sequence of character codes denoting substituted characters

hasMapping

public boolean hasMapping(int start,
                          int end)
Determine if characters over specific interval have a mapping.

Parameters:
start - index in character buffer
end - index in character buffer
Returns:
true if a mapping exist such that the mapping's interval is coincident to [start,end)

getMapping

public java.lang.String getMapping(int start,
                                   int end)
Obtain mapping of characters over specific interval.

Parameters:
start - index in character buffer
end - index in character buffer
Returns:
a string of characters representing the mapping over the interval [start,end)

getMappingLength

public int getMappingLength(int start,
                            int end)
Obtain length of mapping of characters over specific interval.

Parameters:
start - index in character buffer
end - index in character buffer
Returns:
the length of the mapping (if present) or zero

getMappingBidiLevels

public int[] getMappingBidiLevels(int start,
                                  int end)
Obtain bidirectional levels of mapping of characters over specific interval.

Parameters:
start - index in character buffer
end - index in character buffer
Returns:
a (possibly empty) array of bidi levels or null in case no bidi levels have been assigned

collectDelimitedTextRanges

protected java.util.Stack collectDelimitedTextRanges(java.util.Stack ranges,
                                                     DelimitedTextRange currentRange)
Description copied from class: FONode
Collect the sequence of delimited text ranges, where each new range is pushed onto RANGES, where default implementation collects ranges of child nodes.

Overrides:
collectDelimitedTextRanges in class FONode
Parameters:
ranges - a stack of delimited text ranges
currentRange - the current range or null (if none)
Returns:
the (possibly) updated stack of delimited text ranges

fop 1.1

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