cvs commit: xml-fop/src/org/apache/fop/xml SyncedXmlEventsBuffer.java

2002-10-08 Thread pbwest

pbwest  2002/10/08 23:07:04

  Modified:src/org/apache/fop/xml Tag: FOP_0-20-0_Alt-Design
SyncedXmlEventsBuffer.java
  Log:
  Added get/expectTypedEvent.  Modified all other get/expect methods to use these.  
Added array arguments to multiple choice get/expectStartElement().
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.1.2.3   +429 -170  xml-fop/src/org/apache/fop/xml/Attic/SyncedXmlEventsBuffer.java
  
  Index: SyncedXmlEventsBuffer.java
  ===
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/xml/Attic/SyncedXmlEventsBuffer.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- SyncedXmlEventsBuffer.java3 Oct 2002 03:37:26 -   1.1.2.2
  +++ SyncedXmlEventsBuffer.java9 Oct 2002 06:07:03 -   1.1.2.3
  @@ -69,7 +69,7 @@
   XMLEvent ev;
   try {
   ev = (XMLEvent)get();
  -//System.out.println(getEvent:  + ev);
  +System.out.println(getEvent:  + ev);
   return ev;
   } catch (InterruptedException e) {
   throw new FOPException(e);
  @@ -77,68 +77,244 @@
   }
   
   /**
  - * @return an ENDDOCUMENT event
  - * @exception FOPException if buffer errors or interrupts occur
  - * @exception NoSuchElementException if the event is not found
  + * Get the next event of the given type from the buffer.  Discard
  + * intervening events.
  + * @param eventType - the ttint/tt event type.
  + * @return an event of the given type.
  + * @exception FOPException if buffer errors or interrupts occur.
  + * @exception NoSuchElementException if the event is not found.
*/
  -public XMLEvent getEndDocument() throws FOPException {
  +public XMLEvent getTypedEvent(int eventType) throws FOPException {
   XMLEvent ev = getEvent();
  -while (ev != null  ev.type != XMLEvent.ENDDOCUMENT) {
  +while (ev != null  ev.type != eventType) {
   ev = getEvent();
   }
   if (ev == null) {
  -throw new NoSuchElementException(EndDocument not found.);
  +throw new NoSuchElementException
  +(XMLEvent.eventTypeName(eventType) +  not found.);
   }
   return ev;
   }
   
   /**
  - * @return an ENDDOCUMENT event
  - * @exception FOPException if buffer errors or interrupts occur
  - * @exception NoSuchElementException if ENDDOCUMENT is not the next
  - * event detected.  The erroneous event is pushed back.
  + * Get the next event of the given type and with the given ttQName/tt
  + * from the buffer.  Discard intervening events.
  + * @param eventType - the ttint/tt event type.
  + * @param qName a ttString/tt with the ttQName/tt of the
  + * required element.
  + * @return an event of the given type.
  + * @exception FOPException if buffer errors or interrupts occur.
  + * @exception NoSuchElementException if the event is not found.
*/
  -public XMLEvent expectEndDocument() throws FOPException {
  +public XMLEvent getTypedEvent(int eventType, String qName)
  +throws FOPException
  +{
  +XMLEvent ev = getEvent();
  +while (ev != null 
  +   ! (ev.type == eventType  ev.qName.equals(qName))) {
  +ev = getEvent();
  +}
  +if (ev == null) {
  +throw new NoSuchElementException
  +(XMLEvent.eventTypeName(eventType) +   + qName +  not found.);
  +}
  +return ev;
  +}
  +
  +/**
  + * Get the next event of the given type, and with the given URI index and
  + * local name, from the buffer.  Discard intervening events.
  + * @param eventType - the ttint/tt event type.
  + * @param uriIndex - the ttint/tt URI index maintained in the
  + * ttXMLNamespaces/tt object.
  + * @param localName a ttString/tt with the local name of the
  + * required element.
  + * @return an event of the given type.
  + * @exception FOPException if buffer errors or interrupts occur.
  + * @exception NoSuchElementException if the event is not found.
  + */
  +public XMLEvent getTypedEvent
  +(int eventType, int uriIndex, String localName)
  +throws FOPException
  +{
   XMLEvent ev = getEvent();
  -if (ev != null  ev.type == XMLEvent.ENDDOCUMENT) {
  +while (ev != null 
  +   ! (ev.type == eventType
  +   ev.type == eventType
  +   ev.localName.equals(localName))) {
  +ev = getEvent();
  +}
  +if (ev == null)
  +throw new NoSuchElementException
  +(XMLEvent.eventTypeName(eventType)
  

cvs commit: xml-fop/src/org/apache/fop/xml SyncedXmlEventsBuffer.java

2002-10-02 Thread pbwest

pbwest  2002/10/02 20:37:27

  Modified:src/org/apache/fop/xml Tag: FOP_0-20-0_Alt-Design
SyncedXmlEventsBuffer.java
  Log:
  Rethrow InterruptedException directly.
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.1.2.2   +4 -3  xml-fop/src/org/apache/fop/xml/Attic/SyncedXmlEventsBuffer.java
  
  Index: SyncedXmlEventsBuffer.java
  ===
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/xml/Attic/SyncedXmlEventsBuffer.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- SyncedXmlEventsBuffer.java16 Sep 2002 04:20:24 -  1.1.2.1
  +++ SyncedXmlEventsBuffer.java3 Oct 2002 03:37:26 -   1.1.2.2
  @@ -72,7 +72,7 @@
   //System.out.println(getEvent:  + ev);
   return ev;
   } catch (InterruptedException e) {
  -throw new FOPException(InterruptedException);
  +throw new FOPException(e);
   }
   }
   
  @@ -221,6 +221,7 @@
   public XMLEvent expectStartElement(int uriIndex, String localName)
   throws FOPException
   {
  +//System.out.println(In expectStartElement..);
   XMLEvent ev = getEvent();
   if (ev != null 
   (ev.type == XMLEvent.STARTELEMENT
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]