dims        2002/11/05 06:40:31

  Modified:    java/src/org/apache/axis/message MessageElement.java
  Log:
  Fix for Bug 14140 - getNamespacePrefixes of MessageElement throws a 
NullPointerException if no namespaces have been declared.
  
  Revision  Changes    Path
  1.134     +16 -22    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.133
  retrieving revision 1.134
  diff -u -r1.133 -r1.134
  --- MessageElement.java       4 Nov 2002 19:40:54 -0000       1.133
  +++ MessageElement.java       5 Nov 2002 14:40:31 -0000       1.134
  @@ -143,7 +143,7 @@
   
       protected MessageElement parent = null;
   
  -    public ArrayList namespaces = null;
  +    public ArrayList namespaces = new ArrayList();
   
       /** Our encoding style, if any */
       protected String encodingStyle = null;
  @@ -301,9 +301,9 @@
        * @return Attributes collection
        */
       public Attributes getCompleteAttributes() {
  -        if (namespaces == null)
  +        if (namespaces.size()==0)
               return attributes;
  -
  +        
           AttributesImpl attrs = null;
           if (attributes == NullAttributes.singleton)
               attrs = new AttributesImpl();
  @@ -447,7 +447,8 @@
   
       public void setNSMappings(ArrayList namespaces)
       {
  -        this.namespaces = namespaces;
  +        if(namespaces != null)
  +            this.namespaces = namespaces;
       }
   
       public String getPrefix(String namespaceURI) {
  @@ -458,12 +459,10 @@
               return getRealElement().getPrefix(namespaceURI);
           }
   
  -        if (namespaces != null) {
  -            for (int i = 0; i < namespaces.size(); i++) {
  -                Mapping map = (Mapping)namespaces.get(i);
  -                if (map.getNamespaceURI().equals(namespaceURI))
  -                    return map.getPrefix();
  -            }
  +        for (int i = 0; i < namespaces.size(); i++) {
  +            Mapping map = (Mapping)namespaces.get(i);
  +            if (map.getNamespaceURI().equals(namespaceURI))
  +                return map.getPrefix();
           }
   
           if (parent != null)
  @@ -480,12 +479,10 @@
               return getRealElement().getNamespaceURI(prefix);
           }
   
  -        if (namespaces != null) {
  -            for (int i = 0; i < namespaces.size(); i++) {
  -                Mapping map = (Mapping)namespaces.get(i);
  -                if (map.getPrefix().equals(prefix)) {
  -                    return map.getNamespaceURI();
  -                }
  +        for (int i = 0; i < namespaces.size(); i++) {
  +            Mapping map = (Mapping)namespaces.get(i);
  +            if (map.getPrefix().equals(prefix)) {
  +                return map.getNamespaceURI();
               }
           }
   
  @@ -783,11 +780,9 @@
           if (prefix != null)
               context.registerPrefixForURI(prefix, namespaceURI);
   
  -        if (namespaces != null) {
  -            for (Iterator i = namespaces.iterator(); i.hasNext();) {
  -                Mapping mapping = (Mapping) i.next();
  -                context.registerPrefixForURI(mapping.getPrefix(), 
mapping.getNamespaceURI());
  -            }
  +        for (Iterator i = namespaces.iterator(); i.hasNext();) {
  +            Mapping mapping = (Mapping) i.next();
  +            context.registerPrefixForURI(mapping.getPrefix(), 
mapping.getNamespaceURI());
           }
   
           if (objectValue != null) {
  @@ -817,7 +812,6 @@
       }
   
       public void addMapping(Mapping map) {
  -        if (namespaces == null) namespaces = new ArrayList();
           namespaces.add(map);
       }
   
  
  
  


Reply via email to