You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by pb...@apache.org on 2002/12/01 15:53:12 UTC
cvs commit: xml-fop/src/org/apache/fop/xml SyncedFoXmlEventsBuffer.java
pbwest 2002/12/01 06:53:12
Modified: src/org/apache/fop/xml Tag: FOP_0-20-0_Alt-Design
SyncedFoXmlEventsBuffer.java
Log:
Added getEndElement(boolean, ...).
Revision Changes Path
No revision
No revision
1.1.2.7 +70 -2 xml-fop/src/org/apache/fop/xml/Attic/SyncedFoXmlEventsBuffer.java
Index: SyncedFoXmlEventsBuffer.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/xml/Attic/SyncedFoXmlEventsBuffer.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- SyncedFoXmlEventsBuffer.java 29 Nov 2002 17:33:51 -0000 1.1.2.6
+++ SyncedFoXmlEventsBuffer.java 1 Dec 2002 14:53:11 -0000 1.1.2.7
@@ -29,6 +29,13 @@
public class SyncedFoXmlEventsBuffer extends SyncedCircularBuffer {
/**
+ * Constant for <i>discardEvent</i> field of
+ * <i>getEndElement(boolean discardEvent, FoXMLEvent(, boolean)).
+ */
+ public static final boolean DISCARD_EV = true,
+ RETAIN_EV = false;
+
+ /**
* Maintains an index of namespace URIs. These can then be referred to
* by an <tt>int</tt> index.
*/
@@ -1151,6 +1158,67 @@
return expectTypedEvent
(XMLEvent.ENDELEMENT, event.uriIndex, event.localName,
discardWhiteSpace);
+ }
+
+ /**
+ * Get the next ENDELEMENT event, with the same URI index and local name
+ * as the <tt>FoXMLEvent</tt> argument, from the buffer.
+ * Discard any other events preceding the ENDELEMENT event.
+ * @param discardEvent the argument event may be discarded.
+ * @param event an <tt>FoXMLEvent</tt>. Only the uriIndex and the
+ * localName from the event are used. It is intended that the FoXMLEvent
+ * returned to the corresponding get/expectStartElement() call be used.
+ * @return an ENDELEMENT event
+ * @exception FOPException if buffer errors or interrupts occur
+ * @exception NoSuchElementException if the event is not found
+ */
+ public FoXMLEvent getEndElement(boolean discardEvent, FoXMLEvent event)
+ throws FOPException
+ {
+ FoXMLEvent ev;
+ if (event.foType != FObjectNames.NO_FO)
+ ev = getTypedEvent(XMLEvent.ENDELEMENT, event.foType);
+ else
+ ev = getTypedEvent
+ (XMLEvent.ENDELEMENT, event.uriIndex, event.localName);
+ if (discardEvent) {
+ //System.out.println("discardEvent");
+ pool.surrenderEvent(event);
+ }
+ return ev;
+ }
+
+ /**
+ * Return the next element if it is an ENDELEMENT with the same
+ * URI index and local name as the <tt>FoXMLEvent argument</tt>. If the
+ * next element is not of the required type, push it back onto the buffer.
+ * @param discardEvent the argument event may be discarded.
+ * @param event an <tt>FoXMLEvent</tt>. Only the uriIndex and the
+ * localName from the event are used. It is intended that the FoXMLEvent
+ * returned to the corresponding get/expectStartElement() call be used.
+ * @param discardWhiteSpace - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * @return a matching ENDELEMENT event. If the next
+ * event detected is not an ENDELEMENT, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * @exception FOPException if buffer errors or interrupts occur
+ * @exception NoSuchElementException if end of buffer detected.
+ */
+ public FoXMLEvent expectEndElement
+ (boolean discardEvent, FoXMLEvent event, boolean discardWhiteSpace)
+ throws FOPException
+ {
+ FoXMLEvent ev;
+ if (event.foType != FObjectNames.NO_FO)
+ ev = expectTypedEvent
+ (XMLEvent.ENDELEMENT, event.foType, discardWhiteSpace);
+ else
+ ev = expectTypedEvent
+ (XMLEvent.ENDELEMENT, event.uriIndex, event.localName,
+ discardWhiteSpace);
+ if (discardEvent)
+ pool.surrenderEvent(event);
+ return ev;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org