*/
package org.apache.fop.xml;
-import org.apache.fop.apps.FOPException;
+import org.apache.fop.pool.Poolable;
+
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$";
// 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;
}
/**
String localName, String qName,
AttributesImpl attributes)
{
+ super(sequence);
this.namespaces = namespaces;
- id = sequence;
this.type = type;
this.chars = chars;
this.uriIndex = uriIndex;
/**
* 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;
* @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;
}
/**
* 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;