]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Added sequence, seqMask and getSequence().
authorPeter Bernard West <pbwest@apache.org>
Fri, 29 Nov 2002 17:24:05 +0000 (17:24 +0000)
committerPeter Bernard West <pbwest@apache.org>
Fri, 29 Nov 2002 17:24:05 +0000 (17:24 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@195668 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/xml/XMLNamespaces.java

index 74b13f2a871f8b39aefa830f2be94a5c9322c1fa..144ccd129061bf1d7851517e1ceb73b6f7e94c0d 100644 (file)
@@ -67,6 +67,31 @@ public class XMLNamespaces {
      */
     private ArrayList uris;
 
+    /**
+     * A sequence object for use by <tt>XMLEvent</tt>s.  Because an
+     * <tt>XMLEvent</tt> object must always be associated with an
+     * <i>XMLNamespace</i> object, this namespace object will act as a
+     * singleton for <tt>XMLEvent</tt>s.  This field provides a
+     * counter for those objects.  The range of values which may be
+     * assigned to <i>sequence</i> is restricted by <i>seqMask</i>.
+     */
+    private int sequence = 0;
+
+    /** Mask to restrict the range of values within which <i>sequence</i>
+     * may cycle.
+     */
+    public final int seqMask = (1 << 20) - 1;
+
+    /**
+     * The access function for the sequence.
+     * @return the next positive sequence number.  This number may wrap
+     * but is guaranteed to be within the range seqMask >= sequence >= 0.
+     */
+    public int getSequence() {
+        sequence = ++sequence & seqMask;
+        return sequence;
+    }
+
     public XMLNamespaces() {
         uriIndices = new HashMap(4);
         uris = new ArrayList(4);