From 3935df25decaf8413f36bdddedac2005dafa103d Mon Sep 17 00:00:00 2001 From: Peter Bernard West Date: Wed, 13 Nov 2002 04:04:48 +0000 Subject: [PATCH] Created stateFlags. Moved attribute set constants from FOPropertySets and merged with stateFlags. Changed attrSet argument to constructor to a stateFlags arg. Removed numProps arg from constructor. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@195510 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/fo/FONode.java | 74 ++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 15 deletions(-) diff --git a/src/org/apache/fop/fo/FONode.java b/src/org/apache/fop/fo/FONode.java index 3d81124fb..672fe85b4 100644 --- a/src/org/apache/fop/fo/FONode.java +++ b/src/org/apache/fop/fo/FONode.java @@ -52,26 +52,57 @@ public class FONode extends Node{ private static final String tag = "$Name$"; private static final String revision = "$Revision$"; + /** + * State flags: a bit set of states applicable during FO tree build. + * N.B. States must be powers of 2. + */ + public static final int + NOSTATE = 0 + // These are used to select the attribute set for the node + ,ROOT_SET = 1 + ,DECLARATIONS_SET = 2 + ,LAYOUT_SET = 4 + ,SEQ_MASTER_SET = 8 + ,PAGESEQ_SET = 16 + ,FLOW_SET = 32 + ,STATIC_SET = 64 + ,TITLE_SET = 128 + ,MARKER_SET = 256 + ,OUT_OF_LINE = 512 + ; + + /** The subset of stateFlags that select the relevant + atttribute set or the node. */ + public static final int ATTRIBUTESETS = + ROOT_SET | DECLARATIONS_SET | LAYOUT_SET | SEQ_MASTER_SET | + PAGESEQ_SET | FLOW_SET | STATIC_SET | TITLE_SET | MARKER_SET; + /** The buffer from which parser events are drawn. */ protected SyncedFoXmlEventsBuffer xmlevents; + /** The namespaces object associated with xmlevents. */ protected XMLNamespaces namespaces; + /** The FO type. */ public final int type; /** The attributes defined on this node. When the FO subtree of this * node has been constructed, it will be deleted. */ public FOAttributes foAttributes; + /** The map of properties specified on this node. N.B. This * HashMap starts life in FOAttributes. It is modifiable, and * will be modified when is contains shorthands or compounds. * When the FO subtree of this node has been constructed, and the * propertySet is complete, it will be deleted. */ public HashMap foProperties = null; + /** The sorted keys of foProperties. */ protected Integer[] foKeys = null; + /** The size of foKeys. */ private int numAttrs = 0; + /** BitSet of properties which have been specified on this node. */ private BitSet specifiedProps = new BitSet(PropNames.LAST_PROPERTY_INDEX + 1); @@ -85,17 +116,21 @@ public class FONode extends Node{ While sparsePropsSet is null, this variable will be a reference to the complete property set. */ private PropertyValue[] propertySet; + /** The set of properties directly applicable to this node. Its size is determined by the numProps value passed in to the constructor. */ private PropertyValue[] sparsePropsSet; + /** Map of Integer indices of sparsePropsSet array. It is indexed by the FO index of the FO associated with a given position in the propertySet array. */ private final HashMap sparsePropsMap; + /** An array of of the applicable property indices, in property index order. */ private final int[] sparseIndices; + /** The number of applicable properties. Size of sparsePropsSet. */ private final int numProps; @@ -103,16 +138,13 @@ public class FONode extends Node{ protected PropertyParser exprParser; /** The attrSet argument. */ - public final int attrSet; + protected int attrSet; + /** The ROBitSet of the attrSet argument. */ protected ROBitSet attrBitSet; - /** The ROBitSet of inherited properties for the - attrSet argument. */ - //protected ROBitSet inheritedBitSet; - /** The ROBitSet of non-inherited properties for the - attrSet argument. */ - //protected ROBitSet nonInheritedBitSet; + /** The state flags passed to this node. */ + protected int stateFlags; /** Ancestor reference area of this FONode. */ protected FONode ancestorRefArea = null; @@ -141,30 +173,42 @@ public class FONode extends Node{ * @param parent an FONode, the parent node of this node in * foTree * @param event the XMLEvent that triggered the creation of this - * @param attrSet the set of attributes relevant at this point in the - * tree. - * node + * node. + * @param stateFlags - the set of states relevant at this point in the + * tree. Includes the state information necessaryto select an attribute + * set for this node. + * @param sparsePropsMap - a HashMap mapping the property indices + * to their offsets in the set of properties applicable to this node. + * @param sparseindices - an int[] holding the set of property + * indices applicable to this node, in ascending order. + * sparsePropsMap maps property indices to a position in this array. + * Together they paovide a sparse array facility for this node's + * properties. */ public FONode - (FOTree foTree, int type, FONode parent, FoXMLEvent event, int attrSet, - HashMap sparsePropsMap, int[] sparseIndices, int numProps) + (FOTree foTree, int type, FONode parent, FoXMLEvent event, + int stateFlags, HashMap sparsePropsMap, int[] sparseIndices) throws TreeException, FOPException, PropertyException { super(foTree, parent); if (type == FObjectNames.BLOCK) System.out.println("Constructing FONode for FoBlock"); this.type = type; - this.attrSet = attrSet; + this.stateFlags = stateFlags; + attrSet = stateFlags & ATTRIBUTESETS; + if ((attrSet & (attrSet - 1)) != 0) + throw new PropertyException + ("Invalid attribut set: " + attrSet); this.sparsePropsMap = sparsePropsMap; this.sparseIndices = sparseIndices; - this.numProps = numProps; + this.numProps = sparseIndices.length; attrBitSet = FOPropertySets.getAttrROBitSet(attrSet); xmlevents = foTree.xmlevents; namespaces = xmlevents.getNamespaces(); exprParser = foTree.exprParser; propertySet = new PropertyValue[PropNames.LAST_PROPERTY_INDEX + 1]; foAttributes = new FOAttributes(event, this); - if ( ! (attrSet == FOPropertySets.MARKER_SET)) { + if ( ! (attrSet == MARKER_SET)) { processAttributes(); } // Do not set up the remaining properties now. -- 2.39.5