--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<!-- Created by htmlize-0.67 in css mode. -->
+<html>
+ <head>
+ <title>SyncedFoXmlEventsBuffer.java</title>
+ <style type="text/css">
+ <!--
+ body {
+ color: #000000;
+ background-color: #faf0e6;
+ } /* default */
+ .reference {
+ color: #cd0000;
+ background-color: #faf0e6;
+ } /* font-lock-reference-face */
+ .comment {
+ color: #00008b;
+ background-color: #faf0e6;
+ } /* font-lock-comment-face */
+ .jde-java-font-lock-package {
+ color: #0000cd;
+ background-color: #faf0e6;
+ } /* jde-java-font-lock-package-face */
+ .jde-java-font-lock-constant {
+ color: #5f9ea0;
+ background-color: #faf0e6;
+ } /* jde-java-font-lock-constant-face */
+ .function-name {
+ color: #8b2323;
+ background-color: #faf0e6;
+ } /* font-lock-function-name-face */
+ .variable-name {
+ color: #8b008b;
+ background-color: #faf0e6;
+ } /* font-lock-variable-name-face */
+ .jde-java-font-lock-bold {
+ background-color: #faf0e6;
+ font-weight: bold;
+ } /* jde-java-font-lock-bold-face */
+ .jde-java-font-lock-doc-tag {
+ color: #008b00;
+ background-color: #faf0e6;
+ } /* jde-java-font-lock-doc-tag-face */
+ .keyword {
+ color: #8b0000;
+ background-color: #faf0e6;
+ } /* font-lock-keyword-face */
+ .jde-java-font-lock-number {
+ color: #bc8f8f;
+ background-color: #faf0e6;
+ } /* jde-java-font-lock-number-face */
+ .jde-java-font-lock-code {
+ background-color: #faf0e6;
+ } /* jde-java-font-lock-code-face */
+ .jde-java-font-lock-italic {
+ background-color: #faf0e6;
+ font-style: italic;
+ } /* jde-java-font-lock-italic-face */
+ .jde-java-font-lock-modifier {
+ color: #da70d6;
+ background-color: #faf0e6;
+ } /* jde-java-font-lock-modifier-face */
+ .string {
+ color: #008b00;
+ background-color: #faf0e6;
+ } /* font-lock-string-face */
+ .type {
+ color: #4682b4;
+ background-color: #faf0e6;
+ } /* font-lock-type-face */
+ a {
+ color: inherit;
+ background-color: inherit;
+ font: inherit;
+ text-decoration: inherit;
+ }
+ a:hover {
+ text-decoration: underline;
+ }
+ -->
+ </style>
+ </head>
+ <body>
+ <pre>
+<span class="keyword">package</span> <span class="jde-java-font-lock-package">org</span>.<span class="jde-java-font-lock-package">apache</span>.<span class="jde-java-font-lock-package">fop</span>.<span class="jde-java-font-lock-package">xml</span>;
+
+<span class="keyword">import</span> <span class="jde-java-font-lock-package">org</span>.<span class="jde-java-font-lock-package">apache</span>.<span class="jde-java-font-lock-package">fop</span>.<span class="jde-java-font-lock-package">datastructs</span>.<span class="type">SyncedCircularBuffer</span>;
+<span class="keyword">import</span> <span class="jde-java-font-lock-package">org</span>.<span class="jde-java-font-lock-package">apache</span>.<span class="jde-java-font-lock-package">fop</span>.<span class="jde-java-font-lock-package">apps</span>.<span class="type">FOPException</span>;
+<span class="keyword">import</span> <span class="jde-java-font-lock-package">org</span>.<span class="jde-java-font-lock-package">apache</span>.<span class="jde-java-font-lock-package">fop</span>.<span class="jde-java-font-lock-package">fo</span>.<span class="type">FObjectNames</span>;
+<span class="keyword">import</span> <span class="jde-java-font-lock-package">org</span>.<span class="jde-java-font-lock-package">apache</span>.<span class="jde-java-font-lock-package">fop</span>.<span class="jde-java-font-lock-package">fo</span>.<span class="type">FObjectSets</span>;
+
+<span class="keyword">import</span> <span class="jde-java-font-lock-package">org</span>.<span class="jde-java-font-lock-package">apache</span>.<span class="jde-java-font-lock-package">fop</span>.<span class="jde-java-font-lock-package">xml</span>.<span class="type">FoXMLEventPool</span>;
+
+<span class="keyword">import</span> <span class="jde-java-font-lock-package">java</span>.<span class="jde-java-font-lock-package">util</span>.<span class="type">NoSuchElementException</span>;
+<span class="keyword">import</span> <span class="jde-java-font-lock-package">java</span>.<span class="jde-java-font-lock-package">util</span>.<span class="type">LinkedList</span>;
+<span class="keyword">import</span> <span class="jde-java-font-lock-package">java</span>.<span class="jde-java-font-lock-package">util</span>.<span class="type">Iterator</span>;
+<span class="keyword">import</span> <span class="jde-java-font-lock-package">java</span>.<span class="jde-java-font-lock-package">util</span>.<span class="type">BitSet</span>;
+
+<span class="comment">/*
+ * $Id$
+ *
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
+ *
+ * @author <a href="mailto:pbwest@powerup.com.au">Peter B. West</a>
+ * @version $Revision$ $Name$
+ */</span>
+<span class="comment">/**
+ * A synchronized circular buffer for FoXMLEvents.
+ * </span><span class="jde-java-font-lock-doc-tag">@see</span><span class="comment"> </span><span class="jde-java-font-lock-code">org.apache.fop.datastructs.SyncedCircularBuffer</span><span class="comment">
+ */</span>
+<span class="jde-java-font-lock-modifier">public</span> <span class="keyword">class</span> <span class="function-name" id="SyncedFoXmlEventsBufferClass">SyncedFoXmlEventsBuffer</span> <span class="keyword">extends</span> <span class="type">SyncedCircularBuffer</span> {
+
+ <span class="comment">/**
+ * Constant for <i></span><span class="jde-java-font-lock-italic">discardEvent</span><span class="comment"></i> field of
+ * <i>getEndElement(boolean discardEvent, FoXMLEvent(, boolean)).
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="jde-java-font-lock-modifier">static</span> <span class="jde-java-font-lock-modifier">final</span> <span class="type">boolean</span> <span class="variable-name" id="DISCARD_EV">DISCARD_EV</span> = <span class="jde-java-font-lock-constant" id="true">true</span>,
+ <span class="jde-java-font-lock-constant" id="RETAIN_EV">RETAIN_EV</span> = <span class="jde-java-font-lock-constant">false</span>;
+
+ <span class="comment">/**
+ * Maintains an index of namespace URIs. These can then be referred to
+ * by an <tt>int</tt> index.
+ */</span>
+ <span class="jde-java-font-lock-modifier">private</span> <span class="type">XMLNamespaces</span> <span class="variable-name" id="namespaces">namespaces</span>;
+
+ <span class="comment">/**
+ * The FoXMLEventPool for this buffer.
+ */</span>
+ <span class="jde-java-font-lock-modifier">private</span> <span class="type">FoXMLEventPool</span> <span class="variable-name" id="pool">pool</span>;
+
+ <span class="comment">/**
+ * No-argument constructor sets up a buffer with the default number of
+ * elements.
+ * The producer and consumer <tt>Thread</tt>s default to the current
+ * thread at the time of instantiation.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="function-name" id="SyncedFoXmlEventsBuffer">SyncedFoXmlEventsBuffer</span>()
+ <span class="keyword">throws</span> <span class="type">IllegalArgumentException</span>
+ {
+ <span class="keyword">super</span>();
+ namespaces = <span class="keyword">new</span> <span class="type">XMLNamespaces</span>();
+ pool = <span class="keyword">new</span> <span class="type">FoXMLEventPool</span>(namespaces, <span class="jde-java-font-lock-constant" id="DEFAULTBUFSIZE">DEFAULTBUFSIZE</span>);
+ }
+
+ <span class="comment">/**
+ * Constructor taking one argument; the size of the buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name" id="size">size</span><span class="comment"> the size of the buffer. Must be > 1.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="function-name">SyncedFoXmlEventsBuffer</span>(<span class="type">int</span> <span class="variable-name">size</span>)
+ <span class="keyword">throws</span> <span class="type">IllegalArgumentException</span>
+ {
+ <span class="keyword">super</span>(size);
+ namespaces = <span class="keyword">new</span> <span class="type">XMLNamespaces</span>();
+ pool = <span class="keyword">new</span> <span class="type">FoXMLEventPool</span>(namespaces);
+ }
+
+ <span class="comment">/**
+ * Get the <tt>XMLNamespaces</tt> from this buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> - the namespaces object.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">XMLNamespaces</span> <span class="function-name" id="getNamespaces">getNamespaces</span>() { <span class="keyword">return</span> namespaces; }
+
+ <span class="comment">/**
+ * Get the <tt>FoXMLEventPool</tt> from this buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> - the pool object.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEventPool</span> <span class="function-name" id="getPool">getPool</span>() { <span class="keyword">return</span> pool; }
+
+ <span class="comment">/**
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> next event from the SyncedCircularBuffer
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException.</span><span class="comment"> The purpose of this method is to catch
+ * and transform any InterruptedException exceptions thrown by the
+ * <tt>SyncedCircularBuffer</tt>.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name" id="getEvent">getEvent</span>() <span class="keyword">throws</span> <span class="type">FOPException</span> {
+ <span class="type">FoXMLEvent</span> <span class="variable-name" id="ev">ev</span>;
+ <span class="keyword">try</span> {
+ ev = (<span class="type">FoXMLEvent</span>)get();
+ <span class="comment">//System.out.println("getEvent: " + ev);
+</span> <span class="keyword">return</span> ev;
+ } <span class="keyword">catch</span> (<span class="type">InterruptedException</span> <span class="variable-name" id="e">e</span>) {
+ <span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">FOPException</span>(e);
+ }
+ }
+
+ <span class="comment">/**
+ * Get the next event of the given type from the buffer. Discard
+ * intervening events.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name" id="eventType">eventType</span><span class="comment"> - the <tt>int</tt> event type.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> an event of the given type.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name" id="getTypedEvent">getTypedEvent</span>(<span class="type">int</span> <span class="variable-name">eventType</span>) <span class="keyword">throws</span> <span class="type">FOPException</span> {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span> = getEvent();
+ <span class="keyword">while</span> (ev != <span class="jde-java-font-lock-constant" id="null">null</span> && ev.type != eventType) {
+ ev = getEvent();
+ }
+ <span class="keyword">if</span> (ev == <span class="jde-java-font-lock-constant">null</span>) {
+ <span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">NoSuchElementException</span>
+ (XMLEvent.eventTypeName(eventType) + "<span class="string"> not found.</span>");
+ }
+ <span class="keyword">return</span> ev;
+ }
+
+ <span class="comment">/**
+ * Get the next event of the given type and with the given <tt>QName</tt>
+ * from the buffer. Discard intervening events.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">eventType</span><span class="comment"> - the <tt>int</tt> event type.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name" id="qName">qName</span><span class="comment"> a <tt>String</tt> with the <tt>QName</tt> of the
+ * required element.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> an event of the given type.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name">getTypedEvent</span>(<span class="type">int</span> <span class="variable-name">eventType</span>, <span class="type">String</span> <span class="variable-name">qName</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span> = getEvent();
+ <span class="keyword">while</span> (ev != <span class="jde-java-font-lock-constant">null</span> &&
+ ! (ev.type == eventType && ev.qName.equals(qName))) {
+ ev = getEvent();
+ }
+ <span class="keyword">if</span> (ev == <span class="jde-java-font-lock-constant">null</span>) {
+ <span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">NoSuchElementException</span>
+ (XMLEvent.eventTypeName(eventType) + "<span class="string"> </span>" + qName + "<span class="string"> not found.</span>");
+ }
+ <span class="keyword">return</span> ev;
+ }
+
+ <span class="comment">/**
+ * Get the next event of the given type, and with the given URI index and
+ * local name, from the buffer. Discard intervening events.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">eventType</span><span class="comment"> - the <tt>int</tt> event type.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name" id="uriIndex">uriIndex</span><span class="comment"> - the <tt>int</tt> URI index maintained in the
+ * <tt>XMLNamespaces</tt> object.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name" id="localName">localName</span><span class="comment"> a <tt>String</tt> with the local name of the
+ * required element.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> an event of the given type.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="variable-name">getTypedEvent</span>
+ (<span class="type">int</span> <span class="variable-name">eventType</span>, <span class="type">int</span> <span class="variable-name">uriIndex</span>, <span class="type">String</span> <span class="variable-name">localName</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span> = getEvent();
+ <span class="keyword">while</span> (ev != <span class="jde-java-font-lock-constant">null</span> &&
+ ! (ev.type == eventType
+ && ev.uriIndex == uriIndex
+ && ev.localName.equals(localName))) {
+ pool.surrenderEvent(ev);
+ ev = getEvent();
+ }
+ <span class="keyword">if</span> (ev == <span class="jde-java-font-lock-constant">null</span>)
+ <span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">NoSuchElementException</span>
+ (XMLEvent.eventTypeName(eventType)
+ + namespaces.getIndexURI(uriIndex)
+ + "<span class="string">:</span>" + localName + "<span class="string"> not found.</span>");
+ <span class="keyword">return</span> ev;
+ }
+
+ <span class="comment">/**
+ * Get the next event of the given type, from the fo: namespace, with
+ * the given FO type. Discard intervening events.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">eventType</span><span class="comment"> - the <tt>int</tt> event type.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name" id="foType">foType</span><span class="comment"> - the <tt>int</tt> FO type.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> an event of the given type.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name">getTypedEvent</span>(<span class="type">int</span> <span class="variable-name">eventType</span>, <span class="type">int</span> <span class="variable-name">foType</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span> = getEvent();
+ <span class="keyword">while</span> (ev != <span class="jde-java-font-lock-constant">null</span> &&
+ ! (ev.type == eventType && ev.foType == foType)) {
+ pool.surrenderEvent(ev);
+ ev = getEvent();
+ }
+ <span class="keyword">if</span> (ev == <span class="jde-java-font-lock-constant">null</span>)
+ <span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">NoSuchElementException</span>
+ (XMLEvent.eventTypeName(eventType)
+ + "<span class="string"> FO type </span>" + foType + "<span class="string"> not found.</span>");
+ <span class="keyword">return</span> ev;
+ }
+
+ <span class="comment">/**
+ * Return the next element if it is of the required type. If the next
+ * element is not of the required type, push it back onto the buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">eventType</span><span class="comment"> - the <tt>int</tt> event type.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name" id="discardWhiteSpace">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> an event of the required type. If the next
+ * event detected is not of the required type, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the buffer is empty.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="variable-name" id="expectTypedEvent">expectTypedEvent</span>
+ (<span class="type">int</span> <span class="variable-name">eventType</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span> = getEvent();
+ <span class="keyword">if</span> (discardWhiteSpace) {
+ <span class="keyword">while</span> (ev != <span class="jde-java-font-lock-constant">null</span> && ev.type == <span class="reference">XMLEvent</span>.<span class="type">CHARACTERS</span>
+ && ev.chars.trim().equals("")) {
+ pool.surrenderEvent(ev);
+ ev = getEvent();
+ }
+ }
+ <span class="keyword">if</span> (ev != <span class="jde-java-font-lock-constant">null</span> && ev.type == eventType) {
+ <span class="keyword">return</span> ev;
+ }
+ <span class="keyword">if</span> (ev == <span class="jde-java-font-lock-constant">null</span>)
+ <span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">NoSuchElementException</span>
+ (XMLEvent.eventTypeName(eventType)
+ + "<span class="string"> not found: end of buffer.</span>");
+ pushBack(ev);
+ <span class="keyword">return</span> <span class="jde-java-font-lock-constant">null</span>;
+ }
+
+ <span class="comment">/**
+ * Return the next element if it is of the required type and has the
+ * required <tt>QName</tt>. If the next
+ * element is not of the required type, push it back onto the buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">eventType</span><span class="comment"> - the <tt>int</tt> event type.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">qName</span><span class="comment"> a <tt>String</tt> with the <tt>QName</tt> of the
+ * required element.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> an event of the required type. If the next
+ * event detected is not of the required type, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="variable-name">expectTypedEvent</span>
+ (<span class="type">int</span> <span class="variable-name">eventType</span>, <span class="type">String</span> <span class="variable-name">qName</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span> = getEvent();
+ <span class="keyword">if</span> (discardWhiteSpace) {
+ <span class="keyword">while</span> (ev != <span class="jde-java-font-lock-constant">null</span> && ev.type == <span class="reference">XMLEvent</span>.<span class="type">CHARACTERS</span>
+ && ev.chars.trim().equals("")) {
+ pool.surrenderEvent(ev);
+ ev = getEvent();
+ }
+ }
+ <span class="keyword">if</span> (ev != <span class="jde-java-font-lock-constant">null</span> && ev.type == eventType && ev.qName.equals(qName)) {
+ <span class="keyword">return</span> ev;
+ }
+ <span class="keyword">if</span> (ev == <span class="jde-java-font-lock-constant">null</span>)
+ <span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">NoSuchElementException</span>
+ (XMLEvent.eventTypeName(eventType)
+ + "<span class="string"> not found: end of buffer.</span>");
+ pushBack(ev);
+ <span class="keyword">return</span> <span class="jde-java-font-lock-constant">null</span>;
+ }
+
+ <span class="comment">/**
+ * Return the next element if it is of the required type and has the
+ * required URI index and local name. If the next
+ * element is not of the required type, push it back onto the buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">eventType</span><span class="comment"> - the <tt>int</tt> event type.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">uriIndex</span><span class="comment"> - the <tt>int</tt> URI index.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">localName</span><span class="comment"> a <tt>String</tt> with the local name of the
+ * required element.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> an event of the required type. If the next
+ * event detected is not of the required type, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="variable-name">expectTypedEvent</span>
+ (<span class="type">int</span> <span class="variable-name">eventType</span>, <span class="type">int</span> <span class="variable-name">uriIndex</span>,
+ <span class="type">String</span> <span class="variable-name">localName</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span> = getEvent();
+ <span class="keyword">if</span> (discardWhiteSpace) {
+ <span class="keyword">while</span> (ev != <span class="jde-java-font-lock-constant">null</span> && ev.type == <span class="reference">XMLEvent</span>.<span class="type">CHARACTERS</span>
+ && ev.chars.trim().equals("")) {
+ pool.surrenderEvent(ev);
+ ev = getEvent();
+ }
+ }
+ <span class="keyword">if</span> (ev != <span class="jde-java-font-lock-constant">null</span>
+ && ev.type == eventType
+ && ev.uriIndex == uriIndex
+ && ev.localName.equals(localName)) {
+ <span class="keyword">return</span> ev;
+ }
+ <span class="keyword">if</span> (ev == <span class="jde-java-font-lock-constant">null</span>)
+ <span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">NoSuchElementException</span>
+ (XMLEvent.eventTypeName(eventType)
+ + "<span class="string"> not found: end of buffer.</span>");
+ pushBack(ev);
+ <span class="keyword">return</span> <span class="jde-java-font-lock-constant">null</span>;
+ }
+
+ <span class="comment">/**
+ * Return the next element if it is of the required type and has the
+ * required FO type. If the next
+ * element is not of the required type, push it back onto the buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">eventType</span><span class="comment"> - the <tt>int</tt> event type.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">foType</span><span class="comment"> - the <tt>int</tt> FO type.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> an event of the required type. If the next
+ * event detected is not of the required type, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="variable-name">expectTypedEvent</span>
+ (<span class="type">int</span> <span class="variable-name">eventType</span>, <span class="type">int</span> <span class="variable-name">foType</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span> = getEvent();
+ <span class="keyword">if</span> (discardWhiteSpace) {
+ <span class="keyword">while</span> (ev != <span class="jde-java-font-lock-constant">null</span> && ev.type == <span class="reference">XMLEvent</span>.<span class="type">CHARACTERS</span>
+ && ev.chars.trim().equals("")) {
+ pool.surrenderEvent(ev);
+ ev = getEvent();
+ }
+ }
+ <span class="keyword">if</span> (ev != <span class="jde-java-font-lock-constant">null</span> && ev.type == eventType && ev.foType == foType) {
+ <span class="keyword">return</span> ev;
+ }
+ <span class="keyword">if</span> (ev == <span class="jde-java-font-lock-constant">null</span>)
+ <span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">NoSuchElementException</span>
+ (XMLEvent.eventTypeName(eventType)
+ + "<span class="string"> not found: end of buffer.</span>");
+ pushBack(ev);
+ <span class="keyword">return</span> <span class="jde-java-font-lock-constant">null</span>;
+ }
+
+ <span class="comment">/**
+ * Get the next ENDDOCUMENT event from the buffer. Discard any other
+ * events preceding the ENDDOCUMENT event.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> an ENDDOCUMENT event
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name" id="getEndDocument">getEndDocument</span>() <span class="keyword">throws</span> <span class="type">FOPException</span> {
+ <span class="keyword">return</span> getTypedEvent(XMLEvent.<span class="jde-java-font-lock-constant" id="ENDDOCUMENT">ENDDOCUMENT</span>);
+ }
+
+ <span class="comment">/**
+ * Return the next element if it is an ENDDOCUMENT. If the next
+ * element is not of the required type, push it back onto the buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> an ENDDOCUMENT event. If the next
+ * event detected is not of the required type, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name" id="expectEndDocument">expectEndDocument</span>(<span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="keyword">return</span> expectTypedEvent(XMLEvent.<span class="jde-java-font-lock-constant">ENDDOCUMENT</span>, discardWhiteSpace);
+ }
+
+ <span class="comment">/**
+ * Get the next STARTELEMENT event from the buffer. Discard any other
+ * events preceding the STARTELEMENT event.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> a STARTELEMENT event
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name" id="getStartElement">getStartElement</span>() <span class="keyword">throws</span> <span class="type">FOPException</span> {
+ <span class="keyword">return</span> getTypedEvent(XMLEvent.<span class="jde-java-font-lock-constant" id="STARTELEMENT">STARTELEMENT</span>);
+ }
+
+ <span class="comment">/**
+ * Return the next element if it is a STARTELEMENT. If the next
+ * element is not of the required type, push it back onto the buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> a STARTELEMENT event. If the next
+ * event detected is not of the required type, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name" id="expectStartElement">expectStartElement</span>(<span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="keyword">return</span> expectTypedEvent(XMLEvent.<span class="jde-java-font-lock-constant">STARTELEMENT</span>, discardWhiteSpace);
+ }
+
+ <span class="comment">/**
+ * Get the next STARTELEMENT event with the given <tt>QName</tt>
+ * from the buffer. Discard any other events preceding the
+ * STARTELEMENT event.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">qName</span><span class="comment"> a <tt>String</tt> with the <tt>QName</tt> of the
+ * required STARTELEMENT
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> a STARTELEMENT event
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name">getStartElement</span>(<span class="type">String</span> <span class="variable-name">qName</span>) <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="keyword">return</span> getTypedEvent(XMLEvent.<span class="jde-java-font-lock-constant">STARTELEMENT</span>, qName);
+ }
+
+ <span class="comment">/**
+ * Return the next element if it is a STARTELEMENT with the given
+ * <tt>QName</tt>. If the next
+ * element is not of the required type, push it back onto the buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">qName</span><span class="comment"> a <tt>String</tt> with the <tt>QName</tt> of the
+ * required STARTELEMENT
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> a STARTELEMENT event. If the next
+ * event detected is not of the required type, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="variable-name">expectStartElement</span>
+ (<span class="type">String</span> <span class="variable-name">qName</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="keyword">return</span> expectTypedEvent
+ (XMLEvent.<span class="jde-java-font-lock-constant">STARTELEMENT</span>, qName, discardWhiteSpace);
+ }
+
+ <span class="comment">/**
+ * Get the next STARTELEMENT event with the given URI index and local name
+ * from the buffer. Discard any other events preceding the
+ * STARTELEMENT event.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">uriIndex</span><span class="comment"> an <tt>int</tt> with the index of the URI of the
+ * required URI
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">localName</span><span class="comment"> a <tt>String</tt> with the local name of the
+ * required STARTELEMENT
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> a STARTELEMENT event
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name">getStartElement</span>(<span class="type">int</span> <span class="variable-name">uriIndex</span>, <span class="type">String</span> <span class="variable-name">localName</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="keyword">return</span> getTypedEvent(XMLEvent.<span class="jde-java-font-lock-constant">STARTELEMENT</span>, uriIndex, localName);
+ }
+
+ <span class="comment">/**
+ * Return the next element if it is a STARTELEMENT with the given
+ * URI index and local name. If the next
+ * element is not of the required type, push it back onto the buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">uriIndex</span><span class="comment"> an <tt>int</tt> URI index.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">localName</span><span class="comment"> a <tt>String</tt> with the local name of the
+ * required STARTELEMENT
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> a STARTELEMENT event. If the next
+ * event detected is not of the required type, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="variable-name">expectStartElement</span>
+ (<span class="type">int</span> <span class="variable-name">uriIndex</span>, <span class="type">String</span> <span class="variable-name">localName</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="keyword">return</span> expectTypedEvent
+ (XMLEvent.<span class="jde-java-font-lock-constant">STARTELEMENT</span>, uriIndex, localName, discardWhiteSpace);
+ }
+
+ <span class="comment">/**
+ * From the buffer get the next STARTELEMENT event from the fo: namespace
+ * with the given FO object type.
+ * Discard any other events preceding the
+ * STARTELEMENT event.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">foType</span><span class="comment"> - the <tt>int</tt> FO object type, as defined in
+ * <tt>FObjectNames</tt>.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> a matching STARTELEMENT event.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name">getStartElement</span>(<span class="type">int</span> <span class="variable-name">foType</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="keyword">return</span> getTypedEvent(XMLEvent.<span class="jde-java-font-lock-constant">STARTELEMENT</span>, foType);
+ }
+
+ <span class="comment">/**
+ * From the buffer return the next STARTELEMENT event from the fo:
+ * namespace with the given FO object type. If the next
+ * element is not of the required type, push it back onto the buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">foType</span><span class="comment"> - the <tt>int</tt> FO object type, as defined in
+ * <tt>FObjectNames</tt>.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> a matching STARTELEMENT event. If the next
+ * event detected is not of the required type, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="variable-name">expectStartElement</span>
+ (<span class="type">int</span> <span class="variable-name">foType</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="keyword">return</span> expectTypedEvent
+ (XMLEvent.<span class="jde-java-font-lock-constant">STARTELEMENT</span>, foType, discardWhiteSpace);
+ }
+
+ <span class="comment">/**
+ * Get one of a list of possible STARTELEMENT events.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name" id="list">list</span><span class="comment"> a <tt>LinkedList</tt> containing either <tt>String</tt>s
+ * with the <tt>QName</tt>, or <tt>UriLocalName</tt>
+ * objects with the URI index and local name of one of the required
+ * STARTELEMENT events.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> a STARTELEMENT event
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="variable-name">getStartElement</span>
+ (<span class="type">LinkedList</span> <span class="variable-name">list</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span>;
+ <span class="keyword">do</span> {
+ ev = expectStartElement(list, discardWhiteSpace);
+ <span class="keyword">if</span> (ev != <span class="jde-java-font-lock-constant">null</span>) <span class="keyword">return</span> ev;
+ <span class="comment">// The non-matching event has been pushed back.
+</span> <span class="comment">// Get it and discard. Note that if the first attempt to
+</span> <span class="comment">// getEvent() returns null, the expectStartElement() calls
+</span> <span class="comment">// return null.
+</span> ev = getEvent();
+ pool.surrenderEvent(ev);
+ } <span class="keyword">while</span> (ev != <span class="jde-java-font-lock-constant">null</span>);
+ <span class="comment">// Exit from this while loop is only by discovery of null event
+</span> <span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">NoSuchElementException</span>
+ ("<span class="string">StartElement from list not found.</span>");
+ }
+
+ <span class="comment">/**
+ * Get one of a list of possible STARTELEMENT events.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">list</span><span class="comment"> a <tt>LinkedList</tt> containing either <tt>String</tt>s
+ * with the <tt>QName</tt>, or <tt>UriLocalName</tt>
+ * objects with the URI index and local name of one of the required
+ * STARTELEMENT events.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> a STARTELEMENT event. If the next
+ * event detected is not of the required type, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="variable-name">expectStartElement</span>
+ (<span class="type">LinkedList</span> <span class="variable-name">list</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span>;
+ <span class="type">Iterator</span> <span class="variable-name" id="elements">elements</span> = list.iterator();
+ <span class="keyword">while</span> (elements.hasNext()) {
+ <span class="type">Object</span> <span class="variable-name" id="o">o</span> = elements.next();
+ <span class="keyword">if</span> (o <span class="keyword">instanceof</span> <span class="type">String</span>) {
+ ev = expectStartElement((<span class="type">String</span>) o, discardWhiteSpace);
+ <span class="comment">// Found it!
+</span> <span class="keyword">if</span> (ev != <span class="jde-java-font-lock-constant">null</span>) <span class="keyword">return</span> ev;
+ } <span class="keyword">else</span> <span class="keyword">if</span> (o <span class="keyword">instanceof</span> <span class="type">UriLocalName</span>) {
+ ev = expectStartElement
+ (((<span class="type">UriLocalName</span>) o).uriIndex,
+ ((<span class="type">UriLocalName</span>) o).localName,
+ discardWhiteSpace);
+ <span class="comment">// Found it!
+</span> <span class="keyword">if</span> (ev != <span class="jde-java-font-lock-constant">null</span>) <span class="keyword">return</span> ev;
+ } <span class="keyword">else</span> <span class="keyword">if</span> (o <span class="keyword">instanceof</span> <span class="type">Integer</span>) {
+ ev = expectStartElement(((<span class="type">Integer</span>)o).intValue(),
+ discardWhiteSpace);
+ <span class="keyword">if</span> (ev != <span class="jde-java-font-lock-constant">null</span>) <span class="keyword">return</span> ev;
+ } <span class="keyword">else</span>
+ <span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">FOPException</span>
+ ("<span class="string">Invalid list elements for getStartElement</span>");
+ }
+ <span class="keyword">return</span> <span class="jde-java-font-lock-constant">null</span>;
+ }
+
+ <span class="comment">/**
+ * Get one of a array of possible STARTELEMENT events. Scan and discard
+ * events until a STARTELEMENT event is found whose URI index and
+ * local name matches one of those in the argument
+ * <tt>UriLocalName[]</tt> array.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">list</span><span class="comment"> an array containing <tt>UriLocalName</tt>
+ * objects with the URI index and local name of
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * STARTELEMENT events, one of which is required.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> the next matching STARTELEMENT event from the buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="variable-name">getStartElement</span>
+ (<span class="type">UriLocalName</span>[] <span class="variable-name">list</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span>;
+ <span class="keyword">do</span> {
+ ev = expectStartElement(list, discardWhiteSpace);
+ <span class="keyword">if</span> (ev != <span class="jde-java-font-lock-constant">null</span>) <span class="keyword">return</span> ev;
+ <span class="comment">// The non-matching event has been pushed back.
+</span> <span class="comment">// Get it and discard. Note that if the first attempt to
+</span> <span class="comment">// getEvent() returns null, the expectStartElement() calls
+</span> <span class="comment">// will throw a NoSuchElementException
+</span> ev = getEvent();
+ pool.surrenderEvent(ev);
+ } <span class="keyword">while</span> (ev != <span class="jde-java-font-lock-constant">null</span>);
+ <span class="comment">// Exit from this while loop is only by discovery of null event
+</span> <span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">NoSuchElementException</span>
+ ("<span class="string">StartElement from list not found.</span>");
+ }
+
+ <span class="comment">/**
+ * Expect one of an array of possible STARTELEMENT events. The next
+ * STARTELEMENT must have a URI index and local name which match
+ * an element of the argument <tt>UriLocalName[]</tt> list.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">list</span><span class="comment"> an <tt>UriLocalName[]</tt> array containing the
+ * namespace Uri index and LocalName
+ * of possible events, one of which must be the next returned.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> the matching STARTELEMENT event. If the next
+ * event detected is not of the required type, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="variable-name">expectStartElement</span>
+ (<span class="type">UriLocalName</span>[] <span class="variable-name">list</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span>;
+ <span class="keyword">for</span> (<span class="type">int</span> <span class="variable-name" id="i">i</span> = <span class="jde-java-font-lock-number">0</span>; i < list.length; i++) {
+ ev = expectStartElement(list[i].uriIndex,
+ list[i].localName,
+ discardWhiteSpace);
+ <span class="comment">// Found it!
+</span> <span class="keyword">if</span> (ev != <span class="jde-java-font-lock-constant">null</span>) <span class="keyword">return</span> ev;
+ }
+ <span class="keyword">return</span> <span class="jde-java-font-lock-constant">null</span>;
+ }
+
+ <span class="comment">/**
+ * Get one of a array of possible STARTELEMENT events. Scan and discard
+ * events until a STARTELEMENT event is found whose <tt>QName</tt>
+ * matches one of those in the argument <tt>String[]</tt> array.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">list</span><span class="comment"> a <tt>String[]</tt> array containing <tt>QName</tt>s,
+ * one of which is required.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> the next matching STARTELEMENT event from the buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name">getStartElement</span>(<span class="type">String</span>[] <span class="variable-name">list</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span>;
+ <span class="keyword">do</span> {
+ ev = expectStartElement(list, discardWhiteSpace);
+ <span class="keyword">if</span> (ev != <span class="jde-java-font-lock-constant">null</span>) <span class="keyword">return</span> ev;
+ <span class="comment">// The non-matching event has been pushed back.
+</span> <span class="comment">// Get it and discard. Note that if the first attempt to
+</span> <span class="comment">// getEvent() returns null, the expectStartElement() calls
+</span> <span class="comment">// will throw a NoSuchElementException
+</span> ev = getEvent();
+ pool.surrenderEvent(ev);
+ } <span class="keyword">while</span> (ev != <span class="jde-java-font-lock-constant">null</span>);
+ <span class="comment">// Exit from this while loop is only by discovery of null event
+</span> <span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">NoSuchElementException</span>
+ ("<span class="string">StartElement from array not found.</span>");
+ }
+
+ <span class="comment">/**
+ * Expect one of an array of possible STARTELEMENT events. The next
+ * STARTELEMENT must have a <tt>QName</tt> which matches an element
+ * of the argument <tt>String[]</tt> list.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">list</span><span class="comment"> a <tt>String[]</tt> array containing <tt>QName</tt>s
+ * of possible events, one of which must be the next returned.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> the matching STARTELEMENT event.If the next
+ * event detected is not of the required type, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="variable-name">expectStartElement</span>
+ (<span class="type">String</span>[] <span class="variable-name">list</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span>;
+ <span class="keyword">for</span> (<span class="type">int</span> <span class="variable-name">i</span> = <span class="jde-java-font-lock-number">0</span>; i < list.length; i++) {
+ ev = expectStartElement(list[i], discardWhiteSpace);
+ <span class="comment">// Found it!
+</span> <span class="keyword">if</span> (ev != <span class="jde-java-font-lock-constant">null</span>) <span class="keyword">return</span> ev;
+ }
+ <span class="keyword">return</span> <span class="jde-java-font-lock-constant">null</span>;
+ }
+
+ <span class="comment">/**
+ * Get one of a array of possible STARTELEMENT events. Scan and discard
+ * events until a STARTELEMENT event is found which is in the fo:
+ * namespace and whose FO type matches one of those in the argument
+ * <tt>int</tt> array.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">list</span><span class="comment"> an <tt>int[]</tt> array containing FO types
+ * one of which is required.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> the next matching STARTELEMENT event from the buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name">getStartElement</span>(<span class="type">int</span>[] <span class="variable-name">list</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span>;
+ <span class="keyword">do</span> {
+ ev = expectStartElement(list, discardWhiteSpace);
+ <span class="keyword">if</span> (ev != <span class="jde-java-font-lock-constant">null</span>) <span class="keyword">return</span> ev;
+ <span class="comment">// The non-matching event has been pushed back.
+</span> <span class="comment">// Get it and discard. Note that if the first attempt to
+</span> <span class="comment">// getEvent() returns null, the expectStartElement() calls
+</span> <span class="comment">// will throw a NoSuchElementException
+</span> ev = getEvent();
+ pool.surrenderEvent(ev);
+ } <span class="keyword">while</span> (ev != <span class="jde-java-font-lock-constant">null</span>);
+ <span class="comment">// Exit from this while loop is only by discovery of null event
+</span> <span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">NoSuchElementException</span>
+ ("<span class="string">StartElement from array not found.</span>");
+ }
+
+ <span class="comment">/**
+ * Expect one of an array of possible STARTELEMENT events. The next
+ * STARTELEMENT must be in the fo: namespace, and must have an FO type
+ * which matches one of those in the argument <tt>int[]</tt> list.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">list</span><span class="comment"> a <tt>int[]</tt> array containing the FO types
+ * of possible events, one of which must be the next returned.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> the matching STARTELEMENT event.If the next
+ * event detected is not of the required type, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="variable-name">expectStartElement</span>
+ (<span class="type">int</span>[] <span class="variable-name">list</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span>;
+ <span class="keyword">for</span> (<span class="type">int</span> <span class="variable-name">i</span> = <span class="jde-java-font-lock-number">0</span>; i < list.length; i++) {
+ ev = expectStartElement(list[i], discardWhiteSpace);
+ <span class="comment">// Found it!
+</span> <span class="keyword">if</span> (ev != <span class="jde-java-font-lock-constant">null</span>) <span class="keyword">return</span> ev;
+ }
+ <span class="keyword">return</span> <span class="jde-java-font-lock-constant">null</span>;
+ }
+
+ <span class="comment">/**
+ * Get one of a <tt>BitSet</tt> of possible STARTELEMENT events. Scan
+ * and discard events until a STARTELEMENT event is found which is in
+ * the fo: namespace and whose FO type matches one of those in the
+ * argument <tt>BitSet</tt>.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name" id="set">set</span><span class="comment"> a <tt>BitSet</tt> containing FO types one of which is
+ * required.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> the next matching STARTELEMENT event from the buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name">getStartElement</span>(<span class="type">BitSet</span> <span class="variable-name">set</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span>;
+ <span class="keyword">do</span> {
+ <span class="keyword">try</span> {
+ ev = expectStartElement(set, discardWhiteSpace);
+ <span class="keyword">if</span> (ev != <span class="jde-java-font-lock-constant">null</span>) <span class="keyword">return</span> ev;
+ <span class="comment">// The non-matching event has been pushed back.
+</span> <span class="comment">// Get it and discard. Note that if the first attempt to
+</span> <span class="comment">// getEvent() returns null, the expectStartElement() calls
+</span> <span class="comment">// will throw a NoSuchElementException
+</span> ev = getEvent();
+ pool.surrenderEvent(ev);
+ } <span class="keyword">catch</span>(<span class="type">UnexpectedStartElementException</span> <span class="variable-name">e</span>) {
+ ev = getEvent();
+ pool.surrenderEvent(ev);
+ }
+ } <span class="keyword">while</span> (ev != <span class="jde-java-font-lock-constant">null</span>);
+ <span class="comment">// Exit from this while loop is only by discovery of null event
+</span> <span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">NoSuchElementException</span>
+ ("<span class="string">StartElement from BitSet not found.</span>");
+ }
+
+ <span class="comment">/**
+ * Expect one of an <tt>BitSet</tt> of possible STARTELEMENT events.
+ * The next STARTELEMENT must be in the fo: namespace, and must have an
+ * FO type which matches one of those in the argument <tt>BitSet</tt>.
+ * <p>TODO:<br>
+ * This method should be retro-fitted to list and array versions.
+ *
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">set</span><span class="comment"> a <tt>BitSet</tt> containing the FO types
+ * of possible events, one of which must be the next returned.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> the matching STARTELEMENT event.If the next
+ * event detected is not of the required type, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="variable-name">expectStartElement</span>
+ (<span class="type">BitSet</span> <span class="variable-name">set</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>, <span class="type">UnexpectedStartElementException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span>;
+ ev = expectTypedEvent(XMLEvent.<span class="jde-java-font-lock-constant">STARTELEMENT</span>, discardWhiteSpace);
+ <span class="keyword">if</span> (ev == <span class="jde-java-font-lock-constant">null</span>) <span class="keyword">return</span> ev;
+
+ <span class="keyword">for</span> (<span class="type">int</span> <span class="variable-name">i</span> = set.nextSetBit(<span class="jde-java-font-lock-number">0</span>); i >= <span class="jde-java-font-lock-number">0</span>; i = set.nextSetBit(++i)) {
+ <span class="keyword">if</span> (ev.foType == i)
+ <span class="keyword">return</span> ev; <span class="comment">// Found it!
+</span> }
+ <span class="comment">// Not found - push the STARTELEMENT event back and throw an
+</span> <span class="comment">// UnexpectedStartElementException
+</span> pushBack(ev);
+ <span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">UnexpectedStartElementException</span>
+ ("<span class="string">Unexpected START element: </span>" + ev.getQName());
+ }
+
+ <span class="comment">/**
+ * Expect that the next element will be a STARTELEMENT for one of the
+ * flow objects which are members of %block; from
+ * <b></span><span class="jde-java-font-lock-bold">6.2 Formatting Object Content</span><span class="comment"></b>, including out-of-line flow
+ * objects which may occur except as descendents of out-of-line formatting
+ * objects. White space is discarded.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> the <tt>FoXMLEvent found. If any other events are encountered
+ * return <tt>null</tt>.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name" id="expectBlock">expectBlock</span>()
+ <span class="keyword">throws</span> <span class="type">FOPException</span>, <span class="type">UnexpectedStartElementException</span>
+ {
+ <span class="keyword">return</span> expectStartElement
+ (FObjectSets.blockEntity, XMLEvent.<span class="jde-java-font-lock-constant" id="DISCARD_W_SPACE">DISCARD_W_SPACE</span>);
+ }
+
+ <span class="comment">/**
+ * Expect that the next element will be a STARTELEMENT for one of the
+ * flow objects which are members of %block; from
+ * <b></span><span class="jde-java-font-lock-bold">6.2 Formatting Object Content</span><span class="comment"></b>, excluding out-of-line flow
+ * objects which may not occur as descendents of out-of-line formatting
+ * objects. White space is discarded.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> the <tt>FoXMLEvent found. If any other events are encountered
+ * return <tt>null</tt>.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name" id="expectOutOfLineBlock">expectOutOfLineBlock</span>()
+ <span class="keyword">throws</span> <span class="type">FOPException</span>, <span class="type">UnexpectedStartElementException</span>
+ {
+ <span class="keyword">return</span> expectStartElement
+ (FObjectSets.outOfLineBlockSet, XMLEvent.<span class="jde-java-font-lock-constant">DISCARD_W_SPACE</span>);
+ }
+
+ <span class="comment">/**
+ * Expect that the next element will be a STARTELEMENT for one of the
+ * flow objects which are members of (#PCDATA|%inline;) from
+ * <b></span><span class="jde-java-font-lock-bold">6.2 Formatting Object Content</span><span class="comment"></b>, including out-of-line flow
+ * objects which may occur except as descendents of out-of-line
+ * formatting objects. White space is retained, and
+ * will appear as #PCDATA, i.e, as an instance of FoCharacters.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> the <tt>FoXMLEvent found. If any other events are encountered
+ * return <tt>null</tt>.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name" id="expectPcdataOrInline">expectPcdataOrInline</span>()
+ <span class="keyword">throws</span> <span class="type">FOPException</span>, <span class="type">UnexpectedStartElementException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span> = expectStartElement
+ (FObjectSets.normalPcdataInlineSet, XMLEvent.<span class="jde-java-font-lock-constant" id="RETAIN_W_SPACE">RETAIN_W_SPACE</span>);
+ <span class="keyword">if</span> (ev == <span class="jde-java-font-lock-constant">null</span>)
+ ev = expectCharacters();
+ <span class="keyword">return</span> ev;
+ }
+
+ <span class="comment">/**
+ * Expect that the next element will be a STARTELEMENT for one of the
+ * flow objects which are members of (#PCDATA|%inline;) from
+ * <b></span><span class="jde-java-font-lock-bold">6.2 Formatting Object Content</span><span class="comment"></b>, excluding out-of-line flow
+ * objects which may not occur as descendents of out-of-line formatting
+ * objects. White space is retained, and
+ * will appear as #PCDATA, i.e, as an instance of FoCharacters.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> the <tt>FoXMLEvent found. If any other events are encountered
+ * return <tt>null</tt>.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name" id="expectOutOfLinePcdataOrInline">expectOutOfLinePcdataOrInline</span>()
+ <span class="keyword">throws</span> <span class="type">FOPException</span>, <span class="type">UnexpectedStartElementException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span> = expectStartElement
+ (FObjectSets.inlineEntity, XMLEvent.<span class="jde-java-font-lock-constant">RETAIN_W_SPACE</span>);
+ <span class="keyword">if</span> (ev == <span class="jde-java-font-lock-constant">null</span>)
+ ev = expectCharacters();
+ <span class="keyword">return</span> ev;
+ }
+
+ <span class="comment">/**
+ * Expect that the next element will be a STARTELEMENT for one of the
+ * flow objects which are members of (#PCDATA|%inline;|%block;) from
+ * <b></span><span class="jde-java-font-lock-bold">6.2 Formatting Object Content</span><span class="comment"></b>, including out-of-line flow
+ * objects which may occur except as descendents of out-of-line
+ * formatting objects. White space is retained, and
+ * will appear as #PCDATA, i.e, as an instance of FoCharacters.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> the <tt>FoXMLEvent</tt> found. If any other events are
+ * encountered return <tt>null</tt>.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name" id="expectPcdataOrInlineOrBlock">expectPcdataOrInlineOrBlock</span>()
+ <span class="keyword">throws</span> <span class="type">FOPException</span>, <span class="type">UnexpectedStartElementException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span> = expectStartElement
+ (FObjectSets.normalPcdataBlockInlineSet, XMLEvent.<span class="jde-java-font-lock-constant">RETAIN_W_SPACE</span>);
+ <span class="keyword">if</span> (ev == <span class="jde-java-font-lock-constant">null</span>)
+ ev = expectCharacters();
+ <span class="keyword">return</span> ev;
+ }
+
+ <span class="comment">/**
+ * Expect that the next element will be a STARTELEMENT for one of the
+ * flow objects which are members of (#PCDATA|%inline;|%block;) from
+ * <b></span><span class="jde-java-font-lock-bold">6.2 Formatting Object Content</span><span class="comment"></b>, excluding out-of-line flow
+ * objects which may not occur as descendents of out-of-line formatting
+ * objects. White space is retained, and
+ * will appear as #PCDATA, i.e, as an instance of FoCharacters.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> the <tt>FoXMLEvent</tt> found. If any other events are
+ * encountered return <tt>null</tt>.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name" id="expectOutOfLinePcdataOrInlineOrBlock">expectOutOfLinePcdataOrInlineOrBlock</span>()
+ <span class="keyword">throws</span> <span class="type">FOPException</span>, <span class="type">UnexpectedStartElementException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span> = expectStartElement
+ (FObjectSets.outOfLinePcdataBlockInlineSet,
+ XMLEvent.<span class="jde-java-font-lock-constant">RETAIN_W_SPACE</span>);
+ <span class="keyword">if</span> (ev == <span class="jde-java-font-lock-constant">null</span>)
+ ev = expectCharacters();
+ <span class="keyword">return</span> ev;
+ }
+
+ <span class="comment">/**
+ * Get the next ENDELEMENT event from the buffer. Discard any other
+ * events preceding the ENDELEMENT event.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> an ENDELEMENT event
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name" id="getEndElement">getEndElement</span>() <span class="keyword">throws</span> <span class="type">FOPException</span> {
+ <span class="keyword">return</span> getTypedEvent(XMLEvent.<span class="jde-java-font-lock-constant" id="ENDELEMENT">ENDELEMENT</span>);
+ }
+
+ <span class="comment">/**
+ * Return the next element if it is an ENDELEMENT. If the next
+ * element is not of the required type, push it back onto the buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> a matching ENDELEMENT event. If the next
+ * event detected is not of the required type, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if ENDELEMENT is not the next
+ * event detected. The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name" id="expectEndElement">expectEndElement</span>(<span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="keyword">return</span> expectTypedEvent(XMLEvent.<span class="jde-java-font-lock-constant">ENDELEMENT</span>, discardWhiteSpace);
+ }
+
+ <span class="comment">/**
+ * Get the next ENDELEMENT event with the given <tt>QName</tt>
+ * from the buffer. Discard any other events preceding the
+ * ENDELEMENT event.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">qName</span><span class="comment"> a <tt>String</tt> with the <tt>QName</tt> of the
+ * required STARTELEMENT
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> an ENDELEMENT event
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name">getEndElement</span>(<span class="type">String</span> <span class="variable-name">qName</span>) <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="keyword">return</span> getTypedEvent(XMLEvent.<span class="jde-java-font-lock-constant">ENDELEMENT</span>, qName);
+ }
+
+ <span class="comment">/**
+ * Return the next element if it is an ENDELEMENT with the given
+ * <tt>QName</tt>. If the next
+ * element is not of the required type, push it back onto the buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">qName</span><span class="comment"> a <tt>String</tt> with the <tt>QName</tt> of the
+ * required ENDELEMENT
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> an ENDELEMENT with the given qname. If the next
+ * event detected is not an ENDELEMENT, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name">expectEndElement</span>(<span class="type">String</span> <span class="variable-name">qName</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="keyword">return</span> expectTypedEvent(XMLEvent.<span class="jde-java-font-lock-constant">ENDELEMENT</span>, qName, discardWhiteSpace);
+ }
+
+ <span class="comment">/**
+ * Get the next ENDELEMENT event with the given URI index and local name
+ * from the buffer. Discard any other events preceding the
+ * ENDELEMENT event.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">uriIndex</span><span class="comment"> an <tt>int</tt> with the index of the URI of the
+ * required URI
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">localName</span><span class="comment"> a <tt>String</tt> with the local name of the
+ * required ENDELEMENT
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> an ENDELEMENT event
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name">getEndElement</span>(<span class="type">int</span> <span class="variable-name">uriIndex</span>, <span class="type">String</span> <span class="variable-name">localName</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="keyword">return</span> getTypedEvent(XMLEvent.<span class="jde-java-font-lock-constant">ENDELEMENT</span>, uriIndex, localName);
+ }
+
+ <span class="comment">/**
+ * Return the next element if it is an ENDELEMENT with the given
+ * URI index and local name. If the next
+ * element is not of the required type, push it back onto the buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">uriIndex</span><span class="comment"> an <tt>int</tt> with the index of the URI of the
+ * required URI
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">localName</span><span class="comment"> a <tt>String</tt> with the local name of the
+ * required ENDELEMENT
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> a matching ENDELEMENT event.
+ * If the next
+ * event detected is not an ENDELEMENT, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="variable-name">expectEndElement</span>
+ (<span class="type">int</span> <span class="variable-name">uriIndex</span>, <span class="type">String</span> <span class="variable-name">localName</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="keyword">return</span> expectTypedEvent
+ (XMLEvent.<span class="jde-java-font-lock-constant">ENDELEMENT</span>, uriIndex, localName, discardWhiteSpace);
+ }
+
+ <span class="comment">/**
+ * Get the next ENDELEMENT event with the given Fo type
+ * from the buffer. Discard any other events preceding the
+ * ENDELEMENT event.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">foType</span><span class="comment"> - the FO type of the required ENDELEMENT
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> a matching ENDELEMENT event.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name">getEndElement</span>(<span class="type">int</span> <span class="variable-name">foType</span>) <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="keyword">return</span> getTypedEvent(XMLEvent.<span class="jde-java-font-lock-constant">ENDELEMENT</span>, foType);
+ }
+
+ <span class="comment">/**
+ * Return the next element if it is an ENDELEMENT with the given
+ * FO type. If the next
+ * element is not of the required type, push it back onto the buffer.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">foType</span><span class="comment"> - the FO type of the required ENDELEMENT
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> a matching ENDELEMENT. If the next
+ * event detected is not an ENDELEMENT, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name">expectEndElement</span>(<span class="type">int</span> <span class="variable-name">foType</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="keyword">return</span> expectTypedEvent
+ (XMLEvent.<span class="jde-java-font-lock-constant">ENDELEMENT</span>, foType, discardWhiteSpace);
+ }
+
+ <span class="comment">/**
+ * 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.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name" id="event">event</span><span class="comment"> 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.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> an ENDELEMENT event
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name">getEndElement</span>(<span class="type">FoXMLEvent</span> <span class="variable-name">event</span>) <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="keyword">if</span> (event.foType != FObjectNames.<span class="jde-java-font-lock-constant" id="NO_FO">NO_FO</span>)
+ <span class="keyword">return</span> getTypedEvent(XMLEvent.<span class="jde-java-font-lock-constant">ENDELEMENT</span>, event.foType);
+ <span class="keyword">return</span> getTypedEvent
+ (XMLEvent.<span class="jde-java-font-lock-constant">ENDELEMENT</span>, event.uriIndex, event.localName);
+ }
+
+ <span class="comment">/**
+ * 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.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">event</span><span class="comment"> 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.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> a matching ENDELEMENT event. If the next
+ * event detected is not an ENDELEMENT, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="variable-name">expectEndElement</span>
+ (<span class="type">FoXMLEvent</span> <span class="variable-name">event</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="keyword">if</span> (event.foType != FObjectNames.<span class="jde-java-font-lock-constant">NO_FO</span>)
+ <span class="keyword">return</span> expectTypedEvent
+ (XMLEvent.<span class="jde-java-font-lock-constant">ENDELEMENT</span>, event.foType, discardWhiteSpace);
+ <span class="keyword">return</span> expectTypedEvent
+ (XMLEvent.<span class="jde-java-font-lock-constant">ENDELEMENT</span>, event.uriIndex, event.localName,
+ discardWhiteSpace);
+ }
+
+ <span class="comment">/**
+ * 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.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name" id="discardEvent">discardEvent</span><span class="comment"> the argument event may be discarded.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">event</span><span class="comment"> 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.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> an ENDELEMENT event
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name">getEndElement</span>(<span class="type">boolean</span> <span class="variable-name">discardEvent</span>, <span class="type">FoXMLEvent</span> <span class="variable-name">event</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span>;
+ <span class="keyword">if</span> (event.foType != FObjectNames.<span class="jde-java-font-lock-constant">NO_FO</span>)
+ ev = getTypedEvent(XMLEvent.<span class="jde-java-font-lock-constant">ENDELEMENT</span>, event.foType);
+ <span class="keyword">else</span>
+ ev = getTypedEvent
+ (XMLEvent.<span class="jde-java-font-lock-constant">ENDELEMENT</span>, event.uriIndex, event.localName);
+ <span class="keyword">if</span> (discardEvent) {
+ <span class="comment">//System.out.println("discardEvent");
+</span> pool.surrenderEvent(event);
+ }
+ <span class="keyword">return</span> ev;
+ }
+
+ <span class="comment">/**
+ * 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.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardEvent</span><span class="comment"> the argument event may be discarded.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">event</span><span class="comment"> 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.
+ * </span><span class="jde-java-font-lock-doc-tag">@param</span><span class="comment"> </span><span class="variable-name">discardWhiteSpace</span><span class="comment"> - if true, discard any <tt>characters</tt>
+ * events which contain only whitespace.
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> a matching ENDELEMENT event. If the next
+ * event detected is not an ENDELEMENT, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="variable-name">expectEndElement</span>
+ (<span class="type">boolean</span> <span class="variable-name">discardEvent</span>, <span class="type">FoXMLEvent</span> <span class="variable-name">event</span>, <span class="type">boolean</span> <span class="variable-name">discardWhiteSpace</span>)
+ <span class="keyword">throws</span> <span class="type">FOPException</span>
+ {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span>;
+ <span class="keyword">if</span> (event.foType != FObjectNames.<span class="jde-java-font-lock-constant">NO_FO</span>)
+ ev = expectTypedEvent
+ (XMLEvent.<span class="jde-java-font-lock-constant">ENDELEMENT</span>, event.foType, discardWhiteSpace);
+ <span class="keyword">else</span>
+ ev = expectTypedEvent
+ (XMLEvent.<span class="jde-java-font-lock-constant">ENDELEMENT</span>, event.uriIndex, event.localName,
+ discardWhiteSpace);
+ <span class="keyword">if</span> (discardEvent)
+ pool.surrenderEvent(event);
+ <span class="keyword">return</span> ev;
+ }
+
+ <span class="comment">/**
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> a CHARACTERS event
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if the event is not found
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name" id="getCharacters">getCharacters</span>() <span class="keyword">throws</span> <span class="type">FOPException</span> {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span> = getEvent();
+ <span class="keyword">while</span> (ev != <span class="jde-java-font-lock-constant">null</span> && ev.type != XMLEvent.<span class="jde-java-font-lock-constant">CHARACTERS</span>) {
+ pool.surrenderEvent(ev);
+ ev = getEvent();
+ }
+ <span class="keyword">if</span> (ev == <span class="jde-java-font-lock-constant">null</span>) {
+ <span class="keyword">throw</span> <span class="keyword">new</span> <span class="type">NoSuchElementException</span>("<span class="string">Characters not found.</span>");
+ }
+ <span class="keyword">return</span> ev;
+ }
+
+ <span class="comment">/**
+ * </span><span class="jde-java-font-lock-doc-tag">@return</span><span class="comment"> a CHARACTERS event. If the next event detected is not
+ * a CHARACTERS event, <tt>null</tt> is returned.
+ * The erroneous event is pushed back.
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">FOPException</span><span class="comment"> if buffer errors or interrupts occur
+ * </span><span class="jde-java-font-lock-doc-tag">@exception</span><span class="comment"> </span><span class="type">NoSuchElementException</span><span class="comment"> if end of buffer detected.
+ */</span>
+ <span class="jde-java-font-lock-modifier">public</span> <span class="type">FoXMLEvent</span> <span class="function-name" id="expectCharacters">expectCharacters</span>() <span class="keyword">throws</span> <span class="type">FOPException</span> {
+ <span class="type">FoXMLEvent</span> <span class="variable-name">ev</span> = getEvent();
+ <span class="keyword">if</span> (ev != <span class="jde-java-font-lock-constant">null</span> && ev.type == XMLEvent.<span class="jde-java-font-lock-constant">CHARACTERS</span>) {
+ <span class="keyword">return</span> ev;
+ }
+ pushBack(ev);
+ <span class="keyword">return</span> <span class="jde-java-font-lock-constant">null</span>;
+ }
+
+}
+</pre>
+ </body>
+</html>