You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by pc...@apache.org on 2004/03/20 21:10:45 UTC
cvs commit: xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam JamTestBase.java
pcal 2004/03/20 12:10:45
Modified: v2/jam/src/org/apache/xmlbeans/impl/jam JAnnotation.java
JClass.java JProperty.java JamServiceFactory.java
JamServiceParams.java
v2/jam/src/org/apache/xmlbeans/impl/jam/annotation
AnnotationProxy.java
v2/jam/src/org/apache/xmlbeans/impl/jam/internal
JamServiceContextImpl.java
v2/jam/src/org/apache/xmlbeans/impl/jam/internal/elements
AnnotatedElementImpl.java BuiltinClassImpl.java
ClassImpl.java PropertyImpl.java
v2/jam/src/org/apache/xmlbeans/impl/jam/mutable MClass.java
v2/jam/src/org/apache/xmlbeans/impl/jam/provider
JamServiceContext.java JamServiceFactoryImpl.java
v2/jam/src/org/apache/xmlbeans/impl/jam/visitor
JVisitor.java PropertyInitializer.java
v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses
MultilineTags.java
v2/jam/test/masters/javadoc testManyTags.xml
testMultilineTags.xml
v2/jam/test/tests/org/apache/xmlbeans/test/jam
JamTestBase.java
Log:
jam updates
Revision Changes Path
1.6 +5 -0 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/JAnnotation.java
Index: JAnnotation.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/JAnnotation.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JAnnotation.java 17 Mar 2004 02:25:53 -0000 1.5
+++ JAnnotation.java 20 Mar 2004 20:10:45 -0000 1.6
@@ -32,6 +32,11 @@
public interface JAnnotation extends JElement {
// ========================================================================
+ // Constants
+
+ public static final String SINGLE_VALUE_NAME = "value";
+
+ // ========================================================================
// Public methods
/**
1.5 +6 -0 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/JClass.java
Index: JClass.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/JClass.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JClass.java 10 Mar 2004 11:42:07 -0000 1.4
+++ JClass.java 20 Mar 2004 20:10:45 -0000 1.5
@@ -166,6 +166,12 @@
public JProperty[] getProperties();
/**
+ * <p>Like getProperties(), but only considers methods explicitly declared
+ * on this class in identifying the properties.</p>
+ */
+ public JProperty[] getDeclaredProperties();
+
+ /**
* <p>Returns true if this JClass represents an interface.</p>
*/
public boolean isInterface();
1.4 +1 -1 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/JProperty.java
Index: JProperty.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/JProperty.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JProperty.java 9 Mar 2004 10:38:51 -0000 1.3
+++ JProperty.java 20 Mar 2004 20:10:45 -0000 1.4
@@ -29,7 +29,7 @@
*
* @author Patrick Calahan <email: pcal-at-bea-dot-com>
*/
-public interface JProperty { //is it really an AnnotatedElement?
+public interface JProperty extends JAnnotatedElement {
// ========================================================================
// Public methods
1.5 +14 -0 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/JamServiceFactory.java
Index: JamServiceFactory.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/JamServiceFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JamServiceFactory.java 17 Mar 2004 02:25:53 -0000 1.4
+++ JamServiceFactory.java 20 Mar 2004 20:10:45 -0000 1.5
@@ -84,6 +84,20 @@
*/
public abstract JamService createService(JamServiceParams params) throws IOException;
+ /**
+ * <p>Returns a new JamClassLoader which simply wraps the system
+ * classloader.</p>
+ */
+ public abstract JamClassLoader createSystemJamClassLoader();
+
+ /**
+ * <p>Returns a new JamClassLoader which simply wraps the given
+ * classloader.</p>
+ */
+ public abstract JamClassLoader createJamClassLoader(ClassLoader cl);
+
+
+
// ========================================================================
// main() method
1.7 +5 -0 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/JamServiceParams.java
Index: JamServiceParams.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/JamServiceParams.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- JamServiceParams.java 17 Mar 2004 23:29:45 -0000 1.6
+++ JamServiceParams.java 20 Mar 2004 20:10:45 -0000 1.7
@@ -330,6 +330,11 @@
public void setUseSystemClasspath(boolean use);
/**
+ * DOCME
+ */
+ public void addClassLoader(ClassLoader cl);
+
+ /**
* <p>Sets an implementation-specific property.</p>
*/
public void setProperty(String name, String value);
1.5 +166 -10 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/annotation/AnnotationProxy.java
Index: AnnotationProxy.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/annotation/AnnotationProxy.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AnnotationProxy.java 19 Mar 2004 04:17:52 -0000 1.4
+++ AnnotationProxy.java 20 Mar 2004 20:10:45 -0000 1.5
@@ -19,6 +19,9 @@
import org.apache.xmlbeans.impl.jam.JAnnotationValue;
import java.util.StringTokenizer;
+import java.util.Properties;
+import java.util.Iterator;
+import java.util.Enumeration;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.InvocationTargetException;
@@ -175,6 +178,168 @@
* <p>Extending classes are free to override this method if different
* behavior is required.</p>
*/
+
+ public void initFromJavadocTag(String tagline) {
+ if (tagline == null) throw new IllegalArgumentException("null tagline");
+ setValue(SINGLE_MEMBER_NAME,tagline);
+ Properties props = new Properties();
+ parseAssignments(props,tagline);
+ Enumeration names = props.propertyNames();
+ while(names.hasMoreElements()) {
+ String name = (String)names.nextElement();
+ setValue(name,props.getProperty(name));
+ }
+ }
+
+ // ========================================================================
+ // Protected methods
+
+ /**
+ * <p>Returns an instance of JamLogger that this AnnotationProxy should use
+ * for logging debug and error messages.</p>
+ */
+ protected JamLogger getLogger() { return mContext; }
+
+
+ // ========================================================================
+ // Private methods
+
+ //REVIEW the comment parsing logic here should be factored and made pluggable
+
+ /**
+ * Parse a line that contains assignments, taking into account
+ * - newlines (ignore them)
+ * - double quotes (the value is everything in-between)
+ * - // (everything after is ignored)
+ * - multiple assignments on the same line
+ *
+ * @param out This variable will contain a list of properties
+ * representing the line once parsed.
+ * @param line The line to be parsed
+ *
+ * This method contributed by Cedric Beust
+ */
+ private void parseAssignments(Properties out, String line) {
+ getLogger().verbose("PARSING LINE " + line,this);
+ String originalLine = line;
+ line = removeComments(line);
+ while (null != line && -1 != line.indexOf("=")) {
+ int keyStart = -1;
+ int keyEnd = -1;
+ int ind = 0;
+ // Skip stuff before the key
+ char c = line.charAt(ind);
+ while (isBlank(c)) {
+ ind++;
+ c = line.charAt(ind);
+ }
+ keyStart = ind;
+ while (isLegal(line.charAt(ind))) ind++;
+ keyEnd = ind;
+ String key = line.substring(keyStart, keyEnd);
+ ind = line.indexOf("=");
+ if (ind == -1) {
+ return; //FIXME let's be a little conservative, just for now
+ //throw new IllegalStateException("'=' expected: "+line);
+ }
+ ind++;
+ // Skip stuff after the equal sign
+ try {
+ c = line.charAt(ind);
+ }
+ catch(StringIndexOutOfBoundsException ex){
+ ex.printStackTrace();
+ }
+ while (isBlank(c)) {
+ ind++;
+ c = line.charAt(ind);
+ }
+
+ String value;
+ int valueStart = -1;
+ int valueEnd = -1;
+ if (c == '"') {
+ valueStart = ++ind;
+ while ('"' != line.charAt(ind)) {
+ ind++;
+ if (ind >= line.length()) {
+ getLogger().verbose("missing double quotes on line "+line,this);
+ }
+ }
+ valueEnd = ind;
+ }
+ else {
+ valueStart = ind++;
+ while (ind < line.length() && isLegal(line.charAt(ind))) ind++;
+ valueEnd = ind;
+ }
+ value = line.substring(valueStart, valueEnd);
+ if (ind < line.length()) {
+ line = line.substring(ind + 1);
+ }
+ else {
+ line = null;
+ }
+ getLogger().verbose("SETTING KEY:"+key+" VALUE:"+value,this);
+ out.setProperty(key, value);
+ }
+ }
+
+ /**
+ * Remove all the texts between "//" and '\n'
+ *
+ * This method contributed by Cedric Beust
+ */
+ private String removeComments(String value) {
+ String result = new String();
+ int size = value.length();
+ String current = value;
+
+ int currentIndex = 0;
+
+ int beginning = current.indexOf("//");
+
+ //
+ // Ignore // if it's between double quotes
+ //
+ int doubleQuotesIndex = current.indexOf("\"");
+ if (-1 != doubleQuotesIndex && doubleQuotesIndex < beginning) {
+ // do nothing
+ result = value;
+ }
+ else {
+ while (currentIndex < size && beginning != -1) {
+ beginning = value.indexOf("//", currentIndex);
+ if (-1 != beginning) {
+ String tmp = value.substring(beginning);
+ int end = value.indexOf('\n', beginning);
+ if (-1 == end) end = size;
+
+ // We have identified a portion to remove, copy the one we want to
+ // keep
+ result = result + value.substring(currentIndex, beginning).trim() + "\n";
+ current = value.substring(end);
+ currentIndex = end;
+ }
+ }
+ result += current;
+ }
+
+ return result.trim();
+ }
+
+ private boolean isBlank(char c) {
+ return c == ' ' || c == '\t' || c == '\n';
+ }
+
+ private boolean isLegal(char c) {
+ return (! isBlank(c)) && c != '=';
+// return Character.isJavaIdentifierStart(c) || c == '-' || Character.isDigit(c) || c == '.';
+ }
+
+ /*
+ OLD TAG PARSING CODE
+
public void initFromJavadocTag(String tagline) {
if (tagline == null) throw new IllegalArgumentException("null tagline");
StringTokenizer st = new StringTokenizer(tagline, mNvPairDelims);
@@ -209,14 +374,5 @@
}
}
}
-
- // ========================================================================
- // Protected methods
-
- /**
- * <p>Returns an instance of JamLogger that this AnnotationProxy should use
- * for logging debug and error messages.</p>
- */
- protected JamLogger getLogger() { return mContext; }
-
+ */
}
1.11 +19 -1 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/JamServiceContextImpl.java
Index: JamServiceContextImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/JamServiceContextImpl.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- JamServiceContextImpl.java 18 Mar 2004 04:31:35 -0000 1.10
+++ JamServiceContextImpl.java 20 Mar 2004 20:10:45 -0000 1.11
@@ -68,6 +68,7 @@
private MVisitor mPropertyInitializer = null;
private List mOtherInitializers = null;
private List mUnstructuredSourceFiles = null;
+ private List mClassLoaders = null;
private JamClassLoader mLoader = null;
@@ -373,6 +374,11 @@
mUseSystemClasspath = use;
}
+ public void addClassLoader(ClassLoader cl) {
+ if (mClassLoaders == null) mClassLoaders = new ArrayList();
+ mClassLoaders.add(cl);
+ }
+
public void setDefaultAnnotationProxyClass(Class proxy) {
validateProxyClass(proxy);
mDefaultAnnotationProxyClass = proxy;
@@ -381,8 +387,20 @@
// ========================================================================
// JamServiceContext implementation
- public boolean isUseSystemClasspath() { return mUseSystemClasspath; }
+ //public boolean isUseSystemClasspath() { return mUseSystemClasspath; }
+ public ClassLoader[] getReflectionClassLoaders() {
+ if (mClassLoaders == null) {
+ return new ClassLoader[] { ClassLoader.getSystemClassLoader() };
+ } else {
+ ClassLoader[] out = new ClassLoader[mClassLoaders.size()];
+ for(int i=0; i<out.length; i++) {
+ out[i] = (ClassLoader)mClassLoaders.get(i);
+ }
+ out[out.length-1] = ClassLoader.getSystemClassLoader();
+ return out;
+ }
+ }
// ========================================================================
// ElementContext implementation
1.10 +18 -21 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/elements/AnnotatedElementImpl.java
Index: AnnotatedElementImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/elements/AnnotatedElementImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AnnotatedElementImpl.java 19 Mar 2004 04:17:52 -0000 1.9
+++ AnnotatedElementImpl.java 20 Mar 2004 20:10:45 -0000 1.10
@@ -3,7 +3,6 @@
import org.apache.xmlbeans.impl.jam.JAnnotation;
import org.apache.xmlbeans.impl.jam.JComment;
import org.apache.xmlbeans.impl.jam.JAnnotationValue;
-import org.apache.xmlbeans.impl.jam.visitor.MVisitor;
import org.apache.xmlbeans.impl.jam.annotation.AnnotationProxy;
import org.apache.xmlbeans.impl.jam.mutable.MAnnotatedElement;
import org.apache.xmlbeans.impl.jam.mutable.MAnnotation;
@@ -130,11 +129,10 @@
public MAnnotation addAnnotationForTag(String tagName) {
{
// looks like we need to maintain a full list no matter what
- if (mAllJavadocTags == null) mAllJavadocTags = new ArrayList();
AnnotationProxy proxy = getContext().createProxyForTag(tagName);
MAnnotation ann = new AnnotationImpl(getContext(),proxy,tagName);
ann.setArtifact("@"+tagName);
- mAllJavadocTags.add(ann);
+ addJavadocAnnotation(ann);
}
MAnnotation out = getMutableAnnotation(tagName);
if (out != null) {
@@ -142,7 +140,7 @@
} else {
AnnotationProxy proxy = getContext().createProxyForTag(tagName);
out = new AnnotationImpl(getContext(),proxy,tagName);
- getName2Annotation().put(tagName,out);
+ addAnnotation(out);
}
return out;
}
@@ -150,12 +148,11 @@
public MAnnotation addAnnotationForTag(String tagName, String tagContents) {
{
// looks like we need to maintain a full list no matter what
- if (mAllJavadocTags == null) mAllJavadocTags = new ArrayList();
AnnotationProxy proxy = getContext().createProxyForTag(tagName);
proxy.initFromJavadocTag(tagContents);
MAnnotation ann = new AnnotationImpl(getContext(),proxy,tagName);
ann.setArtifact("@"+tagName+" "+tagContents);
- mAllJavadocTags.add(ann);
+ addJavadocAnnotation(ann);
}
MAnnotation out = getMutableAnnotation(tagName);
if (out != null) {
@@ -167,7 +164,7 @@
proxy.initFromJavadocTag(tagContents);
out = new AnnotationImpl(getContext(),proxy,tagName);
out.setArtifact(tagContents);
- getName2Annotation().put(tagName,out);
+ addAnnotation(out);
}
return out;
}
@@ -191,7 +188,7 @@
ann = new AnnotationImpl(getContext(),proxy,typename);
ann.setAnnotationInstance(jsr175annotationInstance);
setArtifact(jsr175annotationInstance);
- getName2Annotation().put(typename,ann);
+ addAnnotation(ann);
}
return ann;
}
@@ -203,7 +200,7 @@
AnnotationProxy proxy = getContext().
createProxyForAnnotationType(jsr175annotationClassname);
ann = new AnnotationImpl(getContext(),proxy,jsr175annotationClassname);
- getName2Annotation().put(jsr175annotationClassname,ann);
+ addAnnotation(ann);
return ann;
}
@@ -213,7 +210,7 @@
MAnnotation ann = getMutableAnnotation(name);
if (ann != null) return ann; //REVIEW weird case yet again
ann = new AnnotationImpl(getContext(),proxy,name);
- getName2Annotation().put(name,ann);
+ addAnnotation(ann);
return ann;
}
@@ -225,22 +222,22 @@
public void removeComment() { mComment = null; }
// ========================================================================
- // Protect methods
+ // Protected methods
- protected void visitAnnotations(MVisitor visitor) {
- MAnnotation[] anns = getMutableAnnotations();
- for(int i=0; i<anns.length; i++) visitor.visit(anns[i]);
- if (mComment != null) visitor.visit(mComment);
+ // these are exposed primarily for the benefit of PropertyImpl
+
+ protected void addAnnotation(JAnnotation ann) {
+ if (mName2Annotation == null) mName2Annotation = new HashMap();
+ mName2Annotation.put(ann.getSimpleName(),ann);
+ }
+
+ protected void addJavadocAnnotation(JAnnotation ann) {
+ if (mAllJavadocTags == null) mAllJavadocTags = new ArrayList();
+ mAllJavadocTags.add(ann);
}
// ========================================================================
// Private methods
-
-
- private Map getName2Annotation() {
- if (mName2Annotation == null) mName2Annotation = new HashMap();
- return mName2Annotation;
- }
private String getAnnotationTypeFor(/*Annotation*/ Object annotationInstance) {
//FIXME this may be broken, not sure yet what the class of an annotation
1.6 +9 -1 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/elements/BuiltinClassImpl.java
Index: BuiltinClassImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/elements/BuiltinClassImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- BuiltinClassImpl.java 11 Mar 2004 23:01:41 -0000 1.5
+++ BuiltinClassImpl.java 20 Mar 2004 20:10:45 -0000 1.6
@@ -99,6 +99,7 @@
public boolean isStatic() { return false; }
public JClass[] getClasses() { return NO_CLASS; }
public JProperty[] getProperties() { return NO_PROPERTY; }
+ public JProperty[] getDeclaredProperties() { return NO_PROPERTY; }
public JPackage[] getImportedPackages() { return NO_PACKAGE; }
public JClass[] getImportedClasses() { return NO_CLASS; }
@@ -129,11 +130,18 @@
public MMethod addNewMethod() { nocando(); return null; }
public void removeMethod(MMethod method) { nocando(); }
public void setModifiers(int modifiers) { nocando(); }
- public JProperty addNewProperty(String name, MMethod m, MMethod x) {
+
+ public JProperty addNewProperty(String name, JMethod m, JMethod x) {
nocando();
return null;
}
public void removeProperty(JProperty prop) { nocando(); }
+
+ public JProperty addNewDeclaredProperty(String name, JMethod m, JMethod x) {
+ nocando();
+ return null;
+ }
+ public void removeDeclaredProperty(JProperty prop) { nocando(); }
// ========================================================================
// Object implementation
1.10 +21 -1 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/elements/ClassImpl.java
Index: ClassImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/elements/ClassImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ClassImpl.java 18 Mar 2004 04:31:35 -0000 1.9
+++ ClassImpl.java 20 Mar 2004 20:10:45 -0000 1.10
@@ -64,6 +64,7 @@
private ArrayList mMethods = null;
private ArrayList mConstructors = null;
private ArrayList mProperties = null;
+ private ArrayList mDeclaredProperties = null;
private String[] mImports = null;
@@ -138,6 +139,13 @@
return out;
}
+ public JProperty[] getDeclaredProperties() {
+ if (mDeclaredProperties == null) return new JProperty[0];
+ JProperty[] out = new JProperty[mDeclaredProperties.size()];
+ mDeclaredProperties.toArray(out);
+ return out;
+ }
+
public JMethod[] getDeclaredMethods() { return getMutableMethods(); }
public JConstructor[] getConstructors() { return getMutableConstructors(); }
@@ -328,7 +336,7 @@
return out;
}
- public JProperty addNewProperty(String name, MMethod getter, MMethod setter) {
+ public JProperty addNewProperty(String name, JMethod getter, JMethod setter) {
if (mProperties == null) mProperties = new ArrayList();
JProperty out = new PropertyImpl(name,getter,setter,
getter.getReturnType().getFieldDescriptor());
@@ -338,6 +346,18 @@
public void removeProperty(JProperty p) {
if (mProperties != null) mProperties.remove(p);
+ }
+
+ public JProperty addNewDeclaredProperty(String name, JMethod getter, JMethod setter) {
+ if (mDeclaredProperties == null) mDeclaredProperties = new ArrayList();
+ JProperty out = new PropertyImpl(name,getter,setter,
+ getter.getReturnType().getFieldDescriptor());
+ mDeclaredProperties.add(out);
+ return out;
+ }
+
+ public void removeDeclaredProperty(JProperty p) {
+ if (mDeclaredProperties != null) mDeclaredProperties.remove(p);
}
public void setIsInterface(boolean b) { mIsInterface = b; }
1.3 +34 -5 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/elements/PropertyImpl.java
Index: PropertyImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/internal/elements/PropertyImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PropertyImpl.java 16 Mar 2004 21:55:31 -0000 1.2
+++ PropertyImpl.java 20 Mar 2004 20:10:45 -0000 1.3
@@ -17,6 +17,9 @@
import org.apache.xmlbeans.impl.jam.*;
+import org.apache.xmlbeans.impl.jam.mutable.MMethod;
+import org.apache.xmlbeans.impl.jam.visitor.MVisitor;
+import org.apache.xmlbeans.impl.jam.visitor.JVisitor;
import org.apache.xmlbeans.impl.jam.internal.classrefs.JClassRef;
import org.apache.xmlbeans.impl.jam.internal.classrefs.QualifiedJClassRef;
@@ -29,7 +32,7 @@
*
* @author Patrick Calahan <email: pcal-at-bea-dot-com>
*/
-public class PropertyImpl implements JProperty {
+public class PropertyImpl extends AnnotatedElementImpl implements JProperty {
// ========================================================================
// Variables
@@ -53,12 +56,15 @@
JMethod setter,
String qualifiedTypeName)
{
+ super((ElementImpl)
+ ((getter != null) ? getter.getParent() : setter.getParent()));
//FIXME should do more validation on the arguments
mName = name;
mGetter = getter;
mSetter = setter;
mTypeRef = QualifiedJClassRef.create
(qualifiedTypeName,((ClassImpl)getter.getContainingClass()));
+ initAnnotations();
}
// ========================================================================
@@ -145,15 +151,15 @@
return null;
}
- public JElement getParent() {
- return mGetter != null ? mGetter.getParent() : mSetter.getParent();
- }
-
public JSourcePosition getSourcePosition() {
return mGetter != null ?
mGetter.getSourcePosition() : mSetter.getSourcePosition();
}
+ public void accept(JVisitor visitor) {
+ if (mGetter != null) visitor.visit(mGetter);
+ if (mSetter != null) visitor.visit(mSetter);
+ }
// ========================================================================
// Object implementation
@@ -163,6 +169,22 @@
// ========================================================================
// Private methods
+ private void initAnnotations() {
+ if (mSetter != null) {
+ JAnnotation[] anns = mSetter.getAnnotations();
+ for(int i=0; i<anns.length; i++) super.addAnnotation(anns[i]);
+ anns = mSetter.getAllJavadocTags();
+ for(int i=0; i<anns.length; i++) super.addJavadocAnnotation(anns[i]);
+ }
+ if (mGetter != null) {
+ JAnnotation[] anns = mGetter.getAnnotations();
+ for(int i=0; i<anns.length; i++) super.addAnnotation(anns[i]);
+ anns = mGetter.getAllJavadocTags();
+ for(int i=0; i<anns.length; i++) super.addJavadocAnnotation(anns[i]);
+ }
+ }
+
+
/**
* Returns an array that is the union of the two arrays of
* anotations.
@@ -188,4 +210,11 @@
System.arraycopy(b,0,out,a.length,b.length);
return out;
}
+
+ public void accept(MVisitor visitor) {
+ //review this is kinda broken
+ if (mGetter != null) visitor.visit((MMethod)mGetter);
+ if (mSetter != null) visitor.visit((MMethod)mSetter);
+ }
+
}
1.3 +6 -1 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/mutable/MClass.java
Index: MClass.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/mutable/MClass.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MClass.java 11 Mar 2004 23:01:42 -0000 1.2
+++ MClass.java 20 Mar 2004 20:10:45 -0000 1.3
@@ -17,6 +17,7 @@
import org.apache.xmlbeans.impl.jam.JClass;
import org.apache.xmlbeans.impl.jam.JProperty;
+import org.apache.xmlbeans.impl.jam.JMethod;
/**
* <p>Mutable version of JClass.</p>
@@ -156,9 +157,13 @@
public MMethod[] getMutableMethods();
- public JProperty addNewProperty(String name, MMethod getter, MMethod setter);
+ 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);
1.7 +1 -1 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/provider/JamServiceContext.java
Index: JamServiceContext.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/provider/JamServiceContext.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- JamServiceContext.java 17 Mar 2004 23:29:46 -0000 1.6
+++ JamServiceContext.java 20 Mar 2004 20:10:45 -0000 1.7
@@ -107,7 +107,7 @@
public MVisitor getInitializer();
- public boolean isUseSystemClasspath();
+ public ClassLoader[] getReflectionClassLoaders();
public File[] getSourceFiles() throws IOException;
1.6 +28 -2 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/provider/JamServiceFactoryImpl.java
Index: JamServiceFactoryImpl.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/provider/JamServiceFactoryImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JamServiceFactoryImpl.java 17 Mar 2004 02:25:54 -0000 1.5
+++ JamServiceFactoryImpl.java 20 Mar 2004 20:10:45 -0000 1.6
@@ -83,6 +83,31 @@
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(true); //?
+ 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
@@ -126,8 +151,9 @@
if (b != null) builders.add(b); // prefer first source
b = createClassfileBuilder(ctx); // then custom classpath
if (b != null) builders.add(b);
- if (ctx.isUseSystemClasspath()) { // then system classpath
- builders.add(ReflectClassBuilder.getSystemClassBuilder(ctx));
+ ClassLoader[] cls = ctx.getReflectionClassLoaders();
+ for(int i=0; i<cls.length; i++) {
+ builders.add(new ReflectClassBuilder(cls[i],ctx));
}
JamClassBuilder[] barray = new JamClassBuilder[builders.size()];
builders.toArray(barray);
1.2 +2 -0 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/visitor/JVisitor.java
Index: JVisitor.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/visitor/JVisitor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JVisitor.java 11 Mar 2004 23:01:42 -0000 1.1
+++ JVisitor.java 20 Mar 2004 20:10:45 -0000 1.2
@@ -22,6 +22,7 @@
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;
/**
* <p>To be extended by classes which wish to traverse an MElement tree.</p>
@@ -45,4 +46,5 @@
public void visit(JAnnotation ann) {}
public void visit(JComment comment) {}
+
}
1.6 +15 -5 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/visitor/PropertyInitializer.java
Index: PropertyInitializer.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/visitor/PropertyInitializer.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PropertyInitializer.java 11 Mar 2004 23:01:42 -0000 1.5
+++ PropertyInitializer.java 20 Mar 2004 20:10:45 -0000 1.6
@@ -16,9 +16,9 @@
import org.apache.xmlbeans.impl.jam.JClass;
import org.apache.xmlbeans.impl.jam.JProperty;
+import org.apache.xmlbeans.impl.jam.JMethod;
import org.apache.xmlbeans.impl.jam.internal.elements.PropertyImpl;
import org.apache.xmlbeans.impl.jam.mutable.MClass;
-import org.apache.xmlbeans.impl.jam.mutable.MMethod;
import java.util.HashMap;
import java.util.Map;
@@ -28,13 +28,21 @@
*/
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();
- MMethod[] methods = clazz.getMutableMethods();
-
for(int i=0; i<methods.length; i++) {
String name = methods[i].getSimpleName();
//
@@ -52,7 +60,8 @@
}
JProperty prop = (JProperty)name2prop.get(name);
if (prop == null) {
- prop = clazz.addNewProperty(name,methods[i],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())) {
@@ -70,7 +79,8 @@
name = name.substring(3);
JProperty prop = (JProperty)name2prop.get(name);
if (prop == null) {
- prop = clazz.addNewProperty(name,methods[i],null);
+ prop = declared ? clazz.addNewDeclaredProperty(name,methods[i],null) :
+ clazz.addNewProperty(name,methods[i],null);
name2prop.put(name,prop);
} else {
if (type.equals(prop.getType())) {
1.2 +5 -2 xml-xmlbeans/v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/MultilineTags.java
Index: MultilineTags.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/MultilineTags.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MultilineTags.java 19 Mar 2004 04:17:52 -0000 1.1
+++ MultilineTags.java 20 Mar 2004 20:10:45 -0000 1.2
@@ -32,7 +32,6 @@
*
*
* "
-
* @boo a= " Here is a tag with multiple
* multiline values"
* b = " here is another"
@@ -49,11 +48,15 @@
* ejb-ql = "SELECT OBJECT(o)
* FROM BandEJB AS o
* WHERE o.name = ?1"
- *
+ *
+ * @ejbgen:cmp-field ordering-number="10" primkey-field="true" column="seth"
+ *
* @bee question = Can we confuse the parser? "
* " = "
* " ""
* " = = "
+ *
+ * @oldstyleSingleMemberValueTag I should be called 'value'
*
*/
public interface MultilineTags {
1.2 +2 -1 xml-xmlbeans/v2/jam/test/masters/javadoc/testManyTags.xml
Index: testManyTags.xml
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/test/masters/javadoc/testManyTags.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- testManyTags.xml 19 Mar 2004 04:17:52 -0000 1.1
+++ testManyTags.xml 20 Mar 2004 20:10:45 -0000 1.2
@@ -1 +1,2 @@
-<class><name>org.apache.xmlbeans.test.jam.dummyclasses.ManyTags</name><is-interface>false</is-interface><superclass>java.lang.Object</superclass><modifiers>1</modifiers><constructor><modifiers>1</modifiers><source-position><line>20</line><column>8</column><source-uri>file:/X:/xml-xmlbeans/v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/ManyTags.java</source-uri></source-position></constructor><method><name>getId</name><return-type>int</return-type><modifiers>1</modifiers><annotation><name>foo</name><annotation-value><name>x</name><value>-43 y=124 z=79</value></annotation-value><annotation-value><name>y</name><value>2</value></annotation-value><annotation-value><name>z</name><value>3</value></annotation-value><annotation-value><name>x</name><value>1</value></annotation-value><annotation-value><name>w</name><value>0</value></annotation-value></annotation><annotation><name>baz</name><annotation-value><name>x</name><value>1</value></annotation-value></annotation><annotation><name>bar</name><annotation-value><name>x</name><value>-4343</value></annotation-value></annotation><source-position><line>33</line><column>14</column><source-uri>file:/X:/xml-xmlbeans/v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/ManyTags.java</source-uri></source-position></method><comment><![CDATA[Tests case for javadoc tags is declared more than once in a document.]]></comment><source-position><line>20</line><column>8</column><source-uri>file:/X:/xml-xmlbeans/v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/ManyTags.java</source-uri></source-position></class>
\ No newline at end of file
+<class><name>org.apache.xmlbeans.test.jam.dummyclasses.ManyTags</name><is-interface>false</is-interface><superclass>java.lang.Object</superclass><modifiers>1</modifiers><constructor><modifiers>1</modifiers><source-position><line>20</line><column>8</column><source-uri>file:/X:/xml-xmlbeans/v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/ManyTags.java</source-uri></source-position></constructor><method><name>getId</name><return-type>int</return-type><modifiers>1</modifiers><annotation><name>foo</name><annotation-value><name>value</name><value>x=-43 y=124 z=79</value></annotation-value><annotation-value><name>x</name><value>-43</value></annotation-value><annotation-value><name>z</name><value>79</value></annotation-value><annotation-value><name>y</name><value>124</value></annotation-value><annotation-value><name>value</name><value>y=2</value></annotation-value><annotation-value><name>y</name><value>2</value></annotation-value><annotation-value><name>value</name><value>z=3
+ x=1</value></annotation-value><annotation-value><name>x</name><value>1</value></annotation-value><annotation-value><name>z</name><value>3</value></annotation-value><annotation-value><name>value</name><value>w = 0</value></annotation-value><annotation-value><name>w</name><value>0</value></annotation-value></annotation><annotation><name>baz</name><annotation-value><name>value</name><value>x=1</value></annotation-value><annotation-value><name>x</name><value>1</value></annotation-value></annotation><annotation><name>bar</name><annotation-value><name>value</name><value>x=-4343</value></annotation-value><annotation-value><name>x</name><value>-4343</value></annotation-value></annotation><source-position><line>33</line><column>14</column><source-uri>file:/X:/xml-xmlbeans/v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/ManyTags.java</source-uri></source-position></method><comment><![CDATA[Tests case for javadoc tags is declared more than once in a document.]]></comment><source-position><line>20</line><column>8</column><source-uri>file:/X:/xml-xmlbeans/v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/ManyTags.java</source-uri></source-position></class>
\ No newline at end of file
1.2 +44 -14 xml-xmlbeans/v2/jam/test/masters/javadoc/testMultilineTags.xml
Index: testMultilineTags.xml
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/test/masters/javadoc/testMultilineTags.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- testMultilineTags.xml 19 Mar 2004 04:17:52 -0000 1.1
+++ testMultilineTags.xml 20 Mar 2004 20:10:45 -0000 1.2
@@ -1,14 +1,44 @@
-<class><name>org.apache.xmlbeans.test.jam.dummyclasses.MultilineTags</name><is-interface>true</is-interface><modifiers>513</modifiers><annotation><name>foo</name><annotation-value><name>x</name><value> this is a tag value which
-spans several
-lines indeed</value></annotation-value></annotation><annotation><name>ejbgen:cmp-field</name><annotation-value><name>column</name><value>LicensorEntityID, CompanyID</value></annotation-value><annotation-value><name>table-name</name><value>LicensorEntity, Company</value></annotation-value></annotation><annotation><name>boo</name><annotation-value><name>a</name><value> Here is a tag with multiple
-multiline values</value></annotation-value><annotation-value><name>b</name><value>here is another</value></annotation-value><annotation-value><name>c</name><value> and another
-l = but this is still the same one
-whoa that was = tricky</value></annotation-value><annotation-value><name>d</name><value>yup</value></annotation-value></annotation><annotation><name>baz</name><annotation-value><name>z</name><value>
-I guess even something weird like
-this should work
-</value></annotation-value></annotation><annotation><name>ejbgen:finder</name><annotation-value><name>signature</name><value>java.util.Collection findByName(java.lang.String name)</value></annotation-value><annotation-value><name>ejb-ql</name><value>SELECT OBJECT(o)
-FROM BandEJB AS o
-WHERE o.name = ?1</value></annotation-value></annotation><annotation><name>bar</name><annotation-value><name>y</name><value> This is also a tag which spans
-a few lines but also has its closing
-quote in a weird place</value></annotation-value></annotation><annotation><name>bee</name><annotation-value><name>question</name><value>Can we confuse the parser? "</value></annotation-value><annotation-value><name>"</name><value>
-</value></annotation-value><annotation-value><name>"</name><value>= "</value></annotation-value></annotation><source-position><line>59</line><column>8</column><source-uri>file:/X:/xml-xmlbeans/v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/MultilineTags.java</source-uri></source-position></class>
\ No newline at end of file
+<class><name>org.apache.xmlbeans.test.jam.dummyclasses.MultilineTags</name><is-interface>true</is-interface><modifiers>513</modifiers><annotation><name>foo</name><annotation-value><name>value</name><value>x = " this is a tag value which
+ spans several
+
+ lines indeed"</value></annotation-value><annotation-value><name>x</name><value> this is a tag value which
+ spans several
+
+ lines indeed</value></annotation-value></annotation><annotation><name>ejbgen:cmp-field</name><annotation-value><name>value</name><value>column = "LicensorEntityID, CompanyID"
+ table-name= "LicensorEntity, Company"</value></annotation-value><annotation-value><name>column</name><value>LicensorEntityID, CompanyID</value></annotation-value><annotation-value><name>table-name</name><value>LicensorEntity, Company</value></annotation-value><annotation-value><name>value</name><value>ordering-number="10" primkey-field="true" column="seth"</value></annotation-value><annotation-value><name>column</name><value>seth</value></annotation-value><annotation-value><name>primkey-field</name><value>true</value></annotation-value><annotation-value><name>ordering-number</name><value>10</value></annotation-value></annotation><annotation><name>oldstyleSingleMemberValueTag</name><annotation-value><name>value</name><value>I should be called 'value'</value></annotation-value></annotation><annotation><name>boo</name><annotation-value><name>value</name><value>a= " Here is a tag with multiple
+ multiline values"
+ b = " here is another"
+ c = " and another
+ l = but this is still the same one
+ whoa that was = tricky"
+ d = "yup"</value></annotation-value><annotation-value><name>b</name><value> here is another</value></annotation-value><annotation-value><name>a</name><value> Here is a tag with multiple
+ multiline values</value></annotation-value><annotation-value><name>d</name><value>yup</value></annotation-value><annotation-value><name>c</name><value> and another
+ l = but this is still the same one
+ whoa that was = tricky</value></annotation-value></annotation><annotation><name>baz</name><annotation-value><name>value</name><value>z= "
+
+ I guess even something weird like
+ this should work
+
+
+ "</value></annotation-value><annotation-value><name>z</name><value>
+
+ I guess even something weird like
+ this should work
+
+
+ </value></annotation-value></annotation><annotation><name>ejbgen:finder</name><annotation-value><name>value</name><value>signature = "java.util.Collection findByName(java.lang.String name)"
+ ejb-ql = "SELECT OBJECT(o)
+ FROM BandEJB AS o
+ WHERE o.name = ?1"</value></annotation-value><annotation-value><name>signature</name><value>java.util.Collection findByName(java.lang.String name)</value></annotation-value><annotation-value><name>ejb-ql</name><value>SELECT OBJECT(o)
+ FROM BandEJB AS o
+ WHERE o.name = ?1</value></annotation-value></annotation><annotation><name>bar</name><annotation-value><name>value</name><value>y=" This is also a tag which spans
+
+ a few lines but also has its closing
+ quote in a weird place " see?</value></annotation-value><annotation-value><name>y</name><value> This is also a tag which spans
+
+ a few lines but also has its closing
+ quote in a weird place </value></annotation-value></annotation><annotation><name>bee</name><annotation-value><name>value</name><value>question = Can we confuse the parser? "
+ " = "
+ " ""
+ " = = "</value></annotation-value><annotation-value><name>""</name><value>=</value></annotation-value><annotation-value><name>question</name><value>Can</value></annotation-value><annotation-value><name>we</name><value>
+ </value></annotation-value></annotation><source-position><line>62</line><column>8</column><source-uri>file:/X:/xml-xmlbeans/v2/jam/test/dummyclasses/org/apache/xmlbeans/test/jam/dummyclasses/MultilineTags.java</source-uri></source-position></class>
\ No newline at end of file
1.11 +8 -8 xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/JamTestBase.java
Index: JamTestBase.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/test/tests/org/apache/xmlbeans/test/jam/JamTestBase.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- JamTestBase.java 19 Mar 2004 04:17:52 -0000 1.10
+++ JamTestBase.java 20 Mar 2004 20:10:45 -0000 1.11
@@ -92,9 +92,9 @@
// Constants
private static final boolean CONTINUE_ON_COMPARE_FAIL = false;
- private static final boolean WRITE_MASTER_ON_FAIL = true;
+ private static final boolean WRITE_RESULT_ON_FAIL = true;
- private static final String WRITE_MASTER_PREFIX = "expected-";
+ private static final String WRITE_RESULT_PREFIX = "result-";
protected static final String
DUMMY = "org.apache.xmlbeans.test.jam.dummyclasses";
@@ -419,13 +419,13 @@
} else {
System.out.println("WARNING: Missing master file: "+masterFile);
}
- if (WRITE_MASTER_ON_FAIL) {
- File expected = new File(getMasterDir(),WRITE_MASTER_PREFIX+masterName);
- FileWriter eout = new FileWriter(expected);
- eout.write(result);
- eout.close();
+ if (WRITE_RESULT_ON_FAIL) {
+ File resultFile = new File(getMasterDir(),WRITE_RESULT_PREFIX+masterName);
+ FileWriter rout = new FileWriter(resultFile);
+ rout.write(result);
+ rout.close();
System.out.println("WARNING: Comparison failed, ignoring, wrote \n"+
- expected);
+ resultFile);
}
if (CONTINUE_ON_COMPARE_FAIL) return;
fail("Result did not match master at "+masterFile+":\n"+
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org