public abstract class FONode extends Object implements Cloneable
Modifier and Type | Class and Description |
---|---|
static interface |
FONode.FONodeIterator
Base iterator interface over a FO's children, offering three methods on top of the base interface
methods.
|
static class |
FONode.GatherContextInfoFunction
Function for AdvancedMessageFormat to retrieve context info from an FONode.
|
Modifier and Type | Field and Description |
---|---|
protected static String |
FO_URI
the XSL-FO namespace URI
|
protected static String |
FOX_URI
FOP's proprietary extension namespace URI
|
protected Locator |
locator
Marks the location of this object from the input FO
Call locator.getSystemId() ,
getLineNumber() ,
getColumnNumber() for file, line, column
information |
protected static org.apache.commons.logging.Log |
log
Logger for fo-tree related messages
|
protected List<ChangeBar> |
nodeChangeBarList
The list of active change bars for the given node
|
protected FONode |
parent
Parent FO node
|
protected FONode[] |
siblings
pointer to the sibling nodes
|
protected List<ChangeBar> |
startOfNodeChangeBarList
The list of active change bars for the start of the given node
|
Modifier | Constructor and Description |
---|---|
protected |
FONode(FONode parent)
Base constructor
|
Modifier and Type | Method and Description |
---|---|
protected void |
addCharacters(char[] data,
int start,
int end,
PropertyList pList,
Locator locator)
Deprecated.
Please override
characters(char[], int, int, PropertyList, Locator)
instead! |
protected void |
addChildNode(FONode child)
Adds a node as a child of this node.
|
protected static void |
attachSiblings(FONode precedingSibling,
FONode followingSibling)
This method is used when adding child nodes to a FO that already
contains at least one child.
|
void |
bind(PropertyList propertyList)
Bind the given
PropertyList to this node
Does nothing by default. |
protected boolean |
canHaveMarkers()
Returns
true if fo:marker is allowed as
a child node. |
protected void |
characters(char[] data,
int start,
int length,
PropertyList pList,
Locator locator)
Adds characters.
|
CharIterator |
charIterator()
Return a
CharIterator over all characters in this node |
protected Object |
clone() |
FONode |
clone(FONode cloneparent,
boolean removeChildren)
Performs a shallow cloning operation, sets the clone's parent,
and optionally cleans the list of child nodes
|
Stack<DelimitedTextRange> |
collectDelimitedTextRanges(Stack<DelimitedTextRange> ranges)
Collect the sequence of delimited text ranges, where each new
range is pushed onto RANGES.
|
protected 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 PropertyList |
createPropertyList(PropertyList pList,
FOEventHandler foEventHandler)
Create a property list for this node.
|
static String |
decorateWithContextInfo(String text,
FONode node)
Decorates a log or warning message with context information on the given node.
|
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. |
protected static String |
errorText(Locator loc)
Helper function to return "Error(line#/column#)" string for
above exception messages
|
void |
finalizeNode()
Finalize this node.
|
protected String |
gatherContextInfo()
Gathers context information for the getContextInfo() method.
|
FOTreeBuilderContext |
getBuilderContext()
Returns the context class providing information used during FO tree building.
|
List<ChangeBar> |
getChangeBarList()
Returns the list of active change bars.
|
FONode.FONodeIterator |
getChildNodes()
Return an iterator over all the child nodes of this node.
|
FONode.FONodeIterator |
getChildNodes(FONode childNode)
Return an iterator over the object's child nodes starting
at the passed node.
|
ContentHandlerFactory |
getContentHandlerFactory()
This method is overridden by extension elements and allows the extension element to return
a
ContentHandlerFactory . |
String |
getContextInfo()
Returns a String containing as much context information as possible about a node.
|
protected String |
getContextInfoAlt()
Returns a String containing as some context information about a node.
|
ExtensionAttachment |
getExtensionAttachment()
This method is overridden by extension elements and allows the extension element
to return a pass-through attachment which the parent formatting objects should simply
carry with them but otherwise ignore.
|
FOEventHandler |
getFOEventHandler()
Recursively goes up the FOTree hierarchy until the
fo:root
is found, which returns the parent FOEventHandler . |
protected FOValidationEventProducer |
getFOValidationEventProducer()
Returns an instance of the FOValidationEventProducer.
|
abstract String |
getLocalName()
Returns the local name (i.e.
|
Locator |
getLocator()
Returns the
Locator containing the location information for this
element, or null if not available |
static String |
getLocatorString(Locator loc)
Helper function to format a Locator instance.
|
org.apache.commons.logging.Log |
getLogger()
Returns the logger for the node.
|
String |
getName()
Returns the fully qualified name of the node
|
String |
getName(String prefix)
Returns the fully qualified name of the node
|
int |
getNameId()
Returns the
Constants class integer value of this node |
String |
getNamespaceURI()
Returns the namespace URI for this node
|
static String |
getNodePrefix(String namespaceURI)
Helper function to obtain standard usage prefix for FOP related
namespace URIs.
|
static String |
getNodeString(String namespaceURI,
String localName)
Helper function to standardize the names of all namespace URI - local
name pairs in text messages.
|
abstract String |
getNormalNamespacePrefix()
Returns the normally used namespace prefix for this node
|
FONode |
getParent()
Return the parent node of this node
|
Root |
getRoot()
Returns the root node of this tree
|
StructureTreeElement |
getStructureTreeElement()
Returns the structure tree element associated to this object.
|
FOUserAgent |
getUserAgent()
Returns the user agent that is associated with the
tree's
FOEventHandler . |
protected boolean |
inMarker()
Indicates whether this node is a child of an fo:marker.
|
protected void |
invalidChildError(Locator loc,
String nsURI,
String lName)
Helper function to return "invalid child" exceptions
(e.g.,
fo:block appearing immediately under fo:root ) |
protected void |
invalidChildError(Locator loc,
String parentName,
String nsURI,
String lName,
String ruleViolated)
Helper function to return "invalid child" exceptions with more
complex validation rules (i.e., needing more explanation of the problem)
|
protected void |
invalidPropertyValueError(String propertyName,
String propertyValue,
Exception e)
Helper function to throw an error caused by an invalid property
|
boolean |
isBidiRangeBlockItem()
Determine if this node is a new bidi RANGE block item.
|
boolean |
isChangeBarElement(String namespaceURI,
String localName)
Tests if the given element is a change bar element.
|
boolean |
isDelimitedTextRangeBoundary(int boundary)
Determine if node has a delimited text range boundary.
|
protected void |
missingChildElementError(String contentModel)
Helper function to throw an error caused by missing mandatory child elements.
|
protected void |
missingChildElementError(String contentModel,
boolean canRecover)
Helper function to throw an error caused by missing mandatory child elements.
|
protected void |
missingPropertyError(String propertyName)
Helper function to throw an error caused by missing mandatory properties
|
protected void |
nodesOutOfOrderError(Locator loc,
String tooLateNode,
String tooEarlyNode)
Helper function to standardize "out of order" exceptions
(e.g.,
fo:layout-master-set appearing after fo:page-sequence ) |
protected void |
nodesOutOfOrderError(Locator loc,
String tooLateNode,
String tooEarlyNode,
boolean canRecover)
Helper function to standardize "out of order" exceptions
(e.g., fo:layout-master-set appearing after fo:page-sequence)
|
protected void |
notSupportedChildError(Locator loc,
String nsURI,
String lName)
Helper function to return "not supported child" exceptions.
|
void |
processNode(String elementName,
Locator locator,
Attributes attlist,
PropertyList pList)
Initialize the node with its name, location information, and attributes
The attributes must be used immediately as the sax attributes
will be altered for the next element.
|
void |
removeChild(FONode child)
Removes a child node.
|
void |
setLocator(Locator locator)
Set the location information for this element
|
void |
setStructureTreeElement(StructureTreeElement structureTreeElement)
Sets the structure tree element.
|
void |
startOfNode()
Called after processNode() is called.
|
protected void |
tooManyNodesError(Locator loc,
org.apache.xmlgraphics.util.QName offendingNode)
Helper function to standardize "too many" error exceptions
(e.g., two
fo:declarations within fo:root ) |
protected void |
tooManyNodesError(Locator loc,
String offendingNode)
Helper function to standardize "too many" error exceptions
(e.g., two fo:declarations within fo:root)
This overloaded method helps make the caller code better self-documenting
|
protected void |
tooManyNodesError(Locator loc,
String nsURI,
String lName)
Helper function to standardize "too many" error exceptions
(e.g., two fo:declarations within fo:root)
|
protected static void |
validateChildNode(FONode fo,
Locator loc,
String namespaceURI,
String localName)
Static version of
validateChildNode(Locator, String, String) that
can be used by subclasses that need to validate children against a different node
(for example: fo:wrapper needs to check if the incoming node is a
valid child to its parent) |
protected void |
validateChildNode(Locator loc,
String namespaceURI,
String localName)
Checks to make sure, during SAX processing of input document, that the
incoming node is valid for this (parent) node (e.g., checking to
see that
fo:table is not an immediate child of fo:root )
called from FOTreeBuilder.startElement(String, String, String, Attributes)
before constructing the child FObj . |
protected static String |
warningText(Locator loc)
Helper function to return "Warning(line#/column#)" string for
warning messages
|
protected static final String FO_URI
protected static final String FOX_URI
protected FONode parent
protected FONode[] siblings
protected List<ChangeBar> nodeChangeBarList
protected List<ChangeBar> startOfNodeChangeBarList
protected Locator locator
locator.getSystemId()
,
getLineNumber()
,
getColumnNumber()
for file, line, column
informationprotected static final org.apache.commons.logging.Log log
protected FONode(FONode parent)
parent
- parent of this nodepublic FONode clone(FONode cloneparent, boolean removeChildren) throws FOPException
cloneparent
- the intended parent of the cloneremoveChildren
- if true, clean the list of child nodesFOPException
- if there's a problem while cloning the nodepublic void bind(PropertyList propertyList) throws FOPException
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
.propertyList
- the PropertyList
FOPException
- if there was an error when
processing the PropertyList
public void setLocator(Locator locator)
locator
- the org.xml.sax.Locator objectpublic Locator getLocator()
Locator
containing the location information for this
element, or null
if not availablenull
, if not availablepublic FOEventHandler getFOEventHandler()
fo:root
is found, which returns the parent FOEventHandler
.
Root.getFOEventHandler()
)public FOTreeBuilderContext getBuilderContext()
protected boolean inMarker()
public boolean isChangeBarElement(String namespaceURI, String localName)
namespaceURI
- The name space of the elementlocalName
- The local name of the elementpublic FOUserAgent getUserAgent()
FOEventHandler
.public org.apache.commons.logging.Log getLogger()
public void processNode(String elementName, Locator locator, Attributes attlist, PropertyList pList) throws FOPException
elementName
- element name (e.g., "fo:block")locator
- Locator object (ignored by default)attlist
- Collection of attributes passed to us from the parser.pList
- the property list of the parent nodeFOPException
- for errors or inconsistencies in the attributesprotected PropertyList createPropertyList(PropertyList pList, FOEventHandler foEventHandler) throws FOPException
pList
- the closest parent propertylist.foEventHandler
- The FOEventHandler where the PropertyListMaker
instance can be found.FOPException
- if there's a problem during processingprotected void validateChildNode(Locator loc, String namespaceURI, String localName) throws ValidationException
fo:table
is not an immediate child of fo:root
)
called from FOTreeBuilder.startElement(String, String, String, Attributes)
before constructing the child FObj
.loc
- location in the FO source filenamespaceURI
- namespace of incoming nodelocalName
- name of the incoming node (without namespace prefix)ValidationException
- if incoming node not valid for parentprotected static void validateChildNode(FONode fo, Locator loc, String namespaceURI, String localName) throws ValidationException
validateChildNode(Locator, String, String)
that
can be used by subclasses that need to validate children against a different node
(for example: fo:wrapper
needs to check if the incoming node is a
valid child to its parent)fo
- the FONode
to validate againstloc
- location in the source filenamespaceURI
- namespace of the incoming nodelocalName
- name of the incoming node (without namespace prefix)ValidationException
- if the incoming node is not a valid child for the given FOprotected void addCharacters(char[] data, int start, int end, PropertyList pList, Locator locator) throws FOPException
characters(char[], int, int, PropertyList, Locator)
instead!#PCDATA
content.data
- array of characters containing text to be addedstart
- starting array element to addend
- ending array element to addpList
- currently applicable PropertyListlocator
- location in the XSL-FO source file.FOPException
- if there's a problem during processingprotected void characters(char[] data, int start, int length, PropertyList pList, Locator locator) throws FOPException
#PCDATA
content.data
- array of characters containing text to be addedstart
- starting array element to addlength
- number of elements to addpList
- currently applicable PropertyListlocator
- location in the XSL-FO source file.FOPException
- if there's a problem during processingpublic void startOfNode() throws FOPException
FOPException
- if there's a problem during processingpublic void endOfNode() throws FOPException
FOEventHandler
that the end of this FO
has been reached.
The default implementation simply calls 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
FOPException
- if there's a problem during processingprotected void addChildNode(FONode child) throws FOPException
child
- child node to be added to the childNodes of this nodeFOPException
- if there's a problem during processingpublic void removeChild(FONode child)
child
- child node to be removedpublic void finalizeNode() throws FOPException
FOEventHandler
.
The method is called by the default endOfNode()
implementation.FOPException
- in case there was an errorpublic FONode getParent()
public FONode.FONodeIterator getChildNodes()
public FONode.FONodeIterator getChildNodes(FONode childNode)
childNode
- First node in the iteratornull
if
the given node is not a child of this node.public CharIterator charIterator()
CharIterator
over all characters in this nodepublic static String getNodePrefix(String namespaceURI)
namespaceURI
- URI of node found
(e.g., "http://www.w3.org/1999/XSL/Format")public static String getNodeString(String namespaceURI, String localName)
namespaceURI
- URI of node found
(e.g., "http://www.w3.org/1999/XSL/Format")localName
- local name of node, (e.g., "root" for "fo:root")protected FOValidationEventProducer getFOValidationEventProducer()
protected void tooManyNodesError(Locator loc, String nsURI, String lName) throws ValidationException
loc
- org.xml.sax.Locator object of the error (*not* parent node)nsURI
- namespace URI of incoming invalid nodelName
- local name (i.e., no prefix) of incoming nodeValidationException
- the validation error provoked by the method callprotected void tooManyNodesError(Locator loc, org.apache.xmlgraphics.util.QName offendingNode) throws ValidationException
fo:declarations
within fo:root
)loc
- org.xml.sax.Locator object of the error (*not* parent node)offendingNode
- the qualified name of the offending nodeValidationException
- the validation error provoked by the method callprotected void tooManyNodesError(Locator loc, String offendingNode) throws ValidationException
loc
- org.xml.sax.Locator object of the error (*not* parent node)offendingNode
- incoming node that would cause a duplication.ValidationException
- the validation error provoked by the method callprotected void nodesOutOfOrderError(Locator loc, String tooLateNode, String tooEarlyNode) throws ValidationException
fo:layout-master-set
appearing after fo:page-sequence
)loc
- org.xml.sax.Locator object of the error (*not* parent node)tooLateNode
- string name of node that should be earlier in documenttooEarlyNode
- string name of node that should be later in documentValidationException
- the validation error provoked by the method callprotected void nodesOutOfOrderError(Locator loc, String tooLateNode, String tooEarlyNode, boolean canRecover) throws ValidationException
loc
- org.xml.sax.Locator object of the error (*not* parent node)tooLateNode
- string name of node that should be earlier in documenttooEarlyNode
- string name of node that should be later in documentcanRecover
- indicates whether FOP can recover from this problem and continue workingValidationException
- the validation error provoked by the method callprotected void invalidChildError(Locator loc, String nsURI, String lName) throws ValidationException
fo:block
appearing immediately under fo:root
)loc
- org.xml.sax.Locator object of the error (*not* parent node)nsURI
- namespace URI of incoming invalid nodelName
- local name (i.e., no prefix) of incoming nodeValidationException
- the validation error provoked by the method callprotected void invalidChildError(Locator loc, String parentName, String nsURI, String lName, String ruleViolated) throws ValidationException
loc
- org.xml.sax.Locator object of the error (*not* parent node)parentName
- the name of the parent elementnsURI
- namespace URI of incoming offending nodelName
- local name (i.e., no prefix) of incoming offending noderuleViolated
- name of the rule violated (used to lookup a resource in a bundle)ValidationException
- the validation error provoked by the method callprotected void notSupportedChildError(Locator loc, String nsURI, String lName) throws ValidationException
loc
- org.xml.sax.Locator object of the error (*not* parent node)nsURI
- namespace URI of incoming invalid nodelName
- local name (i.e., no prefix) of incoming nodeValidationException
- the validation error provoked by the method callprotected void missingChildElementError(String contentModel) throws ValidationException
fo:layout-master-set
not having any fo:page-master
child element.contentModel
- The XSL Content Model for the fo: object or a similar description
indicating the necessary child elements.ValidationException
- the validation error provoked by the method callprotected void missingChildElementError(String contentModel, boolean canRecover) throws ValidationException
contentModel
- The XSL Content Model for the fo: object or a similar description
indicating the necessary child elements.canRecover
- indicates whether FOP can recover from this problem and continue workingValidationException
- the validation error provoked by the method callprotected void missingPropertyError(String propertyName) throws ValidationException
propertyName
- the name of the missing property.ValidationException
- the validation error provoked by the method callprotected void invalidPropertyValueError(String propertyName, String propertyValue, Exception e) throws ValidationException
propertyName
- the name of the property.propertyValue
- the value of the property.e
- optional property parsing exception.ValidationException
- the validation error provoked by the method callprotected static String errorText(Locator loc)
loc
- org.xml.sax.Locator objectprotected static String warningText(Locator loc)
loc
- org.xml.sax.Locator objectpublic static String getLocatorString(Locator loc)
loc
- org.xml.sax.Locator objectpublic static String decorateWithContextInfo(String text, FONode node)
text
- the original messagenode
- the context nodepublic String getContextInfo()
protected String getContextInfoAlt()
protected String gatherContextInfo()
public Root getRoot()
public String getName()
public String getName(String prefix)
prefix
- the namespace prefix to build the name with (may be null)public abstract String getLocalName()
public abstract String getNormalNamespacePrefix()
public String getNamespaceURI()
public int getNameId()
Constants
class integer value of this nodeConstants.FO_ROOT
)
if a formatting object, Constants.FO_UNKNOWN_NODE
otherwisepublic ExtensionAttachment getExtensionAttachment()
public ContentHandlerFactory getContentHandlerFactory()
ContentHandlerFactory
. This factory can create ContentHandler implementations that
handle foreign XML content by either building up a specific DOM, a Java object or something
else.ContentHandlerFactory
or null
if not applicableprotected boolean canHaveMarkers()
true
if fo:marker
is allowed as
a child node.
protected static void attachSiblings(FONode precedingSibling, FONode followingSibling)
precedingSibling
- the previous childfollowingSibling
- the new childpublic boolean isDelimitedTextRangeBoundary(int boundary)
boundary
- one of {EN_BEFORE, EN_AFTER, or EN_BOTH} enumeration constantspublic Stack<DelimitedTextRange> collectDelimitedTextRanges(Stack<DelimitedTextRange> ranges)
ranges
- a stack of delimited text rangesprotected Stack<DelimitedTextRange> collectDelimitedTextRanges(Stack<DelimitedTextRange> ranges, DelimitedTextRange currentRange)
ranges
- a stack of delimited text rangescurrentRange
- the current range or null (if none)public boolean isBidiRangeBlockItem()
public List<ChangeBar> getChangeBarList()
public void setStructureTreeElement(StructureTreeElement structureTreeElement)
structureTreeElement
- set.public StructureTreeElement getStructureTreeElement()
Copyright © 2025 Apache Software Foundation. All rights reserved.