Package org.apache.fop.fo
Class XMLWhiteSpaceHandler
- java.lang.Object
-
- org.apache.fop.fo.XMLWhiteSpaceHandler
-
public class XMLWhiteSpaceHandler extends java.lang.ObjectClass encapsulating the functionality for white-space-handling during refinement stage. ThehandleWhiteSpace()methods are called during FOTree-building and marker-cloning:
- from
FObjMixed.addChildNode() - from
FObjMixed.endOfNode() - from
FObjMixed.handleWhiteSpaceFor()
Each time one of the variants is called, white-space is handled for allFOTextorCharacternodes that were added:
- either prior to
newChild(and after the previous non-text child node) - or, if
newChildisnull, after the previous non-text child
The iteration always starts atfirstTextNode, goes on until the last text-node is reached, and deals only withFOTextorCharacternodes.
Note: if the method is called from an inline's endOfNode(), there is too little context to decide whether trailing white-space may be removed, so the pending inline is stored in a List, together with an iterator for which the next() method returns the first in the trailing sequence of white- space characters. This List is processed again at the end of the ancestor block. - from
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classXMLWhiteSpaceHandler.EOLcheckerHelper class, used during white-space handling to look ahead, and see if the next character is a linefeed (or if there will be an equivalent effect during layout, i.e.private classXMLWhiteSpaceHandler.PendingInlineHelper class to store unfinished inline nodes together with an iterator that starts at the first white-space character in the sequence of trailing white-space
-
Field Summary
Fields Modifier and Type Field Description private booleanafterLinefeedTrue if the last char was a linefeedprivate RecursiveCharIteratorcharIterprivate booleanendOfBlockprivate CharIteratorfirstWhiteSpaceInSeqprivate booleaninWhiteSpaceTrue if we are in a run of white spaceprivate intlinefeedTreatmentprivate java.util.StacknestedBlockStackprivate booleannextChildIsBlockLevelprivate intnonWhiteSpaceCountCounter, increased every time a non-white-space is encounteredprivate java.util.ListpendingInlinesprivate intwhiteSpaceCollapseprivate intwhiteSpaceTreatment
-
Constructor Summary
Constructors Constructor Description XMLWhiteSpaceHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddPendingInline()private voidhandlePendingInlines()private voidhandleWhiteSpace()voidhandleWhiteSpace(FObjMixed fo, FONode firstTextNode)Handle white-space for the fo that is passed in, starting at firstTextNode (when a nested FO is encountered)voidhandleWhiteSpace(FObjMixed fo, FONode firstTextNode, FONode nextChild)Handle white-space for the fo that is passed in, starting at firstTextNodeprotected voidreset()Reset the handler, release all references
-
-
-
Field Detail
-
inWhiteSpace
private boolean inWhiteSpace
True if we are in a run of white space
-
afterLinefeed
private boolean afterLinefeed
True if the last char was a linefeed
-
nonWhiteSpaceCount
private int nonWhiteSpaceCount
Counter, increased every time a non-white-space is encountered
-
linefeedTreatment
private int linefeedTreatment
-
whiteSpaceTreatment
private int whiteSpaceTreatment
-
whiteSpaceCollapse
private int whiteSpaceCollapse
-
endOfBlock
private boolean endOfBlock
-
nextChildIsBlockLevel
private boolean nextChildIsBlockLevel
-
charIter
private RecursiveCharIterator charIter
-
pendingInlines
private java.util.List pendingInlines
-
nestedBlockStack
private java.util.Stack nestedBlockStack
-
firstWhiteSpaceInSeq
private CharIterator firstWhiteSpaceInSeq
-
-
Method Detail
-
handleWhiteSpace
public void handleWhiteSpace(FObjMixed fo, FONode firstTextNode, FONode nextChild)
Handle white-space for the fo that is passed in, starting at firstTextNode- Parameters:
fo- the FO for which to handle white-spacefirstTextNode- the node at which to startnextChild- the node that will be added to the list after firstTextNode
-
reset
protected final void reset()
Reset the handler, release all references
-
handleWhiteSpace
public void handleWhiteSpace(FObjMixed fo, FONode firstTextNode)
Handle white-space for the fo that is passed in, starting at firstTextNode (when a nested FO is encountered)- Parameters:
fo- the FO for which to handle white-spacefirstTextNode- the node at which to start
-
handleWhiteSpace
private void handleWhiteSpace()
-
addPendingInline
private void addPendingInline()
-
handlePendingInlines
private void handlePendingInlines()
-
-