]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Extends Poolable
authorPeter Bernard West <pbwest@apache.org>
Wed, 14 Jan 2004 16:22:12 +0000 (16:22 +0000)
committerPeter Bernard West <pbwest@apache.org>
Wed, 14 Jan 2004 16:22:12 +0000 (16:22 +0000)
Defaults to XMLNamespaces.DefAttrNSIndex
Constructor requires sequence
clear() return Poolable

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197180 13f79535-47bb-0310-9956-ffa450edef68

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

index 6fa26a10e1d9f7ea4dbc070841dbaa9cd3dfa4db..43d5d4817e33ffb488e62e7ef45f06b646594258 100644 (file)
@@ -53,7 +53,8 @@
  */
 package org.apache.fop.xml;
 
-import org.apache.fop.apps.FOPException;
+import org.apache.fop.pool.Poolable;
+
 import org.xml.sax.helpers.AttributesImpl;
 
 /**
@@ -63,7 +64,7 @@ import org.xml.sax.helpers.AttributesImpl;
  * <tt>XMLSerialHandler</tt> methods set the values directly.
  */
 
-public class XMLEvent {
+public class XMLEvent extends Poolable {
 
     private static final String tag = "$Name$";
     private static final String revision = "$Revision$";
@@ -105,26 +106,25 @@ public class XMLEvent {
     // the basic XML events are unlikely to change.
     protected int type = NOEVENT;
     protected String chars;
-    protected int uriIndex;
+    protected int uriIndex = XMLNamespaces.DefAttrNSIndex;
     protected String localName;
     protected String qName;
     protected AttributesImpl attributes;
     protected XMLNamespaces namespaces;
-
-    /** Sequence id for this event */
-    public final int id;
     
     /**
      * The one-argument constructor uses the default initialization values:
-     * NOEVENT for the event <i>type</i>, and null references for all others
-     * except <i>namespaces</i>.
+     * NOEVENT for the event <i>type</i>, the default attribute namespace,
+     * and null references for all others except <i>namespaces</i>.
      * @param namespaces the object maintaing the URIs and their indices
      * @param sequence the sequence number of this event within its
      * namespace
+     * @param uriIndex the namespace index
      */
-    public XMLEvent (XMLNamespaces namespaces, int sequence) {
+    public XMLEvent (XMLNamespaces namespaces, int sequence, int uriIndex ) {
+        super(sequence);
         this.namespaces = namespaces;
-        id = sequence;
+        this.uriIndex = uriIndex;
     }
 
     /**
@@ -145,8 +145,8 @@ public class XMLEvent {
                     String localName, String qName,
                     AttributesImpl attributes)
     {
+        super(sequence);
         this.namespaces = namespaces;
-        id = sequence;
         this.type = type;
         this.chars = chars;
         this.uriIndex = uriIndex;
@@ -158,13 +158,13 @@ public class XMLEvent {
     /**
      * The cloning constructor takes a reference to an existing
      * <tt>XMLEvent</tt> object.  Only the <code>id</code> field is not
-     * cloned, but generated by a call on the <code>namespaces</code>
-     * object.
-     * @param ev the event
+     * cloned, but set from the <code>sequence</code> parameter.
+     * @param ev the event to clone
+     * @param sequence the sequence number of the clone
      */
-    public XMLEvent(XMLEvent ev) throws FOPException {
+    public XMLEvent(XMLEvent ev, int sequence) {
+        super(sequence);
         namespaces = ev.namespaces;
-        id = namespaces.getNextSequence(ev.uriIndex);
         type = ev.type;
         chars = ev.chars;
         uriIndex = ev.uriIndex;
@@ -180,11 +180,14 @@ public class XMLEvent {
      * @param namespaces the object maintaing URIs and their indices
      */
     public XMLEvent(XMLNamespaces namespaces, int sequence,
-            int type, String chars) {
+            int uriIndex, int type, String chars) {
+        super(sequence);
         this.namespaces = namespaces;
-        id = sequence;
         this.type = type;
         this.chars = chars;
+        // N.B. CHARACTERS events have no namespace - they should always
+        // belong to the DefAttrNSpace
+        this.uriIndex = uriIndex;
     }
 
     /**
@@ -192,7 +195,7 @@ public class XMLEvent {
      * Neither the <i>namespaces</i> nor the <i>id</i> field is cleared.
      * @return the cleared event.
      */
-    public XMLEvent clear() {
+    public Poolable clear() {
         type = NOEVENT;
         chars = null;
         uriIndex = 0;