xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject cvs commit: xml-xmlbeans/v2/test/src/drt/drtcases BindingTests.java
Date Wed, 07 Apr 2004 04:18:10 GMT
pcal        2004/04/06 21:18:10

  Modified:    v2/jam/src/org/apache/xmlbeans/impl/jam/internal/java15
                        Reflect15DelegateImpl.java
               v2/jam/src/org/apache/xmlbeans/impl/jam/internal/javadoc
                        JavadocClassBuilder.java
               v2/jam/src/org/apache/xmlbeans/impl/jam/internal/reflect
                        ReflectClassBuilder.java
               v2/src/binding/org/apache/xmlbeans/impl/binding/compile
                        BindingCompiler.java Java2Schema.java
                        Schema2Java.java TypeMatcherContext.java
               v2/src/binding/org/apache/xmlbeans/impl/binding/tylar
                        BaseTylarImpl.java CompositeTylar.java
                        DebugTylarWriter.java ExplodedTylarImpl.java
                        Tylar.java TylarConstants.java TylarImpl.java
                        TylarWriter.java
               v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        TylarSchemaTypeLoaderProvider.java
               v2/test/src/drt/drtcases BindingTests.java
  Log:
  J2S: changes to SchemaTypeSystems/Loaders in Tylars
  JAM:  remove some hyperactive warning messages
  JAM: guard against bugs in reflection in earler 1.5 drops
  
  Revision  Changes    Path
  1.4       +22 -6     xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/java15/Reflect15DelegateImpl.java
  
  Index: Reflect15DelegateImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/java15/Reflect15DelegateImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Reflect15DelegateImpl.java	6 Apr 2004 00:17:22 -0000	1.3
  +++ Reflect15DelegateImpl.java	7 Apr 2004 04:18:09 -0000	1.4
  @@ -77,11 +77,22 @@
       extractAnnotations(dest,anns);
     }
   
  -  public void extractAnnotations(MParameter dest, Method src, int paramNum) {
  -    Annotation[][] anns = src.getParameterAnnotations();
  +  public void extractAnnotations(MParameter dest, Method src,
  +                                 int paramNum) {
  +    Annotation[][] anns;
  +    try {
  +      anns = src.getParameterAnnotations();
  +    } catch(NullPointerException wtf) {
  +      //FIXME workaround, sun code throws an NPE here
  +      if (mLogger.isVerbose(this)) {
  +        mLogger.verbose("ignoring unexpected error while calling Method.getParameterAnnotations():");
  +        mLogger.verbose(wtf);
  +      }
  +      //wtf.printStackTrace();
  +      return;
  +    }
       if (anns == null) return;
  -    if (anns.length <= paramNum) {
  -      //FIXME something is not right here, just a quick fix.  bug in reflection?
  +    if (paramNum >= anns.length) {
         if (mLogger.isVerbose(this)) {
           mLogger.warning("method "+src.getName()+
                           " has fewer than expected parameter annotations ");
  @@ -106,9 +117,14 @@
         return;
       }
       if (anns == null) return;
  -    for(int i=0; i<anns[paramNum].length; i++) {
  -      extractAnnotations(dest,anns[i]);
  +    if (paramNum >= anns.length) {
  +      if (mLogger.isVerbose(this)) {
  +        mLogger.warning("constructor "+src.getName()+
  +                        " has fewer than expected parameter annotations ");
  +      }
  +      return;
       }
  +    extractAnnotations(dest,anns[paramNum]);
     }
   
     public boolean isEnum(Class clazz) { return clazz.isEnum(); }
  
  
  
  1.19      +2 -2      xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/javadoc/JavadocClassBuilder.java
  
  Index: JavadocClassBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/javadoc/JavadocClassBuilder.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- JavadocClassBuilder.java	2 Apr 2004 02:41:07 -0000	1.18
  +++ JavadocClassBuilder.java	7 Apr 2004 04:18:09 -0000	1.19
  @@ -67,9 +67,9 @@
         // don't want to use the extractor
         Class.forName("com.sun.javadoc.AnnotationDesc");
       } catch (ClassNotFoundException e) {
  -      mLogger.warning("You are running under a pre-1.5 JDK.  JSR175-style "+
  -                      "source annotations will not be understood");
         if (mLogger.isVerbose(this)) {
  +        mLogger.warning("You are running under a pre-1.5 JDK.  JSR175-style "+
  +                        "source annotations will not be understood");
           mLogger.verbose(e);
         }
         return;
  
  
  
  1.9       +2 -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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ReflectClassBuilder.java	2 Apr 2004 02:41:07 -0000	1.8
  +++ ReflectClassBuilder.java	7 Apr 2004 04:18:09 -0000	1.9
  @@ -63,9 +63,9 @@
         // don't want to use the extractor
         Class.forName("java.lang.annotation.Annotation");
       } catch (ClassNotFoundException e) {
  -      mLogger.warning("You are running under a pre-1.5 JDK.  JSR175-style "+
  -                      "class annotations will not be understood");
         if (mLogger.isVerbose(this)) {
  +        mLogger.warning("You are running under a pre-1.5 JDK.  JSR175-style "+
  +                        "class annotations will not be understood");
           mLogger.verbose(e);
         }
         return;
  
  
  
  1.17      +2 -2      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/BindingCompiler.java
  
  Index: BindingCompiler.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/BindingCompiler.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- BindingCompiler.java	20 Mar 2004 21:51:34 -0000	1.16
  +++ BindingCompiler.java	7 Apr 2004 04:18:09 -0000	1.17
  @@ -222,13 +222,13 @@
      * @throws IllegalStateException if this method is called before
      * the abstract bind() method is called.
      */
  -  public SchemaTypeSystem getBaseSchemaTypeSystem()
  +  public SchemaTypeLoader getBaseSchemaTypeLoader()
     {
       assertCompilationStarted(true);
       if (mBaseTylar == null) {
         return XmlBeans.getBuiltinTypeSystem();
       } else {
  -      return mBaseTylar.getSchemaTypeSystem();
  +      return mBaseTylar.getSchemaTypeLoader();
       }
     }
   
  
  
  
  1.46      +35 -4     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.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- Java2Schema.java	26 Mar 2004 19:40:25 -0000	1.45
  +++ Java2Schema.java	7 Apr 2004 04:18:09 -0000	1.46
  @@ -20,6 +20,10 @@
   import org.apache.xmlbeans.impl.jam.*;
   import org.apache.xmlbeans.impl.jam.visitor.MVisitor;
   import org.apache.xmlbeans.impl.common.XMLChar;
  +import org.apache.xmlbeans.XmlBeans;
  +import org.apache.xmlbeans.SchemaTypeSystem;
  +import org.apache.xmlbeans.XmlObject;
  +import org.apache.xmlbeans.XmlException;
   import org.w3.x2001.xmlSchema.*;
   import javax.xml.namespace.QName;
   import java.util.ArrayList;
  @@ -118,6 +122,16 @@
       try {
         writer.writeBindingFile(mBindingFile);
         writer.writeSchema(mSchemaDocument,"schema-0.xsd");
  +
  +    } catch(IOException ioe) {
  +      logError(ioe);
  +    }
  +    try {
  +      SchemaTypeSystem sts = XmlBeans.compileXsd
  +        (new XmlObject[] {mSchemaDocument},XmlBeans.getBuiltinTypeSystem(),null);
  +      writer.writeSchemaTypeSystem(sts);
  +    } catch(XmlException xe) {
  +      logError(xe);
       } catch(IOException ioe) {
         logError(ioe);
       }
  @@ -157,13 +171,19 @@
       xsType.setName(xsdName);
       // deal with inheritance - see if it extends anything
       JClass superclass = clazz.getSuperclass();
  +    // we have to remember whether we created an ExtensionType because that
  +    // is where the sequence of properties have to go - note that this
  +    // gets passed into the SchemaPropertyFacade created below.  It's
  +    // unforuntante that the SchemaDocument model does not allow us to deal
  +    // with this kind of thing in a more elegant and polymorphic way.
  +    ExtensionType extType = null;
       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();
  -      ExtensionType et = ccd.addNewExtension();
  -      et.setBase(superBindingType.getName().getXmlName().getQName());
  +      extType = ccd.addNewExtension();
  +      extType.setBase(superBindingType.getName().getXmlName().getQName());
       }
       // create a binding type
       BindingTypeName btname = BindingTypeName.forPair(getJavaName(clazz),
  @@ -186,7 +206,7 @@
         mBindingFile.addBindingType(sdb,true,true);
       }
       // run through the class' properties to populate the binding and xsdtypes
  -    SchemaPropertyFacade facade = new SchemaPropertyFacade(xsType,bindType,tns);
  +    SchemaPropertyFacade facade = new SchemaPropertyFacade(xsType,extType,bindType,tns);
       Map props2issetters = new HashMap();
       getIsSetters(clazz,props2issetters);
       bindProperties(clazz.getDeclaredProperties(),props2issetters,facade);
  @@ -474,6 +494,9 @@
      * on a given BTS/XSD type pair, and any operations on the facade will
      * apply to that property until the next property is created
      * (via newAttributeProperty or newElementProperty).
  +   *
  +   * This class really wouldn't be necessary if the SchemaDocument model
  +   * were a bit more user-friendly.
      */
     class SchemaPropertyFacade {
   
  @@ -481,6 +504,7 @@
       // Variables
   
       private TopLevelComplexType mXsType;
  +    private ExtensionType mExtensionType = null;
       private String mXsTargetNamespace;
       private LocalElement mXsElement = null; // exactly one of these two is
       private Attribute mXsAttribute = null;  // remains null
  @@ -494,12 +518,14 @@
       // Constructors
   
       public SchemaPropertyFacade(TopLevelComplexType xsType,
  +                                ExtensionType extType, //may be null
                                   ByNameBean bt,
                                   String tns) {
         if (xsType == null) throw new IllegalArgumentException("null xsType");
         if (bt == null) throw new IllegalArgumentException("null bt");
         if (tns == null) throw new IllegalArgumentException("null tns");
         mXsType = xsType;
  +      mExtensionType = extType;
         mBtsType = bt;
         mXsTargetNamespace = tns;
       }
  @@ -521,7 +547,12 @@
       public void newElementProperty(JElement srcContext) {
         newBtsProperty();
         mSrcContext = srcContext;
  -      if (mXsSequence == null) mXsSequence = mXsType.addNewSequence();
  +      if (mXsSequence == null) {
  +        // nest it inside the extension element if they specified one,
  +        // otherwise just do it in the complexType
  +        mXsSequence = (mExtensionType != null) ?
  +          mExtensionType.addNewSequence() : mXsType.addNewSequence();
  +      }
         mXsElement = mXsSequence.addNewElement();
         mXsAttribute = null;
       }
  
  
  
  1.21      +1 -1      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Schema2Java.java
  
  Index: Schema2Java.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Schema2Java.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- Schema2Java.java	29 Mar 2004 22:02:57 -0000	1.20
  +++ Schema2Java.java	7 Apr 2004 04:18:09 -0000	1.21
  @@ -55,7 +55,7 @@
     // Variables
   
     private Set usedNames = new HashSet();
  -  private SchemaTypeSystem sts = null;
  +  private SchemaTypeLoader sts = null;
     private Map scratchFromXmlName = new LinkedHashMap();
     private Map scratchFromSchemaType = new HashMap(); // for convenience
     private Map scratchFromJavaNameString = new HashMap(); // for printing
  
  
  
  1.6       +2 -1      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/TypeMatcherContext.java
  
  Index: TypeMatcherContext.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/TypeMatcherContext.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TypeMatcherContext.java	20 Mar 2004 21:51:34 -0000	1.5
  +++ TypeMatcherContext.java	7 Apr 2004 04:18:09 -0000	1.6
  @@ -19,6 +19,7 @@
   import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
   import org.apache.xmlbeans.impl.jam.JamClassLoader;
   import org.apache.xmlbeans.SchemaTypeSystem;
  +import org.apache.xmlbeans.SchemaTypeLoader;
   
   /**
    * Provides context/initialzation information for a TypeMatcher instance.
  @@ -42,7 +43,7 @@
      * Returns a SchemaTypeLoader to be used as a basis for the binding process.
      * Normally, this will simply be the builtin loader.
      */
  -  public SchemaTypeSystem getBaseSchemaTypeSystem();
  +  public SchemaTypeLoader getBaseSchemaTypeLoader();
   
     /**
      * Returns a JClassLoader to be used as a basis for the binding process.
  
  
  
  1.7       +19 -8     xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/tylar/BaseTylarImpl.java
  
  Index: BaseTylarImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/tylar/BaseTylarImpl.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BaseTylarImpl.java	20 Mar 2004 21:51:34 -0000	1.6
  +++ BaseTylarImpl.java	7 Apr 2004 04:18:10 -0000	1.7
  @@ -54,9 +54,26 @@
       return CompositeBindingLoader.forPath(loaders);
     }
   
  -  public SchemaTypeSystem getSchemaTypeSystem()
  +  public JamClassLoader getJamClassLoader()
     {
       // REVIEW should consider caching this result
  +    // create a classloader chain that runs throw all of the base tylars
  +    ClassLoader cl = createClassLoader(ClassLoader.getSystemClassLoader());
  +    return JamServiceFactory.getInstance().createJamClassLoader(cl);
  +  }
  +
  +  // ========================================================================
  +  // Protected methods
  +
  +  /**
  +   * <p>Creates a schema type system by compiling all of the schema documents
  +   * returned by getSchemas().  This can be used as a fallback for 
  +   * implementing getSchemaTypeSystem().
  +   *
  +   * @return
  +   */
  +  protected SchemaTypeSystem getDefaultSchemaTypeSystem()
  +  {
       SchemaDocument[] xsds = getSchemas();
       XmlObject[] xxds = new XmlObject[xsds.length];
       for(int i=0; i<xsds.length; i++) xxds[i] = xsds[i].getSchema();
  @@ -70,11 +87,5 @@
       }
     }
   
  -  public JamClassLoader getJamClassLoader()
  -  {
  -    // REVIEW should consider caching this result
  -    // create a classloader chain that runs throw all of the base tylars
  -    ClassLoader cl = createClassLoader(ClassLoader.getSystemClassLoader());
  -    return JamServiceFactory.getInstance().createJamClassLoader(cl);
  -  }
  +
   }
  
  
  
  1.3       +12 -0     xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/tylar/CompositeTylar.java
  
  Index: CompositeTylar.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/tylar/CompositeTylar.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CompositeTylar.java	12 Feb 2004 20:06:07 -0000	1.2
  +++ CompositeTylar.java	7 Apr 2004 04:18:10 -0000	1.3
  @@ -16,6 +16,8 @@
   package org.apache.xmlbeans.impl.binding.tylar;
   
   import org.apache.xmlbeans.impl.binding.bts.BindingFile;
  +import org.apache.xmlbeans.XmlBeans;
  +import org.apache.xmlbeans.SchemaTypeLoader;
   import org.w3.x2001.xmlSchema.SchemaDocument;
   
   import java.util.Collection;
  @@ -98,6 +100,16 @@
       SchemaDocument[] out = new SchemaDocument[all.size()];
       all.toArray(out);
       return out;
  +  }
  +
  +  public SchemaTypeLoader getSchemaTypeLoader() {
  +    if (mTylars.length == 0) return XmlBeans.getBuiltinTypeSystem();
  +    if (mTylars.length == 1) return mTylars[0].getSchemaTypeLoader();
  +    SchemaTypeLoader[] sts = new SchemaTypeLoader[mTylars.length];
  +    for(int i=0; i<mTylars.length; i++) sts[i] = mTylars[i].getSchemaTypeLoader();
  +    return XmlBeans.typeLoaderUnion(sts);
  +
  +
     }
   
     public ClassLoader createClassLoader(ClassLoader cl) {
  
  
  
  1.4       +5 -0      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/tylar/DebugTylarWriter.java
  
  Index: DebugTylarWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/tylar/DebugTylarWriter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DebugTylarWriter.java	12 Feb 2004 20:06:08 -0000	1.3
  +++ DebugTylarWriter.java	7 Apr 2004 04:18:10 -0000	1.4
  @@ -20,6 +20,7 @@
   import org.apache.xmlbeans.impl.binding.joust.SourceJavaOutputStream;
   import org.apache.xmlbeans.impl.binding.joust.WriterFactory;
   import org.apache.xmlbeans.XmlOptions;
  +import org.apache.xmlbeans.SchemaTypeSystem;
   import org.w3.x2001.xmlSchema.SchemaDocument;
   
   import java.io.IOException;
  @@ -93,6 +94,10 @@
   
     public void writeSchema(SchemaDocument xsd, String fp) throws IOException {
       xsd.save(mOut,mOptions);
  +  }
  +
  +  public void writeSchemaTypeSystem(SchemaTypeSystem sts) throws IOException {
  +    //FIXME implement me
     }
   
     public JavaOutputStream getJavaOutputStream() {
  
  
  
  1.11      +39 -3     xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/tylar/ExplodedTylarImpl.java
  
  Index: ExplodedTylarImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/tylar/ExplodedTylarImpl.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ExplodedTylarImpl.java	18 Mar 2004 23:25:35 -0000	1.10
  +++ ExplodedTylarImpl.java	7 Apr 2004 04:18:10 -0000	1.11
  @@ -29,6 +29,9 @@
   import org.apache.xml.xmlbeans.bindingConfig.BindingConfigDocument;
   import org.apache.xmlbeans.XmlException;
   import org.apache.xmlbeans.XmlOptions;
  +import org.apache.xmlbeans.SchemaTypeSystem;
  +import org.apache.xmlbeans.XmlBeans;
  +import org.apache.xmlbeans.SchemaTypeLoader;
   import org.apache.xmlbeans.impl.binding.bts.BindingFile;
   import org.apache.xmlbeans.impl.binding.joust.FileWriterFactory;
   import org.apache.xmlbeans.impl.binding.joust.JavaOutputStream;
  @@ -63,6 +66,7 @@
     private BindingFile mBindingFile = null;
     private JavaOutputStream mJoust = null;
     private Collection mSchemaDocuments = null;
  +  private SchemaTypeSystem mSchemaTypeSystem = null;
   
     // ========================================================================
     // Factory methods
  @@ -96,7 +100,7 @@
       } else {
         if (!dir.mkdirs()) throw new IOException("Failed to create " + dir);
       }
  -    return new ExplodedTylarImpl(dir, null, null, joust);
  +    return new ExplodedTylarImpl(dir, null, null, null, joust);
     }
   
     /**
  @@ -113,7 +117,17 @@
       BindingFile bf = parseBindingFile(new File(dir, BINDING_FILE));
       Collection schemas = new ArrayList();
       parseSchemas(new File(dir, SCHEMA_DIR), schemas);
  -    return new ExplodedTylarImpl(dir, bf, schemas, joust);
  +    SchemaTypeSystem sts = null;
  +    {
  +      File stsDir = new File(dir, STS_DIR);
  +      if (stsDir.exists()) {
  +        //FIXME i still dont get how to do this.  Where is the TypeSystemHolder?
  +        // sts = SchemaTypeSystemImpl.forName()
  +      }
  +
  +    }
  +
  +    return new ExplodedTylarImpl(dir, bf, schemas, sts, joust);
     }
   
     // ========================================================================
  @@ -125,7 +139,8 @@
      */
     private ExplodedTylarImpl(File dir, // must exist
                               BindingFile bindingFile, // null ok
  -                            Collection schemas, // null ok
  +                            Collection schemas, // null ok,
  +                            SchemaTypeSystem sts, // null ok
                               JavaOutputStream joust)    // null ok
     {
       mRootDir = dir;
  @@ -155,6 +170,12 @@
       writeXsd(xsd, new File(mSchemaDir, schemaFileName));
     }
   
  +  public void writeSchemaTypeSystem(SchemaTypeSystem sts) throws IOException {
  +    if (sts == null) throw new IllegalArgumentException("null sts");
  +    mSchemaTypeSystem = sts;
  +    sts.saveToDirectory(new File(mRootDir, STS_DIR));
  +  }
  +
     public JavaOutputStream getJavaOutputStream() {
       return mJoust;
     }
  @@ -177,6 +198,13 @@
       return out;
     }
   
  +  public SchemaTypeLoader getSchemaTypeLoader() {
  +    if (mSchemaTypeSystem == null) {
  +      mSchemaTypeSystem = getDefaultSchemaTypeSystem();
  +    }
  +    return mSchemaTypeSystem;
  +  }
  +
     public URI getLocation() {
       return mRootDir.toURI();
     }
  @@ -232,6 +260,14 @@
       File srcDir = new File(dir,TylarConstants.SRC_ROOT);
       return new ValidatingJavaOutputStream
               (new SourceJavaOutputStream(new FileWriterFactory(srcDir)));
  +  }
  +
  +  private static SchemaTypeSystem buildSts(Collection xsds)
  +    throws XmlException
  +  {
  +    SchemaDocument[] x = new SchemaDocument[xsds.size()];
  +    xsds.toArray(x);
  +    return XmlBeans.compileXsd(x,XmlBeans.getBuiltinTypeSystem(),null);
     }
   
     private static void parseSchemas(File schemaDir, Collection out)
  
  
  
  1.8       +2 -2      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/tylar/Tylar.java
  
  Index: Tylar.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/tylar/Tylar.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Tylar.java	20 Mar 2004 21:51:34 -0000	1.7
  +++ Tylar.java	7 Apr 2004 04:18:10 -0000	1.8
  @@ -19,7 +19,7 @@
   import org.apache.xmlbeans.impl.binding.bts.BindingFile;
   import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
   import org.apache.xmlbeans.impl.jam.JamClassLoader;
  -import org.apache.xmlbeans.SchemaTypeSystem;
  +import org.apache.xmlbeans.SchemaTypeLoader;
   import org.w3.x2001.xmlSchema.SchemaDocument;
   
   /**
  @@ -69,7 +69,7 @@
      * that results from compiling all of the schemas returned by getSchemas()
      * plus the BuiltinSchemaTypeSystem.
      */
  -  public SchemaTypeSystem getSchemaTypeSystem();
  +  public SchemaTypeLoader getSchemaTypeLoader();
   
   
     /**
  
  
  
  1.5       +1 -0      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/tylar/TylarConstants.java
  
  Index: TylarConstants.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/tylar/TylarConstants.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TylarConstants.java	12 Feb 2004 20:06:08 -0000	1.4
  +++ TylarConstants.java	7 Apr 2004 04:18:10 -0000	1.5
  @@ -34,5 +34,6 @@
     public static final String SRC_ROOT     = "META-INF"+SEP+"src";
     public static final String BINDING_FILE = "META-INF"+SEP+"binding-file.xml";
     public static final String SCHEMA_DIR   = "META-INF"+SEP+"schemas";
  +  public static final String STS_DIR      = "META-INF"+SEP+"schema_type_system"; 
   
   }
  
  
  
  1.6       +14 -0     xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/tylar/TylarImpl.java
  
  Index: TylarImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/tylar/TylarImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TylarImpl.java	12 Feb 2004 20:06:08 -0000	1.5
  +++ TylarImpl.java	7 Apr 2004 04:18:10 -0000	1.6
  @@ -24,6 +24,8 @@
   
   import org.apache.xmlbeans.impl.binding.bts.BindingFile;
   import org.apache.xmlbeans.impl.binding.joust.JavaOutputStream;
  +import org.apache.xmlbeans.SchemaTypeSystem;
  +import org.apache.xmlbeans.SchemaTypeLoader;
   import org.w3.x2001.xmlSchema.SchemaDocument;
   
   /**
  @@ -39,6 +41,7 @@
     private URI mSourceURI;
     private BindingFile mBindingFile = null;
     private Collection mSchemas = null;
  +  private SchemaTypeSystem mSts = null;
   
     // ========================================================================
     // Constructors
  @@ -73,6 +76,13 @@
       return out;
     }
   
  +  public SchemaTypeLoader getSchemaTypeLoader() {
  +    if (mSts == null) {
  +      mSts = getDefaultSchemaTypeSystem();
  +    }
  +    return mSts;
  +  }
  +
     public URI getLocation() {
       return mSourceURI;
     }
  @@ -98,6 +108,10 @@
     public void writeSchema(SchemaDocument xsd, String path) {
       if (mSchemas == null) mSchemas = new ArrayList();
       mSchemas.add(xsd);
  +  }
  +
  +  public void writeSchemaTypeSystem(SchemaTypeSystem sts) {
  +    mSts = sts;
     }
   
     public JavaOutputStream getJavaOutputStream() {
  
  
  
  1.7       +10 -0     xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/tylar/TylarWriter.java
  
  Index: TylarWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/tylar/TylarWriter.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TylarWriter.java	25 Feb 2004 18:56:48 -0000	1.6
  +++ TylarWriter.java	7 Apr 2004 04:18:10 -0000	1.7
  @@ -18,6 +18,7 @@
   import java.io.IOException;
   import org.apache.xmlbeans.impl.binding.bts.BindingFile;
   import org.apache.xmlbeans.impl.binding.joust.JavaOutputStream;
  +import org.apache.xmlbeans.SchemaTypeSystem;
   import org.w3.x2001.xmlSchema.SchemaDocument;
   
   /**
  @@ -43,6 +44,15 @@
      * @throws IOException
      */
     public void writeSchema(SchemaDocument xsd, String filepath) throws IOException;
  +
  +  /**
  +   * Writes the given schema type system into the tylar in a binary format.
  +   * Note that this functionality is completely independent of writeSchema() -
  +   * if you want both, you need to write them separately.
  +   *
  +   * @param sts  The schema type system to write.
  +   */
  +  public void writeSchemaTypeSystem(SchemaTypeSystem sts) throws IOException;
   
     /**
      * Returns the JavaOutputStream which should be used for creating new java
  
  
  
  1.2       +1 -1      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/TylarSchemaTypeLoaderProvider.java
  
  Index: TylarSchemaTypeLoaderProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/TylarSchemaTypeLoaderProvider.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TylarSchemaTypeLoaderProvider.java	16 Mar 2004 00:55:01 -0000	1.1
  +++ TylarSchemaTypeLoaderProvider.java	7 Apr 2004 04:18:10 -0000	1.2
  @@ -73,7 +73,7 @@
       public SchemaTypeLoader getSchemaTypeLoader()
       {
           if (schemaTypeLoader == null) {
  -            schemaTypeLoader = tylar.getSchemaTypeSystem();
  +            schemaTypeLoader = tylar.getSchemaTypeLoader();
           }
           assert schemaTypeLoader != null;
           return schemaTypeLoader;
  
  
  
  1.20      +2 -0      xml-xmlbeans/v2/test/src/drt/drtcases/BindingTests.java
  
  Index: BindingTests.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/drt/drtcases/BindingTests.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- BindingTests.java	25 Feb 2004 18:56:50 -0000	1.19
  +++ BindingTests.java	7 Apr 2004 04:18:10 -0000	1.20
  @@ -20,6 +20,7 @@
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
   import org.apache.xmlbeans.impl.binding.bts.*;
  +import org.apache.xmlbeans.SchemaTypeSystem;
   import org.apache.xmlbeans.impl.binding.compile.Schema2Java;
   import org.apache.xmlbeans.impl.binding.compile.BindingCompilerTask;
   import org.apache.xmlbeans.impl.binding.joust.SourceJavaOutputStream;
  @@ -54,6 +55,7 @@
               if (verbose) bf.write().save(System.out);
             }
             public void writeSchema(SchemaDocument xsd, String filepath) {}
  +          public void writeSchemaTypeSystem(SchemaTypeSystem sts) {}
             public void close() {}
           };
           //FIXME this is kinda dumb, just emulating current behavior.
  
  
  

---------------------------------------------------------------------
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