axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/message DebugHeader.java ElementRecorder.java MessageElement.java RPCElement.java RPCParam.java SOAPFaultElement.java SOAPSAXHandler.java
Date Thu, 03 May 2001 15:36:01 GMT
gdaniels    01/05/03 08:36:00

  Modified:    java/src/org/apache/axis/encoding
                        DeserializationContext.java DeserializerBase.java
               java/src/org/apache/axis/message DebugHeader.java
                        ElementRecorder.java MessageElement.java
                        RPCElement.java RPCParam.java SOAPFaultElement.java
                        SOAPSAXHandler.java
  Log:
  First stage of cleaning up control flow and deserialization handling.  Add
  a couple of "events" to DeserializerBase, for start and end of child
  elements.  This makes deserializing structures much nicer (see samples/
  encoding).
  
  Next step is to clean up the MessageElement/RPCElement/RPCParam
  classes, but wanted to checkpoint this.
  
  Revision  Changes    Path
  1.3       +1 -1      xml-axis/java/src/org/apache/axis/encoding/DeserializationContext.java
  
  Index: DeserializationContext.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DeserializationContext.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DeserializationContext.java	2001/05/03 14:31:43	1.2
  +++ DeserializationContext.java	2001/05/03 15:35:18	1.3
  @@ -80,7 +80,7 @@
           mappingRegistry.setDeserializationContext(this);
       }
       
  -    public void pushElementHandler(ContentHandler handler)
  +    public void pushElementHandler(DeserializerBase handler)
       {
           baseHandler.pushElementHandler(handler);    
       }
  
  
  
  1.3       +7 -64     xml-axis/java/src/org/apache/axis/encoding/DeserializerBase.java
  
  Index: DeserializerBase.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DeserializerBase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DeserializerBase.java	2001/05/03 14:31:44	1.2
  +++ DeserializerBase.java	2001/05/03 15:35:21	1.3
  @@ -76,7 +76,6 @@
   {
       protected Object value = null;
       protected DeserializationContext context = null;
  -    protected DeserializerBase parent = null;
       
       public Object getValue()
       {
  @@ -88,75 +87,19 @@
           this.context = context;
       }
       
  -    public void setParent(DeserializerBase parent)
  -    {
  -        this.parent = parent;
  -    }
  -    
       /** Deserialization structure handlers
        */
  -    public void onEndChild(String localName, DeserializerBase deserializer)
  -        throws SAXException
  -    {
  -    }
  -    
  -    /** DEFAULT IMPLEMENTATIONS OF SAX EVENT HANDLERS
  -     * 
  -     * All of these throw errors at this level, so if you want to allow
  -     * things like children, you need to override these methods in your
  -     * deserializer.
  -     */
  -    public void startDocument() throws SAXException {
  -        throw new SAXException(
  -            "StartDocument event not allowed in this context.");
  -    }
  -    
  -    public void endDocument() throws SAXException {
  -        throw new SAXException(
  -            "EndDocument event not allowed in this context.");
  -    }
  -    
  -    public void startPrefixMapping(String p1, String p2) throws SAXException {
  -        throw new SAXException(
  -            "StartPrefixMapping event not allowed in this context.");
  -    }
  -    
  -    public void endPrefixMapping(String p1) throws SAXException {
  -        throw new SAXException(
  -            "EndPrefixMapping event not allowed in this context.");
  -    }
  -    
  -    public void characters(char[] p1, int p2, int p3) throws SAXException {
  -        throw new SAXException(
  -            "Characters event not allowed in this context.");
  -    }
  -    
  -    public void ignorableWhitespace(char[] p1, int p2, int p3) 
  -        throws SAXException
  -    {
  -        throw new SAXException(
  -            "IgnorableWhitespace event not allowed in this context.");
  -    }
  -    
  -    public void skippedEntity(String p1) throws SAXException {
  -        throw new SAXException(
  -            "SkippedEntity event not allowed in this context.");
  -    }
  -    
  -    public void startElement(String namespace, String localName,
  +
  +    public void onStartChild(String namespace, String localName,
                                String qName, Attributes attributes)
           throws SAXException
       {
  -        throw new SAXException(
  -            "StartElement event not allowed in this context.");
  +        // Base does nothing
       }
  -
  -    public void endElement(String namespace, String localName,
  -                             String qName)
  +    
  +    public void onEndChild(String localName, DeserializerBase deserializer)
           throws SAXException
       {
  -        if (parent != null) {
  -            parent.onEndChild(localName, this);
  -        }
  -    }
  +        // Base does nothing
  +    }    
   }
  
  
  
  1.3       +2 -2      xml-axis/java/src/org/apache/axis/message/DebugHeader.java
  
  Index: DebugHeader.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/DebugHeader.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DebugHeader.java	2001/04/30 05:24:16	1.2
  +++ DebugHeader.java	2001/05/03 15:35:34	1.3
  @@ -29,7 +29,7 @@
           return new DebugHeaderFactory();
       }
       
  -    class SAXHandler extends DefaultHandler
  +    class SAXHandler extends DeserializerBase
       {
           public void characters(char [] chars, int start, int end)
           {
  @@ -66,7 +66,7 @@
       // Override the default (recording) implementation because we
       // want to parse this header ourselves as it goes by.
       
  -    public ContentHandler getContentHandler()
  +    public DeserializerBase getContentHandler()
       { return new SAXHandler(); }
       
       public void output(SerializationContext context)
  
  
  
  1.4       +12 -1     xml-axis/java/src/org/apache/axis/message/ElementRecorder.java
  
  Index: ElementRecorder.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/ElementRecorder.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ElementRecorder.java	2001/05/03 14:32:15	1.3
  +++ ElementRecorder.java	2001/05/03 15:35:38	1.4
  @@ -68,7 +68,7 @@
    * 
    * @author Glen Daniels (gdaniels@allaire.com)
    */
  -class ElementRecorder extends org.xml.sax.helpers.DefaultHandler
  +class ElementRecorder extends DeserializerBase
   {
       private static final boolean DEBUG_LOG = false;
       
  @@ -85,6 +85,17 @@
       {
           if (DEBUG_LOG) {
               System.err.println("(rec) startElement ['" + namespace + "' " +
  +                           localName + "]");
  +        }
  +        
  +        _events.addElement(new StartElementEvent(namespace, localName, qName, attributes));
  +    }
  +    
  +    public void onStartChild(String namespace, String localName,
  +                             String qName, Attributes attributes)
  +    {
  +        if (DEBUG_LOG) {
  +            System.err.println("(rec) startChild ['" + namespace + "' " +
                              localName + "]");
           }
           
  
  
  
  1.12      +3 -3      xml-axis/java/src/org/apache/axis/message/MessageElement.java
  
  Index: MessageElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/MessageElement.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- MessageElement.java	2001/05/03 14:32:17	1.11
  +++ MessageElement.java	2001/05/03 15:35:40	1.12
  @@ -78,7 +78,7 @@
       protected String    href;
       protected boolean   isRoot = false;
       protected SOAPEnvelope message = null;
  -    protected DeserializationContext context = null;
  +    private DeserializationContext context = null;
       DeserializerBase deserializer;
       
       // The java Object value of this element.  This is either set by
  @@ -108,7 +108,7 @@
           }
         this.namespaceURI = namespace;
         this.name = localPart;
  -      this.context = context;
  +      //this.context = context;
   
         if (attributes == null) {
           this.attributes = new AttributesImpl();
  @@ -178,7 +178,7 @@
           value = val;
       }
       
  -    public ContentHandler getContentHandler()
  +    public DeserializerBase getContentHandler()
       {
           if (recorder == null)
               recorder = new ElementRecorder();
  
  
  
  1.4       +6 -11     xml-axis/java/src/org/apache/axis/message/RPCElement.java
  
  Index: RPCElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCElement.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RPCElement.java	2001/05/03 14:32:19	1.3
  +++ RPCElement.java	2001/05/03 15:35:43	1.4
  @@ -84,19 +84,12 @@
           return new RPCElementFactory();
       }
       
  -    class RPCContentHandler extends DefaultHandler
  +    class RPCContentHandler extends DeserializerBase
       {
  -        private boolean passedMyStart = false;
  -        
  -        public void startElement(String namespace, String name, String qName,
  +        public void onStartChild(String namespace, String name, String qName,
                                    Attributes attributes)
               throws SAXException
           {
  -            if (!passedMyStart) {
  -                passedMyStart = true;
  -                return;
  -            }
  -            
               // Start of an arg...
               RPCParam param = new RPCParam(namespace, name, attributes, context);
               
  @@ -116,13 +109,15 @@
                    */
                   
               }
  -            ContentHandler handler = param.getContentHandler();
               
  +            DeserializerBase handler = param.getContentHandler(context);
  +            
               handler.startElement(namespace, name, qName, attributes);
  +            
               context.pushElementHandler(handler);
           }
       }
  -    public ContentHandler getContentHandler() { return new RPCContentHandler(); }
  +    public DeserializerBase getContentHandler() { return new RPCContentHandler(); }
       
       ///////////////////////////////////////////////////////////////
       
  
  
  
  1.7       +1 -1      xml-axis/java/src/org/apache/axis/message/RPCParam.java
  
  Index: RPCParam.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCParam.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RPCParam.java	2001/05/03 14:32:20	1.6
  +++ RPCParam.java	2001/05/03 15:35:44	1.7
  @@ -144,7 +144,7 @@
           return super.getEnvelope();
       }
       
  -    public ContentHandler getContentHandler()
  +    public DeserializerBase getContentHandler(DeserializationContext context)
       {
           // Look up type and return an appropriate deserializer
           if (typeQName != null) {
  
  
  
  1.2       +2 -2      xml-axis/java/src/org/apache/axis/message/SOAPFaultElement.java
  
  Index: SOAPFaultElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPFaultElement.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SOAPFaultElement.java	2001/04/27 19:58:29	1.1
  +++ SOAPFaultElement.java	2001/05/03 15:35:46	1.2
  @@ -86,7 +86,7 @@
           return new FaultElementFactory();
       }
       
  -    class FaultContentHandler extends DefaultHandler
  +    class FaultContentHandler extends DeserializerBase
       {
           private boolean passedMyStart = false;
           
  @@ -96,7 +96,7 @@
               // *** TBD ***
           }
       }
  -    public ContentHandler getContentHandler() { return new FaultContentHandler(); }
  +    public DeserializerBase getContentHandler() { return new FaultContentHandler(); }
       
       ///////////////////////////////////////////////////////////////
       
  
  
  
  1.6       +13 -7     xml-axis/java/src/org/apache/axis/message/SOAPSAXHandler.java
  
  Index: SOAPSAXHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPSAXHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SOAPSAXHandler.java	2001/05/03 14:32:23	1.5
  +++ SOAPSAXHandler.java	2001/05/03 15:35:47	1.6
  @@ -58,6 +58,7 @@
   import java.io.*;
   import java.util.*;
   import org.apache.axis.*;
  +import org.apache.axis.encoding.DeserializerBase;
   import org.apache.axis.encoding.DeserializationContext;
   import org.apache.axis.encoding.ServiceDescription;
   import org.apache.axis.utils.NSStack;
  @@ -115,7 +116,7 @@
       
       protected boolean parsingToEnd = false;
       
  -    private ContentHandler elementHandler = null;
  +    private DeserializerBase elementHandler = null;
       private int recordingDepth = 0;
   
       protected DeserializationContext context;
  @@ -290,18 +291,18 @@
       /** A little utility class to keep track of our parsing state.
        */
       class HandlerContext {
  -        public HandlerContext(int recordingDepth, ContentHandler handler)
  +        public HandlerContext(int recordingDepth, DeserializerBase handler)
           {
               this.recordingDepth = recordingDepth;
               this.handler = handler;
           }
           public int recordingDepth;
  -        public ContentHandler handler;
  +        public DeserializerBase handler;
       }
       
       Stack handlerContexts = new Stack();
       
  -    public void pushElementHandler(ContentHandler handler)
  +    public void pushElementHandler(DeserializerBase handler)
       {
           // System.out.println("Pushing handler (" + recordingDepth + ") " + handler);
           
  @@ -412,11 +413,10 @@
           if (DEBUG_LOG) {
               System.out.println("startElement ['" + namespace + "' " +
                              localName + "]");
  -            namespaces.dump();
           }
           
           if (elementHandler != null) {
  -            elementHandler.startElement(namespace, localName, qName, attributes);
  +            elementHandler.onStartChild(namespace, localName, qName, attributes);
               
               recordingDepth++;
               
  @@ -521,6 +521,7 @@
                   element.setEnvelope(envelope);
                   pushElementHandler(element.getContentHandler());
                   element.setPrefix(namespaces.getPrefix(namespace));
  +                elementHandler.setDeserializationContext(context);
                   elementHandler.startElement(namespace, localName, qName, attributes);
               }
           } catch (SAXException saxEx) {
  @@ -545,8 +546,13 @@
               
               elementHandler.endElement(namespace, localName, qName);
   
  -            if (recordingDepth == 0)
  +            if (recordingDepth == 0) {
  +                DeserializerBase oldElementHandler = elementHandler;
                   popElementHandler();
  +            
  +                if (elementHandler != null)
  +                    elementHandler.onEndChild(localName, oldElementHandler);
  +            }
   
               return;
           }
  
  
  

Mime
View raw message