jmsnell     2003/02/27 15:13:19

  Modified:    java/src/org/apache/axis/wsdl/toJava
                        JavaGeneratorFactory.java
  Log:
  Partial FIX http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12935
  
  A collision error would occur when an anonymous type was named 
  the same as a top level type because of the way the filename and 
  typename was generated.
  
  Revision  Changes    Path
  1.34      +19 -12    
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaGeneratorFactory.java
  
  Index: JavaGeneratorFactory.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaGeneratorFactory.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- JavaGeneratorFactory.java 15 Jan 2003 13:53:03 -0000      1.33
  +++ JavaGeneratorFactory.java 27 Feb 2003 23:13:19 -0000      1.34
  @@ -372,18 +372,25 @@
                               // the qName
                               tEntry.setName(emitter.getJavaName(typeQName));
                           } else {
  -                            // This is an anonymous type name.
  -                            // Axis uses '>' as a nesting token to generate
  -                            // unique qnames for anonymous types.
  -                            // Only consider the localName after the last '>' 
  -                            // when generating the java name
  -                            String localName = typeQName.getLocalPart();
  -                            localName = 
  -                                localName.substring(
  -                                    localName.lastIndexOf(
  -                                        SymbolTable.ANON_TOKEN)+1);
  -                            typeQName = new QName(typeQName.getNamespaceURI(), 
  -                                                  localName);
  +                           String localName = typeQName.getLocalPart();
  +                              
  +                           // Check to see if this is an anonymous type,
  +                           // if it is, replace Axis' ANON_TOKEN with
  +                           // an underscore to make sure we don't run
  +                           // into name collisions with similarly named
  +                           // non-anonymous types                          
  +                           StringBuffer sb = new StringBuffer(localName);
  +                           int aidx = -1;
  +                           while (
  +                             (aidx = sb.indexOf(
  +                               SymbolTable.ANON_TOKEN)) > -1) {
  +                                 sb.replace(aidx, 
aidx+SymbolTable.ANON_TOKEN.length(), "_");
  +                           }
  +                           localName = sb.toString();
  +                                                 
  +                           typeQName = new QName(typeQName.getNamespaceURI(), 
  +                                                 localName);
  +                                                  
                               // If there is already an existing type,
                               // there will be a collision.  
                               // If there is an existing anon type, 
  
  
  

Reply via email to