com.sun.xml.xsom.impl.parser.state
Class NGCCRuntime

java.lang.Object
  extended by com.sun.xml.xsom.impl.parser.state.NGCCRuntime
All Implemented Interfaces:
NGCCEventSource, ContentHandler
Direct Known Subclasses:
NGCCRuntimeEx

public class NGCCRuntime
extends Object
implements ContentHandler, NGCCEventSource

Runtime Engine for RELAXNGCC execution. This class has the following functionalities:

  1. Managing a stack of NGCCHandler objects and switching between them appropriately.
  2. Keep track of all Attributes.
  3. manage mapping between namespace URIs and prefixes.
  4. TODO: provide support for interleaving.

    Version:
    $Id: NGCCRuntime.java,v 1.16 2003/03/23 02:47:46 okajima Exp $
    Author:
    Kohsuke Kawaguchi (kk@kohsuke.org)

    Constructor Summary
    NGCCRuntime()
               
     
    Method Summary
     void characters(char[] ch, int start, int length)
               
     void consumeAttribute(int index)
               
     void endDocument()
               
     void endElement(String uri, String localname, String qname)
               
     void endPrefixMapping(String prefix)
               
     int getAttributeIndex(String uri, String localname)
               
     Attributes getCurrentAttributes()
              Attributes that belong to the current element.
     Locator getLocator()
              Gets the source location of the current event.
     void ignorableWhitespace(char[] ch, int start, int length)
               
     void onEnterElementConsumed(String uri, String localName, String qname, Attributes atts)
              Called by the generated handler code when an enter element event is consumed.
     void onLeaveElementConsumed(String uri, String localName, String qname)
               
     void processingInstruction(String target, String data)
               
     void processList(String str)
               
     void redirectSubtree(ContentHandler child, String uri, String local, String qname)
              This method can be called only from the enterElement handler.
     int replace(NGCCEventReceiver o, NGCCEventReceiver n)
              Replaces an old handler with a new handler, and returns ID of the EventReceiver thread.
     void reset()
              Cleans up all the data structure so that the object can be reused later.
     String resolveNamespacePrefix(String prefix)
               
     void sendEnterAttribute(int threadId, String uri, String local, String qname)
               
     void sendEnterElement(int threadId, String uri, String local, String qname, Attributes atts)
              Sends an enter element event to the specified EventReceiver thread.
     void sendLeaveAttribute(int threadId, String uri, String local, String qname)
               
     void sendLeaveElement(int threadId, String uri, String local, String qname)
               
     void sendText(int threadId, String value)
               
     void setDocumentLocator(Locator _loc)
               
     void setRootHandler(NGCCHandler rootHandler)
              Sets the root handler, which will be used to parse the root element.
     void skippedEntity(String name)
               
     void startDocument()
               
     void startElement(String uri, String localname, String qname, Attributes atts)
               
     void startPrefixMapping(String prefix, String uri)
               
     void trace(String s)
               
     void traceln(String s)
               
    protected  void unexpectedX(String token)
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    NGCCRuntime

    public NGCCRuntime()
    Method Detail

    setRootHandler

    public void setRootHandler(NGCCHandler rootHandler)
    Sets the root handler, which will be used to parse the root element.

    This method can be called right after the object is created or the reset method is called. You can't replace the root handler while parsing is in progress.

    Usually a generated class that corresponds to the <start> pattern will be used as the root handler, but any NGCCHandler can be a root handler.

    Throws:
    IllegalStateException - If this method is called but it doesn't satisfy the pre-condition stated above.

    reset

    public void reset()
    Cleans up all the data structure so that the object can be reused later. Normally, applications do not need to call this method directly, as the runtime resets itself after the endDocument method.


    setDocumentLocator

    public void setDocumentLocator(Locator _loc)
    Specified by:
    setDocumentLocator in interface ContentHandler

    getLocator

    public Locator getLocator()
    Gets the source location of the current event.

    One can call this method from RelaxNGCC handlers to access the line number information. Note that to


    getCurrentAttributes

    public Attributes getCurrentAttributes()
    Attributes that belong to the current element.

    It's generally not recommended for applications to use this method. RelaxNGCC internally removes processed attributes, so this doesn't correctly reflect all the attributes an element carries.


    replace

    public int replace(NGCCEventReceiver o,
                       NGCCEventReceiver n)
    Description copied from interface: NGCCEventSource
    Replaces an old handler with a new handler, and returns ID of the EventReceiver thread.

    Specified by:
    replace in interface NGCCEventSource

    processList

    public void processList(String str)
                     throws SAXException
    Throws:
    SAXException

    startElement

    public void startElement(String uri,
                             String localname,
                             String qname,
                             Attributes atts)
                      throws SAXException
    Specified by:
    startElement in interface ContentHandler
    Throws:
    SAXException

    onEnterElementConsumed

    public void onEnterElementConsumed(String uri,
                                       String localName,
                                       String qname,
                                       Attributes atts)
                                throws SAXException
    Called by the generated handler code when an enter element event is consumed.

    Pushes a new attribute set.

    Note that attributes are NOT pushed at the startElement method, because the processing of the enterElement event can trigger other attribute events and etc.

    This method will be called from one of handlers when it truely consumes the enterElement event.

    Throws:
    SAXException

    onLeaveElementConsumed

    public void onLeaveElementConsumed(String uri,
                                       String localName,
                                       String qname)
                                throws SAXException
    Throws:
    SAXException

    endElement

    public void endElement(String uri,
                           String localname,
                           String qname)
                    throws SAXException
    Specified by:
    endElement in interface ContentHandler
    Throws:
    SAXException

    characters

    public void characters(char[] ch,
                           int start,
                           int length)
                    throws SAXException
    Specified by:
    characters in interface ContentHandler
    Throws:
    SAXException

    ignorableWhitespace

    public void ignorableWhitespace(char[] ch,
                                    int start,
                                    int length)
                             throws SAXException
    Specified by:
    ignorableWhitespace in interface ContentHandler
    Throws:
    SAXException

    getAttributeIndex

    public int getAttributeIndex(String uri,
                                 String localname)

    consumeAttribute

    public void consumeAttribute(int index)
                          throws SAXException
    Throws:
    SAXException

    startPrefixMapping

    public void startPrefixMapping(String prefix,
                                   String uri)
                            throws SAXException
    Specified by:
    startPrefixMapping in interface ContentHandler
    Throws:
    SAXException

    endPrefixMapping

    public void endPrefixMapping(String prefix)
                          throws SAXException
    Specified by:
    endPrefixMapping in interface ContentHandler
    Throws:
    SAXException

    skippedEntity

    public void skippedEntity(String name)
                       throws SAXException
    Specified by:
    skippedEntity in interface ContentHandler
    Throws:
    SAXException

    processingInstruction

    public void processingInstruction(String target,
                                      String data)
                               throws SAXException
    Specified by:
    processingInstruction in interface ContentHandler
    Throws:
    SAXException

    endDocument

    public void endDocument()
                     throws SAXException
    Specified by:
    endDocument in interface ContentHandler
    Throws:
    SAXException

    startDocument

    public void startDocument()
                       throws SAXException
    Specified by:
    startDocument in interface ContentHandler
    Throws:
    SAXException

    sendEnterAttribute

    public void sendEnterAttribute(int threadId,
                                   String uri,
                                   String local,
                                   String qname)
                            throws SAXException
    Specified by:
    sendEnterAttribute in interface NGCCEventSource
    Throws:
    SAXException

    sendEnterElement

    public void sendEnterElement(int threadId,
                                 String uri,
                                 String local,
                                 String qname,
                                 Attributes atts)
                          throws SAXException
    Description copied from interface: NGCCEventSource
    Sends an enter element event to the specified EventReceiver thread.

    Specified by:
    sendEnterElement in interface NGCCEventSource
    Throws:
    SAXException

    sendLeaveAttribute

    public void sendLeaveAttribute(int threadId,
                                   String uri,
                                   String local,
                                   String qname)
                            throws SAXException
    Specified by:
    sendLeaveAttribute in interface NGCCEventSource
    Throws:
    SAXException

    sendLeaveElement

    public void sendLeaveElement(int threadId,
                                 String uri,
                                 String local,
                                 String qname)
                          throws SAXException
    Specified by:
    sendLeaveElement in interface NGCCEventSource
    Throws:
    SAXException

    sendText

    public void sendText(int threadId,
                         String value)
                  throws SAXException
    Specified by:
    sendText in interface NGCCEventSource
    Throws:
    SAXException

    redirectSubtree

    public void redirectSubtree(ContentHandler child,
                                String uri,
                                String local,
                                String qname)
                         throws SAXException
    This method can be called only from the enterElement handler. The sub-tree rooted at the new element will be redirected to the specified ContentHandler.

    Currently active NGCCHandler will only receive the leaveElement event of the newly started element.

    Parameters:
    uri,local,qname - Parameters passed to the enter element event. Used to simulate the startElement event for the new ContentHandler.
    Throws:
    SAXException

    resolveNamespacePrefix

    public String resolveNamespacePrefix(String prefix)

    unexpectedX

    protected void unexpectedX(String token)
                        throws SAXException
    Throws:
    SAXException

    trace

    public void trace(String s)

    traceln

    public void traceln(String s)


    Copyright © 2012 Oracle. All Rights Reserved.