xml-xmlbeans-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject cvs commit: xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile Java2Schema.java Java2SchemaTask.java Java2Schema_new.java
Date Fri, 26 Mar 2004 19:40:25 GMT
pcal        2004/03/26 11:40:25

  Modified:    v2/jam/src/org/apache/xmlbeans/impl/jam/annotation
                        AnnotationProxy.java
               v2/jam/src/org/apache/xmlbeans/impl/jam/internal/reflect
                        ReflectClassBuilder.java
               v2/jam/test/tests/org/apache/xmlbeans/test/jam
                        JamTestBase.java ParserJamTest.java
                        ReflectJamTest.java SourcesJamTest.java
               v2/src/binding/org/apache/xmlbeans/impl/binding/compile
                        Java2Schema.java Java2SchemaTask.java
  Added:       v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses
                        ImportsGalore.java
  Removed:     v2/src/binding/org/apache/xmlbeans/impl/binding/compile
                        Java2Schema_new.java
  Log:
  remove stray 1.5 imports, add some tests, delete Java2Schema_new
  
  Revision  Changes    Path
  1.11      +0 -4      xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/annotation/AnnotationProxy.java
  
  Index: AnnotationProxy.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/annotation/AnnotationProxy.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AnnotationProxy.java	26 Mar 2004 00:15:39 -0000	1.10
  +++ AnnotationProxy.java	26 Mar 2004 19:40:25 -0000	1.11
  @@ -18,15 +18,11 @@
   import org.apache.xmlbeans.impl.jam.provider.JamServiceContext;
   import org.apache.xmlbeans.impl.jam.JAnnotationValue;
   
  -import java.util.StringTokenizer;
   import java.util.Properties;
  -import java.util.Iterator;
   import java.util.Enumeration;
   import java.lang.reflect.Method;
   import java.lang.reflect.Modifier;
   import java.lang.reflect.InvocationTargetException;
  -import java.lang.annotation.Annotation;
  -import java.io.StringWriter;
   
   /**
    * <p>Provides a proxied view of some annotation artifact.  JAM calls the
  
  
  
  1.7       +0 -2      xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/reflect/ReflectClassBuilder.java
  
  Index: ReflectClassBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/reflect/ReflectClassBuilder.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ReflectClassBuilder.java	26 Mar 2004 00:15:39 -0000	1.6
  +++ ReflectClassBuilder.java	26 Mar 2004 19:40:25 -0000	1.7
  @@ -18,12 +18,10 @@
   import org.apache.xmlbeans.impl.jam.provider.JamClassBuilder;
   import org.apache.xmlbeans.impl.jam.provider.JamServiceContext;
   import org.apache.xmlbeans.impl.jam.provider.JamLogger;
  -import org.apache.xmlbeans.impl.jam.internal.javadoc.JavadocAnnotationExtractor;
   
   import java.lang.reflect.Constructor;
   import java.lang.reflect.Field;
   import java.lang.reflect.Method;
  -import java.lang.annotation.Annotation;
   
   /**
    *
  
  
  
  1.1                  xml-xmlbeans/v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/ImportsGalore.java
  
  Index: ImportsGalore.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  package org.apache.xmlbeans.test.jam.dummyclasses;
  
  import org.apache.xmlbeans.impl.jam.JClass;
  import javax.xml.stream.XMLStreamException;
  import java.util.Properties;
  
  /**
   * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
   */
  public interface ImportsGalore {
  }
  
  
  
  1.17      +14 -0     xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/JamTestBase.java
  
  Index: JamTestBase.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/JamTestBase.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- JamTestBase.java	26 Mar 2004 00:15:39 -0000	1.16
  +++ JamTestBase.java	26 Mar 2004 19:40:25 -0000	1.17
  @@ -122,6 +122,7 @@
       DUMMY+".Foo",
       DUMMY+".FooImpl",
       DUMMY+".HeavilyCommented",
  +    DUMMY+".ImportsGalore",
       DUMMY+".MyException",
       DUMMY+".MultilineTags",
       DUMMY+".ManyTags",
  @@ -183,10 +184,12 @@
   
     public JamTestBase() {
       super("JamTestBase");
  +    System.out.println("constructed JamTestBase");
     }
   
     public JamTestBase(String casename) {
       super(casename);
  +    System.out.println("constructed JamTestBase "+casename);    
     }
   
     // ========================================================================
  @@ -216,6 +219,8 @@
   
     protected abstract boolean isCommentsAvailable();
   
  +  protected abstract boolean isImportsAvailable();
  +
     protected abstract File getMasterDir();
   
     // ========================================================================
  @@ -414,6 +419,15 @@
                                 methods,isParameterNamesKnown(),this);
     }
   
  +
  +  public void testImports()
  +  {
  +    if (!isImportsAvailable()) return;
  +    JClass clazz = resolved(mLoader.loadClass(DUMMY+".ImportsGalore"));
  +    JClass[] imports = clazz.getImportedClasses();
  +    assertTrue("class has "+imports.length+" imports",
  +               imports.length == 3);
  +  }
   
   
     public void testInterfaceIsAssignableFrom()
  
  
  
  1.8       +3 -2      xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/ParserJamTest.java
  
  Index: ParserJamTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/ParserJamTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ParserJamTest.java	26 Mar 2004 00:15:40 -0000	1.7
  +++ ParserJamTest.java	26 Mar 2004 19:40:25 -0000	1.8
  @@ -46,9 +46,10 @@
       return jsf.createService(params);
     }
   
  -  protected boolean isAnnotationsAvailable() {
  -    return false;//FIXME!!
  +  protected boolean isAnnotationsAvailable() { return false;//FIXME!!
     }
  +
  +  protected boolean isImportsAvailable() { return false; }
   
     //kind of a quick hack for now, should remove this and make sure that
     //even the classes case make the annotations available using a special
  
  
  
  1.3       +4 -3      xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/ReflectJamTest.java
  
  Index: ReflectJamTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/ReflectJamTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ReflectJamTest.java	26 Mar 2004 00:15:40 -0000	1.2
  +++ ReflectJamTest.java	26 Mar 2004 19:40:25 -0000	1.3
  @@ -86,9 +86,10 @@
       return jsf.createService(params);
     }
   
  -  protected boolean isAnnotationsAvailable() {
  -    return false;
  -  }
  +  protected boolean isAnnotationsAvailable() { return false; }
  +
  +  protected boolean isImportsAvailable() { return false; }  
  +
   
     //kind of a quick hack for now, should remove this and make sure that
     //even the classes case make the annotations available using a special
  
  
  
  1.10      +3 -3      xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/SourcesJamTest.java
  
  Index: SourcesJamTest.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/SourcesJamTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SourcesJamTest.java	26 Mar 2004 00:15:40 -0000	1.9
  +++ SourcesJamTest.java	26 Mar 2004 19:40:25 -0000	1.10
  @@ -93,9 +93,9 @@
       return jsf.createService(params);
     }
   
  -  protected boolean isAnnotationsAvailable() {
  -    return true;
  -  }
  +  protected boolean isAnnotationsAvailable() { return true; }
  +
  +  protected boolean isImportsAvailable() { return false; }
   
     //kind of a quick hack for now, should remove this and make sure that
     //even the classes case make the annotations available using a special
  
  
  
  1.45      +135 -65   xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Java2Schema.java
  
  Index: Java2Schema.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Java2Schema.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- Java2Schema.java	20 Mar 2004 21:51:34 -0000	1.44
  +++ Java2Schema.java	26 Mar 2004 19:40:25 -0000	1.45
  @@ -17,15 +17,15 @@
   
   import org.apache.xmlbeans.impl.binding.bts.*;
   import org.apache.xmlbeans.impl.binding.tylar.TylarWriter;
  -import org.apache.xmlbeans.impl.jam_old.*;
  -import org.apache.xmlbeans.impl.jam_old.internal.BaseJElement;
  -import org.apache.xmlbeans.impl.jam_old.internal.JPropertyImpl;
  +import org.apache.xmlbeans.impl.jam.*;
  +import org.apache.xmlbeans.impl.jam.visitor.MVisitor;
   import org.apache.xmlbeans.impl.common.XMLChar;
   import org.w3.x2001.xmlSchema.*;
   import javax.xml.namespace.QName;
   import java.util.ArrayList;
   import java.util.List;
  -import java.util.Properties;
  +import java.util.Map;
  +import java.util.HashMap;
   import java.io.IOException;
   import java.io.StringWriter;
   
  @@ -63,8 +63,8 @@
   
     public static final String TAG_AT               = "xsdgen:attribute";
     public static final String TAG_AT_NAME          = TAG_AT+".name";
  -  public static final String TAG_AT_CHECKER       = TAG_AT+".isSetMethod";
   
  +  public static final String TAG_ISSETTER         = "xsdgen:isSetMethodFor";
   
     // this is the character that replaces invalid characters when creating new
     // xml names.
  @@ -79,7 +79,6 @@
     //private Map mTns2Schema = new HashMap();
     private SchemaDocument.Schema mSchema;
     private JClass[] mClasses; // the input classes
  -  private JAnnotationLoader mAnnotationLoader = null;
   
     // =========================================================================
     // Constructors
  @@ -92,25 +91,6 @@
     }
   
     // ========================================================================
  -  // Public methods
  -
  -  /**
  -   * Sets the JAnnotionLoader to be used to 'overlay' external annotations
  -   * onto the input JClass set.
  -   */
  -  public void setAnnotationLoader(JAnnotationLoader jal) {
  -    if (jal == null) throw new IllegalArgumentException("null jal");
  -    mAnnotationLoader = jal;
  -    //FIXME this is a gross quick hack to get the external annotations
  -    //working.  long term, we need to extend jam_old to allow a jam_old facade to be
  -    //created that imposes the annotations without actually modifying the
  -    //input JClasses like we do here.
  -    for(int i=0; i<mClasses.length; i++) {
  -      ((BaseJElement)mClasses[i]).setAnnotationLoader(mAnnotationLoader);
  -    }
  -  }
  -
  -  // ========================================================================
     // BindingCompiler implementation
   
     /**
  @@ -177,8 +157,8 @@
       xsType.setName(xsdName);
       // deal with inheritance - see if it extends anything
       JClass superclass = clazz.getSuperclass();
  -    if (superclass != null && !superclass.isObject() &&
  -      !getAnnotation(clazz,TAG_CT_IGNORESUPER,false)) {
  +    if (superclass != null && !superclass.isObjectType() &&
  +            !getAnnotation(clazz,TAG_CT_IGNORESUPER,false)) {
         // FIXME we're ignoring interfaces at the moment
         BindingType superBindingType = getBindingTypeFor(superclass);
         ComplexContentDocument.ComplexContent ccd = xsType.addNewComplexContent();
  @@ -190,30 +170,33 @@
                                                        XmlTypeName.forTypeNamed(qname));
       ByNameBean bindType = new ByNameBean(btname);
       mBindingFile.addBindingType(bindType,true,true);
  -    if (clazz.isPrimitive()) {
  +    if (clazz.isPrimitiveType()) {
         // it's good to have registerd the dummy type, but don't go further
  -      logError("Unexpected simple type: "+clazz.getQualifiedName());
  +      logError("Unexpected simple type",clazz);
         return bindType;
       }
       String rootName = getAnnotation(clazz,TAG_CT_ROOT,null);
       if (rootName != null) {
         QName rootQName = new QName(tns, rootName);
         BindingTypeName docBtName =
  -        BindingTypeName.forPair(getJavaName(clazz),
  -                                XmlTypeName.forGlobalName(XmlTypeName.ELEMENT, rootQName));
  +              BindingTypeName.forPair(getJavaName(clazz),
  +                                      XmlTypeName.forGlobalName(XmlTypeName.ELEMENT, rootQName));
         SimpleDocumentBinding sdb = new SimpleDocumentBinding(docBtName);
         sdb.setTypeOfElement(btname.getXmlName());
         mBindingFile.addBindingType(sdb,true,true);
       }
       // run through the class' properties to populate the binding and xsdtypes
       SchemaPropertyFacade facade = new SchemaPropertyFacade(xsType,bindType,tns);
  -    bindProperties(JPropertyImpl.getProperties(clazz.getDeclaredMethods()),facade);
  +    Map props2issetters = new HashMap();
  +    getIsSetters(clazz,props2issetters);
  +    bindProperties(clazz.getDeclaredProperties(),props2issetters,facade);
       facade.finish();
       // check to see if they want to create a root elements from this type
  -    JAnnotation[] anns = clazz.getAnnotations(TAG_CT_ROOT);
  +    JAnnotation[] anns = getNamedTags(clazz.getAllJavadocTags(),TAG_CT_ROOT);
       for(int i=0; i<anns.length; i++) {
         TopLevelElement root = mSchema.addNewElement();
  -      root.setName(makeNcNameSafe(anns[i].getStringValue()));
  +      root.setName(makeNcNameSafe(anns[i].getValue
  +                                  (JAnnotation.SINGLE_VALUE_NAME).asString()));
         root.setType(qname);
         // FIXME still not entirely clear to me what we should do about
         // the binding file here
  @@ -221,6 +204,33 @@
       return bindType;
     }
   
  +  private void getIsSetters(JClass clazz, Map outPropname2jmethod) {
  +    JMethod[] methods = clazz.getDeclaredMethods();
  +    for(int i=0; i<methods.length; i++) {
  +      JAnnotation ann = methods[i].getAnnotation(TAG_ISSETTER);
  +      if (ann != null) {
  +        if (!methods[i].getReturnType().getQualifiedName().equals("boolean")) {
  +          logWarning("Method "+methods[i].getQualifiedName()+" is marked "+
  +                     TAG_ISSETTER+"\nbut it does not return boolean."+
  +                     "Ignoring.");
  +          continue;
  +        }
  +        if (methods[i].getParameters().length > 0) {
  +          logWarning("Method "+methods[i].getQualifiedName()+" is marked "+
  +                     TAG_ISSETTER+"\nbut takes arguments.  Ignoring.");
  +          continue;
  +        }
  +        JAnnotationValue propNameVal = ann.getValue(JAnnotation.SINGLE_VALUE_NAME);
  +        if (propNameVal == null) {
  +          logWarning("Method "+methods[i].getQualifiedName()+" is marked "+
  +                     TAG_ISSETTER+"\nbut but no property name is given.  Ignoring");
  +          continue;
  +        }
  +        outPropname2jmethod.put(propNameVal.asString(),methods[i]);
  +      }
  +    }
  +  }
  +
     /**
      * Runs through a set of JProperties to creates schema and bts elements
      * to represent those properties.  Note that the details of manipulating the
  @@ -232,25 +242,28 @@
      * @param facade Allows us to create and manipulate properties,
      * hides the dirty work
      */
  -  private void bindProperties(JProperty[] props, SchemaPropertyFacade facade) {
  +  private void bindProperties(JProperty[] props,
  +                              Map props2issetters,
  +                              SchemaPropertyFacade facade) {
       for(int i=0; i<props.length; i++) {
         if (getAnnotation(props[i],TAG_EL_EXCLUDE,false)) {
  -        logVerbose("Marked excluded, skipping property "+props[i].getQualifiedName());
  +        logVerbose("Marked excluded, skipping",props[i]);
           continue;
         }
         if (props[i].getGetter() == null || props[i].getSetter() == null) {
  -        logVerbose("Does not have both getter and setter, skipping "+props[i].getQualifiedName());
  +        logVerbose("Does not have both getter and setter, skipping",props[i]);
           continue; // REVIEW this might have to change someday
         }
  +      String propName;
         { // determine the property name to use and set it
  -        String propName = getAnnotation(props[i],TAG_AT_NAME,null);
  +        propName = getAnnotation(props[i],TAG_AT_NAME,null);
           if (propName != null) {
             facade.newAttributeProperty(props[i]);
             facade.setSchemaName(propName);
           } else {
             facade.newElementProperty(props[i]);
             facade.setSchemaName(getAnnotation
  -                               (props[i],TAG_EL_NAME,props[i].getSimpleName()));
  +                         (props[i],TAG_EL_NAME,props[i].getSimpleName()));
           }
         }
         { // determine the property type to use and set it
  @@ -259,16 +272,16 @@
           if (annotatedType == null) {
             facade.setType(propType = props[i].getType());
           } else {
  -          if (props[i].getType().isArray()) {
  +          if (props[i].getType().isArrayType()) {
               //THIS IS A QUICK GROSS HACK THAT SHOULD BE REMOVED.
               //IF SOMEONE WANTS TO AS TYPE AN ARRAY PROPERTY, THEY NEED
               //TO ASTYPE IT TO THE ARRAY TYPE THEMSELVES
               annotatedType = "[L"+annotatedType+";";
             }
             propType = props[i].getType().forName(annotatedType);
  -          if (propType.isUnresolved()) {
  +          if (propType.isUnresolvedType()) {
               logError("Could not find class named '"+
  -                    propType.getQualifiedName()+"'");
  +                    propType.getQualifiedName()+"'",props[i]);
             } else {
               facade.setType(propType);
             }
  @@ -278,14 +291,19 @@
           facade.setGetter(props[i].getGetter());
           facade.setSetter(props[i].getSetter());
         }
  +      {
  +        JMethod issetter = (JMethod)props2issetters.get(propName);
  +        if (issetter != null) facade.setIssetter(issetter);
  +      }
         { // determine if the property is nillable
           JAnnotation a = props[i].getAnnotation(TAG_EL_NILLABLE);
           if (a != null) {
             // if the tag is there but empty, set it to true.  is that weird?
  -          if (a.getStringValue().trim().length() == 0) {
  +          JAnnotationValue val = a.getValue(JAnnotation.SINGLE_VALUE_NAME);
  +          if (val == null || val.asString().trim().length() == 0) {
               facade.setNillable(true);
             } else {
  -            facade.setNillable(a.getBooleanValue());
  +            facade.setNillable(val.asBoolean());
             }
           }
         }
  @@ -305,9 +323,22 @@
      * if the annotation is not present.
      * REVIEW seems like having this functionality in jam_old would be nice
      */
  -  private String getAnnotation(JElement elem, String annName, String dflt) {
  -    JAnnotation ann = elem.getAnnotation(annName);
  -    return (ann == null) ? dflt : ann.getStringValue();
  +  private String getAnnotation(JAnnotatedElement elem,
  +                               String annName,
  +                               String dflt) {
  +    //System.out.print("checking for "+annName+" on "+elem.getQualifiedName());
  +    JAnnotation ann = getAnnotation(elem,annName);
  +    if (ann == null) {
  +      //System.out.println("...no annotation");
  +      return dflt;
  +    }
  +    JAnnotationValue val = ann.getValue(JAnnotation.SINGLE_VALUE_NAME);
  +    if (val == null) {
  +      //System.out.println("...no value!!!");
  +      return dflt;
  +    }
  +    //System.out.println("\n\n\n...value of "+annName+" is "+val.asString()+"!!!!!!!!!");
  +    return val.asString();
     }
   
     /**
  @@ -315,13 +346,35 @@
      * if the annotation is not present.
      * REVIEW seems like having this functionality in jam_old would be nice
      */
  -  private boolean getAnnotation(JElement elem, String annName, boolean dflt) {
  -    JAnnotation ann = elem.getAnnotation(annName);
  -//    return (ann == null) ? dflt : ann.getBooleanValue();
  -    if (ann == null) return false;
  -    String a = ann.getStringValue();
  -    if (a == null || a.trim().length() == 0) return true; //ewww
  -    return ann.getBooleanValue();
  +  private boolean getAnnotation(JAnnotatedElement elem,
  +                                String annName,
  +                                boolean dflt) {
  +    //System.out.print("checking for "+annName+" on "+elem.getQualifiedName());
  +    JAnnotation ann = getAnnotation(elem,annName);
  +    if (ann == null) {
  +      //System.out.println("...no annotation");
  +      return dflt;
  +    }
  +    JAnnotationValue val = ann.getValue(JAnnotation.SINGLE_VALUE_NAME);
  +    if (val == null || val.asString().length() == 0) {
  +      //System.out.println("\n\n\n...no value, returning true!!!");
  +      //this is a little bit gross.  the logic here is that if the tag is
  +      //present but empty, it actually is a true value.  E.g., an empty
  +      //@exclude tag means "yes, do exclude."
  +      return true;
  +    }
  +    //System.out.println("\n\n\n...value of "+annName+" is "+val.asBoolean()+"!!!!!!!!!");
  +    return val.asBoolean();
  +  }
  +
  +  //FIXME this is temporary until we get the tags/175 sorted out
  +  private JAnnotation getAnnotation(JAnnotatedElement e,
  +                                    String named) {
  +    JAnnotation[] tags = e.getAllJavadocTags();
  +    for(int i=0; i<tags.length; i++) {
  +      if (tags[i].getSimpleName().equals(named)) return tags[i];
  +    }
  +    return null;
     }
   
     /**
  @@ -331,10 +384,10 @@
       getBindingTypeFor(clazz);  //ensure that we've bound it
       JavaTypeName jtn = JavaTypeName.forString(clazz.getQualifiedName());
       BindingTypeName btn = mLoader.lookupTypeFor(jtn);
  -    logVerbose("BindingTypeName is "+btn);
  +    logVerbose("BindingTypeName is "+btn,clazz);
       BindingType bt = mLoader.getBindingType(btn);
       if (bt != null) return bt.getName().getXmlName().getQName();
  -    logError("could not get qname");
  +    logError("could not get qname",clazz);
       return new QName("ERROR",clazz.getQualifiedName());
     }
   
  @@ -343,18 +396,18 @@
      * This takes annotations into consideration.
      */
     private String getTargetNamespace(JClass clazz) {
  -    JAnnotation ann = clazz.getAnnotation(TAG_CT_TARGETNS);
  -    if (ann != null) return ann.getStringValue();
  +    String val = getAnnotation(clazz,TAG_CT_TARGETNS,null);
  +    if (val != null) return val;
       // Ok, they didn't specify it in the markup, so we have to
       // synthesize it from the classname.
       String pkg_name;
  -    if (clazz.isPrimitive()) {
  +    if (clazz.isPrimitiveType()) {
         pkg_name = JAVA_NAMESPACE_URI;
       } else {
         JPackage pkg = clazz.getContainingPackage();
         pkg_name = (pkg == null) ? "" : pkg.getQualifiedName();
         if (pkg_name.startsWith(JAVA_PACKAGE_PREFIX)) {
  -        pkg_name = JAVA_NAMESPACE_URI+"."+
  +        pkg_name = JAVA_NAMESPACE_URI+'.'+
                   pkg_name.substring(JAVA_PACKAGE_PREFIX.length());
         }
       }
  @@ -536,9 +589,9 @@
        */
       public void setType(JClass propType) {
         if (mXsElement != null) {
  -        if (propType.isArray()) {
  +        if (propType.isArrayType()) {
             if (propType.getArrayDimensions() != 1) {
  -            logError("Multidimensional arrays NYI"); //FIXME
  +            logError("Multidimensional arrays NYI",mSrcContext); //FIXME
             }
             JClass componentType = propType.getArrayComponentType();
             mXsElement.setMaxOccurs("unbounded");
  @@ -552,8 +605,9 @@
             mBtsProp.setBindingType(getBindingTypeFor(propType));
           }
         } else if (mXsAttribute != null) {
  -        if (propType.isArray()) {
  -          logError("Array properties cannot be mapped to xml attributes");
  +        if (propType.isArrayType()) {
  +          logError("Array properties cannot be mapped to xml attributes",
  +                  mSrcContext);
           } else {
             mXsAttribute.setType(getQnameFor(propType));
             mBtsProp.setBindingType(getBindingTypeFor(propType));
  @@ -571,7 +625,7 @@
           mXsElement.setNillable(b);
           mBtsProp.setNillable(b);
         } else if (mXsAttribute != null) {
  -        logError("Attributes cannot be nillable:");
  +        logError("Attributes cannot be nillable:",mSrcContext);
         } else {
           throw new IllegalStateException();
         }
  @@ -613,6 +667,22 @@
         mBtsProp = new QNameProperty();
       }
     }
  +
  +
  +  //this is temporary, will go away when we have our 175 story straight
  +  private static JAnnotation[] getNamedTags(JAnnotation[] tags,
  +                                            String named)
  +  {
  +    if (tags == null || tags.length == 0) return new JAnnotation[0];
  +    List list = new ArrayList();
  +    for(int i=0; i<tags.length; i++) {
  +      if (tags[i].getSimpleName().equals(named)) list.add(tags[i]);
  +    }
  +    JAnnotation[] out = new JAnnotation[list.size()];
  +    list.toArray(out);
  +    return out;
  +  }
  +
   
   
   }
  
  
  
  1.21      +1 -1      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Java2SchemaTask.java
  
  Index: Java2SchemaTask.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Java2SchemaTask.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- Java2SchemaTask.java	20 Mar 2004 21:51:34 -0000	1.20
  +++ Java2SchemaTask.java	26 Mar 2004 19:40:25 -0000	1.21
  @@ -149,7 +149,7 @@
       } catch(IOException ioe) {
         throw new BuildException(ioe);
       }
  -    return new Java2Schema_new(service.getAllClasses());
  +    return new Java2Schema(service.getAllClasses());
     }
   
     // ========================================================================
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org


Mime
View raw message