Package org.apache.fop.fo
Class FOText
java.lang.Object
org.apache.fop.fo.FONode
org.apache.fop.fo.FOText
- All Implemented Interfaces:
CharSequence
,Cloneable
,TextFragment
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, nodeChangeBarList, parent, siblings, startOfNodeChangeBarList
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
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 givenPropertyList
to this node Does nothing by default.protected void
characters
(char[] data, int start, int length, PropertyList list, Locator locator) Adds characters.char
charAt
(int position) Obtain character at specified index within this fragment's sub-sequence, where index 0 corresponds to beginning index in overal text source, and subSequenceIndex must be less than ending index - beginning index.Return aCharIterator
over all characters in this nodePerforms a shallow cloning operation, sets the clone's parent, and optionally cleans the list of child nodesprotected Stack<DelimitedTextRange>
collectDelimitedTextRanges
(Stack<DelimitedTextRange> 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 Blockvoid
Primarily used for making final content model validation checks and/or informing theFOEventHandler
that the end of this FO has been reached.void
Finalize this node.protected String
Gathers context information for the getContextInfo() method.int
Obtain beginning index (inclusive) of sub-sequence of fragment in overall text source.int
Obtain associated bidi level (if known) or -1 if not.int[]
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).Return the array of characters for this instance.getColor()
int
Obtain ending index (exclusive) of sub-sequence of fragment in overall text source.Obtain reference to underlying iterator.Obtain associated language (if designated) or "none" if not.Returns the local name (i.e.Returns the normally used namespace prefix for this nodeObtain associated script (if designated) or "auto" if not.Returns the structure tree element associated to this object.int
int
boolean
isDelimitedTextRangeBoundary
(int boundary) Determine if node has a delimited text range boundary.int
length()
void
Resets the backingjava.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.subSequence
(int start, int end) toString()
boolean
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, getChangeBarList, getChildNodes, getChildNodes, getContentHandlerFactory, getContextInfo, getContextInfoAlt, getExtensionAttachment, getFOEventHandler, getFOValidationEventProducer, getLocator, getLocatorString, getLogger, getName, getName, getNameId, getNamespaceURI, getNodePrefix, getNodeString, getParent, getRoot, getUserAgent, inMarker, invalidChildError, invalidChildError, invalidPropertyValueError, isBidiRangeBlockItem, isChangeBarElement, missingChildElementError, missingChildElementError, missingPropertyError, nodesOutOfOrderError, nodesOutOfOrderError, notSupportedChildError, 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
Methods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Constructor Details
-
FOText
Creates a new FO text node.- Parameters:
parent
- FONode that is the parent of this object
-
-
Method Details
-
characters
protected void characters(char[] data, int start, int length, PropertyList list, Locator locator) throws FOPException Adds characters. Does nothing by default. To be overridden in subclasses that allow#PCDATA
content.- Overrides:
characters
in classFONode
- Parameters:
data
- array of characters containing text to be addedstart
- starting array element to addlength
- number of elements to addlist
- currently applicable PropertyListlocator
- location in the XSL-FO source file.- Throws:
FOPException
- if there's a problem during processing
-
getCharSequence
Return the array of characters for this instance.- Returns:
- a char sequence containing the text
-
clone
Performs a shallow cloning operation, sets the clone's parent, and optionally cleans the list of child nodes- Overrides:
clone
in classFONode
- Parameters:
parent
- the intended parent of the cloneremoveChildren
- 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
Bind the givenPropertyList
to this node Does nothing by default. Subclasses should override this method in case they want to use the properties available on thePropertyList
.- Overrides:
bind
in classFONode
- Parameters:
pList
- thePropertyList
- Throws:
FOPException
- if there was an error when processing thePropertyList
-
endOfNode
Primarily used for making final content model validation checks and/or informing theFOEventHandler
that the end of this FO has been reached. The default implementation simply callsFONode.finalizeNode()
, without sending any event to theFOEventHandler
.Note: the recommended way to override this method in subclasses is
super.endOfNode(); // invoke finalizeNode()
getFOEventHandler().endXXX(); // send endOfNode() notification
- Overrides:
endOfNode
in classFONode
- 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 theFOEventHandler
. The method is called by the defaultFONode.endOfNode()
implementation.- Overrides:
finalizeNode
in classFONode
-
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
Description copied from class:FONode
Return aCharIterator
over all characters in this node- Overrides:
charIterator
in classFONode
- Returns:
- a new TextCharIterator
-
createBlockPointers
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
- Returns:
- the Common Font Properties.
-
getCommonHyphenation
- Returns:
- the Common Hyphenation Properties.
-
getColor
- Returns:
- the "color" trait.
-
getKeepTogether
- Returns:
- the "keep-together" trait.
-
getLetterSpacing
- Returns:
- the "letter-spacing" trait.
-
getLineHeight
- Returns:
- the "line-height" trait.
-
getWhitespaceTreatment
public int getWhitespaceTreatment()- Returns:
- the "white-space-treatment" trait
-
getWordSpacing
- Returns:
- the "word-spacing" trait.
-
getWrapOption
public int getWrapOption()- Returns:
- the "wrap-option" trait.
-
getTextDecoration
- Returns:
- the "text-decoration" trait.
-
getBaseLineShift
- Returns:
- the baseline-shift trait
-
getCountry
- Returns:
- the country trait
-
getIterator
Description copied from interface:TextFragment
Obtain reference to underlying iterator.- Specified by:
getIterator
in interfaceTextFragment
-
getBeginIndex
public int getBeginIndex()Description copied from interface:TextFragment
Obtain beginning index (inclusive) of sub-sequence of fragment in overall text source.- Specified by:
getBeginIndex
in interfaceTextFragment
-
getEndIndex
public int getEndIndex()Description copied from interface:TextFragment
Obtain ending index (exclusive) of sub-sequence of fragment in overall text source.- Specified by:
getEndIndex
in interfaceTextFragment
-
getLanguage
Description copied from interface:TextFragment
Obtain associated language (if designated) or "none" if not.- Specified by:
getLanguage
in interfaceTextFragment
-
getScript
Description copied from interface:TextFragment
Obtain associated script (if designated) or "auto" if not.- Specified by:
getScript
in interfaceTextFragment
-
getBidiLevel
public int getBidiLevel()Description copied from interface:TextFragment
Obtain associated bidi level (if known) or -1 if not.- Specified by:
getBidiLevel
in interfaceTextFragment
-
toString
- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
-
getLocalName
Returns the local name (i.e. without namespace prefix) of the node- Specified by:
getLocalName
in classFONode
- Returns:
- the local name of this node
-
getNormalNamespacePrefix
Returns the normally used namespace prefix for this node- Specified by:
getNormalNamespacePrefix
in classFONode
- Returns:
- the normally used namespace prefix for this kind of node (ex. "fo" for XSL-FO)
-
gatherContextInfo
Gathers context information for the getContextInfo() method.- Overrides:
gatherContextInfo
in classFONode
- Returns:
- the collected context information or null, if none is available
-
charAt
public char charAt(int position) Obtain character at specified index within this fragment's sub-sequence, where index 0 corresponds to beginning index in overal text source, and subSequenceIndex must be less than ending index - beginning index.- Specified by:
charAt
in interfaceCharSequence
- Specified by:
charAt
in interfaceTextFragment
-
subSequence
- Specified by:
subSequence
in interfaceCharSequence
- Specified by:
subSequence
in interfaceTextFragment
-
length
public int length()- Specified by:
length
in interfaceCharSequence
-
resetBuffer
public void resetBuffer()Resets the backingjava.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 classFONode
- 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
Description copied from class:FONode
Sets the structure tree element.- Overrides:
setStructureTreeElement
in classFONode
- Parameters:
structureTreeElement
- set.
-
getStructureTreeElement
Description copied from class:FONode
Returns the structure tree element associated to this object.- Overrides:
getStructureTreeElement
in classFONode
- 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 levelstart
- the starting index of intervalend
- 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 intervalend
- the ending index of interval- Returns:
- a (possibly empty) array of bidi levels or null in case no bidi levels have been assigned
-
bidiLevelAt
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:
IndexOutOfBoundsException
- if position is not non-negative integer or is greater than or equal to length
-
collectDelimitedTextRanges
protected Stack<DelimitedTextRange> collectDelimitedTextRanges(Stack<DelimitedTextRange> 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 classFONode
- Parameters:
ranges
- a stack of delimited text rangescurrentRange
- the current range or null (if none)- Returns:
- the (possibly) updated stack of delimited text ranges
-