ws-xmlrpc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject cvs commit: xml-rpc/src/java/org/apache/xmlrpc XmlRpc.java
Date Thu, 17 Jan 2002 19:13:51 GMT
dlr         02/01/17 11:13:51

  Modified:    src/java/org/apache/xmlrpc XmlRpc.java
  Log:
  o In the inner class Value, refactored endElement() and setType() to
  use switches instead of ifs.  New format is slightly more efficient
  and easier to read.
  
  o Tweaked some JavaDoc.
  
  Revision  Changes    Path
  1.7       +31 -17    xml-rpc/src/java/org/apache/xmlrpc/XmlRpc.java
  
  Index: XmlRpc.java
  ===================================================================
  RCS file: /home/cvs/xml-rpc/src/java/org/apache/xmlrpc/XmlRpc.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -u -r1.6 -r1.7
  --- XmlRpc.java	17 Jan 2002 19:06:59 -0000	1.6
  +++ XmlRpc.java	17 Jan 2002 19:13:51 -0000	1.7
  @@ -557,11 +557,10 @@
       }
   
       /**
  -      * This represents an XML-RPC Value while the request is being parsed.
  -      */
  +     * This represents a XML-RPC value parsed from the request.
  +     */
       class Value
       {
  -
           int type;
           Object value;
           // the name to use for the next member of struct values
  @@ -583,29 +582,39 @@
             */
           public void endElement (Value child)
           {
  -            if (type == ARRAY)
  +            switch (type)
  +            {
  +            case ARRAY:
                   array.addElement (child.value);
  -            else if (type == STRUCT)
  +                break;
  +            case STRUCT:
                   struct.put (nextMemberName, child.value);
  +            }
           }
   
           /**
  -          * Set the type of this value. If it's a container, create the corresponding java
container.
  -          */
  +         * Set the type of this value. If it's a container, create the
  +         * corresponding java container.
  +         */
           public void setType (int type)
           {
               // System.err.println ("setting type to "+types[type]);
               this.type = type;
  -            if (type == ARRAY)
  +            switch (type)
  +            {
  +            case ARRAY:
                   value = array = new Vector ();
  -            if (type == STRUCT)
  +                break;
  +            case STRUCT:
                   value = struct = new Hashtable ();
  +                break;
  +            }
           }
   
           /**
  -          * Set the character data for the element and interpret it according to the
  -          * element type
  -          */
  +         * Set the character data for the element and interpret it
  +         * according to the element type.
  +         */
           public void characterData (String cdata)
           {
               switch (type)
  @@ -643,9 +652,12 @@
               }
           }
   
  -        // This is a performance hack to get the type of a value without casting the Object.
  -        // It breaks the contract of method hashCode, but it doesn't matter since
  -        // Value objects are never used as keys in Hashtables.
  +        /**
  +         * This is a performance hack to get the type of a value
  +         * without casting the Object.  It breaks the contract of
  +         * method hashCode, but it doesn't matter since Value objects
  +         * are never used as keys in Hashtables.
  +         */
           public int hashCode ()
           {
               return type;
  @@ -653,12 +665,14 @@
   
           public String toString ()
           {
  -            return (types[type] + " element "+value);
  +            return (types[type] + " element " + value);
           }
       }
   
   
  -    // A quick and dirty XML writer.
  +    /**
  +     * A quick and dirty XML writer.
  +     */
       class XmlWriter
       {
   
  
  
  

Mime
View raw message