You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ru...@apache.org on 2002/08/19 21:13:55 UTC

cvs commit: xml-axis/java/src/org/apache/axis/message NullAttributes.java MessageElement.java

rubys       2002/08/19 12:13:55

  Modified:    java/src/org/apache/axis/encoding
                        DeserializationContextImpl.java
               java/src/org/apache/axis/message MessageElement.java
  Added:       java/src/org/apache/axis/message NullAttributes.java
  Log:
  Optimize heavily for the elements will no attributes case (both because
  it is easy, and because it frequently occurs in doc/lit scenarios).
  
  Revision  Changes    Path
  1.49      +6 -1      xml-axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java
  
  Index: DeserializationContextImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- DeserializationContextImpl.java	19 Aug 2002 18:51:27 -0000	1.48
  +++ DeserializationContextImpl.java	19 Aug 2002 19:13:53 -0000	1.49
  @@ -63,6 +63,7 @@
   import org.apache.axis.message.EnvelopeHandler;
   import org.apache.axis.message.IDResolver;
   import org.apache.axis.message.MessageElement;
  +import org.apache.axis.message.NullAttributes;
   import org.apache.axis.message.SAX2EventRecorder;
   import org.apache.axis.message.SOAPEnvelope;
   import org.apache.axis.message.SOAPHandler;
  @@ -848,7 +849,11 @@
               log.debug("Enter: DeserializationContextImpl::startElement(" + namespace + ", " + localName + ")");
           }
           
  -        attributes = new AttributesImpl(attributes);
  +        if (attributes == null || attributes.getLength() == 0) {
  +            attributes = NullAttributes.singleton;
  +        } else {
  +            attributes = new AttributesImpl(attributes);
  +        }
   
           SOAPHandler nextHandler = null;
   
  
  
  
  1.122     +2 -4      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.121
  retrieving revision 1.122
  diff -u -r1.121 -r1.122
  --- MessageElement.java	19 Aug 2002 18:51:27 -0000	1.121
  +++ MessageElement.java	19 Aug 2002 19:13:53 -0000	1.122
  @@ -109,12 +109,10 @@
               new Mapping(Constants.URI_DEFAULT_SOAP_ENC,
                           "SOAP-ENC");
   
  -    private static final Attributes nullAttributes = new AttributesImpl();
  -
       protected String    name ;
       protected String    prefix ;
       protected String    namespaceURI ;
  -    protected transient Attributes attributes = nullAttributes;
  +    protected transient Attributes attributes = NullAttributes.singleton;
       protected String    id;
       protected String    href;
       protected boolean   _isRoot = true;
  @@ -561,7 +559,7 @@
       }
   
       protected AttributesImpl makeAttributesEditable() {
  -        if (attributes == null || attributes == nullAttributes) {
  +        if (attributes == null || attributes instanceof NullAttributes) {
               attributes =  new AttributesImpl();
           } else if (!(attributes instanceof AttributesImpl)) {
               attributes = new AttributesImpl(attributes);
  
  
  
  1.1                  xml-axis/java/src/org/apache/axis/message/NullAttributes.java
  
  Index: NullAttributes.java
  ===================================================================
  package org.apache.axis.message;
  
  import org.xml.sax.Attributes;
  
  /**
   * Null implementation of the Attributes interface.
   *
   * @author David Megginson
   * @author Sam Ruby <ru...@us.ibm.com>
   */
  public class NullAttributes implements Attributes {
  
      public static final NullAttributes singleton = new NullAttributes();
  
      ////////////////////////////////////////////////////////////////////
      // Implementation of org.xml.sax.Attributes.
      ////////////////////////////////////////////////////////////////////
  
  
      /**
       * Return the number of attributes in the list.
       *
       * @return The number of attributes in the list.
       * @see org.xml.sax.Attributes#getLength
       */
      public int getLength () {
  	return 0;
      }
  
  
      /**
       * Return an attribute's Namespace URI.
       *
       * @param index The attribute's index (zero-based).
       * @return The Namespace URI, the empty string if none is
       *         available, or null if the index is out of range.
       * @see org.xml.sax.Attributes#getURI
       */
      public String getURI (int index) {
  	return null;
      }
  
  
      /**
       * Return an attribute's local name.
       *
       * @param index The attribute's index (zero-based).
       * @return The attribute's local name, the empty string if 
       *         none is available, or null if the index if out of range.
       * @see org.xml.sax.Attributes#getLocalName
       */
      public String getLocalName (int index) {
  	return null;
      }
  
  
      /**
       * Return an attribute's qualified (prefixed) name.
       *
       * @param index The attribute's index (zero-based).
       * @return The attribute's qualified name, the empty string if 
       *         none is available, or null if the index is out of bounds.
       * @see org.xml.sax.Attributes#getQName
       */
      public String getQName (int index) {
  	return null;
      }
  
  
      /**
       * Return an attribute's type by index.
       *
       * @param index The attribute's index (zero-based).
       * @return The attribute's type, "CDATA" if the type is unknown, or null
       *         if the index is out of bounds.
       * @see org.xml.sax.Attributes#getType(int)
       */
      public String getType (int index) {
  	return null;
      }
  
  
      /**
       * Return an attribute's value by index.
       *
       * @param index The attribute's index (zero-based).
       * @return The attribute's value or null if the index is out of bounds.
       * @see org.xml.sax.Attributes#getValue(int)
       */
      public String getValue (int index) {
  	return null;
      }
  
  
      /**
       * Look up an attribute's index by Namespace name.
       *
       * <p>In many cases, it will be more efficient to look up the name once and
       * use the index query methods rather than using the name query methods
       * repeatedly.</p>
       *
       * @param uri The attribute's Namespace URI, or the empty
       *        string if none is available.
       * @param localName The attribute's local name.
       * @return The attribute's index, or -1 if none matches.
       * @see org.xml.sax.Attributes#getIndex(java.lang.String,java.lang.String)
       */
      public int getIndex (String uri, String localName) {
  	return -1;
      }
  
  
      /**
       * Look up an attribute's index by qualified (prefixed) name.
       *
       * @param qName The qualified name.
       * @return The attribute's index, or -1 if none matches.
       * @see org.xml.sax.Attributes#getIndex(java.lang.String)
       */
      public int getIndex (String qName) {
  	return -1;
      }
  
  
      /**
       * Look up an attribute's type by Namespace-qualified name.
       *
       * @param uri The Namespace URI, or the empty string for a name
       *        with no explicit Namespace URI.
       * @param localName The local name.
       * @return The attribute's type, or null if there is no
       *         matching attribute.
       * @see org.xml.sax.Attributes#getType(java.lang.String,java.lang.String)
       */
      public String getType (String uri, String localName) {
  	return null;
      }
  
  
      /**
       * Look up an attribute's type by qualified (prefixed) name.
       *
       * @param qName The qualified name.
       * @return The attribute's type, or null if there is no
       *         matching attribute.
       * @see org.xml.sax.Attributes#getType(java.lang.String)
       */
      public String getType (String qName) {
  	return null;
      }
  
  
      /**
       * Look up an attribute's value by Namespace-qualified name.
       *
       * @param uri The Namespace URI, or the empty string for a name
       *        with no explicit Namespace URI.
       * @param localName The local name.
       * @return The attribute's value, or null if there is no
       *         matching attribute.
       * @see org.xml.sax.Attributes#getValue(java.lang.String,java.lang.String)
       */
      public String getValue (String uri, String localName) {
  	return null;
      }
  
  
      /**
       * Look up an attribute's value by qualified (prefixed) name.
       *
       * @param qName The qualified name.
       * @return The attribute's value, or null if there is no
       *         matching attribute.
       * @see org.xml.sax.Attributes#getValue(java.lang.String)
       */
      public String getValue (String qName) {
  	return null;
      }
  }