You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2019/04/14 13:55:07 UTC

svn commit: r1857518 [6/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...

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/reflect/ReflectTigerDelegate.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/reflect/ReflectTigerDelegate.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/reflect/ReflectTigerDelegate.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/internal/reflect/ReflectTigerDelegate.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,114 @@
+/*   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.reflect;
+
+import org.apache.xmlbeans.impl.jam.internal.TigerDelegate;
+import org.apache.xmlbeans.impl.jam.internal.elements.ElementContext;
+import org.apache.xmlbeans.impl.jam.mutable.MClass;
+import org.apache.xmlbeans.impl.jam.mutable.MConstructor;
+import org.apache.xmlbeans.impl.jam.mutable.MField;
+import org.apache.xmlbeans.impl.jam.mutable.MMember;
+import org.apache.xmlbeans.impl.jam.mutable.MParameter;
+import org.apache.xmlbeans.impl.jam.provider.JamLogger;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+/**
+ * @author Patrick Calahan <email: pcal-at-bea-dot-com>
+ */
+public abstract class ReflectTigerDelegate extends TigerDelegate {
+
+  // ========================================================================
+  // Constants
+
+  private static final String IMPL_NAME =
+    "org.apache.xmlbeans.impl.jam.internal.reflect.ReflectTigerDelegateImpl_150";
+
+  // ========================================================================
+  // Static methods
+
+  public static ReflectTigerDelegate create(JamLogger logger) {
+    if (!isTigerReflectionAvailable(logger)) return null;
+    // ok, if we could load that, let's new up the extractor delegate
+    try {
+      ReflectTigerDelegate out = (ReflectTigerDelegate)
+        Class.forName(IMPL_NAME).newInstance();
+      out.init(logger);
+      return out;
+    } catch (ClassNotFoundException e) {
+      issue14BuildWarning(e,logger);
+    } catch (IllegalAccessException e) {
+      logger.error(e);
+    } catch (InstantiationException e) {
+      logger.error(e);
+    }
+    return null;
+  }
+
+  /**
+   * @deprecated
+   */
+  public static ReflectTigerDelegate create(ElementContext ctx) {
+    if (!isTigerReflectionAvailable(ctx.getLogger())) return null;
+    // ok, if we could load that, let's new up the extractor delegate
+    try {
+      ReflectTigerDelegate out = (ReflectTigerDelegate)
+        Class.forName(IMPL_NAME).newInstance();
+      out.init(ctx);
+      return out;
+    } catch (ClassNotFoundException e) {
+      issue14BuildWarning(e,ctx.getLogger());
+    } catch (IllegalAccessException e) {
+      ctx.getLogger().error(e);
+    } catch (InstantiationException e) {
+      ctx.getLogger().error(e);
+    }
+    return null;
+  }
+
+
+  // ========================================================================
+  // Constructors
+
+  protected ReflectTigerDelegate() {}
+
+  // ========================================================================
+  // Public methods
+
+  public abstract void populateAnnotationTypeIfNecessary(Class cd,
+                                                MClass clazz,
+                                                ReflectClassBuilder builder);
+
+  public abstract boolean isEnum(Class clazz);
+
+  public abstract Constructor getEnclosingConstructor(Class clazz);
+
+  public abstract Method getEnclosingMethod(Class clazz);
+
+  public abstract void extractAnnotations(MMember dest, Method src);
+
+  public abstract void extractAnnotations(MConstructor dest, Constructor src);
+
+  public abstract void extractAnnotations(MField dest, Field src);
+
+  public abstract void extractAnnotations(MClass dest, Class src);
+
+  public abstract void extractAnnotations(MParameter dest, Method src, int paramNum);
+
+  public abstract void extractAnnotations(MParameter dest, Constructor src, int paramNum);
+
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MAnnotatedElement.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MAnnotatedElement.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MAnnotatedElement.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MAnnotatedElement.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,45 @@
+package org.apache.xmlbeans.impl.jam.mutable;
+
+import org.apache.xmlbeans.impl.jam.JAnnotatedElement;
+
+
+/**
+ * <p>Mutable version of JAnnotatedElement.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public interface MAnnotatedElement extends MElement, JAnnotatedElement {
+
+  /**
+   * Returns the annotation having the given name, creating it if it doesn't
+   * exist.
+   */
+  public MAnnotation findOrCreateAnnotation(String annotationName);
+
+
+  
+  public MAnnotation[] getMutableAnnotations();
+
+  //DOCME
+  public MAnnotation getMutableAnnotation(String named);
+
+
+
+  //DOCME
+  public MAnnotation addLiteralAnnotation(String annotationName);
+
+//  public MAnnotation[] getLiteralMutableAnnotations();
+
+//  public MAnnotation[] getLiteralMutableAnnotations(String named);
+
+
+  //DOCME
+  public MComment getMutableComment();
+
+  //DOCME
+  public MComment createComment();
+
+  //DOCME
+  public void removeComment();
+
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MAnnotation.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MAnnotation.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MAnnotation.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MAnnotation.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,43 @@
+/*   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.mutable;
+
+import org.apache.xmlbeans.impl.jam.JAnnotation;
+import org.apache.xmlbeans.impl.jam.JClass;
+
+/**
+ * <p>Mutable version of JAnnotation.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public interface MAnnotation extends JAnnotation, MElement {
+
+  // ========================================================================
+  // MAnnotation implementation
+
+  public void setAnnotationInstance(Object o);
+
+  public void setSimpleValue(String name, Object value, JClass declaredType);
+
+  public MAnnotation createNestedValue(String name, String annTypeName);
+
+  public MAnnotation[] createNestedValueArray(String name,
+                                              String componentTypeName,
+                                              int dimensions);
+
+  //public AnnotationProxy getMutableProxy();//i think this is bad
+
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MClass.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MClass.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MClass.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MClass.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,177 @@
+/*   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.mutable;
+
+import org.apache.xmlbeans.impl.jam.JClass;
+import org.apache.xmlbeans.impl.jam.JMethod;
+import org.apache.xmlbeans.impl.jam.JProperty;
+
+/**
+ * <p>Mutable version of JClass.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public interface MClass extends MMember, JClass {
+
+  public void setIsInterface(boolean b);
+
+  public void setIsAnnotationType(boolean b);
+
+  public void setIsEnumType(boolean b);
+
+  /**
+   * Sets the class which this class extends.  The class name must be fully-
+   * qualified.  Pass null to make the class extend nothing.
+   *
+   * @throws IllegalArgumentException if the name is not a valid class name.
+   */
+  public void setSuperclass(String qualifiedClassName);
+
+  /**
+   * Sets the name of this class that this class extends.  The name
+   * may or may nor be fully-qualified.  Pass null to make the class
+   * extend nothing.
+   *
+   * @throws IllegalArgumentException if the name is not a valid class name.
+   */
+  public void setSuperclassUnqualified(String unqualifiedClassName);
+
+  /**
+   * Sets the class which this class extends.  Pass null to make the class
+   * extend nothing.
+   *
+   * @throws IllegalArgumentException if the given class cannot be extended
+   * (i.e. final classes, interfaces, void, primitives, arrays).
+   */
+  public void setSuperclass(JClass clazz);
+
+  /**
+   * Adds to the list of interfaces implemented by this class.
+   *
+   * @throws IllegalArgumentException if the parameter is null or is not
+   * a valid class name.
+   */
+  public void addInterface(String className);
+
+  /**
+   * Adds to the list of interfaces implemented by this class.  The class name
+   * may or may not be qualified.
+   *
+   * @throws IllegalArgumentException if the parameter is null or is not
+   * a valid class name.
+   */
+  public void addInterfaceUnqualified(String unqualifiedClassName);
+
+  /**
+   * Adds to the list of interfaces implemented by this class.
+   *
+   * @throws IllegalArgumentException if the given class cannot be implemented
+   * (i.e. is not an interface).
+   */
+  public void addInterface(JClass interf);
+
+  /**
+   * Removes a named interface from the list of interfaces implemented by
+   * this class.  Does nothing if the class does not implement the named
+   * interface.
+   *
+   * @throws IllegalArgumentException if the parameter is null or is not
+   * a valid class name.
+   */
+  public void removeInterface(String className);
+
+  /**
+   * Removes an interface from the list of interfaces implemented by
+   * this class.  Does nothing if the class does not implement the named
+   * interface.
+   *
+   * @throws IllegalArgumentException if the parameter is null or is not
+   * an interface.
+   */
+  public void removeInterface(JClass interf);
+
+  /**
+   * Creates a new constructor, adds it to this class, and returns it.
+   */
+  public MConstructor addNewConstructor();
+
+  /**
+   * Removes a constructor from this class.  Does nothing if the given
+   * constructor is not on this class.
+   */
+  public void removeConstructor(MConstructor constr);
+
+  /**
+   * Returns the constructors declared on this class.  This does not include
+   * constructors from any base class or interface.  This is simply a more
+   * strongly-typed version of getDeclaredConstructors().
+   */
+  public MConstructor[] getMutableConstructors();
+
+  /**
+   * Creates a new field, adds it to this class, and returns it.
+   * The type of the field must be qualified
+   */
+  public MField addNewField();
+
+  /**
+   * Removes the given field from this class.  Does nothing if this class
+   * does not contain the field.
+   */
+  public void removeField(MField field);
+
+  /**
+   * Returns the fields declared on this class.  This does not include
+   * fields from any base class or interface.  This is simply a more
+   * strongly-typed version of getDeclaredFields().
+   */
+  public MField[] getMutableFields();
+
+  /**
+   * Creates a new method, adds it to this class, and returns it.
+   */
+  public MMethod addNewMethod();
+
+  /**
+   * Removes the given method from this class.  Does nothing if this class
+   * does not contain the method.
+   */
+  public void removeMethod(MMethod method);
+
+  /**
+   * Returns the EditableMethods declared on this class.  This does not
+   * include methods inherited from any base class or interface.  This is
+   * simply a more strongly-typed version of getDeclaredMethods().
+   */
+  public MMethod[] getMutableMethods();
+
+
+  public JProperty addNewProperty(String name, JMethod getter, JMethod setter);
+
+  public void removeProperty(JProperty prop);
+
+  public JProperty addNewDeclaredProperty(String name, JMethod getter, JMethod setter);
+
+  public void removeDeclaredProperty(JProperty prop);
+
+  public MClass addNewInnerClass(String name);
+
+  public void removeInnerClass(MClass clazz);
+
+
+
+
+}
\ No newline at end of file

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MComment.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MComment.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MComment.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MComment.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,31 @@
+/*   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.mutable;
+
+import org.apache.xmlbeans.impl.jam.JComment;
+
+/**
+ * <p>Mutable version of JComment.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public interface MComment extends MElement, JComment {
+
+  /**
+   * Sets the text of this comment.
+   */
+  public void setText(String text);
+
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MConstructor.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MConstructor.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MConstructor.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MConstructor.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,27 @@
+/*   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.mutable;
+
+import org.apache.xmlbeans.impl.jam.JConstructor;
+
+/**
+ * <p>Mutable version of JConstructor.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public interface MConstructor extends JConstructor, MInvokable {
+
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MElement.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MElement.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MElement.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MElement.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,48 @@
+/*   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.mutable;
+
+import org.apache.xmlbeans.impl.jam.JElement;
+import org.apache.xmlbeans.impl.jam.JamClassLoader;
+import org.apache.xmlbeans.impl.jam.visitor.MVisitor;
+
+/**
+ * <p>Mutable version of JElement.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public interface MElement extends JElement {
+
+  public JamClassLoader getClassLoader();
+
+  //DOCME
+  public void setSimpleName(String name);
+
+  //DOCME
+  public MSourcePosition createSourcePosition();
+
+  //DOCME
+  public void removeSourcePosition();
+
+  //DOCME
+  public MSourcePosition getMutableSourcePosition();
+
+  //DOCME
+  public void accept(MVisitor visitor);
+
+  //DOCME
+  public void setArtifact(Object o);
+}
\ No newline at end of file

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MField.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MField.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MField.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MField.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.mutable;
+
+import org.apache.xmlbeans.impl.jam.JClass;
+import org.apache.xmlbeans.impl.jam.JField;
+
+/**
+ * <p>Mutable version of JField.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public interface MField extends JField, MMember {
+
+  public void setType(String typeName);
+
+  public void setUnqualifiedType(String typeName);
+
+  public void setType(JClass type);
+
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MInvokable.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MInvokable.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MInvokable.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MInvokable.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,120 @@
+/*
+* 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.jam.mutable;
+
+import org.apache.xmlbeans.impl.jam.JClass;
+import org.apache.xmlbeans.impl.jam.JInvokable;
+
+/**
+ * <p>Mutable version of JInvokable.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public interface MInvokable extends JInvokable, MMember {
+  /**
+   * <p>Adds a declaration of a checked exception of the given type.</p>
+   *
+   * @throws java.lang.IllegalArgumentException if the parameter is null or is not
+   * a valid class name.
+   */
+  public void addException(String qualifiedClassName);
+
+  /**
+   * <p>Adds a declaration of a checked exception of the given type.</p>
+   *
+   * @throws java.lang.IllegalArgumentException if the parameter is null or represents
+   * a class which does not extend throwable.
+   */
+  public void addException(JClass exceptionClass);
+
+  /**
+   * Removes a declaration of a checked exception of the named class.  Does
+   * nothing if no such declaration exists.
+   *
+   * @throws java.lang.IllegalArgumentException if the parameter is null or is not
+   * a valid class name.
+   */
+  public void removeException(String qualifiedClassName);
+
+  /**
+   * Removes a declaration of a checked exception of the given class.  Does
+   * nothing if no such declaration exists.
+   *
+   * @throws java.lang.IllegalArgumentException if the parameter is null.
+   */
+  public void removeException(JClass exceptionClass);
+
+  /**
+   * Creates a new parameter on this method of type java.lang.Object and
+   * with a default name.
+   */
+  public MParameter addNewParameter();
+
+  /**
+   * Removes the given parameter.  Does nothing if the parameter is not
+   * present on this method.
+   *
+   * @throws java.lang.IllegalArgumentException if either parameter is null.
+   */
+  public void removeParameter(MParameter parameter);
+
+  /**
+   * Returns all of the parameters on this method, or an empty array if there
+   * are none.  This is simply a more strongly-typed version of
+   * getParameters().
+   */
+  public MParameter[] getMutableParameters();
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MMember.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MMember.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MMember.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MMember.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,28 @@
+/*   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.mutable;
+
+import org.apache.xmlbeans.impl.jam.JMember;
+
+/**
+ * <p>Mutable version of JMember.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public interface MMember extends MAnnotatedElement, JMember {
+
+  public void setModifiers(int modifiers);
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MMethod.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MMethod.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MMethod.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MMethod.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,46 @@
+/*   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.mutable;
+
+import org.apache.xmlbeans.impl.jam.JClass;
+import org.apache.xmlbeans.impl.jam.JMethod;
+
+/**
+ * <p>Mutable version of JMethod.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public interface MMethod extends JMethod, MInvokable {
+
+  /**
+   * <p>Sets the type of this method's return value.  Null can be passed if
+   * a 'void' return type is desired.</p>
+   *
+   * @throws IllegalArgumentException if the parameter is not a valid
+   * java class name.
+   */
+  public void setReturnType(String qualifiedTypeName);
+
+  public void setUnqualifiedReturnType(String unqualifiedTypeName);
+
+  /**
+   * <p>Sets the type of this method's return value.  Null may be passed if
+   * a 'void' return type is desired.  This method is exactly equivalent to
+   * calling setReturnType(jclass.getQualifiedName()).</p>
+   */
+  public void setReturnType(JClass c);
+
+}
\ No newline at end of file

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MPackage.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MPackage.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MPackage.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MPackage.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,27 @@
+/*   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.mutable;
+
+import org.apache.xmlbeans.impl.jam.JPackage;
+
+/**
+ * <p>Mutable version of JPackage.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public interface MPackage extends  JPackage, MAnnotatedElement {
+
+  public MClass[] getMutableClasses();
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MParameter.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MParameter.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MParameter.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MParameter.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,33 @@
+/*   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.mutable;
+
+import org.apache.xmlbeans.impl.jam.JClass;
+import org.apache.xmlbeans.impl.jam.JParameter;
+
+/**
+ * <p>Mutable version of JParameter.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public interface MParameter extends JParameter, MMember {
+
+  public void setType(String typeName);
+
+  public void setType(JClass type);
+
+  public void setUnqualifiedType(String ucname);
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MSourcePosition.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MSourcePosition.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MSourcePosition.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/mutable/MSourcePosition.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,46 @@
+/*   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.mutable;
+
+import org.apache.xmlbeans.impl.jam.JSourcePosition;
+
+import java.net.URI;
+
+/**
+ * <p>Mutable version of JSourcePosition.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public interface MSourcePosition extends JSourcePosition {
+
+  /**
+   * Sets the text column number for this source position.  Set to -1 if
+   * it is not known.
+   */
+  public void setColumn(int col);
+
+  /**
+   * Sets the text line number for this source position.  Set to -1 if
+   * it is not known.
+   */
+  public void setLine(int line);
+
+  /**
+   * Sets the URI of the source file.  Set to null if it is not known.
+   */
+  public void setSourceURI(URI uri);
+
+}
\ No newline at end of file

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/CompositeJamClassBuilder.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/CompositeJamClassBuilder.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/CompositeJamClassBuilder.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/CompositeJamClassBuilder.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,57 @@
+/*   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.provider;
+
+import org.apache.xmlbeans.impl.jam.internal.elements.ElementContext;
+import org.apache.xmlbeans.impl.jam.mutable.MClass;
+
+/**
+ * <p>Composite implementation of JamClassBuilder.  When building,
+ * the first one in the list to not return null wins.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public class CompositeJamClassBuilder extends JamClassBuilder {
+
+  // ========================================================================
+  // Variables
+
+  private JamClassBuilder[] mBuilders;
+
+  // ========================================================================
+  // Constructors
+
+  public CompositeJamClassBuilder(JamClassBuilder[] builders) {
+    if (builders == null) throw new IllegalArgumentException("null builders");
+    mBuilders = builders;
+  }
+
+  // ========================================================================
+  // JamClassBuilder implementation
+
+  public void init(ElementContext ctx) {
+    for(int i=0; i<mBuilders.length; i++) mBuilders[i].init(ctx);
+  }
+
+  public MClass build(String pkg, String cname) {
+    MClass out = null;
+    for(int i=0; i<mBuilders.length; i++) {
+      out = mBuilders[i].build(pkg,cname);
+      if (out != null) return out;
+    }
+    return null;
+  }
+
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamClassBuilder.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamClassBuilder.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamClassBuilder.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamClassBuilder.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,148 @@
+/*   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.provider;
+
+import org.apache.xmlbeans.impl.jam.internal.elements.ClassImpl;
+import org.apache.xmlbeans.impl.jam.internal.elements.ElementContext;
+import org.apache.xmlbeans.impl.jam.mutable.MClass;
+
+/**
+ * <p>Implemented by providers to build and initialize classes on demand.
+ * The main responsibility a JAM provider has is writing an extension of this
+ * class.
+ * </p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public abstract class JamClassBuilder {
+
+  // ========================================================================
+  // Variables
+
+  private ElementContext mContext = null;
+
+  // ========================================================================
+  // Public methods
+
+  /**
+   * This method is called by JAM to initialize this class builder.  Extending
+   * classes can override this to perform additional initialization work
+   * (just remember to call super.init()!).
+   *
+   * @param ctx
+   */
+  public void init(ElementContext ctx) {
+    if (mContext != null) {
+      throw new IllegalStateException("init called more than once");
+    }
+    if (ctx == null) throw new IllegalArgumentException("null ctx");
+    mContext = ctx;
+  }
+
+
+  // ========================================================================
+  // Abstract methods
+
+  /**
+   * <p>This is called by JAM when it attempts to load a class.  If the
+   * builder has access to an artifact (typically a java source or classfile)
+   * that represents the given type, it should call createClassToBuild() to get
+   * a new instance of MClass and then return it.  No caching should be
+   * performed - if an MClass is going to be returned, it should be a new
+   * instance returned by createClassToBuild()</p>
+   *
+   * <p>If no artififact is available, the builder should just return null,
+   * signalling that other JamClassBuilders should attempt to build the
+   * class.</p>
+   *
+   * @param packageName
+   * @param className
+   * @return
+   */
+  public abstract MClass build(String packageName, String className);
+
+  // ========================================================================
+  // Protected methods
+
+  /**
+   * <p>When a JamClassBuilder decides that it is going to be able
+   * to respond to a build() request, it must call this method to get an
+   * initial instance of MClass to return.</p>
+   *
+   * @param packageName qualified name of the package that contains the
+   * class to create
+   * @param className simple name of the class to create.
+   * @param importSpecs array of import specs to be used in the class,
+   * or null if not known or relevant.  Import specs are only strictly
+   * required if the builder is planning on setting any unqualified type
+   * references on the class.  The importspec values will be used in
+   * determining what is retuned by JClass.getImportedPackages() and
+   * getImportedClasses().  Note that an importSpec does not include the
+   * word 'import' - e.g. it should only be 'java.util.List' or 'java.util.*'
+   */
+  protected MClass createClassToBuild(String packageName,
+                                      String className,
+                                      String[] importSpecs,
+                                      JamClassPopulator pop)
+  {
+    if (mContext == null) throw new IllegalStateException("init not called");
+    if (packageName == null) throw new IllegalArgumentException("null pkg");
+    if (className == null) throw new IllegalArgumentException("null class");
+    if (pop == null) throw new IllegalArgumentException("null pop");
+    assertInitialized();
+    className = className.replace('.','$');
+    ClassImpl out = new ClassImpl(packageName,className,mContext,importSpecs,pop);
+    return out;
+  }
+
+  /**
+   * <p>When a JamClassBuilder decides that it is going to be able
+   * to respond to a build() request, it must call this method to get an
+   * initial instance of MClass to return.</p>
+   *
+   * @param packageName qualified name of the package that contains the
+   * class to create
+   * @param className simple name of the class to create.
+   * @param importSpecs array of import specs to be used in the class,
+   * or null if not known or relevant.  Import specs are only needed if
+   * the builder is planning on setting any unqualified type references
+   * on the class.
+   */
+  protected MClass createClassToBuild(String packageName,
+                                      String className,
+                                      String[] importSpecs)
+  {
+    if (mContext == null) throw new IllegalStateException("init not called");
+    if (packageName == null) throw new IllegalArgumentException("null pkg");
+    if (className == null) throw new IllegalArgumentException("null class");
+    assertInitialized();
+    className = className.replace('.','$');
+    ClassImpl out = new ClassImpl(packageName,className,mContext,importSpecs);
+    return out;
+  }
+
+  protected JamLogger getLogger() { return mContext; }
+
+
+  /**
+   * Asserts that init() has been called on this class builder.
+   */
+  protected final void assertInitialized() {
+    if (mContext == null) {
+      throw new IllegalStateException(this+" not yet initialized.");
+    }
+  }
+
+}
\ No newline at end of file

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamClassPopulator.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamClassPopulator.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamClassPopulator.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamClassPopulator.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.provider;
+
+import org.apache.xmlbeans.impl.jam.mutable.MClass;
+
+/**
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public interface JamClassPopulator {
+
+  /**
+   * <p>Called by JAM to 'fill out' an instance of a given MClass with
+   * things like methods and fields.  The implementing builder is responsible
+   * for inspecting the source artifact (typically a source or class file)
+   * to call the appropriate createX methods on the given MClass.</p>
+   *
+   * @param c
+   */
+  public abstract void populate(MClass c);
+
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamLogger.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamLogger.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamLogger.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamLogger.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,78 @@
+/*   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.provider;
+
+/**
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public interface JamLogger {
+
+  public void setVerbose(Class c);
+
+  public boolean isVerbose(Object o);
+
+  public boolean isVerbose(Class c);  
+
+  public void setShowWarnings(boolean b);
+
+  /**
+   * <p>Outputs a debug message if appropriate for the given object.</p>
+   */
+  public void verbose(String msg, Object ifThisIsVerbose);
+
+  /**
+   * <p>Outputs a debug message if appropriate for the given object.</p>
+   */
+  public void verbose(Throwable t, Object ifThisIsVerbose);
+
+  /**
+   * <p>Outputs a debug message no matter what.</p>
+   */
+  public void verbose(String msg);
+
+  /**
+   * <p>Outputs a debug message no matter what.</p>
+   */
+  public void verbose(Throwable t);
+
+  /**
+   * <p>Outputs a debug message as appropriate.</p>
+   */
+  public void warning(Throwable t);
+
+  /**
+   * <p>Outputs a debug message as appropriate.</p>
+   */
+  public void warning(String w);
+
+  /**
+   * <p>Outputs an error as appropriate.</p>
+   */
+  public void error(Throwable t);
+
+  /**
+   * <p>Outputs an error as appropriate.</p>
+   */
+  public void error(String msg);
+
+
+  /**
+   * @deprecated
+   *
+   * @return
+   */
+  public boolean isVerbose();
+  
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamServiceContext.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamServiceContext.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamServiceContext.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamServiceContext.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,145 @@
+/*
+* 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.jam.provider;
+
+import org.apache.xmlbeans.impl.jam.annotation.JavadocTagParser;
+import org.apache.xmlbeans.impl.jam.visitor.MVisitor;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * <p>Structure containing information given to a BaseJProvider subclass in
+ * order to instantiate a new JStore.  This interface is the flip-side
+ * of JamServiceParams - it provides a view into the params the user specified.
+ * In reality, JamServiceContext and JamServiceParams are implemented by the
+ * same object, JamServiceContextImpl, but it is cleaner to separate
+ * the users' view of that data (which is write-only) from the provider's
+ * view (which is view-only).</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public interface JamServiceContext extends JamLogger/*killme*/ {
+
+  // ========================================================================
+  // Public methods
+
+  /**
+   * @return The classpath to be searched when trying to initialize an MClass
+   * for a java class which was not in the inputSources or inputClasses,
+   * or null.
+   */
+  public ResourcePath getInputClasspath();
+
+  /**
+   * @return The sourcepath to be searched when trying to initialize an MClass
+   * for a java class which was not in the inputSources or inputClasses, or
+   * null.
+   */
+  public ResourcePath getInputSourcepath();
+
+  /**
+   * @return The classpath to be used in loading external classes on which
+   * the service implementation depends, or null.  This is not generally
+   * needed.
+   */
+  public ResourcePath getToolClasspath();
+
+  /**
+   * @return an implementation-specific property, as specified by
+   * <code>JamServiceParams.setProperty()</code>.
+   */
+  public String getProperty(String name);
+
+  public MVisitor getInitializer();
+
+  public ClassLoader[] getReflectionClassLoaders();
+
+  public File[] getSourceFiles() throws IOException;
+
+  public String[] getAllClassnames() throws IOException;
+
+  public JamLogger getLogger();
+
+  public JamClassBuilder getBaseBuilder();
+
+  /**
+   * <p>Returns the JavadocTagParser to be used in processing javadoc tags.
+   * This never returns null - if no parser was specified by the user,
+   * the default one is used.  This method should be used only by
+   * JavadocClassBuilder.</p>
+   */
+  public JavadocTagParser getTagParser();
+
+  //public PrintWriter getOut();
+
+  public boolean is14WarningsEnabled();
+
+
+  // ========================================================================
+  // killme
+
+  /**
+   * <p>Returns a subclass of TypedAnnotationProxyBase that should be instantiated
+   * and used to proxy annotation metadata when no registered proxy is
+   * available.  By default, this is DefaultAnnotationProxy.class, though
+   * the user can override this if, for example, they need to change the
+   * default javadoc tag parsing behavior.</p>
+   *
+   * @return
+   */
+
+}
\ No newline at end of file

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamServiceFactoryImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamServiceFactoryImpl.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamServiceFactoryImpl.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/JamServiceFactoryImpl.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,259 @@
+/*   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.provider;
+
+import org.apache.xmlbeans.impl.jam.JClass;
+import org.apache.xmlbeans.impl.jam.JamClassLoader;
+import org.apache.xmlbeans.impl.jam.JamService;
+import org.apache.xmlbeans.impl.jam.JamServiceFactory;
+import org.apache.xmlbeans.impl.jam.JamServiceParams;
+import org.apache.xmlbeans.impl.jam.internal.JamClassLoaderImpl;
+import org.apache.xmlbeans.impl.jam.internal.JamServiceContextImpl;
+import org.apache.xmlbeans.impl.jam.internal.JamServiceImpl;
+import org.apache.xmlbeans.impl.jam.internal.elements.ElementContext;
+import org.apache.xmlbeans.impl.jam.internal.javadoc.JavadocClassBuilder;
+import org.apache.xmlbeans.impl.jam.internal.parser.ParserClassBuilder;
+import org.apache.xmlbeans.impl.jam.internal.reflect.ReflectClassBuilder;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>Default implementation of the JamServiceFactory singleton.  Custom
+ * JAM providers need to extend this class and override whatever methods
+ * they need to.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public class JamServiceFactoryImpl extends JamServiceFactory {
+
+  // ========================================================================
+  // Constants
+
+  /**
+   * <p>Service context property which turns on the javadoc killer.
+   * This will be removed when javadoc has been phased out.</p>
+   */
+  public static final String USE_NEW_PARSER =
+    "JamServiceFactoryImpl.use-new-parser";
+
+  private static final String PREFIX = "[JamServiceFactoryImpl]";
+  
+  // ========================================================================
+  // Constructors
+
+  public JamServiceFactoryImpl() {}
+
+  // ========================================================================
+  // JamServiceFactory implementation
+
+  public JamServiceParams createServiceParams() {
+    return new JamServiceContextImpl();
+  }
+
+  public JamService createService(JamServiceParams jsps) throws IOException {
+    //assert that they aren't implementing JamServiceParams themselves or
+    //getting them from somewhere else
+    if (!(jsps instanceof JamServiceContextImpl)) {
+      throw new IllegalArgumentException
+              ("JamServiceParams must be instantiated by this JamServiceFactory.");
+    }
+    //create and return the service
+    JamClassLoader clToUse = createClassLoader((JamServiceContextImpl)jsps);
+
+    //this is a nasty way to shoehorn it in there, should do better
+    ((JamServiceContextImpl)jsps).setClassLoader(clToUse);
+
+    return new JamServiceImpl((ElementContext)jsps,
+                              getSpecifiedClasses((JamServiceContextImpl)jsps));
+  }
+
+  public JamClassLoader createSystemJamClassLoader() {
+    JamServiceParams params = createServiceParams();
+    params.setUseSystemClasspath(true);
+    try {
+      JamService service = createService(params);
+      return service.getClassLoader();
+    } catch(IOException reallyUnexpected) {
+      reallyUnexpected.printStackTrace();
+      throw new IllegalStateException(reallyUnexpected.getMessage());
+    }
+  }
+
+  public JamClassLoader createJamClassLoader(ClassLoader cl) {
+    JamServiceParams params = createServiceParams();
+    params.setUseSystemClasspath(false); //?
+    params.setPropertyInitializer(null);
+    params.addClassLoader(cl);
+    try {
+      JamService service = createService(params);
+      return service.getClassLoader();
+    } catch(IOException reallyUnexpected) {
+      reallyUnexpected.printStackTrace();
+      throw new IllegalStateException(reallyUnexpected.getMessage());
+    }
+  }
+
+
+  // ========================================================================
+  // Protected methods - override these at your own risk
+
+  /**
+   * <p>Returns the set of classes to be included in a JamService to be
+   * created by the given params.  You should not override this
+   * unless you really know what you're doing.</p>
+   */
+  protected String[] getSpecifiedClasses(JamServiceContext params)
+          throws IOException
+  {
+    return params.getAllClassnames();
+  }
+
+  /**
+   * <p>Creates the main classloader to be used given the input ctx.
+   * This is usually a composite of the source classloader and a
+   * classfile classloader.  Subclasses may override to change the behavior.
+   * </p>
+   */
+  protected JamClassLoader createClassLoader(JamServiceContext ctx)
+          throws IOException
+  {
+    JamClassBuilder builder = createBuilder(ctx);
+    return new JamClassLoaderImpl((ElementContext)ctx,//eww
+      builder,ctx.getInitializer());
+  }
+
+  /**
+   * <p>Creates the JamClassBuilder for the given context.  This will be
+   * a composite that may include custom source and class-based classbuilders.
+   * It usually includes the system classbuilders and always contains the
+   * builtin classbuilder.</b>
+   */
+  protected JamClassBuilder createBuilder(JamServiceContext ctx)
+    throws IOException
+
+  {
+    JamLogger log = ctx.getLogger();
+    List builders = new ArrayList();  // make a list of the builders we want
+    // add the base builder if there is one
+    JamClassBuilder b = ctx.getBaseBuilder();
+    if (b != null) builders.add(b);
+    // look for source file builder
+    b = createSourceBuilder(ctx);
+    if (log.isVerbose(this)) {
+      log.verbose("added classbuilder for sources");
+    }
+    if (b != null) builders.add(b);   // prefer first source
+    b = createClassfileBuilder(ctx);  // then custom classpath
+    if (log.isVerbose(this)) {
+      log.verbose("added classbuilder for custom classpath");
+    }
+    if (b != null) builders.add(b);
+    ClassLoader[] cls = ctx.getReflectionClassLoaders();
+    for(int i=0; i<cls.length; i++) {
+      if (log.isVerbose(this)) {
+        log.verbose("added classbuilder for classloader "+cls[i].getClass());
+      }
+      builders.add(new ReflectClassBuilder(cls[i]));
+    }
+    JamClassBuilder[] barray = new JamClassBuilder[builders.size()];
+    builders.toArray(barray);
+    JamClassBuilder out = new CompositeJamClassBuilder(barray);
+    out.init((ElementContext)ctx);
+    if (log.isVerbose(this)) {
+      log.verbose("returning a composite of "+barray.length+" class builders.");
+      JClass c = out.build("java.lang","Object");
+      c = out.build("javax.ejb","SessionBean");
+    }
+    return out;
+
+  }
+
+  /**
+   * <p>Creates the source-based classbuilder for the given context.
+   * If no source files or paths are specified in the context,
+   * just returns null.</p>
+   */
+  protected JamClassBuilder createSourceBuilder(JamServiceContext ctx)
+    throws IOException
+  {
+    File[] sources = ctx.getSourceFiles();
+    if (sources == null || sources.length == 0) {
+      if (ctx.isVerbose(this)) {
+        ctx.verbose(PREFIX+ "no source files present, "+
+                    "skipping source ClassBuilder");
+      }
+      return null;
+    }
+    if(ctx.getProperty(USE_NEW_PARSER) == null) {
+      return new JavadocClassBuilder();
+    } else {
+      return new ParserClassBuilder(ctx);
+    }
+  }
+
+
+  /**
+   * <p>Creates the class-based classbuilder for the given context.
+   * If no class files or classloaders are specified in the params,
+   * just returns null.</p>
+   */
+  protected JamClassBuilder createClassfileBuilder(JamServiceContext jp)
+    throws IOException
+  {
+    //FIXME someday should make the name of the service class to use here
+    //settable via a system property
+    ResourcePath cp = jp.getInputClasspath();
+    if (cp == null) {
+      return null;
+    } else {
+      URL[] urls = cp.toUrlPath();
+      ClassLoader cl = new URLClassLoader(urls);
+      return new ReflectClassBuilder(cl);
+    }
+  }
+
+  /**
+   * <p>Creates a source class loader that is based on javadoc.  This
+   * is currently the default, but someday that will change.</p>
+
+  protected JamClassBuilder createJavadocSourceBuilder(JamServiceContext ctx)
+    throws IOException
+  {
+    //FIXME someday should make the name of the service class to use here
+    //settable via a system property
+    File[] files = ctx.getSourceFiles();
+    if (files == null || files.length == 0) return null;
+    String sourcePath = (ctx.getInputSourcepath() == null) ? null :
+            ctx.getInputSourcepath().toString();
+    String classPath = (ctx.getInputClasspath() == null) ? null :
+            ctx.getInputClasspath().toString();
+    return JavadocRunner.getInstance().
+            create(files,
+                   parent,
+                   ctx.getOut(),
+                   sourcePath,
+                   classPath,
+                   null);//FIXME get javadoc args from param props
+  }
+   */
+
+
+
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/ResourcePath.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/ResourcePath.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/ResourcePath.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/provider/ResourcePath.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,106 @@
+/*   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.provider;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+
+/**
+ * Represent a file search path, such as a classpath or sourcepath.
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public class ResourcePath {
+
+  // ========================================================================
+  // Factory
+
+  public static ResourcePath forFiles(File[] files) {
+    return new ResourcePath(files);
+  }
+
+  // ========================================================================
+  // Constants
+
+  //public static final ResourcePath EMPTY_JPATH = new ResourcePath(new File[]{});
+
+  // ========================================================================
+  // Variables
+
+  private File[] mFiles;
+
+  // ========================================================================
+  // Constructors
+
+  private ResourcePath(File[] files) {
+    if (files == null) throw new IllegalArgumentException("null files");
+    mFiles = files;
+  }
+
+  // ========================================================================
+  // Public methods
+
+  public URI[] toUriPath() {
+    URI[] out = new URI[mFiles.length];
+    for(int i=0; i<mFiles.length; i++) {
+      out[i] = mFiles[i].toURI();
+    }
+    return out;
+  }
+
+  public URL[] toUrlPath() throws MalformedURLException {
+    URL[] out = new URL[mFiles.length];
+    for(int i=0; i<mFiles.length; i++) {
+      out[i] = mFiles[i].toURL();
+    }
+    return out;
+  }
+
+  //fixme - need to abstract out ResourcePath and have separate impls
+  public InputStream findInPath(String resource) {
+    for(int i=0; i<mFiles.length; i++) {
+      File f = new File(mFiles[i],resource);
+      try {
+        if (f.exists()) return new FileInputStream(f);
+      } catch(FileNotFoundException weird) {
+        weird.printStackTrace();
+      }
+    }
+    return null;
+  }
+
+  // ========================================================================
+  // Object implementation
+
+  /**
+   * Returns the path as a single string in which each file component is
+   * separates by File.pathSeparatorChar.
+   */
+  public String toString() {
+    StringWriter out = new StringWriter();
+    for(int i=0; i<mFiles.length; i++) {
+      out.write(mFiles[i].getAbsolutePath());
+      out.write(File.pathSeparatorChar);
+    }
+    return out.toString();
+  }
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/CompositeJVisitor.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/CompositeJVisitor.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/CompositeJVisitor.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/CompositeJVisitor.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,80 @@
+/*   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.visitor;
+
+import org.apache.xmlbeans.impl.jam.JAnnotation;
+import org.apache.xmlbeans.impl.jam.JClass;
+import org.apache.xmlbeans.impl.jam.JComment;
+import org.apache.xmlbeans.impl.jam.JConstructor;
+import org.apache.xmlbeans.impl.jam.JField;
+import org.apache.xmlbeans.impl.jam.JMethod;
+import org.apache.xmlbeans.impl.jam.JPackage;
+import org.apache.xmlbeans.impl.jam.JParameter;
+
+/**
+ * <p>Composite implementation of JVisitor.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public class CompositeJVisitor extends JVisitor {
+
+  // ========================================================================
+  // Variables
+
+  private JVisitor[] mVisitors;
+
+  // ========================================================================
+  // Constructors
+
+  public CompositeJVisitor(JVisitor[] visitors) {
+    if (visitors == null) throw new IllegalArgumentException("null visitors");
+    mVisitors = visitors;
+  }
+
+  // ========================================================================
+  // JVisitor implementation
+
+  public void visit(JPackage pkg) {
+    for(int i=0; i<mVisitors.length; i++) mVisitors[i].visit(pkg);
+  }
+
+  public void visit(JClass clazz) {
+    for(int i=0; i<mVisitors.length; i++) mVisitors[i].visit(clazz);
+  }
+
+  public void visit(JConstructor ctor) {
+    for(int i=0; i<mVisitors.length; i++) mVisitors[i].visit(ctor);
+  }
+
+  public void visit(JField field) {
+    for(int i=0; i<mVisitors.length; i++) mVisitors[i].visit(field);
+  }
+
+  public void visit(JMethod method) {
+    for(int i=0; i<mVisitors.length; i++) mVisitors[i].visit(method);
+  }
+
+  public void visit(JParameter param) {
+    for(int i=0; i<mVisitors.length; i++) mVisitors[i].visit(param);
+  }
+
+  public void visit(JAnnotation ann) {
+    for(int i=0; i<mVisitors.length; i++) mVisitors[i].visit(ann);
+  }
+
+  public void visit(JComment comment) {
+    for(int i=0; i<mVisitors.length; i++) mVisitors[i].visit(comment);
+  }
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/CompositeMVisitor.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/CompositeMVisitor.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/CompositeMVisitor.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/CompositeMVisitor.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,82 @@
+/*   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.visitor;
+
+import org.apache.xmlbeans.impl.jam.mutable.MAnnotation;
+import org.apache.xmlbeans.impl.jam.mutable.MClass;
+import org.apache.xmlbeans.impl.jam.mutable.MComment;
+import org.apache.xmlbeans.impl.jam.mutable.MConstructor;
+import org.apache.xmlbeans.impl.jam.mutable.MField;
+import org.apache.xmlbeans.impl.jam.mutable.MMethod;
+import org.apache.xmlbeans.impl.jam.mutable.MPackage;
+import org.apache.xmlbeans.impl.jam.mutable.MParameter;
+
+/**
+ * <p>Composite implementation of MVisitor.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public class CompositeMVisitor extends MVisitor {
+
+  // ========================================================================
+  // Variables
+
+  private MVisitor[] mVisitors;
+
+  // ========================================================================
+  // Constructors
+
+  public CompositeMVisitor(MVisitor[] visitors) {
+    if (visitors == null) throw new IllegalArgumentException("null visitors");
+    mVisitors = visitors;
+  }
+
+  // ========================================================================
+  // MVisitor implementation
+
+  public void visit(MPackage pkg) {
+    for(int i=0; i<mVisitors.length; i++) mVisitors[i].visit(pkg);
+  }
+
+  public void visit(MClass clazz) {
+    for(int i=0; i<mVisitors.length; i++) mVisitors[i].visit(clazz);
+  }
+
+  public void visit(MConstructor ctor) {
+    for(int i=0; i<mVisitors.length; i++) mVisitors[i].visit(ctor);
+  }
+
+  public void visit(MField field) {
+    for(int i=0; i<mVisitors.length; i++) mVisitors[i].visit(field);
+  }
+
+  public void visit(MMethod method) {
+    for(int i=0; i<mVisitors.length; i++) mVisitors[i].visit(method);
+  }
+
+  public void visit(MParameter param) {
+    for(int i=0; i<mVisitors.length; i++) mVisitors[i].visit(param);
+  }
+
+  public void visit(MAnnotation ann) {
+    for(int i=0; i<mVisitors.length; i++) mVisitors[i].visit(ann);
+  }
+
+  public void visit(MComment comment) {
+    for(int i=0; i<mVisitors.length; i++) mVisitors[i].visit(comment);
+  }
+
+
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/JVisitor.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/JVisitor.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/JVisitor.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/JVisitor.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,53 @@
+/*   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.visitor;
+
+import org.apache.xmlbeans.impl.jam.JAnnotation;
+import org.apache.xmlbeans.impl.jam.JClass;
+import org.apache.xmlbeans.impl.jam.JComment;
+import org.apache.xmlbeans.impl.jam.JConstructor;
+import org.apache.xmlbeans.impl.jam.JField;
+import org.apache.xmlbeans.impl.jam.JMethod;
+import org.apache.xmlbeans.impl.jam.JPackage;
+import org.apache.xmlbeans.impl.jam.JParameter;
+import org.apache.xmlbeans.impl.jam.JProperty;
+
+//REVIEW I think this should be an interface
+/**
+ * <p>To be implemented by classes which wish to traverse a JElement tree.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public abstract class JVisitor {
+
+  public void visit(JPackage pkg) {}
+
+  public void visit(JClass clazz) {}
+
+  public void visit(JConstructor ctor) {}
+
+  public void visit(JField field) {}
+
+  public void visit(JMethod method) {}
+
+  public void visit(JParameter param) {}
+
+  public void visit(JAnnotation ann) {}
+
+  public void visit(JComment comment) {}
+
+  public void visit(JProperty proprty) {}
+
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/MVisitor.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/MVisitor.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/MVisitor.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/MVisitor.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,49 @@
+/*   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.visitor;
+
+import org.apache.xmlbeans.impl.jam.mutable.MAnnotation;
+import org.apache.xmlbeans.impl.jam.mutable.MClass;
+import org.apache.xmlbeans.impl.jam.mutable.MComment;
+import org.apache.xmlbeans.impl.jam.mutable.MConstructor;
+import org.apache.xmlbeans.impl.jam.mutable.MField;
+import org.apache.xmlbeans.impl.jam.mutable.MMethod;
+import org.apache.xmlbeans.impl.jam.mutable.MPackage;
+import org.apache.xmlbeans.impl.jam.mutable.MParameter;
+
+/**
+ * <p>To be extended by classes which wish to traverse an MElement tree.</p>
+ *
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public abstract class MVisitor {
+
+  public void visit(MPackage pkg) {}
+
+  public void visit(MClass clazz) {}
+
+  public void visit(MConstructor ctor) {}
+
+  public void visit(MField field) {}
+
+  public void visit(MMethod method) {}
+
+  public void visit(MParameter param) {}
+
+  public void visit(MAnnotation ann) {}
+
+  public void visit(MComment comment) {}
+
+}

Added: xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/PropertyInitializer.java
URL: http://svn.apache.org/viewvc/xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/PropertyInitializer.java?rev=1857518&view=auto
==============================================================================
--- xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/PropertyInitializer.java (added)
+++ xmlbeans/branches/xmlbeans-536/src/jam/org/apache/xmlbeans/impl/jam/visitor/PropertyInitializer.java Sun Apr 14 13:55:06 2019
@@ -0,0 +1,96 @@
+/*   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.visitor;
+
+import org.apache.xmlbeans.impl.jam.JClass;
+import org.apache.xmlbeans.impl.jam.JMethod;
+import org.apache.xmlbeans.impl.jam.JProperty;
+import org.apache.xmlbeans.impl.jam.internal.elements.PropertyImpl;
+import org.apache.xmlbeans.impl.jam.mutable.MClass;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Patrick Calahan &lt;email: pcal-at-bea-dot-com&gt;
+ */
+public class PropertyInitializer extends MVisitor {
+
+  //FIXME we may want to move to a model in which property initialization
+  //is done even more lazily, i.e. only when getProperties is called.
+
+  // ========================================================================
+  // Element visitor implementation
+
+  public void visit(MClass clazz) {
+    addProperties(clazz,true);
+    addProperties(clazz,false);
+  }
+
+  private void addProperties(MClass clazz, boolean declared) {
+    JMethod[] methods = declared ? clazz.getDeclaredMethods() :
+      clazz.getMethods();
+    Map name2prop = new HashMap();
+    for(int i=0; i<methods.length; i++) {
+      String name = methods[i].getSimpleName();
+      //
+      // process getters
+      //
+      if (name.startsWith("get") && name.length() > 3 ||
+        name.startsWith("is") && name.length() > 2) {
+        JClass typ = methods[i].getReturnType();
+        //FIXME we just want the name - this forces the whole thing to be resolved
+        // need to either getReturnTypeRef() or change ClassImpl so that it lazily builds itself
+        if (typ == null) continue; // must have a typ and have
+        if (methods[i].getParameters().length > 0) continue; //no params
+        if (name.startsWith("get")) {
+          name = name.substring(3);
+        } else {
+          name = name.substring(2);
+        }
+        JProperty prop = (JProperty)name2prop.get(name);
+        if (prop == null) {
+          prop = declared ? clazz.addNewDeclaredProperty(name,methods[i],null) :
+            clazz.addNewProperty(name,methods[i],null);
+          name2prop.put(name,prop);
+        } else {
+          if (typ.equals(prop.getType())) {
+            ((PropertyImpl)prop).setGetter(methods[i]); // cheater
+          }
+        }
+      }
+
+      //
+      // process setters
+      //
+      if (name.startsWith("set") && name.length() > 3) {
+        if (methods[i].getParameters().length != 1) continue; //1 param reqd
+        JClass type = methods[i].getParameters()[0].getType();
+        name = name.substring(3);
+        JProperty prop = (JProperty)name2prop.get(name);
+        if (prop == null) {
+          prop = declared ? clazz.addNewDeclaredProperty(name,null,methods[i]) :
+            clazz.addNewProperty(name,null,methods[i]);
+          name2prop.put(name,prop);
+        } else {
+          if (type.equals(prop.getType())) {
+            // if it's the same type, cool - just add the getter
+            ((PropertyImpl)prop).setSetter(methods[i]); // with a sneaky cast
+          }
+        }
+      }
+    }
+  }
+}



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