You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlbeans-cvs@xml.apache.org by pc...@apache.org on 2004/01/13 06:40:11 UTC

cvs commit: xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal BindingContextImpl.java

pcal        2004/01/12 21:40:11

  Modified:    v2/src/binding/org/apache/xmlbeans/impl/binding/compile
                        BindingCompiler.java BindingCompilerTask.java
                        Schema2Java.java
               v2/src/binding/org/apache/xmlbeans/impl/binding/joust
                        CompilingJavaOutputStream.java
                        SourceJavaOutputStream.java
               v2/src/binding/org/apache/xmlbeans/impl/binding/tylar
                        ExplodedTylarImpl.java TylarWriter.java
               v2/src/jam/org/apache/xmlbeans/impl/jam/internal
                        BaseJElement.java
               v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        BindingContextImpl.java
  Added:       v2/src/binding/org/apache/xmlbeans/impl/binding/compile
                        TypeMatcherContext.java
               v2/src/binding/org/apache/xmlbeans/impl/binding/logger
                        BindingLogger.java Message.java MessageImpl.java
                        MessageSink.java SimpleMessageSink.java
  Removed:     v2/src/binding/org/apache/xmlbeans/impl/binding/compile
                        BindingLogger.java BindingLoggerMessage.java
                        BindingLoggerMessageImpl.java
                        SimpleBindingLogger.java
  Log:
  refactor logging, push javac-specific stuff stuff down into Schema2Java
  
  Revision  Changes    Path
  1.7       +28 -263   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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BindingCompiler.java	8 Jan 2004 23:48:10 -0000	1.6
  +++ BindingCompiler.java	13 Jan 2004 05:40:11 -0000	1.7
  @@ -56,20 +56,18 @@
   package org.apache.xmlbeans.impl.binding.compile;
   
   import org.apache.xmlbeans.impl.binding.tylar.*;
  -import org.apache.xmlbeans.impl.binding.joust.CompilingJavaOutputStream;
   import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
   import org.apache.xmlbeans.impl.binding.bts.PathBindingLoader;
   import org.apache.xmlbeans.impl.binding.bts.BuiltinBindingLoader;
  -import org.apache.xmlbeans.impl.jam.JElement;
  +import org.apache.xmlbeans.impl.binding.logger.BindingLogger;
  +import org.apache.xmlbeans.impl.binding.joust.JavaOutputStream;
   import org.apache.xmlbeans.impl.jam.JClassLoader;
   import org.apache.xmlbeans.impl.jam.JFactory;
   import org.apache.xmlbeans.*;
   import org.w3.x2001.xmlSchema.SchemaDocument;
  -import org.w3.x2001.xmlSchema.Element;
   
   import java.io.File;
   import java.io.IOException;
  -import java.util.logging.Level;
   import java.util.ArrayList;
   import java.util.Collection;
   
  @@ -90,39 +88,22 @@
    *
    * @author Patrick Calahan <pc...@bea.com>
    */
  -public abstract class BindingCompiler {
  -
  -  // ========================================================================
  -  // Constants
  -
  -  private static final BindingLogger DEFAULT_LOG = new SimpleBindingLogger();
  +public abstract class BindingCompiler extends BindingLogger
  +        implements TypeMatcherContext {
   
     // ========================================================================
     // Variables
   
  -  private BindingLogger mLogger = DEFAULT_LOG;
  -  private boolean mAnyErrorsFound = false;
  -  private boolean mIgnoreErrors = false;
  -  private boolean mVerbose = false;
  -  private boolean mDoCompile = true;
     private Tylar[] mBaseLibraries = null;
     private BindingLoader mBaseBindingLoader = null;
     private SchemaTypeLoader mBaseSchemaTypeLoader = null;
     private JClassLoader mBaseJClassLoader = null;
     private boolean mIsCompilationStarted = false;
   
  -  // this is the joust we use to build up the tylar that is passed to
  -  // the subclass' bind() methods in all cases.  However, BindingCompiler
  -  // makes no assumption that the subclass will actually make use of any
  -  // of the codegen facilities - they're just there if you want them.
  -  private CompilingJavaOutputStream mJoust;
  -
     // ========================================================================
     // Constructors
   
  -  public BindingCompiler() {
  -    mJoust = new CompilingJavaOutputStream();
  -  }
  +  public BindingCompiler() {}
   
     // ========================================================================
     // Abstract/Overrideable methods
  @@ -135,6 +116,12 @@
      */
     public abstract void bind(TylarWriter writer);
   
  +  /**
  +   * Should be overridden by subclasses which want a java output stream
  +   * attached to TylarWriters.
  +   */
  +  protected JavaOutputStream getJoust(File tylarDestDir) { return null; }
  +
     // ========================================================================
     // Public methods
   
  @@ -142,16 +129,10 @@
      * Performs the binding and returns an exploded tylar in the specified
      * directory.  Returns null if any severe errors were encountered.
      */
  -  public ExplodedTylar bindAsExplodedTylar(File tylarDestDir)
  -  {
  -    mJoust.setSourceDir(new File(tylarDestDir,TylarConstants.SRC_ROOT));
  -    if (mDoCompile) {
  -      // signal the compile outputstream to compile classes
  -      mJoust.setCompilationDir(tylarDestDir);
  -    }
  +  public ExplodedTylar bindAsExplodedTylar(File tylarDestDir)  {
       ExplodedTylarImpl tylar;
       try {
  -      tylar = ExplodedTylarImpl.create(tylarDestDir,mJoust);
  +      tylar = ExplodedTylarImpl.create(tylarDestDir,getJoust(tylarDestDir));
       } catch(IOException ioe) {
         logError(ioe);
         return null;
  @@ -162,17 +143,18 @@
           return null;
         }
       }
  -    bind((TylarWriter)tylar);
  +    bind(tylar); //ExplodedTylarImpl is also a TylarWriter
       try {
         // close it up.  this may cause the generated code to be compiled.
  -      if (mDoCompile) logVerbose("Compiling java sources...");
         tylar.close();
       } catch(IOException ioe) {
         logError(ioe);
       }
  -    return !mAnyErrorsFound || mIgnoreErrors ? tylar : null;
  +    return !super.isAnyErrorsFound() || super.isIgnoreErrors() ? tylar : null;
     }
   
  +
  +
     /**
      * Performs the binding and returns a tylar in the specified jar file.
      * Note that this is done by simply creating an exploded tylar in a
  @@ -209,15 +191,9 @@
       mBaseLibraries = list;
     }
   
  -  /**
  -   * Sets the BindingLogger which will receive log messages from work
  -   * done by this BindingCompiler.
  -   */
  -  public void setLogger(BindingLogger logger) {
  -    if (logger == null) throw new IllegalArgumentException("null logger");
  -    assertCompilationStarted(false);
  -    mLogger = logger;
  -  }
  +
  +  // ========================================================================
  +  // BindingLogger overrides
   
     /**
      * Sets whether this compiler should return a result and keep artificats
  @@ -227,62 +203,21 @@
      */
     public void setIgnoreSevereErrors(boolean really) {
       assertCompilationStarted(false);
  -    mIgnoreErrors = true;
  +    super.setIgnoreErrors(really);
     }
   
     /**
  -   * Sets whether this BindingCompiler should keep any generated java source
  -   * code it generates.  The default is true.  Note that not all
  -   * BindingCompilers generate any source code at all, so setting this may
  -   * have no effect.
  +   * Enables verbose output to our MessageSink.
      */
  -  public void setCompileJava(boolean b) {
  -    assertCompilationStarted(false);
  -    mDoCompile = b;
  -  }
  -
  -  /**
  -   * Sets the location of javac to be invoked.  Default compiler is used
  -   * if this is not set.  Ignored if doCompile is set to false.  Also note
  -   * that not all BindingCompilers generate any source code at all, so
  -   * setting this may have no effect.
  -   */
  -  public void setJavac(String javacPath) {
  -    assertCompilationStarted(false);
  -    mJoust.setJavac(javacPath);
  -  }
  -
  -  /**
  -   * Sets the classpath to use for compilation of generated sources.
  -   * The System classpath is used by default.  This is ignored if doCompile is
  -   * false.  Also note that not all BindingCompilers generate any source
  -   * code at all, so setting this may have no effect.
  -   */
  -  public void setJavacClasspath(File[] classpath) {
  +  public void setVerbose(boolean b) {
       assertCompilationStarted(false);
  -    mJoust.setJavacClasspath(classpath);
  +    super.setVerbose(b);
     }
   
  -  /**
  -   * Sets whether this BindingCompiler should keep any generated java source
  -   * code it generates.  The default is true.  This will have no effect if
  -   * doCompile is set to false.  Also note that not all BindingCompilers
  -   * generate any source code at all, so setting this may have no effect in
  -   * any event.
  -   */
  -  public void setKeepGeneratedJava(boolean b) {
  -    assertCompilationStarted(false);
  -    mJoust.setKeepGenerated(b);
  -  }
  +  // ========================================================================
  +  // TypeMatcherContext impl
   
  -  /**
  -   * Enables verbose output to our BindingLogger.
  -   */
  -  public void setVerbose(boolean b) {
  -    assertCompilationStarted(false);
  -    mJoust.setVerbose(b);
  -    mVerbose = b;
  -  }
  +  public BindingLogger getLogger() { return this; }
   
     // ========================================================================
     // Protected methods
  @@ -407,176 +342,6 @@
       mIsCompilationStarted = true;
     }
   
  -  // ========================================================================
  -  // Protected logging methods
  -  //
  -  //   These methods provide subclasses with a tighter interface to the
  -  //   logger, as well as 'choke points' so that we can, for example,
  -  //   suppress verbose messages.
  -  //
  -  //   It also allows us to indicate to the subclass whether or not
  -  //   processing should proceed after a given message is logged.
  -  //   Currently, this is just a yes/no flag that applies to all errors,
  -  //   but one could imagine wanting to be more discriminating someday.
  -
  -  /**
  -   * Logs a message that some error occurred while performing binding.
  -   *
  -   * @return true if processing should attempt to continue.
  -   */
  -  protected boolean logError(String msg) {
  -    mAnyErrorsFound = true;
  -    mLogger.log(new BindingLoggerMessageImpl
  -            (Level.SEVERE,msg,null,null,null,null));
  -    return mIgnoreErrors;
  -  }
  -
  -  /**
  -   * Logs a message that an error occurred.
  -   *
  -   * @return true if processing should attempt to continue.
  -   */
  -  protected boolean logError(Throwable t) {
  -    mAnyErrorsFound = true;
  -    mLogger.log(new BindingLoggerMessageImpl
  -            (Level.SEVERE,null,t,null,null,null));
  -    return mIgnoreErrors;
  -  }
  -
  -  /**
  -   * Logs a message that fatal error that occurred while performing binding
  -   * on the given java construct.
  -   *
  -   * @return true if processing should attempt to continue.
  -   */
  -  protected boolean logError(Throwable error, JElement javaContext) {
  -    mAnyErrorsFound = true;
  -    mLogger.log(new BindingLoggerMessageImpl
  -            (Level.SEVERE,null,error,javaContext,null,null));
  -    return mIgnoreErrors;
  -  }
  -
  -  /**
  -   * Logs a message that fatal error that occurred while performing binding
  -   * on the given schema construct.
  -   *
  -   * @return true if processing should attempt to continue.
  -   */
  -  protected boolean logError(Throwable error, SchemaType schemaContext) {
  -    mAnyErrorsFound = true;
  -    mLogger.log(new BindingLoggerMessageImpl
  -            (Level.SEVERE,null,error,null,schemaContext,null));
  -    return mIgnoreErrors;
  -  }
  -
  -  /**
  -   * Logs a message that fatal error that occurred while performing binding
  -   * on the given java and schema constructs.
  -   *
  -   * @return true if processing should attempt to continue.
  -   */
  -  protected boolean logError(Throwable t, JElement jCtx, SchemaType xsdCtx) {
  -    mAnyErrorsFound = true;
  -    mLogger.log(new BindingLoggerMessageImpl
  -            (Level.SEVERE,null,t,jCtx,xsdCtx,null));
  -    return mIgnoreErrors;
  -  }
  -
  -  /**
  -   * Logs a message that fatal error that occurred while performing binding
  -   * on the given java construct.
  -   *
  -   * @return true if processing should attempt to continue.
  -   */
  -  protected boolean logError(String msg, JElement javaContext) {
  -    mAnyErrorsFound = true;
  -    mLogger.log(new BindingLoggerMessageImpl
  -            (Level.SEVERE,msg,null,javaContext,null,null));
  -    return mIgnoreErrors;
  -  }
  -
  -  /**
  -   * Logs a message that fatal error that occurred while performing binding
  -   * on the given schema construct.
  -   *
  -   * @return true if processing should attempt to continue.
  -   */
  -  protected boolean logError(String msg, SchemaType xsdCtx) {
  -    mAnyErrorsFound = true;
  -    mLogger.log(new BindingLoggerMessageImpl
  -            (Level.SEVERE,msg,null,null,xsdCtx,null));
  -    return mIgnoreErrors;
  -  }
  -
  -  /**
  -   * Logs a message that fatal error that occurred while performing binding
  -   * on the given schema construct.
  -   *
  -   * @return true if processing should attempt to continue.
  -   */
  -  protected boolean logError(String msg, JElement javaCtx, SchemaType xsdCtx) {
  -    mAnyErrorsFound = true;
  -    mLogger.log(new BindingLoggerMessageImpl
  -            (Level.SEVERE,msg,null,javaCtx,xsdCtx,null));
  -    return mIgnoreErrors;
  -  }
  -
  -  /**
  -   * Logs a message that fatal error that occurred while performing binding
  -   * on the given schema construct.
  -   *
  -   * @return true if processing should attempt to continue.
  -   */
  -  protected boolean logError(String msg, JElement jCtx, SchemaProperty xCtx) {
  -    mAnyErrorsFound = true;
  -    mLogger.log(new BindingLoggerMessageImpl
  -            (Level.SEVERE,msg,null,jCtx,null,xCtx));
  -    return mIgnoreErrors;
  -  }
  -
  -  /**
  -   * Logs an informative message that should be printed only in 'verbose'
  -   * mode.
  -   */
  -  protected void logVerbose(String msg) {
  -    if (mVerbose) {
  -      mLogger.log(new BindingLoggerMessageImpl
  -              (Level.FINEST,msg,null,null,null,null));
  -    }
  -  }
  -
  -  /**
  -   * Logs an informative message that should be printed only in 'verbose'
  -   * mode.
  -   */
  -  protected void logVerbose(String msg, JElement javaContext) {
  -    if (mVerbose) {
  -      mLogger.log(new BindingLoggerMessageImpl
  -              (Level.FINEST,msg,null,javaContext,null,null));
  -    }
  -  }
  -
  -  /**
  -   * Logs an informative message that should be printed only in 'verbose'
  -   * mode.
  -   */
  -  protected void logVerbose(String msg, SchemaType xsdType) {
  -    if (mVerbose) {
  -      mLogger.log(new BindingLoggerMessageImpl
  -              (Level.FINEST,msg,null,null,xsdType,null));
  -    }
  -  }
  -
  -  /**
  -   * Logs an informative message that should be printed only in 'verbose'
  -   * mode.
  -   */
  -  protected void logVerbose(String msg, JElement javaCtx, SchemaType xsdCtx) {
  -    if (mVerbose) {
  -      mLogger.log(new BindingLoggerMessageImpl
  -              (Level.FINEST,msg,null,javaCtx,xsdCtx,null));
  -    }
  -  }
   
     // ========================================================================
     // Private methods
  @@ -584,7 +349,7 @@
     private static File createTempDir() throws IOException
     {
       //FIXME this is not great
  -    String prefix = "java2schema-"+System.currentTimeMillis();
  +    String prefix = "BindingCompiler-"+System.currentTimeMillis();
       File directory = null;
       File f = File.createTempFile(prefix, null);
       directory = f.getParentFile();
  
  
  
  1.5       +5 -4      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/BindingCompilerTask.java
  
  Index: BindingCompilerTask.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/BindingCompilerTask.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BindingCompilerTask.java	8 Jan 2004 23:48:10 -0000	1.4
  +++ BindingCompilerTask.java	13 Jan 2004 05:40:11 -0000	1.5
  @@ -58,6 +58,8 @@
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.taskdefs.MatchingTask;
   import org.apache.xmlbeans.impl.binding.tylar.Tylar;
  +import org.apache.xmlbeans.impl.binding.logger.MessageSink;
  +import org.apache.xmlbeans.impl.binding.logger.SimpleMessageSink;
   import org.apache.xmlbeans.SchemaTypeSystem;
   import org.apache.xmlbeans.XmlException;
   import org.apache.xmlbeans.XmlObject;
  @@ -67,7 +69,6 @@
   import org.w3.x2001.xmlSchema.SchemaDocument;
   import java.io.File;
   import java.io.IOException;
  -import java.util.logging.Level;
   
   /**
    * Abstract base class for Ant Task classes which drive a BindingCompiler.
  @@ -146,7 +147,7 @@
       try {
         BindingCompiler bc = getCompilerToExecute();
         bc.setIgnoreSevereErrors(mIgnoreErrors);
  -      bc.setLogger(createLogger());
  +      bc.setMessageSink(createMessageSink());
         bc.setVerbose(mVerbose);
         if (mDestDir != null) {
           tylar = bc.bindAsExplodedTylar(mDestDir);
  @@ -197,8 +198,8 @@
                 (file, SchemaDocument.type, options);
     }
   
  -  private  BindingLogger createLogger() {
  +  private  MessageSink createMessageSink() {
       //FIXME this should be an AntBindingLogger
  -    return new SimpleBindingLogger();
  +    return new SimpleMessageSink();
     }
   }
  
  
  
  1.7       +63 -10    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Schema2Java.java	18 Dec 2003 01:58:58 -0000	1.6
  +++ Schema2Java.java	13 Jan 2004 05:40:11 -0000	1.7
  @@ -58,8 +58,10 @@
   
   import org.apache.xmlbeans.impl.binding.bts.*;
   import org.apache.xmlbeans.impl.binding.tylar.TylarWriter;
  +import org.apache.xmlbeans.impl.binding.tylar.TylarConstants;
   import org.apache.xmlbeans.impl.binding.joust.JavaOutputStream;
   import org.apache.xmlbeans.impl.binding.joust.Variable;
  +import org.apache.xmlbeans.impl.binding.joust.CompilingJavaOutputStream;
   import org.apache.xmlbeans.impl.common.NameUtil;
   import org.apache.xmlbeans.*;
   import org.apache.xmlbeans.soap.SOAPArrayType;
  @@ -98,7 +100,7 @@
     private BindingLoader mLoader;
     private int structureCount;
     private BindingFile bindingFile = new BindingFile();
  -  private JavaOutputStream mJoust = null;
  +  private CompilingJavaOutputStream mJoust;
   
     // ========================================================================
     // Constructors
  @@ -108,6 +110,8 @@
      */
     public Schema2Java(SchemaTypeSystem s) {
       setSchemaTypeSystem(s);
  +    mJoust = new CompilingJavaOutputStream();
  +    mJoust.setLogger(this);
     }
   
     /**
  @@ -122,16 +126,70 @@
     }
   
     // ========================================================================
  +  // Public methods
  +
  +  /**
  +   * Sets whether javac should be run on the generated java sources.
  +   * The default is true.
  +   */
  +  public void setCompileJava(boolean b) {
  +    assertCompilationStarted(false);
  +    mJoust.setDoCompile(b);
  +  }
  +
  +  /**
  +   * Sets the location of javac to be invoked.  Default compiler is used
  +   * if this is not set.  Ignored if doCompile is set to false.  Also note
  +   * that not all BindingCompilers generate any source code at all, so
  +   * setting this may have no effect.
  +   */
  +  public void setJavac(String javacPath) {
  +    assertCompilationStarted(false);
  +    mJoust.setJavac(javacPath);
  +  }
  +
  +  /**
  +   * Sets the classpath to use for compilation of generated sources.
  +   * The System classpath is used by default.  This is ignored if doCompile is
  +   * false.  Also note that not all BindingCompilers generate any source
  +   * code at all, so setting this may have no effect.
  +   */
  +  public void setJavacClasspath(File[] classpath) {
  +    assertCompilationStarted(false);
  +    mJoust.setJavacClasspath(classpath);
  +  }
  +
  +  /**
  +   * Sets whether this BindingCompiler should keep any generated java source
  +   * code it generates.  The default is true.  This will have no effect if
  +   * doCompile is set to false.  Also note that not all BindingCompilers
  +   * generate any source code at all, so setting this may have no effect in
  +   * any event.
  +   */
  +  public void setKeepGeneratedJava(boolean b) {
  +    assertCompilationStarted(false);
  +    mJoust.setKeepGenerated(b);
  +  }
  +
  +  // ========================================================================
     // BindingCompiler implementation
   
  +  public JavaOutputStream getJoust(File tylarDestDir) {
  +    mJoust.setSourceDir(new File(tylarDestDir,TylarConstants.SRC_ROOT));
  +    mJoust.setCompilationDir(tylarDestDir);
  +    return mJoust;
  +  }
  +
     /**
      * Computes the binding.
      */
     public void bind(TylarWriter writer) {
       if (sts == null) throw new IllegalStateException("SchemaTypeSystem not set");
       super.notifyCompilationStarted();
  -    mJoust = writer.getJavaOutputStream();
  -    if (mJoust == null) throw new IllegalStateException("joust is null");
  +    if (writer.getJavaOutputStream() == null) {
  +      //sanity check
  +      throw new IllegalStateException("joust is null");
  +    }
       bind();
       try {
         writer.writeBindingFile(bindingFile);
  @@ -139,11 +197,7 @@
         if (!logError(ioe)) return;
       }
       //FIXME also write the input schemas
  -    try {
  -      writeJavaFiles();
  -    } catch(IOException ioe) {
  -      if (!logError(ioe)) return;
  -    }
  +    writeJavaFiles();
     }
   
     // ========================================================================
  @@ -868,7 +922,6 @@
       }
     }
   
  -
     // ========================================================================
     // Java Codegen methods
     //
  @@ -876,7 +929,7 @@
     // class someday.  Somebody conceivably might want to plug in here (at their
     // own risk, of course).   pcal 12/12/03
   
  -  private void writeJavaFiles() throws IOException {
  +  private void writeJavaFiles() {
       Collection classnames = getToplevelClasses();
       for (Iterator i = classnames.iterator(); i.hasNext();) {
         String className = (String) i.next();
  
  
  
  1.1                  xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/TypeMatcherContext.java
  
  Index: TypeMatcherContext.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
  *
  * 3. The end-user documentation included with the redistribution,
  *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
  *
  * 4. The names "Apache" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
  *    software without prior written permission. For written
  *    permission, please contact apache@apache.org.
  *
  * 5. Products derived from this software may not be called "Apache
  *    XMLBeans", nor may "Apache" appear in their name, without prior
  *    written permission of the Apache Software Foundation.
  *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
  *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation and was
  * originally based on software copyright (c) 2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  package org.apache.xmlbeans.impl.binding.compile;
  
  import org.apache.xmlbeans.impl.binding.logger.BindingLogger;
  
  /**
   *
   * @author Patrick Calahan <pc...@bea.com>
   */
  public interface TypeMatcherContext {
  
    public BindingLogger getLogger();
  
  }
  
  
  
  1.2       +27 -9     xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/joust/CompilingJavaOutputStream.java
  
  Index: CompilingJavaOutputStream.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/joust/CompilingJavaOutputStream.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CompilingJavaOutputStream.java	13 Dec 2003 07:56:28 -0000	1.1
  +++ CompilingJavaOutputStream.java	13 Jan 2004 05:40:11 -0000	1.2
  @@ -74,6 +74,11 @@
           implements WriterFactory
    {
     // ========================================================================
  +  // Constants
  +
  +  private static final String PREFIX = "[CompilingJavaOutputStream] ";
  +
  +  // ========================================================================
     // Variables
   
     private FileWriterFactory mWriterFactoryDelegate;
  @@ -83,6 +88,7 @@
     private File[] mJavacClasspath = null;
     private boolean mKeepGenerated;
     private String mJavacPath = null;
  +  private boolean mDoCompile = true;
   
     // ========================================================================
     // Constructors
  @@ -155,6 +161,14 @@
       mKeepGenerated = b;
     }
   
  +  /**
  +   * Sets whether javac should be run on the generated sources.  Default
  +   * is true.
  +   */
  +  public void setDoCompile(boolean b) {
  +    mDoCompile = b;
  +  }
  +
     // ========================================================================
     // WriterFactory implementation
   
  @@ -178,22 +192,26 @@
   
     public void close() throws IOException {
       super.close();
  -    if (mCompileDir != null) {
  -      if (mVerbose) {
  -        System.out.println("compileDir = "+mCompileDir);
  -        Iterator i = mSourceFiles.iterator();
  -        while(i.hasNext()) {
  -          System.out.println(i.next().toString());
  -        }
  +    mLogger.logVerbose(PREFIX+" closing");
  +    if (mDoCompile && mCompileDir != null) {
  +      mLogger.logVerbose(PREFIX+"compileDir = "+mCompileDir);
  +      Iterator i = mSourceFiles.iterator();
  +      while(i.hasNext()) {
  +        mLogger.logVerbose(PREFIX+i.next().toString());
         }
  +      boolean verbose = mLogger.isVerbose();
         boolean result = CodeGenUtil.externalCompile
                 (mSourceFiles,mCompileDir,mJavacClasspath,
  -               mVerbose,mJavacPath,null,null,!mVerbose,mVerbose);
  +               verbose,mJavacPath,null,null,!verbose,verbose);
  +      mLogger.logVerbose(PREFIX+" compilation result: "+result);
         if (!result) {
           throw new IOException("Compilation of sources failed, " +
                                 "check log for details.");
         }
  -      if (!mKeepGenerated) mSourceDir.delete();
  +      if (!mKeepGenerated) {
  +        mLogger.logVerbose(PREFIX+" deleting "+mSourceDir);
  +        mSourceDir.delete();
  +      }
       }
     }
   }
  
  
  
  1.5       +22 -18    xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/joust/SourceJavaOutputStream.java
  
  Index: SourceJavaOutputStream.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/joust/SourceJavaOutputStream.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SourceJavaOutputStream.java	20 Dec 2003 02:03:43 -0000	1.4
  +++ SourceJavaOutputStream.java	13 Jan 2004 05:40:11 -0000	1.5
  @@ -55,6 +55,8 @@
   */
   package org.apache.xmlbeans.impl.binding.joust;
   
  +import org.apache.xmlbeans.impl.binding.logger.BindingLogger;
  +
   import java.io.IOException;
   import java.io.PrintWriter;
   import java.io.Writer;
  @@ -122,10 +124,10 @@
       'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F',
     };
   
  -
     // ========================================================================
     // Variables
   
  +  protected BindingLogger mLogger = BindingLogger.DEFAULT;
     private PrintWriter mOut = null;
     private int mIndentLevel = 0;
     private String mPackageName = null;
  @@ -133,7 +135,6 @@
     private WriterFactory mWriterFactory;
     private StringWriter mCommentBuffer = null;
     private PrintWriter mCommentPrinter = null;
  -  protected boolean mVerbose = false;
   
     // ========================================================================
     // Constructors
  @@ -152,7 +153,14 @@
     // ========================================================================
     // Public methods
   
  -  public void setVerbose(boolean b) { mVerbose = b; }
  +
  +  /**
  +   * Sets the logger to log messages to.
  +   */
  +  public void setLogger(BindingLogger bl) {
  +    if (bl == null) throw new IllegalArgumentException("null logger");
  +    mLogger = bl;
  +  }
   
     // ========================================================================
     // JavaOutputStream implementation
  @@ -182,7 +190,7 @@
             throws IOException {
       checkStateForWrite();
       printCommentsIfNeeded();
  -    if (mVerbose) verbose("startClass "+mPackageName+"."+mClassOrInterfaceName);
  +    mLogger.logVerbose("startClass "+mPackageName+"."+mClassOrInterfaceName);
       extendsClassName = makeI18nSafe(extendsClassName);
       mOut.println("package " + mPackageName + ";");
       mOut.println();
  @@ -210,7 +218,7 @@
   
     public void startInterface(String[] extendsInterfaceNames)
             throws IOException {
  -    if (mVerbose) verbose("startInterface "+mPackageName+"."+mClassOrInterfaceName);
  +    mLogger.logVerbose("startInterface "+mPackageName+"."+mClassOrInterfaceName);
       checkStateForWrite();
       printCommentsIfNeeded();
       mPackageName = makeI18nSafe(mPackageName);
  @@ -236,7 +244,7 @@
                                String typeName,
                                String fieldName,
                                Expression defaultValue) throws IOException {
  -    if (mVerbose) verbose("writeField "+typeName+" "+fieldName);
  +    mLogger.logVerbose("writeField "+typeName+" "+fieldName);
       checkStateForWrite();
       printCommentsIfNeeded();
       printIndents();
  @@ -272,7 +280,7 @@
                                   String[] paramNames,
                                   String[] exceptionClassNames)
             throws IOException {
  -    if (mVerbose) verbose("startMethod "+methodName);
  +    mLogger.logVerbose("startMethod "+methodName);
       checkStateForWrite();
       printCommentsIfNeeded();
       methodName = makeI18nSafe(methodName);
  @@ -314,7 +322,7 @@
     }
   
     public void writeComment(String comment) throws IOException {
  -    if (mVerbose) verbose("comment");
  +    mLogger.logVerbose("comment");
       getCommentPrinter().println(comment);
     }
   
  @@ -337,7 +345,7 @@
     }
   
     public void writeReturnStatement(Expression expression) throws IOException {
  -    if (mVerbose) verbose("return");
  +    mLogger.logVerbose("return");
       checkStateForWrite();
       printCommentsIfNeeded();
       printIndents();
  @@ -348,7 +356,7 @@
   
     public void writeAssignmentStatement(Variable left, Expression right)
             throws IOException {
  -    if (mVerbose) verbose("assignment");
  +    mLogger.logVerbose("assignment");
       checkStateForWrite();
       printCommentsIfNeeded();
       printIndents();
  @@ -359,7 +367,7 @@
     }
   
     public void endMethodOrConstructor() throws IOException {
  -    if (mVerbose) verbose("endMethodOrConstructor");
  +    mLogger.logVerbose("endMethodOrConstructor");
       checkStateForWrite();
       printCommentsIfNeeded();
       reduceIndent();
  @@ -369,7 +377,7 @@
     }
   
     public void endClassOrInterface() throws IOException {
  -    if (mVerbose) verbose("endClassOrInterface");
  +    mLogger.logVerbose("endClassOrInterface");
       checkStateForWrite();
       printCommentsIfNeeded();
       reduceIndent();
  @@ -380,7 +388,7 @@
     public void endFile() throws IOException {
       checkStateForWrite();
       printCommentsIfNeeded();
  -    if (mVerbose) verbose("endFile");
  +    mLogger.logVerbose("endFile");
       closeOut();
     }
   
  @@ -393,7 +401,7 @@
     }
   
     public void close() throws IOException {
  -    if (mVerbose) verbose("close");
  +    mLogger.logVerbose("close");
       closeOut();//just to be safe
     }
   
  @@ -538,10 +546,6 @@
         }
         j = i;
       }
  -  }
  -
  -  private void verbose(String msg) {
  -    if (mVerbose) System.out.println(msg);
     }
   
     // ========================================================================
  
  
  
  1.1                  xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/logger/BindingLogger.java
  
  Index: BindingLogger.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
  *
  * 3. The end-user documentation included with the redistribution,
  *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
  *
  * 4. The names "Apache" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
  *    software without prior written permission. For written
  *    permission, please contact apache@apache.org.
  *
  * 5. Products derived from this software may not be called "Apache
  *    XMLBeans", nor may "Apache" appear in their name, without prior
  *    written permission of the Apache Software Foundation.
  *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
  *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation and was
  * originally based on software copyright (c) 2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  package org.apache.xmlbeans.impl.binding.logger;
  
  import org.apache.xmlbeans.SchemaProperty;
  import org.apache.xmlbeans.SchemaType;
  import org.apache.xmlbeans.impl.jam.JElement;
  
  import java.util.logging.Level;
  
  /**
   * Provides an interface to which binding compilation objects can send
   * log messages.  The various logging methods here simply construct
   * new BindingLoggerMessages and send them on to some MessageSink
   * which actually processes the messsages; this class is primarily
   * responsible for simply providing clients with a 'tighter' interface to
   * that sink.
   *
   * @author Patrick Calahan <pc...@bea.com>
   */
  public class BindingLogger {
  
    // ========================================================================
    // Constants
  
    private static final MessageSink DEFAULT_SINK =
            new SimpleMessageSink();
  
    public static final BindingLogger DEFAULT = new BindingLogger();
  
    // ========================================================================
    // Variables
  
    private boolean mVerbose = false;
    private MessageSink mSink = DEFAULT_SINK;
    private boolean mAnyErrorsFound = false;
    private boolean mIgnoreErrors = false;
  
    // ========================================================================
    // Constructors
  
    protected BindingLogger(MessageSink sink) { mSink = sink; }
  
    protected BindingLogger() { mSink = DEFAULT_SINK; }
  
    // ========================================================================
    // Attributes
  
    public void setVerbose(boolean b) {
      mVerbose = b;
    }
  
    public void setIgnoreErrors(boolean b) {
      mIgnoreErrors = b;
    }
  
    public void setMessageSink(MessageSink blp) {
      mSink = blp;
    }
  
    public boolean isAnyErrorsFound() {
      return mAnyErrorsFound;
    }
  
    public boolean isIgnoreErrors() {
      return mIgnoreErrors;
    }
  
    public boolean isVerbose() {
      return mVerbose;
    }
  
    // ========================================================================
    // Public logging methods
  
    /**
     * Logs a message that some error occurred while performing binding.
     *
     * @return true if processing should attempt to continue.
     */
    public boolean logError(String msg) {
      mAnyErrorsFound = true;
      mSink.log(new MessageImpl
              (Level.SEVERE, msg, null, null, null, null));
      return mIgnoreErrors;
    }
  
    /**
     * Logs a message that an error occurred.
     *
     * @return true if processing should attempt to continue.
     */
    public boolean logError(Throwable t) {
      mAnyErrorsFound = true;
      mSink.log(new MessageImpl
              (Level.SEVERE, null, t, null, null, null));
      return mIgnoreErrors;
    }
  
    /**
     * Logs a message that fatal error that occurred while performing binding
     * on the given java construct.
     *
     * @return true if processing should attempt to continue.
     */
    public boolean logError(Throwable error, JElement javaContext) {
      mAnyErrorsFound = true;
      mSink.log(new MessageImpl
              (Level.SEVERE, null, error, javaContext, null, null));
      return mIgnoreErrors;
    }
  
    /**
     * Logs a message that fatal error that occurred while performing binding
     * on the given schema construct.
     *
     * @return true if processing should attempt to continue.
     */
    public boolean logError(Throwable error, SchemaType schemaContext) {
      mAnyErrorsFound = true;
      mSink.log(new MessageImpl
              (Level.SEVERE, null, error, null, schemaContext, null));
      return mIgnoreErrors;
    }
  
    /**
     * Logs a message that fatal error that occurred while performing binding
     * on the given java and schema constructs.
     *
     * @return true if processing should attempt to continue.
     */
    public boolean logError(Throwable t, JElement jCtx, SchemaType xsdCtx) {
      mAnyErrorsFound = true;
      mSink.log(new MessageImpl
              (Level.SEVERE, null, t, jCtx, xsdCtx, null));
      return mIgnoreErrors;
    }
  
    /**
     * Logs a message that fatal error that occurred while performing binding
     * on the given java construct.
     *
     * @return true if processing should attempt to continue.
     */
    public boolean logError(String msg, JElement javaContext) {
      mAnyErrorsFound = true;
      mSink.log(new MessageImpl
              (Level.SEVERE, msg, null, javaContext, null, null));
      return mIgnoreErrors;
    }
  
    /**
     * Logs a message that fatal error that occurred while performing binding
     * on the given schema construct.
     *
     * @return true if processing should attempt to continue.
     */
    public boolean logError(String msg, SchemaType xsdCtx) {
      mAnyErrorsFound = true;
      mSink.log(new MessageImpl
              (Level.SEVERE, msg, null, null, xsdCtx, null));
      return mIgnoreErrors;
    }
  
    /**
     * Logs a message that fatal error that occurred while performing binding
     * on the given schema construct.
     *
     * @return true if processing should attempt to continue.
     */
    public boolean logError(String msg, JElement javaCtx, SchemaType xsdCtx) {
      mAnyErrorsFound = true;
      mSink.log(new MessageImpl
              (Level.SEVERE, msg, null, javaCtx, xsdCtx, null));
      return mIgnoreErrors;
    }
  
    /**
     * Logs a message that fatal error that occurred while performing binding
     * on the given schema construct.
     *
     * @return true if processing should attempt to continue.
     */
    public boolean logError(String msg, JElement jCtx, SchemaProperty xCtx) {
      mAnyErrorsFound = true;
      mSink.log(new MessageImpl
              (Level.SEVERE, msg, null, jCtx, null, xCtx));
      return mIgnoreErrors;
    }
  
    /**
     * Logs an informative message that should be printed only in 'verbose'
     * mode.
     */
    public void logVerbose(String msg) {
      if (mVerbose) {
        mSink.log(new MessageImpl
                (Level.FINEST, msg, null, null, null, null));
      }
    }
  
    /**
     * Logs an informative message that should be printed only in 'verbose'
     * mode.
     */
    public void logVerbose(String msg, JElement javaContext) {
      if (mVerbose) {
        mSink.log(new MessageImpl
                (Level.FINEST, msg, null, javaContext, null, null));
      }
    }
  
    /**
     * Logs an informative message that should be printed only in 'verbose'
     * mode.
     */
    public void logVerbose(String msg, SchemaType xsdType) {
      if (mVerbose) {
        mSink.log(new MessageImpl
                (Level.FINEST, msg, null, null, xsdType, null));
      }
    }
  
    /**
     * Logs an informative message that should be printed only in 'verbose'
     * mode.
     */
    public void logVerbose(String msg, JElement javaCtx, SchemaType xsdCtx) {
      if (mVerbose) {
        mSink.log(new MessageImpl
                (Level.FINEST, msg, null, javaCtx, xsdCtx, null));
      }
    }
  
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/logger/Message.java
  
  Index: Message.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
  *
  * 3. The end-user documentation included with the redistribution,
  *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
  *
  * 4. The names "Apache" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
  *    software without prior written permission. For written
  *    permission, please contact apache@apache.org.
  *
  * 5. Products derived from this software may not be called "Apache
  *    XMLBeans", nor may "Apache" appear in their name, without prior
  *    written permission of the Apache Software Foundation.
  *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
  *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation and was
  * originally based on software copyright (c) 2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  package org.apache.xmlbeans.impl.binding.logger;
  
  import org.apache.xmlbeans.SchemaProperty;
  import org.apache.xmlbeans.SchemaType;
  import org.apache.xmlbeans.impl.jam.JElement;
  
  import java.util.logging.Level;
  
  /**
   * Encapsulates a message that was generated while running a BindingCompiler.
   *
   * @author Patrick Calahan <pc...@bea.com>
   */
  public interface Message {
  
    /**
     * @return The severity level of the message.  This must never return null.
     */
    public Level getLevel();
  
    /**
     * @return The text of the message.  This must never return null.
     */
    public String getMessage();
  
    /**
     * @return The exception which caused the message, or null.
     */
    public Throwable getException();
  
    /**
     * @return The JElement representing the java construct to which the message
     * applies, or null.
     */
    public JElement getJavaContext();
  
    /**
     * @return The SchemaType representing the xsd type to which the message
     * applies, or null.
     */
    public SchemaType getSchemaTypeContext();
  
    /**
     * @return The SchemaProperty representing the xsd property to which the
     * message applies, or null.
     */
    public SchemaProperty getSchemaPropertyContext();
  }
  
  
  1.1                  xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/logger/MessageImpl.java
  
  Index: MessageImpl.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
  *
  * 3. The end-user documentation included with the redistribution,
  *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
  *
  * 4. The names "Apache" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
  *    software without prior written permission. For written
  *    permission, please contact apache@apache.org.
  *
  * 5. Products derived from this software may not be called "Apache
  *    XMLBeans", nor may "Apache" appear in their name, without prior
  *    written permission of the Apache Software Foundation.
  *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
  *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation and was
  * originally based on software copyright (c) 2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  package org.apache.xmlbeans.impl.binding.logger;
  
  import org.apache.xmlbeans.SchemaProperty;
  import org.apache.xmlbeans.SchemaType;
  import org.apache.xmlbeans.impl.jam.JElement;
  
  import java.io.PrintWriter;
  import java.io.StringWriter;
  import java.util.logging.Level;
  
  /**
   *
   * @author Patrick Calahan <pc...@bea.com>
   */
  public class MessageImpl implements Message {
  
    // ========================================================================
    // Variables
  
    private Level mLevel;
    private String mMessage = null;
    private Throwable mException = null;
    private JElement mJavaContext = null;
    private SchemaType mSchemaTypeContext = null;
    private SchemaProperty mSchemaPropertyContext = null;
  
    // ========================================================================
    // Constructors
  
    public MessageImpl(Level level,
                       String message,
                       Throwable exception,
                       JElement javaContext,
                       SchemaType schemaTypeContext,
                       SchemaProperty schemaPropertyContext) {
      if (level == null) throw new IllegalArgumentException("null level");
      mLevel = level;
      mMessage = message;
      mException = exception;
      mJavaContext = javaContext;
      mSchemaTypeContext = schemaTypeContext;
      mSchemaPropertyContext = schemaPropertyContext;
    }
  
    // ========================================================================
    // Message implementation
  
    public Level getLevel() {
      return mLevel;
    }
  
    public String getMessage() {
      if (mMessage != null) return mMessage;
      if (mException != null) return mException.getMessage();
      return mLevel.getLocalizedName(); //?
    }
  
    public Throwable getException() {
      return mException;
    }
  
    public JElement getJavaContext() {
      return mJavaContext;
    }
  
    public SchemaProperty getSchemaPropertyContext() {
      return mSchemaPropertyContext;
    }
  
    public SchemaType getSchemaTypeContext() {
      return mSchemaTypeContext;
    }
  
    // ========================================================================
    // Object implementation
  
    public String toString() {
      StringWriter sw = new StringWriter();
      print(new PrintWriter(sw));
      return sw.toString();
    }
  
    // ========================================================================
    // Private methods
  
    private void print(PrintWriter out) {
      out.print('[');
      out.print(mLevel.toString());
      out.print("] ");
      if (mMessage != null) {
        out.println(mMessage);
      }
      if (mJavaContext != null) {
        out.print(" on Java element '");
        out.print(mJavaContext.getQualifiedName());
        out.print("'");
      }
      if (mSchemaTypeContext != null) {
        out.print(" on Schema type ");
        out.print(mSchemaTypeContext.getName());//FIXME?
        out.print("'");
      }
      if (mSchemaPropertyContext != null) {
        out.print(" on Schema type ");
        out.print(mSchemaPropertyContext.getName());//FIXME?
        out.print("'");
      }
      if (mException != null) {
        mException.printStackTrace(out);
      }
    }
  }
  
  
  1.1                  xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/logger/MessageSink.java
  
  Index: MessageSink.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
  *
  * 3. The end-user documentation included with the redistribution,
  *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
  *
  * 4. The names "Apache" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
  *    software without prior written permission. For written
  *    permission, please contact apache@apache.org.
  *
  * 5. Products derived from this software may not be called "Apache
  *    XMLBeans", nor may "Apache" appear in their name, without prior
  *    written permission of the Apache Software Foundation.
  *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
  *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation and was
  * originally based on software copyright (c) 2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  package org.apache.xmlbeans.impl.binding.logger;
  
  
  
  /**
   * Implemented by helper objects which can receive log messages from a
   * BindingCompiler and do something useful with them.  Note that
   * BindingCompilers should generally try to proceed even when binding
   * errors are encounted so as to help the user identify as many errors as
   * possible in a single pass.
   *
   * @author Patrick Calahan <pc...@bea.com>
   */
  public interface MessageSink {
  
    /**
     * Logs a message that was produced while performing binding
     * on the given java construct.
     *
     * @param msg  message to be logged
     */
    public void log(Message msg);
  }
  
  
  1.1                  xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/logger/SimpleMessageSink.java
  
  Index: SimpleMessageSink.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
  *
  * 3. The end-user documentation included with the redistribution,
  *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
  *
  * 4. The names "Apache" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
  *    software without prior written permission. For written
  *    permission, please contact apache@apache.org.
  *
  * 5. Products derived from this software may not be called "Apache
  *    XMLBeans", nor may "Apache" appear in their name, without prior
  *    written permission of the Apache Software Foundation.
  *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
  *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation and was
  * originally based on software copyright (c) 2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  package org.apache.xmlbeans.impl.binding.logger;
  
  import java.io.PrintWriter;
  
  /**
   * Implementation of MessageSink that just spews out to some Writer.
   */
  public class SimpleMessageSink implements MessageSink {
  
    // ========================================================================
    // Constants
  
    public static final MessageSink STDOUT = new SimpleMessageSink();
  
    // ========================================================================
    // Variables
  
    private PrintWriter mOut;
  
    // ========================================================================
    // Constructors
  
    public SimpleMessageSink() {
      this(new PrintWriter(System.out));
    }
  
    public SimpleMessageSink(PrintWriter out) {
      if (out == null) throw new IllegalArgumentException();
      mOut = out;
    }
  
    // ========================================================================
    // MessageSink implementation
  
    public void log(Message msg) {
      mOut.print(msg.toString());
      mOut.flush();
    }
  }
  
  
  
  1.5       +2 -2      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ExplodedTylarImpl.java	18 Dec 2003 01:58:58 -0000	1.4
  +++ ExplodedTylarImpl.java	13 Jan 2004 05:40:11 -0000	1.5
  @@ -101,7 +101,7 @@
     private File mSourceRoot;
     private File mSchemaDir;
     private BindingFile mBindingFile = null;
  -  private JavaOutputStream mJoust;
  +  private JavaOutputStream mJoust = null;
     private Collection mSchemaDocuments = null;
   
     // ========================================================================
  @@ -197,7 +197,7 @@
     }
   
     public void close() throws IOException {
  -    mJoust.close();
  +    if (mJoust != null) mJoust.close();
     }
   
     // ========================================================================
  
  
  
  1.4       +2 -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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TylarWriter.java	13 Dec 2003 07:56:29 -0000	1.3
  +++ TylarWriter.java	13 Jan 2004 05:40:11 -0000	1.4
  @@ -88,6 +88,8 @@
      * Returns the JavaOutputStream which should be used for creating new java
      * code to be stored in this tylar.  Note that the caller should never
      * close this stream directly; it will be closed by TylarWriter.close();
  +   * This method may return null, indicating the writer does not support
  +   * java code generation.
      */
     public JavaOutputStream getJavaOutputStream();
   
  
  
  
  1.3       +39 -33    xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/BaseJElement.java
  
  Index: BaseJElement.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/internal/BaseJElement.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BaseJElement.java	3 Dec 2003 22:46:15 -0000	1.2
  +++ BaseJElement.java	13 Jan 2004 05:40:11 -0000	1.3
  @@ -58,6 +58,7 @@
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.List;
  +
   import org.apache.xmlbeans.impl.jam.*;
   
   /**
  @@ -71,17 +72,17 @@
     // Constants
   
     // help reduce object waste
  -  public static final JElement[]     NO_NODE        = new JElement[0];
  -  public static final JClass[]       NO_CLASS       = new JClass[0];
  -  public static final JField[]       NO_FIELD       = new JField[0];
  +  public static final JElement[] NO_NODE = new JElement[0];
  +  public static final JClass[] NO_CLASS = new JClass[0];
  +  public static final JField[] NO_FIELD = new JField[0];
     public static final JConstructor[] NO_CONSTRUCTOR = new JConstructor[0];
  -  public static final JMethod[]      NO_METHOD      = new JMethod[0];
  -  public static final JParameter[]   NO_PARAMETER   = new JParameter[0];
  -  public static final JPackage[]     NO_PACKAGE     = new JPackage[0];
  -  public static final JAnnotation[]  NO_ANNOTATION  = new JAnnotation[0];
  +  public static final JMethod[] NO_METHOD = new JMethod[0];
  +  public static final JParameter[] NO_PARAMETER = new JParameter[0];
  +  public static final JPackage[] NO_PACKAGE = new JPackage[0];
  +  public static final JAnnotation[] NO_ANNOTATION = new JAnnotation[0];
   
  -  public static final JComment[]     NO_COMMENT     = new JComment[0];
  -  public static final JProperty[]    NO_PROPERTY    = new JProperty[0];
  +  public static final JComment[] NO_COMMENT = new JComment[0];
  +  public static final JProperty[] NO_PROPERTY = new JProperty[0];
   
     private static final String ANNOTATION_SEPARATOR = "@";
   
  @@ -95,7 +96,8 @@
     // ========================================================================
     // Constructors
   
  -  protected BaseJElement() {}
  +  protected BaseJElement() {
  +  }
   
     private List getTempList() {
       return new ArrayList();
  @@ -117,10 +119,10 @@
         List list = getTempList();
         getLocalAnnotations(list);
         if (list.size() == 0) {
  -	mAnns = NO_ANNOTATION;
  +        mAnns = NO_ANNOTATION;
         } else {
  -	mAnns = new JAnnotation[list.size()];
  -	list.toArray(mAnns);
  +        mAnns = new JAnnotation[list.size()];
  +        list.toArray(mAnns);
         }
       }
       return mAnns; // FIXME do we need to return a copy?
  @@ -128,7 +130,7 @@
   
     public final JAnnotation[] getAnnotations(String named) {
       List list = getTempList();
  -    gatherAnnotations(named,list);
  +    gatherAnnotations(named, list);
       JAnnotation[] out = new JAnnotation[list.size()];
       list.toArray(out);
       return out;
  @@ -139,13 +141,13 @@
         List list = getTempList();
         getLocalComments(list);
         /*      if (mContext.getExtraMarkupStore() != null) {
  -	mContext.getExtraMarkupStore().getComments(this,list);
  -	}*/
  +      mContext.getExtraMarkupStore().getComments(this,list);
  +      }*/
         if (list.size() == 0) {
  -	mComments = NO_COMMENT;
  +        mComments = NO_COMMENT;
         } else {
  -	mComments = new JComment[list.size()];
  -	list.toArray(mComments);
  +        mComments = new JComment[list.size()];
  +        list.toArray(mComments);
         }
       }
       return mComments; // FIXME do we need to return a copy?
  @@ -159,7 +161,9 @@
     // ========================================================================
     // Object implementation
   
  -  public String toString() { return getQualifiedName(); }
  +  public String toString() {
  +    return getQualifiedName();
  +  }
   
     // ========================================================================
     // Methods to be implemented by subclasses
  @@ -186,19 +190,19 @@
       JAnnotation[] anns = getAnnotations();
       if (anns == NO_ANNOTATION) return;
       int dot = fullName.indexOf(ANNOTATION_SEPARATOR);
  -    String subname = (dot == -1) ? fullName : fullName.substring(0,dot);
  -    String postfix = (dot == -1 || dot == fullName.length()-1) ?
  -      null : fullName.substring(dot+1);
  +    String subname = (dot == -1) ? fullName : fullName.substring(0, dot);
  +    String postfix = (dot == -1 || dot == fullName.length() - 1) ?
  +            null : fullName.substring(dot + 1);
       // System.out.println("===== "+subname+"  "+postfix);
  -    for(int i=0; i<anns.length; i++) {
  +    for (int i = 0; i < anns.length; i++) {
         if (anns[i].getName().equals(subname)) {
  -	if (postfix == null) {
  -	  out.add(anns[i]);
  -	} else {
  -	  // REVIEW nasty cast.  Alternative is to expose this method
  -	  // via a private interface, but that seems like overkill.
  -	  ((BaseJElement)anns[i]).gatherAnnotations(postfix,out);
  -	}
  +        if (postfix == null) {
  +          out.add(anns[i]);
  +        } else {
  +          // REVIEW nasty cast.  Alternative is to expose this method
  +          // via a private interface, but that seems like overkill.
  +          ((BaseJElement) anns[i]).gatherAnnotations(postfix, out);
  +        }
         }
       }
     }
  @@ -211,9 +215,11 @@
   
     public boolean equals(Object o) {
       return (o instanceof JElement) &&
  -      getQualifiedName().equals(((JElement)o).getQualifiedName());
  +            getQualifiedName().equals(((JElement) o).getQualifiedName());
     }
   
  -  public int hashCode() { return getQualifiedName().hashCode(); }
  +  public int hashCode() {
  +    return getQualifiedName().hashCode();
  +  }
   
   }
  
  
  
  1.7       +7 -4      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BindingContextImpl.java
  
  Index: BindingContextImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BindingContextImpl.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BindingContextImpl.java	17 Dec 2003 07:05:35 -0000	1.6
  +++ BindingContextImpl.java	13 Jan 2004 05:40:11 -0000	1.7
  @@ -62,16 +62,13 @@
   import org.apache.xmlbeans.XmlException;
   import org.apache.xmlbeans.XmlOptions;
   import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
  -import org.apache.xmlbeans.impl.common.XmlErrorWatcher;
  -
   import java.util.Collection;
   
   /**
    * Main entry point into marshalling framework.
    * Use the BindingContextFactory to create one
    */
  -final class BindingContextImpl
  -    implements BindingContext
  +public final class BindingContextImpl implements BindingContext
   {
       private final BindingLoader bindingLoader;
       private final RuntimeBindingTypeTable typeTable;
  @@ -108,6 +105,12 @@
                                     typeTable,
                                     options);
       }
  +
  +
  +    /**
  +     * @deprecated do not use this
  +     */
  +    public BindingLoader getBindingLoader() { return bindingLoader; }
   
       static Collection extractErrorHandler(XmlOptions options)
       {
  
  
  

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