poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1857518 [3/7] - in /xmlbeans/branches/xmlbeans-536: ./ src/jam/ src/jam/org/ src/jam/org/apache/ src/jam/org/apache/xmlbeans/ src/jam/org/apache/xmlbeans/impl/ src/jam/org/apache/xmlbeans/impl/jam/ src/jam/org/apache/xmlbeans/impl/jam/anno...
Date Sun, 14 Apr 2019 13:55:07 GMT
Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamClassLoaderImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamClassLoaderImpl.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamClassLoaderImpl.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamClassLoaderImpl.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,245 @@
+/*   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.xmlbeans.impl.jam.internal;
+
+import org.apache.xmlbeans.impl.jam.JClass;
+import org.apache.xmlbeans.impl.jam.JPackage;
+import org.apache.xmlbeans.impl.jam.JamClassLoader;
+import org.apache.xmlbeans.impl.jam.internal.elements.ArrayClassImpl;
+import org.apache.xmlbeans.impl.jam.internal.elements.ClassImpl;
+import org.apache.xmlbeans.impl.jam.internal.elements.ElementContext;
+import org.apache.xmlbeans.impl.jam.internal.elements.PackageImpl;
+import org.apache.xmlbeans.impl.jam.internal.elements.PrimitiveClassImpl;
+import org.apache.xmlbeans.impl.jam.internal.elements.UnresolvedClassImpl;
+import org.apache.xmlbeans.impl.jam.internal.elements.VoidClassImpl;
+import org.apache.xmlbeans.impl.jam.mutable.MClass;
+import org.apache.xmlbeans.impl.jam.provider.JamClassBuilder;
+import org.apache.xmlbeans.impl.jam.visitor.MVisitor;
+import org.apache.xmlbeans.impl.jam.visitor.TraversingMVisitor;
+
+import java.lang.ref.WeakReference;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+/**
+ *
+ * @author Patrick Calahan <email: pcal-at-bea-dot-com>
+ */
+public class JamClassLoaderImpl implements JamClassLoader {
+
+  // ========================================================================
+  // Variables
+
+  private Map mName2Package = new HashMap();
+  private Map mFd2ClassCache = new HashMap();
+  private JamClassBuilder mBuilder;
+  private MVisitor mInitializer = null;
+  private ElementContext mContext;
+  private Stack mInitializeStack = new Stack(); //fixme - decide how to store them
+  private boolean mAlreadyInitializing = false;
+
+  // ========================================================================
+  // Constructor
+
+  public JamClassLoaderImpl(ElementContext context,
+                            JamClassBuilder builder,
+                            MVisitor initializerOrNull) {
+    if (builder == null) throw new IllegalArgumentException("null builder");
+    if (context == null) throw new IllegalArgumentException("null builder");
+    mBuilder = builder;
+    mInitializer = (initializerOrNull == null) ? null : // null is ok, else
+      new TraversingMVisitor(initializerOrNull); // wrap it in a walker
+    mContext = context;
+    initCache();
+  }
+
+  // ========================================================================
+  // JamClassLoader implementation
+
+  public final JClass loadClass(String fd)
+  {
+    fd = fd.trim();
+    JClass out = cacheGet(fd);
+    if (out != null) return out;
+    if (fd.indexOf('[') != -1) { // must be some kind of array name
+      String normalFd = ArrayClassImpl.normalizeArrayName(fd);
+      out = cacheGet(normalFd); // an array by any other name?
+      if (out == null) {
+        out = ArrayClassImpl.createClassForFD(normalFd,this);
+        cachePut(out,normalFd);
+      }
+      cachePut(out,fd); // so we know it by the requested name as well
+      return out;
+    }
+    {
+      // check for loading inner class by name.  if it's not in the cache
+      // yet, that means we need to go get the outer class.  when that's
+      // done, the inner class will in the cache (or not).
+      int dollar = fd.indexOf('$');
+      if (dollar != -1) {
+        String outerName = fd.substring(0,dollar);
+        ((ClassImpl)loadClass(outerName)).ensureLoaded();
+        out = cacheGet(fd);
+        // parse out the package and class names - this is kinda broken
+        int dot = fd.lastIndexOf('.');
+        if (out == null) {
+          String pkg;
+          String name;
+          if (dot == -1) {
+            pkg = "";
+            name = fd;
+          } else {
+            pkg  = fd.substring(0,dot);
+            name = fd.substring(dot+1);
+          }
+          out = new UnresolvedClassImpl(pkg,name,mContext);
+          mContext.warning("failed to resolve class "+fd);
+          cachePut(out);
+        }
+        return out;
+      }
+    }
+    // parse out the package and class names - this is kinda broken
+    int dot = fd.lastIndexOf('.');
+    String pkg;
+    String name;
+    if (dot == -1) {
+      pkg = "";
+      name = fd;
+    } else {
+      pkg  = fd.substring(0,dot);
+      name = fd.substring(dot+1);
+    }
+    out = mBuilder.build(pkg,name);
+    if (out == null) {
+      //FIXME currently, the unqualified ref stuff will keep calling this,
+      //newing up new UnresolvedClassImpls for each import until it finds
+      //something.  We need to break out a separate checkClass() method
+      //or something for them which returns null rather than UnresolvedClass.
+      out = new UnresolvedClassImpl(pkg,name,mContext);
+      mContext.warning("failed to resolve class "+fd);
+      cachePut(out);
+      return out;
+    }
+    cachePut(out);
+    return out;
+  }
+
+  public JPackage getPackage(String named) {
+    JPackage out = (JPackage)mName2Package.get(named);
+    if (out == null) {
+      out = new PackageImpl(mContext,named);
+      mName2Package.put(named,out);
+    }
+    return out;
+  }
+
+  // ========================================================================
+  // Private methods
+
+  /**
+   * <p>Stuff the primitives and void into the cache.</p>
+   */
+  private void initCache() {
+    PrimitiveClassImpl.mapNameToPrimitive(mContext,mFd2ClassCache);
+    mFd2ClassCache.put("void",new VoidClassImpl(mContext));
+  }
+
+  private void cachePut(JClass clazz) {
+    mFd2ClassCache.put(clazz.getFieldDescriptor().trim(),
+                       new WeakReference(clazz));
+  }
+
+  private void cachePut(JClass clazz, String cachedName) {
+    mFd2ClassCache.put(cachedName, new WeakReference(clazz));
+  }
+
+  private JClass cacheGet(String fd) {
+    Object out = mFd2ClassCache.get(fd.trim());
+    if (out == null) return null;
+    if (out instanceof JClass) return (JClass)out;
+    if (out instanceof WeakReference) {
+      out = ((WeakReference)out).get();
+      if (out == null) {
+        mFd2ClassCache.remove(fd.trim());
+        return null;
+      } else {
+        return (JClass)out;
+      }
+    }
+    throw new IllegalStateException();
+  }
+
+  // ========================================================================
+  // Public methods?
+
+  //should only be called by ClassImpl
+  public void initialize(ClassImpl out) {
+    if (mInitializer != null) {
+      // see comments below about this.  we need to document this more openly,
+      // since it affects people writing initializers.
+      if (mAlreadyInitializing) {
+        // we already are running initializers, so we have to do this one later
+        mInitializeStack.push(out);
+      } else {
+        out.accept(mInitializer);
+        while(!mInitializeStack.isEmpty()) {
+          ClassImpl initme = (ClassImpl)mInitializeStack.pop();
+          initme.accept(mInitializer);
+        }
+        mAlreadyInitializing = false;
+      }
+    }
+  }
+
+  /**
+   * Returns an unmodifiable collection containing the JClasses which
+   * have been resolved by this JamClassLoader.
+   */
+  public Collection getResolvedClasses() {
+    return Collections.unmodifiableCollection(mFd2ClassCache.values());
+  }
+
+  public void addToCache(JClass c) {
+    //FIXME hack for mutable classes for now.  also for inner classes.
+    cachePut((MClass)c);
+  }
+
+  //ok, the best thinking here is that when you are in an initializer
+  //and you walk to another type, you will get a JClass that has a name
+  //but is otherwise empty - it's not initialized.  It's like unresolved
+  //except that it still has a chance to be resolved.
+  //
+  // Internally, the classloader will maintain a stack of classes to be
+  // initialized.  When a class is first loaded, the initialization stack
+  // is checked.  If it is empty, the class is placed on the stack and
+  // initialization is performed on the item on the top of the stack until
+  // the stack is empty.
+
+  // If loadClass is called again further down in the stack frame,
+  // at least one class will be on the initialization stack.  In this
+  // case, the class is placed on the stack but initialization is not
+  // performed immediately - the caller original caller higher in the stack
+  // frame will do the initialization.
+
+  // This scheme is necessary to prevent problems with cyclical initialization.
+  //
+//  public boolean isInitialized();
+
+
+}
\ No newline at end of file

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamLoggerImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamLoggerImpl.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamLoggerImpl.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamLoggerImpl.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,149 @@
+/*   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.xmlbeans.impl.jam.internal;
+
+import org.apache.xmlbeans.impl.jam.provider.JamLogger;
+
+import java.io.PrintWriter;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public class JamLoggerImpl implements JamLogger {
+
+  // ========================================================================
+  // Variables
+
+  private boolean mShowWarnings = true;
+  private Set mVerboseClasses = null;
+  private PrintWriter mOut = new PrintWriter(System.out,true);
+
+  //FIXME temp until JamServiceContextImpl is no longer a subclass
+  protected void setOut(PrintWriter out) { mOut= out; }
+
+  // ========================================================================
+  // JamLogger implementation
+
+  public boolean isVerbose(Object o) {
+    if (mVerboseClasses == null) return false;
+    Iterator i = mVerboseClasses.iterator();
+    while(i.hasNext()) {
+      Class c = (Class)i.next();
+      if (c.isAssignableFrom(o.getClass())) return true;
+    }
+    return false;
+  }
+
+  public boolean isVerbose(Class aClass) {
+    if (mVerboseClasses == null) return false;
+    Iterator i = mVerboseClasses.iterator();
+    while(i.hasNext()) {
+      Class c = (Class)i.next();
+      if (c.isAssignableFrom(aClass)) return true;
+    }
+    return false;
+  }
+
+  public void setVerbose(Class c) {
+    if (c == null) throw new IllegalArgumentException();
+    if (mVerboseClasses == null) mVerboseClasses = new HashSet();
+    mVerboseClasses.add(c);
+  }
+
+  public void setShowWarnings(boolean b) {
+    mShowWarnings = b;
+  }
+  
+  public void verbose(String msg, Object o) {
+    if (isVerbose(o)) verbose(msg);
+  }
+
+  public void verbose(Throwable t, Object o) {
+    if (isVerbose(o)) verbose(t);
+  }
+
+  public void verbose(String msg) {
+    printVerbosePrefix();
+    mOut.println(msg);
+  }
+
+
+  public void verbose(Throwable t) {
+    printVerbosePrefix();
+    mOut.println();
+    t.printStackTrace(mOut);
+  }
+
+  public void warning(Throwable t) {
+    if (mShowWarnings) {
+      mOut.println("[JAM] Warning: unexpected exception thrown: ");
+      t.printStackTrace();
+    }
+  }
+
+  public void warning(String w) {
+    if (mShowWarnings) {
+
+      mOut.print("[JAM] Warning: ");
+      mOut.println(w);
+    }
+  }
+
+  public void error(Throwable t) {
+    mOut.println("[JAM] Error: unexpected exception thrown: ");
+    t.printStackTrace(mOut);
+  }
+
+  public void error(String msg) {
+    mOut.print("[JAM] Error: ");
+    mOut.println(msg);
+  }
+
+  // ========================================================================
+  // Deprecated methods
+
+  public void setVerbose(boolean v) { setVerbose(Object.class); }
+
+  public boolean isVerbose() { return mVerboseClasses != null; }
+
+  // ========================================================================
+  // Private methods
+
+  private void printVerbosePrefix() {
+    StackTraceElement[] st = new Exception().getStackTrace();
+    mOut.println("[JAM] Verbose: ");
+    mOut.print('(');
+    mOut.print(shortName(st[2].getClassName()));
+    mOut.print('.');
+    mOut.print(st[2].getMethodName());
+    mOut.print(':');
+    mOut.print(st[2].getLineNumber());
+    mOut.print(")  ");
+  }
+
+  private static String shortName(String className) {
+    int index = className.lastIndexOf('.');
+
+    if (index != -1 ) {
+      className = className.substring(index+1, className.length());
+    }
+
+    return className;
+  }
+
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamPrinter.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamPrinter.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamPrinter.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamPrinter.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,141 @@
+/*   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.jam.internal;
+
+import org.apache.xmlbeans.impl.jam.JAnnotation;
+import org.apache.xmlbeans.impl.jam.JClass;
+import org.apache.xmlbeans.impl.jam.JConstructor;
+import org.apache.xmlbeans.impl.jam.JElement;
+import org.apache.xmlbeans.impl.jam.JMethod;
+import org.apache.xmlbeans.impl.jam.JamClassIterator;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+/**
+ * Utility class for printing out a JAM.
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public class JamPrinter {
+
+  // ========================================================================
+  // Factory
+
+  public static JamPrinter newInstance() {
+    return new JamPrinter();
+  }
+
+  private JamPrinter() {
+  }
+
+  private static final String INDENT = "  ";
+
+  // ========================================================================
+  // Public methods
+
+  public void print(JElement root, PrintWriter out) {
+    print(root, 0, out);
+  }
+
+  public void print(JamClassIterator iter, PrintWriter out) {
+    while(iter.hasNext()) {
+      JClass clazz = iter.nextClass();
+      out.println("------------------------------");
+      out.println(clazz.getQualifiedName());
+      out.println("------------------------------");
+      print(clazz,out);
+      out.println();
+    }
+  }
+
+  // ========================================================================
+  // Private methods
+
+  private void print(JElement a, int indent, PrintWriter out) {
+    indent(indent, out);
+    out.print("[");
+    out.print(getTypeKey(a));
+    out.print("] ");
+    if (a instanceof JMethod) {
+      out.print(((JMethod) a).getReturnType().getFieldDescriptor());
+      out.print(" ");
+      out.println(a.getSimpleName());
+    } else {
+      out.println(a.getSimpleName());
+    }
+    indent++;
+    // print out the annotations
+    /*JAnnotation[] atts = a.getAnnotations();
+    if (atts != null) print(atts, indent, out);
+    // now recursively print out the children
+    JElement[] children = getChildrenFor(a);
+    if (children != null) {
+      for (int i = 0; i < children.length; i++) {
+        if (children[i] != null) print(children[i], indent, out);
+      }
+    }
+    */
+  }
+
+  
+  private void print(JAnnotation[] atts, int indent, PrintWriter out) {
+    for (int i = 0; i < atts.length; i++) {
+      indent(indent, out);
+      out.print("<");
+      out.print(getTypeKey(atts[i]));
+      out.print("> ");
+      out.print(atts[i].getSimpleName());
+    }
+  }
+
+  private void indent(int indent, PrintWriter out) {
+    for (int i = 0; i < indent; i++) out.print(INDENT);
+  }
+
+  private String getTypeKey(Object o) {
+    if (o == null) return "[?UNKNOWN!]";
+    String type = o.getClass().getName();
+    int lastDot = type.lastIndexOf(".");
+    if (lastDot != -1 && lastDot + 1 < type.length()) {
+      type = type.substring(lastDot + 1);
+    }
+    return type;
+  }
+
+
+  // this is quite gross, but we don't want to expose getChildren() to
+  // the public any more
+  private static JElement[] getChildrenFor(JElement parent) {
+    Collection list = new ArrayList();
+    if (parent instanceof JClass) {
+      list.addAll(Arrays.asList(((JClass) parent).getDeclaredFields()));
+      list.addAll(Arrays.asList(((JClass) parent).getDeclaredMethods()));
+      list.addAll(Arrays.asList(((JClass) parent).getConstructors()));
+      list.addAll(Arrays.asList(((JClass) parent).getClasses()));
+    } else if (parent instanceof JConstructor) {
+      list.addAll(Arrays.asList(((JConstructor) parent).getParameters()));
+    } else if (parent instanceof JMethod) {
+      list.addAll(Arrays.asList(((JMethod) parent).getParameters()));
+    }
+    JElement[] out = new JElement[list.size()];
+    list.toArray(out);
+    return out;
+  }
+}
+

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamServiceContextImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamServiceContextImpl.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamServiceContextImpl.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamServiceContextImpl.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,573 @@
+/*   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.jam.internal;
+
+import org.apache.xmlbeans.impl.jam.JamClassLoader;
+import org.apache.xmlbeans.impl.jam.JamServiceParams;
+import org.apache.xmlbeans.impl.jam.annotation.AnnotationProxy;
+import org.apache.xmlbeans.impl.jam.annotation.DefaultAnnotationProxy;
+import org.apache.xmlbeans.impl.jam.annotation.JavadocTagParser;
+import org.apache.xmlbeans.impl.jam.annotation.WhitespaceDelimitedTagParser;
+import org.apache.xmlbeans.impl.jam.internal.elements.ElementContext;
+import org.apache.xmlbeans.impl.jam.provider.CompositeJamClassBuilder;
+import org.apache.xmlbeans.impl.jam.provider.JamClassBuilder;
+import org.apache.xmlbeans.impl.jam.provider.JamLogger;
+import org.apache.xmlbeans.impl.jam.provider.JamServiceContext;
+import org.apache.xmlbeans.impl.jam.provider.ResourcePath;
+import org.apache.xmlbeans.impl.jam.visitor.CompositeMVisitor;
+import org.apache.xmlbeans.impl.jam.visitor.MVisitor;
+import org.apache.xmlbeans.impl.jam.visitor.PropertyInitializer;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * <p>Takes settings from the user (through JamServiceParams) and exposes
+ * them to the implementation (through JamServiceContext).</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public class JamServiceContextImpl extends JamLoggerImpl implements JamServiceContext,
+  JamServiceParams, ElementContext
+{
+
+  // ========================================================================
+  // Constants
+
+  private static final char INNER_CLASS_SEPARATOR = '$';
+
+  // ========================================================================
+  // Variables
+
+  private boolean m14WarningsEnabled = false;
+  private Properties mProperties = null;
+  private Map mSourceRoot2Scanner = null;
+  private Map mClassRoot2Scanner = null;
+
+
+  private List mClasspath = null;
+  private List mSourcepath = null;
+  private List mToolClasspath = null;
+
+  private List mIncludeClasses = null;
+  private List mExcludeClasses = null;
+
+
+  private boolean mUseSystemClasspath = true;
+
+
+  private JavadocTagParser mTagParser = null;
+  private MVisitor mCommentInitializer = null;
+  private MVisitor mPropertyInitializer = new PropertyInitializer();
+  private List mOtherInitializers = null;
+  private List mUnstructuredSourceFiles = null;
+  private List mClassLoaders = null;
+  private List mBaseBuilders = null;
+
+  private JamClassLoader mLoader = null;
+
+  // ========================================================================
+  // REVIEW
+
+  public void setClassLoader(JamClassLoader loader) {
+    mLoader = loader;
+  }
+
+  public JamClassBuilder getBaseBuilder() {
+    if (mBaseBuilders == null || mBaseBuilders.size() == 0) {
+      return null;
+    }
+    if (mBaseBuilders.size() == 1) {
+      return (JamClassBuilder)mBaseBuilders.get(0);
+    }
+    JamClassBuilder[] comp = new JamClassBuilder[mBaseBuilders.size()];
+    mBaseBuilders.toArray(comp);
+    return new CompositeJamClassBuilder(comp);
+  }
+
+  public JavadocTagParser getTagParser() {
+    if (mTagParser == null) {
+      mTagParser = new WhitespaceDelimitedTagParser();
+      mTagParser.init(this);
+    }
+    return mTagParser;
+  }
+
+
+  // ========================================================================
+  // Constructors
+
+  public JamServiceContextImpl() {}
+
+  // ========================================================================
+  // Public methods - used by BaseJProvider
+
+  /**
+   * Returns an array containing the qualified names of the classes which
+   * are in the Service class set.
+   */
+  public String[] getAllClassnames() throws IOException {
+    Set all = new HashSet();
+    if (mIncludeClasses != null) all.addAll(mIncludeClasses);
+    for(Iterator i = getAllDirectoryScanners(); i.hasNext(); ) {
+      DirectoryScanner ds = (DirectoryScanner)i.next();
+      String[] files = ds.getIncludedFiles();
+      for(int j=0; j<files.length; j++) {
+ //System.out.println("including "+files[j]);        
+        // exclude inner classes - they will be on disk as .class files with
+        // a '$' in the name
+        if (files[j].indexOf(INNER_CLASS_SEPARATOR) == -1) {
+          all.add(filename2classname(files[j]));
+        }
+      }
+    }
+    if (mExcludeClasses != null) all.removeAll(mExcludeClasses);
+    String[] out = new String[all.size()];
+    all.toArray(out);
+    return out;
+  }
+
+  public JamLogger getLogger() { return this; }
+
+  /*
+  public String[] getSourceClassnames() throws IOException {
+    if (mSourceRoot2Scanner == null) return new String[0];
+    Set set = new HashSet();
+    for(Iterator i = mSourceRoot2Scanner.values().iterator(); i.hasNext(); ) {
+      DirectoryScanner ds = (DirectoryScanner)i.next();
+      String[] files = ds.getIncludedFiles();
+      for(int j=0; j<files.length; j++) {
+        set.add(filename2classname(files[j]));
+      }
+    }
+    String[] out = new String[set.size()];
+    set.toArray(out);
+    return out;
+  }*/
+
+  public File[] getSourceFiles() throws IOException {
+    Set set = new HashSet();
+    if (mSourceRoot2Scanner != null) {
+      for(Iterator i = mSourceRoot2Scanner.values().iterator(); i.hasNext(); ) {
+        DirectoryScanner ds = (DirectoryScanner)i.next();
+        if (isVerbose(this)) {
+          verbose(PREFIX+ " checking scanner for dir"+ds.getRoot());
+        }
+        String[] files = ds.getIncludedFiles();
+        for(int j=0; j<files.length; j++) {
+          if (isVerbose(this)) {
+            verbose(PREFIX+ " ...including a source file "+files[j]);
+          }
+          set.add(new File(ds.getRoot(),files[j]));
+        }
+      }
+    }
+    // also dump unstructured files in there as well.  javadoc doesn't
+    // know the difference, but eventually we're going to care
+    // when we introduce lazy parsing
+    if (mUnstructuredSourceFiles != null) {
+      if (isVerbose(this)) verbose(PREFIX+ "adding "+mUnstructuredSourceFiles.size()+
+                            " other source files");
+      set.addAll(mUnstructuredSourceFiles);
+    }
+    File[] out = new File[set.size()];
+    set.toArray(out);
+    return out;
+  }
+
+  public File[] getUnstructuredSourceFiles() {
+    if (mUnstructuredSourceFiles == null) return null;
+    File[] out = new File[mUnstructuredSourceFiles.size()];
+    mUnstructuredSourceFiles.toArray(out);
+    return out;
+  }
+
+
+  public ResourcePath getInputClasspath() { return createJPath(mClasspath); }
+
+  public ResourcePath getInputSourcepath() { return createJPath(mSourcepath); }
+
+  public ResourcePath getToolClasspath() { return createJPath(mToolClasspath); }
+
+  public String getProperty(String name) {
+    return (mProperties == null) ? null : mProperties.getProperty(name);
+  }
+
+
+  public MVisitor getInitializer() {
+    List initers = new ArrayList();
+    // for now, we don't have a default comment initializer.  may need to
+    // change this someday.
+    if (mCommentInitializer != null) initers.add(mCommentInitializer);
+    // initers.add((mCommentInitializer != null) ? mCommentInitializer :
+    //             new CommentInitializer());
+    if (mPropertyInitializer != null) initers.add(mPropertyInitializer);
+    if (mOtherInitializers != null) initers.addAll(mOtherInitializers);
+    // now go
+    MVisitor[] inits = new MVisitor[initers.size()];
+    initers.toArray(inits);
+    return new CompositeMVisitor(inits);
+  }
+
+  // ========================================================================
+  // JamServiceParams implementation
+
+  public void addClassBuilder(JamClassBuilder builder) {
+    if (mBaseBuilders == null) mBaseBuilders = new ArrayList();
+    mBaseBuilders.add(builder);
+  }
+
+  //DOCME
+  public void setCommentInitializer(MVisitor initializer) {
+    mCommentInitializer = initializer;
+  }
+
+  //DOCME
+  public void setPropertyInitializer(MVisitor initializer) {
+    mPropertyInitializer = initializer;
+  }
+
+  //DOCME
+  public void addInitializer(MVisitor initializer) {
+    if (mOtherInitializers == null) mOtherInitializers = new ArrayList();
+    mOtherInitializers.add(initializer);
+  }
+
+  //DOCME
+  public void setJavadocTagParser(JavadocTagParser tp) {
+    mTagParser = tp;
+    tp.init(this); //FIXME this is a little broken to do this here
+  }
+
+  public void includeSourceFile(File file) {
+    if (file == null) throw new IllegalArgumentException("null file");
+    file = file.getAbsoluteFile();
+    if (isVerbose(this)) verbose(PREFIX+ "adding source ");
+    if (!file.exists()) throw new IllegalArgumentException(file+" does not exist");
+    if (file.isDirectory()) throw new IllegalArgumentException
+      (file+" cannot be included as a source file because it is a directory.");    
+    if (mUnstructuredSourceFiles == null) {
+      mUnstructuredSourceFiles = new ArrayList();
+    }
+    mUnstructuredSourceFiles.add(file.getAbsoluteFile());
+  }
+
+  public void includeSourcePattern(File[] sourcepath, String pattern) {
+    if (sourcepath == null) throw new IllegalArgumentException("null sourcepath");
+    if (sourcepath.length == 0) throw new IllegalArgumentException("empty sourcepath");
+    if (pattern == null) throw new IllegalArgumentException("null pattern");
+    pattern = pattern.trim();
+    if (pattern.length() == 0) throw new IllegalArgumentException("empty pattern");
+    for(int i=0; i<sourcepath.length; i++) {
+      if (isVerbose(this)) verbose(PREFIX+ "including '"+pattern+"' under "+sourcepath[i]);
+      addSourcepath(sourcepath[i]);
+      getSourceScanner(sourcepath[i]).include(pattern);
+    }
+  }
+
+  public void includeClassPattern(File classpath[], String pattern) {
+    if (classpath == null) throw new IllegalArgumentException("null classpath");
+    if (classpath.length == 0) throw new IllegalArgumentException("empty classpath");
+    if (pattern == null) throw new IllegalArgumentException("null pattern");
+    pattern = pattern.trim();
+    if (pattern.length() == 0) throw new IllegalArgumentException("empty pattern");
+    for(int i=0; i<classpath.length; i++) {
+      if (isVerbose(this)) verbose(PREFIX+ "including '"+pattern+"' under "+classpath[i]);
+      addClasspath(classpath[i]);
+      getClassScanner(classpath[i]).include(pattern);
+    }
+  }
+
+  public void excludeSourcePattern(File[] sourcepath, String pattern) {
+    if (sourcepath == null) throw new IllegalArgumentException("null sourcepath");
+    if (sourcepath.length == 0) throw new IllegalArgumentException("empty sourcepath");
+    if (pattern == null) throw new IllegalArgumentException("null pattern");
+    pattern = pattern.trim();
+    if (pattern.length() == 0) throw new IllegalArgumentException("empty pattern");
+    for(int i=0; i<sourcepath.length; i++) {
+      if (isVerbose(this)) verbose(PREFIX+ "EXCLUDING '"+pattern+"' under "+sourcepath[i]);
+      addSourcepath(sourcepath[i]);
+      getSourceScanner(sourcepath[i]).exclude(pattern);
+    }
+  }
+
+  public void excludeClassPattern(File[] classpath, String pattern) {
+    if (classpath == null) throw new IllegalArgumentException("null classpath");
+    if (classpath.length == 0) throw new IllegalArgumentException("empty classpath");
+    if (pattern == null) throw new IllegalArgumentException("null pattern");
+    pattern = pattern.trim();
+    if (pattern.length() == 0) throw new IllegalArgumentException("empty pattern");
+    for(int i=0; i<classpath.length; i++) {
+      if (isVerbose(this)) verbose(PREFIX+ "EXCLUDING '"+pattern+"' under "+classpath[i]);
+      addClasspath(classpath[i]);
+      getClassScanner(classpath[i]).exclude(pattern);
+    }
+  }
+
+  public void includeSourceFile(File[] sourcepath, File sourceFile) {
+    File root = getPathRootForFile(sourcepath,sourceFile);
+    includeSourcePattern(new File[] {root}, source2pattern(root,sourceFile));
+  }
+
+  public void excludeSourceFile(File[] sourcepath, File sourceFile) {
+    File root = getPathRootForFile(sourcepath,sourceFile);
+    excludeSourcePattern(new File[] {root}, source2pattern(root,sourceFile));
+  }
+
+  public void includeClassFile(File[] classpath, File classFile) {
+    File root = getPathRootForFile(classpath,classFile);
+    includeClassPattern(new File[] {root}, source2pattern(root,classFile));
+  }
+
+  public void excludeClassFile(File[] classpath, File classFile) {
+    File root = getPathRootForFile(classpath,classFile);
+    excludeClassPattern(new File[] {root}, source2pattern(root,classFile));
+  }
+
+  public void includeClass(String qualifiedClassname) {
+    if (mIncludeClasses == null) mIncludeClasses = new ArrayList();
+    mIncludeClasses.add(qualifiedClassname);
+  }
+
+  public void excludeClass(String qualifiedClassname) {
+    if (mExcludeClasses == null) mExcludeClasses = new ArrayList();
+    mExcludeClasses.add(qualifiedClassname);
+  }
+
+  public void addClasspath(File classpathElement) {
+    if (mClasspath == null) {
+      mClasspath = new ArrayList();
+    } else {
+      if (mClasspath.contains(classpathElement)) return;
+    }
+    mClasspath.add(classpathElement);
+  }
+
+  public void setLoggerWriter(PrintWriter out) {
+    super.setOut(out);//FIXME
+  }
+
+  public void setJamLogger(JamLogger logger) {
+    throw new IllegalStateException("NYI");  //have to untangle some mess first
+  }
+
+
+  public void addSourcepath(File sourcepathElement) {
+    if (mSourcepath == null) {
+      mSourcepath = new ArrayList();
+    } else {
+      if (mSourcepath.contains(sourcepathElement)) return;
+    }
+    mSourcepath.add(sourcepathElement);
+  }
+
+  public void addToolClasspath(File classpathElement) {
+    if (mToolClasspath == null) {
+      mToolClasspath = new ArrayList();
+    } else {
+      if (mToolClasspath.contains(classpathElement)) return;
+    }
+    mToolClasspath.add(classpathElement);
+  }
+
+  public void setProperty(String name, String value) {
+    if (mProperties == null) mProperties = new Properties();
+    mProperties.setProperty(name,value);
+  }
+
+  public void set14WarningsEnabled(boolean b) {
+    m14WarningsEnabled = b;
+  }
+
+
+  //public void setLogger(PrintWriter out) { mOut = out; }
+
+
+  public void setParentClassLoader(JamClassLoader loader) {
+    throw new IllegalStateException("NYI"); //FIXME
+  }
+
+  public void setUseSystemClasspath(boolean use) {
+    mUseSystemClasspath = use;
+  }
+
+  public void addClassLoader(ClassLoader cl) {
+    if (mClassLoaders == null) mClassLoaders = new ArrayList();
+    mClassLoaders.add(cl);
+  }
+
+  // ========================================================================
+  // JamServiceContext implementation
+
+  //public boolean isUseSystemClasspath() { return mUseSystemClasspath; }
+
+  public ClassLoader[] getReflectionClassLoaders() {                     
+    if (mClassLoaders == null) {
+      if (mUseSystemClasspath) {
+        return new ClassLoader[] { ClassLoader.getSystemClassLoader() };
+      } else {
+        return new ClassLoader[0];
+      }
+    } else {
+      ClassLoader[] out = new ClassLoader[mClassLoaders.size()+
+        (mUseSystemClasspath ? 1 : 0)];
+      for(int i=0; i<mClassLoaders.size(); i++) {
+        out[i] = (ClassLoader)mClassLoaders.get(i);
+      }
+      if (mUseSystemClasspath) {
+        out[out.length-1] = ClassLoader.getSystemClassLoader();
+      }
+      return out;
+    }
+  }
+
+  public boolean is14WarningsEnabled() { return m14WarningsEnabled; }
+
+  // ========================================================================
+  // ElementContext implementation
+
+  public JamClassLoader getClassLoader() { return mLoader; }
+
+  public AnnotationProxy createAnnotationProxy(String jsr175typename) {
+    AnnotationProxy out = new DefaultAnnotationProxy();
+    out.init(this);
+    return out;
+  }
+
+  // ========================================================================
+  // Private methods
+
+  private static final String PREFIX = "[JamServiceContextImpl] ";
+
+  private File getPathRootForFile(File[] sourcepath, File sourceFile) {
+    if (sourcepath == null) throw new IllegalArgumentException("null sourcepath");
+    if (sourcepath.length == 0) throw new IllegalArgumentException("empty sourcepath");
+    if (sourceFile == null) throw new IllegalArgumentException("null sourceFile");
+    sourceFile = sourceFile.getAbsoluteFile();
+    if (isVerbose(this)) verbose(PREFIX+"Getting root for "+sourceFile+"...");
+    for(int i=0; i<sourcepath.length; i++) {
+      if (isVerbose(this)) verbose(PREFIX+"...looking in "+sourcepath[i]);
+      if (isContainingDir(sourcepath[i].getAbsoluteFile(),sourceFile)) {
+        if (isVerbose(this)) verbose(PREFIX+"...found it!");
+        return sourcepath[i].getAbsoluteFile();
+      }
+    }
+    throw new IllegalArgumentException(sourceFile+" is not in the given path.");
+  }
+
+  /**
+   * Returns true if the given dir contains the given file.
+   */
+  private boolean isContainingDir(File dir, File file) {
+    if (isVerbose(this)) verbose(PREFIX+ "... ...isContainingDir "+dir+"  "+file);
+    if (file == null) return false;
+    if (dir.equals(file)) {
+      if (isVerbose(this)) verbose(PREFIX+ "... ...yes!");
+      return true;
+    }
+    return isContainingDir(dir,file.getParentFile());
+  }
+
+  /**
+   * Converts the sourceFile to a pattern expression relative to the
+   * given root.
+   */
+  private String source2pattern(File root, File sourceFile) {
+    if (isVerbose(this)) verbose(PREFIX+ "source2pattern "+root+"  "+sourceFile);
+    //REVIEW this is a bit cheesy
+    String r = root.getAbsolutePath();
+    String s = sourceFile.getAbsolutePath();
+    if (isVerbose(this)) {
+      verbose(PREFIX+ "source2pattern returning "+s.substring(r.length()+1));
+    }
+    return s.substring(r.length()+1);
+  }
+
+  /**
+   * Converts the given java source or class filename into a qualified
+   * classname.  The filename is assumed to be relative to the source or
+   * class root.
+   */
+  private static String filename2classname(String filename) {
+    int extDot = filename.lastIndexOf('.');
+    if (extDot != -1) filename = filename.substring(0,extDot);
+    filename = filename.replace('/','.');
+    filename = filename.replace('\\','.');
+    return filename;
+  }
+
+  /**
+   * Returns all of the directory scanners for all class and source
+   * roots created in this params object.
+   */
+  private Iterator getAllDirectoryScanners() {
+    Collection out = new ArrayList();
+    if (mSourceRoot2Scanner != null) {
+      out.addAll(mSourceRoot2Scanner.values());
+    }
+    if (mClassRoot2Scanner != null) {
+      out.addAll(mClassRoot2Scanner.values());
+    }
+    return out.iterator();
+  }
+
+  /**
+   * Creates a ResourcePath for the given collection of Files, or returns null
+   * if the collections is null or empty.
+   */
+  private static ResourcePath createJPath(Collection filelist) {
+    if (filelist == null || filelist.size() == 0) return null;
+    File[] files = new File[filelist.size()];
+    filelist.toArray(files);
+    return ResourcePath.forFiles(files);
+  }
+
+  /**
+   * Returns the DirectoryScanner which we have mapped to the given source
+   * root, creating a new one if necessary.
+   */
+  private DirectoryScanner getSourceScanner(File srcRoot) {
+    if (mSourceRoot2Scanner == null) mSourceRoot2Scanner = new HashMap();
+    DirectoryScanner out = (DirectoryScanner)mSourceRoot2Scanner.get(srcRoot);
+    if (out == null) {
+      mSourceRoot2Scanner.put(srcRoot,out = new DirectoryScanner(srcRoot,this));
+    }
+    return out;
+  }
+
+  /**
+   * Returns the DirectoryScanner which we have mapped to the given class
+   * root, creating a new one if necessary.
+   */
+  private DirectoryScanner getClassScanner(File clsRoot) {
+    if (mClassRoot2Scanner == null) mClassRoot2Scanner = new HashMap();
+    DirectoryScanner out = (DirectoryScanner)mClassRoot2Scanner.get(clsRoot);
+    if (out == null) {
+      mClassRoot2Scanner.put(clsRoot,out = new DirectoryScanner(clsRoot,this));
+    }
+    return out;
+  }
+}
\ No newline at end of file

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamServiceImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamServiceImpl.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamServiceImpl.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/JamServiceImpl.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,81 @@
+/*   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.jam.internal;
+
+import org.apache.xmlbeans.impl.jam.JClass;
+import org.apache.xmlbeans.impl.jam.JamClassIterator;
+import org.apache.xmlbeans.impl.jam.JamClassLoader;
+import org.apache.xmlbeans.impl.jam.JamService;
+import org.apache.xmlbeans.impl.jam.internal.elements.ElementContext;
+
+/**
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public class JamServiceImpl implements JamService {
+
+  // ========================================================================
+  // Variables
+
+  private ElementContext mContext;
+  private String[] mClassNames;
+
+
+  // ========================================================================
+  // Constructors
+
+  public JamServiceImpl(ElementContext ctx, String[] classes) {
+    if (ctx == null) throw new IllegalArgumentException("null jcl");
+    if (classes == null) throw new IllegalArgumentException("null classes");
+    mContext = ctx;
+    mClassNames = classes;
+  }
+
+  // ========================================================================
+  // JamService implementation
+
+  public JamClassLoader getClassLoader() {
+    return mContext.getClassLoader();
+  }
+
+  public String[] getClassNames() {
+    return mClassNames;
+  }
+
+  public JamClassIterator getClasses() {
+    return new JamClassIterator(getClassLoader(),getClassNames());
+  }
+
+  public JClass[] getAllClasses() {
+    JClass[] out = new JClass[mClassNames.length];
+    for(int i=0; i<out.length; i++) {
+      out[i] = getClassLoader().loadClass(mClassNames[i]);
+    }
+    return out;
+  }
+
+  // ========================================================================
+  // Hackish methods
+
+  // this is a back door for jamxmlutils, which can't know the class names
+  // until after it's parsed the xml file (which can't be done without
+  // a jamservice - catch 22).
+  public void setClassNames(String[] names) {
+    mClassNames = names;
+  }
+
+
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/TigerDelegate.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/TigerDelegate.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/TigerDelegate.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/TigerDelegate.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,125 @@
+/*   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.xmlbeans.impl.jam.internal;
+
+import org.apache.xmlbeans.impl.jam.internal.elements.ElementContext;
+import org.apache.xmlbeans.impl.jam.provider.JamLogger;
+
+/**
+ * <p>
+ * Base for classes which expose 1.5 (aka 'tiger')-specific functionality.
+ * </p>
+ *
+ * This class should be moved into a common directory between annogen
+ * and jam.
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public abstract class TigerDelegate {
+
+  // ========================================================================
+  // Constants
+
+  private static final String SOME_TIGER_SPECIFIC_JAVADOC_CLASS =
+    "com.sun.javadoc.AnnotationDesc";
+
+  private static final String SOME_TIGER_SPECIFIC_REFLECT_CLASS =
+    "java.lang.annotation.Annotation";
+
+  // ========================================================================
+  // Variables
+
+  protected JamLogger mLogger  = null;
+
+  /**
+   * @deprecated
+   */
+  protected ElementContext mContext = null;
+
+  private static boolean m14RuntimeWarningDone   = false;
+  private static boolean m14BuildWarningDone = false;
+
+  // ========================================================================
+  // Public methods
+
+  /**
+   * @deprecated
+   */
+  public void init(ElementContext ctx) {
+    mContext = ctx;
+    init(ctx.getLogger());
+  }
+
+  public void init(JamLogger log) { mLogger = log; }
+
+  // ========================================================================
+  // Protected methods
+
+  protected TigerDelegate() {}
+
+  protected JamLogger getLogger() { return mLogger; }
+
+  /**
+   * Displays a warning indicating that the current build of JAM was
+   * done under 1.4 (or earlier), which precludes the use of 1.5-specific
+   * features.
+   */
+  protected static void issue14BuildWarning(Throwable t, JamLogger log) {
+    if (!m14BuildWarningDone) {
+      log.warning("This build of JAM was not made with JDK 1.5." +
+                  "Even though you are now running under JDK 1.5, "+
+                  "JSR175-style annotations will not be available");
+      if (log.isVerbose(TigerDelegate.class)) log.verbose(t);
+      m14BuildWarningDone = true;
+    }
+  }
+
+  /**
+   * Displays a warning indicating that JAM is running under 1.4 (or earlier),
+   * which precludes the use of 1.5-specific features.
+   */
+  protected static void issue14RuntimeWarning(Throwable t, JamLogger log) {
+    if (!m14RuntimeWarningDone) {
+      log.warning("You are running under a pre-1.5 JDK.  JSR175-style "+
+                  "source annotations will not be available");
+      if (log.isVerbose(TigerDelegate.class)) log.verbose(t);
+      m14RuntimeWarningDone = true;
+    }
+  }
+
+  protected static boolean isTigerJavadocAvailable(JamLogger logger) {
+    try {
+      // class for name this because it's 1.5 specific.  if it fails, we
+      // don't want to use the extractor
+      Class.forName(SOME_TIGER_SPECIFIC_JAVADOC_CLASS);
+      return true;
+    } catch (ClassNotFoundException e) {
+      issue14RuntimeWarning(e,logger);
+      return false;
+    }
+  }
+
+  protected static boolean isTigerReflectionAvailable(JamLogger logger) {
+    try {
+      // class for name this because it's 1.5 specific.  if it fails, we
+      // don't want to use the extractor
+      Class.forName(SOME_TIGER_SPECIFIC_REFLECT_CLASS);
+      return true;
+    } catch (ClassNotFoundException e) {
+      issue14RuntimeWarning(e,logger);
+      return false;
+    }
+  }
+}
\ No newline at end of file

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/DirectJClassRef.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/DirectJClassRef.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/DirectJClassRef.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/DirectJClassRef.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,58 @@
+/*   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.xmlbeans.impl.jam.internal.classrefs;
+
+import org.apache.xmlbeans.impl.jam.JClass;
+
+/**
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public class DirectJClassRef implements JClassRef {
+
+  // ========================================================================
+  // Factory
+
+  public static JClassRef create(JClass clazz) {
+    // we normally can expect that most JClass impls will simply implement
+    // JClassRef directly
+    if (clazz instanceof JClassRef) return (JClassRef)clazz;
+    return new DirectJClassRef(clazz);
+  }
+
+  // ========================================================================
+  // Variables
+
+  private JClass mClass;
+
+  // ========================================================================
+  // Constructors
+
+  private DirectJClassRef(JClass clazz) {
+    if (clazz == null) throw new IllegalArgumentException("null clazz");
+    mClass = clazz;
+  }
+
+  // ========================================================================
+  // JClassRef implementation
+
+  public JClass getRefClass() {
+    return mClass;
+  }
+
+  public String getQualifiedName() {
+    return mClass.getQualifiedName();
+  }
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/JClassRef.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/JClassRef.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/JClassRef.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/JClassRef.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,36 @@
+/*   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.xmlbeans.impl.jam.internal.classrefs;
+
+import org.apache.xmlbeans.impl.jam.JClass;
+
+/**
+ * <p>Object which holds a reference to a JClass.  Using this interface
+ * (as opposed to referring to the JClass directly) allows us to do lazy
+ * type resolution.</p>
+ *
+ * <p>Note that ClassImpl implements this interface directly (as a reference
+ * to itself) as an optimization for the case where we don't need or want
+ * lazy type resolution</p>.
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public interface JClassRef {
+
+  public JClass getRefClass();
+
+  public String getQualifiedName();
+
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/JClassRefContext.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/JClassRefContext.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/JClassRefContext.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/JClassRefContext.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,34 @@
+/*   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.xmlbeans.impl.jam.internal.classrefs;
+
+import org.apache.xmlbeans.impl.jam.JamClassLoader;
+
+/**
+ * <p>Provides a JClassRef implementation with contextual information it
+ * needs to perform lazy type resolution.  This information is typically
+ * provided by the JClass implementation.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public interface JClassRefContext {
+
+  public String getPackageName();
+
+  public String[] getImportSpecs();
+
+  public JamClassLoader getClassLoader();
+
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/QualifiedJClassRef.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/QualifiedJClassRef.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/QualifiedJClassRef.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/QualifiedJClassRef.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,93 @@
+/*   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.xmlbeans.impl.jam.internal.classrefs;
+
+import org.apache.xmlbeans.impl.jam.JClass;
+import org.apache.xmlbeans.impl.jam.JamClassLoader;
+
+/**
+ * <p>Reference to a JClass by qualified name which is resolved lazily.  Note
+ * that resolved references are not cached, which makes it more likely that
+ * a JClasses will become available for garbage collection.  The performance
+ * hit here is probably not significant, but someday we might want to provide
+ * switch to enable caching of references.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public class QualifiedJClassRef implements JClassRef {
+
+  // ========================================================================
+  // Variables
+
+  private String mQualifiedClassname;
+  private JamClassLoader mClassLoader;
+
+  // ========================================================================
+  // Factory
+
+  /**
+   * Creates a new JClassRef for a qualified class or type name.
+   */
+  public static JClassRef create(JClass clazz) {
+    if (clazz == null) throw new IllegalArgumentException("null clazz");
+    return new QualifiedJClassRef(clazz.getFieldDescriptor(),
+                                  clazz.getClassLoader());
+  }
+
+  /**
+   * Creates a new JClassRef for a qualified class or type name.
+   */
+  public static JClassRef create(String qcname,
+                                 JClassRefContext ctx) {
+    if (qcname == null) throw new IllegalArgumentException("null qcname");
+    if (ctx == null) throw new IllegalArgumentException("null ctx");
+    return create(qcname,ctx.getClassLoader());
+  }
+
+  /**
+   * Creates a new JClassRef for a qualified class or type name.
+   */
+  public static JClassRef create(String qcname, JamClassLoader cl) {
+    if (qcname == null) throw new IllegalArgumentException("null qcname");
+    if (cl == null) throw new IllegalArgumentException("null classloader");
+    return new QualifiedJClassRef(qcname,cl);
+  }
+
+  // ========================================================================
+  // Constructors
+
+  private QualifiedJClassRef(String qcname, JamClassLoader cl) {
+    mClassLoader = cl;
+    mQualifiedClassname = qcname;
+  }
+
+  // ========================================================================
+  // JClassRef implementation
+
+  public JClass getRefClass() {
+    return mClassLoader.loadClass(mQualifiedClassname);
+  }
+
+  public String getQualifiedName() {
+    return mQualifiedClassname;
+  }
+
+  // ========================================================================
+  // Object implementation
+
+  public String toString() {
+    return "(QualifiedJClassRef '"+mQualifiedClassname+"')";
+  }
+}
\ No newline at end of file

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/UnqualifiedJClassRef.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/UnqualifiedJClassRef.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/UnqualifiedJClassRef.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/classrefs/UnqualifiedJClassRef.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,190 @@
+/*   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.xmlbeans.impl.jam.internal.classrefs;
+
+import org.apache.xmlbeans.impl.jam.JClass;
+
+import java.io.StringWriter;
+
+/**
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public class UnqualifiedJClassRef implements JClassRef {
+
+  // ========================================================================
+  // Constants
+
+  private static final boolean VERBOSE = false;
+  private static final String PREFIX = "[UnqualifiedJClassRef]";
+
+  // ========================================================================
+  // Variables
+
+  private String mUnqualifiedClassname;
+  private String mQualifiedClassname = null;
+  private JClassRefContext mContext;
+
+  // ========================================================================
+  // Factory
+
+  /**
+   * Creates a new JClassRef for a qualified class or type name.
+   */
+  public static JClassRef create(String qualifiedClassname,
+                                 JClassRefContext ctx) {
+    throw new IllegalStateException("Unqualified names currently disabled.");
+    //return new UnqualifiedJClassRef(qualifiedClassname,ctx);
+  }
+
+  // ========================================================================
+  // Constructors
+
+  private UnqualifiedJClassRef(String ucname,
+                               JClassRefContext ctx)
+  {
+    if (ctx == null) throw new IllegalArgumentException("null ctx");
+    if (ucname == null) throw new IllegalArgumentException("null ucname");
+    mContext = ctx;
+    mUnqualifiedClassname = ucname;
+    if (VERBOSE) System.out.println("[UnqualifiedJClassRef] created for '"+
+                                    ucname+"'");
+  }
+
+  // ========================================================================
+  // JClassRef implementation
+
+  public JClass getRefClass() {
+    //FIXME this needs optimization, keep it simple and lazy for now
+    return mContext.getClassLoader().loadClass(getQualifiedName());
+  }
+
+  public String getQualifiedName() {
+    if (mQualifiedClassname != null) return mQualifiedClassname;
+    // ok, check to see if it's an array type.  if so, we want to strip
+    // away all the brackets and so we can try to load just the component
+    // type.
+    String candidateName;
+    int arrayDimensions = 0;
+    int bracket = mUnqualifiedClassname.indexOf('[');
+    if (bracket != -1) {
+      candidateName = mUnqualifiedClassname.substring(0,bracket);
+      do {
+        arrayDimensions++;
+        bracket = mUnqualifiedClassname.indexOf('[',bracket+1);
+      } while(bracket != -1);
+    } else {
+      candidateName = mUnqualifiedClassname;
+    }
+    // ok, try to get the class that they are talking about
+    String name = qualifyName(candidateName);
+    if (name == null) {
+      throw new IllegalStateException("unable to handle unqualified java type "+
+                                      "reference '"+candidateName+" ["+
+                                      mUnqualifiedClassname+"]'. "+
+                                      "This is still partially NYI.");
+    }
+    // now if it was an array, we need to convert it into a corresponding
+    // field descriptor
+    if (arrayDimensions > 0) {
+      StringWriter out = new StringWriter();
+      for(int i=0; i<arrayDimensions; i++) out.write('[');
+      out.write('L');
+      out.write(name);
+      out.write(';');
+
+      mQualifiedClassname = out.toString();
+    } else {
+      mQualifiedClassname = name;
+    }
+    return mQualifiedClassname;
+  }
+
+  // ========================================================================
+  // Private methods
+
+  private String qualifyName(String ucname) {
+    String out = null;
+    if ((out = checkExplicitImport(ucname)) != null) return out;
+    if ((out = checkJavaLang(ucname)) != null) return out;
+    if ((out = checkSamePackage(ucname)) != null) return out;
+    if ((out = checkAlreadyQualified(ucname)) != null) return out;
+    return null;
+  }
+
+  /**
+   * Check to see if the unqualified name actually is already qualified.
+   */
+  private String checkSamePackage(String ucname) {
+    String name = mContext.getPackageName()+"."+ucname;
+    JClass clazz = mContext.getClassLoader().loadClass(name);
+    if (VERBOSE) System.out.println(PREFIX+" checkSamePackage '"+name+"'  "+
+                                    clazz.isUnresolvedType()+"  "+mContext.getClassLoader().getClass());
+    return (clazz.isUnresolvedType()) ? null : clazz.getQualifiedName();
+  }
+
+  /**
+   * Check to see if the unqualified name is in java.lang.
+   */
+  private String checkJavaLang(String ucname) {
+    String name = "java.lang."+ucname;
+    JClass clazz = mContext.getClassLoader().loadClass(name);
+    if (VERBOSE) System.out.println(PREFIX+" checkJavaLang '"+name+"'  "+
+                                    clazz.isUnresolvedType()+"  "+mContext.getClassLoader().getClass());
+    return (clazz.isUnresolvedType()) ? null : clazz.getQualifiedName();
+  }
+
+  /**
+   * Check to see if the unqualified name actually is already qualified.
+   */
+  private String checkAlreadyQualified(String ucname) {
+    JClass clazz =
+            mContext.getClassLoader().loadClass(ucname);
+    return (clazz.isUnresolvedType()) ? null : clazz.getQualifiedName();
+  }
+
+
+  /**
+   * Run through the list of import specs and see if the class was explicitly
+   * (i.e. without '*') imported.
+   */
+  private String checkExplicitImport(String ucname) {
+    String[] imports = mContext.getImportSpecs();
+    if (VERBOSE) System.out.println(PREFIX+" checkExplicitImport "+
+                                    imports.length);
+    for(int i=0; i<imports.length; i++) {
+      //FIXME this does not cover inner classes
+      String last = lastSegment(imports[i]);
+      if (VERBOSE) System.out.println(PREFIX+" checkExplicitImport '"+
+                                      imports[i]+"'  '"+last+"'");
+      if (last.equals(ucname)) return imports[i];
+    }
+    return null;
+  }
+
+  private static String lastSegment(String s) {
+    int lastDot = s.lastIndexOf(".");
+    if (lastDot == -1) return s;
+    return s.substring(lastDot+1);
+  }
+
+  private static String firstSegment(String s) {
+    int lastDot = s.indexOf(".");
+    if (lastDot == -1) return s;
+    return s.substring(0,lastDot);
+  }
+
+}
+

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/elements/AnnotatedElementImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/elements/AnnotatedElementImpl.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/elements/AnnotatedElementImpl.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/elements/AnnotatedElementImpl.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,209 @@
+package org.apache.xmlbeans.impl.jam.internal.elements;
+
+import org.apache.xmlbeans.impl.jam.JAnnotation;
+import org.apache.xmlbeans.impl.jam.JAnnotationValue;
+import org.apache.xmlbeans.impl.jam.JComment;
+import org.apache.xmlbeans.impl.jam.annotation.AnnotationProxy;
+import org.apache.xmlbeans.impl.jam.mutable.MAnnotatedElement;
+import org.apache.xmlbeans.impl.jam.mutable.MAnnotation;
+import org.apache.xmlbeans.impl.jam.mutable.MComment;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public abstract class AnnotatedElementImpl extends ElementImpl
+  implements MAnnotatedElement
+ {
+
+  // ========================================================================
+  // Variables
+
+  private Map mName2Annotation = null;
+  private MComment mComment = null;
+  private List mAllAnnotations = null;
+
+  // ========================================================================
+  // Constructors
+
+  protected AnnotatedElementImpl(ElementContext ctx) { super(ctx); }
+
+  protected AnnotatedElementImpl(ElementImpl parent) { super(parent); }
+
+  // ========================================================================
+  // JAnnotatedElement implementation
+
+  public JAnnotation[] getAnnotations() {
+    return getMutableAnnotations();
+  }
+
+  public JAnnotation getAnnotation(Class proxyClass) {
+    return getMutableAnnotation(proxyClass.getName());
+  }
+
+  public JAnnotation getAnnotation(String named) {
+    return getMutableAnnotation(named);
+  }
+
+  public JAnnotationValue getAnnotationValue(String valueId) {
+    if (mName2Annotation == null) return null;
+    valueId = valueId.trim();
+
+    int delim = valueId.indexOf('@');
+    if (delim == -1 || delim == valueId.length()-1) {
+      JAnnotation ann = getAnnotation(valueId);
+      if (ann == null) return null;
+      return ann.getValue(JAnnotation.SINGLE_VALUE_NAME);
+    } else {
+      JAnnotation ann = getAnnotation(valueId.substring(0,delim));
+      if (ann == null) return null;
+
+      return ann.getValue(valueId.substring(delim+1));
+    }
+  }
+
+
+  public Object getAnnotationProxy(Class proxyClass) {
+    return getEditableProxy(proxyClass);
+  }
+
+  public JComment getComment() { return getMutableComment(); }
+
+  /**
+   * @deprecated
+   */
+  public JAnnotation[] getAllJavadocTags() {
+    if (mAllAnnotations == null) return NO_ANNOTATION;
+    JAnnotation[] out = new JAnnotation[mAllAnnotations.size()];
+    mAllAnnotations.toArray(out);
+    return out;
+  }
+
+  /*
+  public JAnnotation[] getAllJavadocTags(String named) {
+    //FIXME this impl is quite gross
+    if (mAllAnnotations == null) return NO_ANNOTATION;
+    List list = new ArrayList();
+    for(int i=0; i<mAllAnnotations.size(); i++) {
+      JAnnotation j = (JAnnotation)mAllAnnotations.get(i);
+      if (j.getSimpleName().equals(named)) {
+        list.add(j);
+      }
+    }
+    JAnnotation[] out = new JAnnotation[list.size()];
+    list.toArray(out);
+    return out;
+  }
+  */
+
+  // ========================================================================
+  // MAnnotatedElement implementation
+
+  public AnnotationProxy getEditableProxy(Class proxyClass) {
+    if (mName2Annotation == null) return null;
+    MAnnotation out = getMutableAnnotation(proxyClass.getName());
+    return (out == null) ? null : (AnnotationProxy)out.getProxy();
+  }
+
+  public void removeAnnotation(MAnnotation ann) {
+    if (mName2Annotation != null) mName2Annotation.values().remove(ann);
+  }
+
+  public MAnnotation[] getMutableAnnotations() {
+    if (mName2Annotation == null) return new MAnnotation[0];
+    MAnnotation[] out = new MAnnotation[mName2Annotation.values().size()];
+    mName2Annotation.values().toArray(out);
+    return out;
+  }
+
+  public MAnnotation getMutableAnnotation(String named) {
+    if (mName2Annotation == null) return null;
+    named = named.trim();
+    return (MAnnotation)mName2Annotation.get(named);
+  }
+
+  public MAnnotation findOrCreateAnnotation(String annotationName) {
+    //ClassImpl.validateClassName(annotationName);
+    MAnnotation ann = getMutableAnnotation(annotationName);
+    if (ann != null) return ann;
+    AnnotationProxy proxy = getContext().
+      createAnnotationProxy(annotationName);
+    ann = new AnnotationImpl(getContext(),proxy,annotationName);
+    if (mName2Annotation == null) {
+      mName2Annotation = new HashMap();
+    }
+    mName2Annotation.put(ann.getQualifiedName(),ann);
+    return ann;
+  }
+
+  public MAnnotation addLiteralAnnotation(String annName) {
+    if (annName == null) throw new IllegalArgumentException("null tagname");
+    annName = annName.trim();
+    // otherwise, we have to create an 'extra' one.  note this will only
+    // happen when processing javadoc tags where more than one tag of a given
+    // name appears in a given scope
+    AnnotationProxy proxy = getContext().createAnnotationProxy(annName);
+    MAnnotation ann = new AnnotationImpl(getContext(),proxy,annName);
+    if (mAllAnnotations == null) mAllAnnotations = new ArrayList();
+    mAllAnnotations.add(ann);
+
+    // if one doesn't exist yet, then create the first one
+    if (getMutableAnnotation(annName) == null) {
+      if (mName2Annotation == null) mName2Annotation = new HashMap();
+      mName2Annotation.put(annName,ann);
+    }
+    return ann;
+  }
+
+  public MComment getMutableComment() { return mComment; }
+
+  public MComment createComment() { return mComment = new CommentImpl(this); }
+
+  public void removeComment() { mComment = null; }
+
+  // ========================================================================
+  // Protected methods
+
+  // these are exposed primarily for the benefit of PropertyImpl
+
+  protected void addAnnotation(JAnnotation ann) {
+    if (mName2Annotation == null) {
+      mName2Annotation = new HashMap();
+      mName2Annotation.put(ann.getQualifiedName(),ann);
+    } else {
+      if (mName2Annotation.get(ann.getQualifiedName()) == null) {
+        mName2Annotation.put(ann.getQualifiedName(),ann);
+      }
+    }
+    if (mAllAnnotations == null) mAllAnnotations = new ArrayList();
+    mAllAnnotations.add(ann);
+  }
+
+
+
+  // ========================================================================
+  // Old stuff
+
+  /**
+   * @deprecated this is a back door for xbeans.  do not use, will
+   * be removed soon.
+   */
+  public MAnnotation addAnnotationForProxy(Class proxyClass,
+                                           AnnotationProxy proxy)
+  {
+    //ClassImpl.validateClassName(annotationName);
+    String annotationName = proxyClass.getName();
+    MAnnotation ann = getMutableAnnotation(annotationName);
+    if (ann != null) return ann;
+    ann = new AnnotationImpl(getContext(),proxy,annotationName);
+    if (mName2Annotation == null) {
+      mName2Annotation = new HashMap();
+    }
+    mName2Annotation.put(ann.getQualifiedName(),ann);
+    return ann;
+  }
+}
\ No newline at end of file

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/elements/AnnotationImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/elements/AnnotationImpl.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/elements/AnnotationImpl.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/elements/AnnotationImpl.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,118 @@
+/*   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.xmlbeans.impl.jam.internal.elements;
+
+import org.apache.xmlbeans.impl.jam.JAnnotationValue;
+import org.apache.xmlbeans.impl.jam.JClass;
+import org.apache.xmlbeans.impl.jam.annotation.AnnotationProxy;
+import org.apache.xmlbeans.impl.jam.mutable.MAnnotation;
+import org.apache.xmlbeans.impl.jam.visitor.JVisitor;
+import org.apache.xmlbeans.impl.jam.visitor.MVisitor;
+
+/**
+ * <p>Standard implementation of AnnotationImpl.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public final class AnnotationImpl extends ElementImpl implements MAnnotation {
+
+  // ========================================================================
+  // Variables
+
+  private AnnotationProxy mProxy;
+  private Object mAnnotationInstance = null;
+  private String mQualifiedName = null;
+
+
+  // ========================================================================
+  // Constructors
+
+  /*package*/ AnnotationImpl(ElementContext ctx,
+                             AnnotationProxy proxy,
+                             String qualifiedName) {
+    super(ctx);
+    if (proxy == null) throw new IllegalArgumentException("null proxy");
+    if (qualifiedName == null) throw new IllegalArgumentException("null qn");
+    mProxy = proxy;
+    // review maybe this should just be the behavior in the default impl
+    // of getSimpleName().
+    setSimpleName(qualifiedName.substring(qualifiedName.lastIndexOf('.')+1));
+    mQualifiedName = qualifiedName;
+  }
+
+  // ========================================================================
+  // JAnnotation implementation
+
+  public Object getProxy() { return mProxy; }
+
+  public JAnnotationValue[] getValues() { return mProxy.getValues(); }
+
+  public JAnnotationValue getValue(String name) {
+    return mProxy.getValue(name);
+  }
+
+  public Object getAnnotationInstance() { return mAnnotationInstance; }
+
+  // ========================================================================
+  // MAnnotation implementation
+
+  public void setAnnotationInstance(Object o) {
+    mAnnotationInstance = o;
+  }
+
+  public void setSimpleValue(String name, Object value, JClass type) {
+    if (name == null) throw new IllegalArgumentException("null name");
+    if (type == null) throw new IllegalArgumentException("null type");
+    if (value == null) throw new IllegalArgumentException("null value");
+    mProxy.setValue(name,value,type);
+  }
+
+  public MAnnotation createNestedValue(String name, String annTypeName) {
+    if (name == null) throw new IllegalArgumentException("null name");
+    if (annTypeName == null) throw new IllegalArgumentException("null typename");
+    AnnotationProxy p = getContext().createAnnotationProxy(annTypeName);
+    AnnotationImpl out = new AnnotationImpl(getContext(),p,annTypeName);
+    JClass type  = getContext().getClassLoader().loadClass(annTypeName);
+    mProxy.setValue(name,out,type);
+    return out;
+  }
+
+  public MAnnotation[] createNestedValueArray(String name,
+                                              String annComponentTypeName,
+                                              int dimensions) {
+    if (name == null) throw new IllegalArgumentException("null name");
+    if (annComponentTypeName == null) throw new IllegalArgumentException("null typename");
+    if (dimensions < 0) throw new IllegalArgumentException("dimensions = "+dimensions);
+    MAnnotation[] out = new MAnnotation[dimensions];
+    for(int i=0; i<out.length; i++) {
+      AnnotationProxy p = getContext().createAnnotationProxy(annComponentTypeName);
+      out[i] = new AnnotationImpl(getContext(),p,annComponentTypeName);
+    }
+    JClass type  = getContext().getClassLoader().loadClass("[L"+annComponentTypeName+";");
+    mProxy.setValue(name,out,type);
+    return out;
+  }
+
+  // ========================================================================
+  // JElement implementation
+
+  public String getQualifiedName() { return mQualifiedName; }
+
+  public void accept(MVisitor visitor) { visitor.visit(this); }
+
+  public void accept(JVisitor visitor) { visitor.visit(this); }
+
+
+}
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message