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/06/17 19:56:04 UTC
cvs commit: xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/annotation AnnotationProxy.java TypedAnnotationProxyBase.java
pcal 2004/06/17 10:56:04
Modified: v2/jam/src/org/apache/xmlbeans/impl/jam/annotation
AnnotationProxy.java TypedAnnotationProxyBase.java
Log:
jam: implement TypedAnnotationProxyBase.getValues()
Revision Changes Path
1.15 +2 -2 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.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- AnnotationProxy.java 28 May 2004 17:02:51 -0000 1.14
+++ AnnotationProxy.java 17 Jun 2004 17:56:04 -0000 1.15
@@ -52,13 +52,13 @@
// ========================================================================
// Variables
- private JamServiceContext mContext;
+ protected JamServiceContext mContext;
//FIXME need to expose a knob for setting this
private String mNvPairDelims = DEFAULT_NVPAIR_DELIMS;
// ========================================================================
- // Initialization methods - called by JAM, don'
+ // Initialization methods - called by JAM, don't implement
/**
* <p>Called by JAM to initialize the proxy. Do not try to call this
1.4 +29 -15 xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/annotation/TypedAnnotationProxyBase.java
Index: TypedAnnotationProxyBase.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/jam/src/org/apache/xmlbeans/impl/jam/annotation/TypedAnnotationProxyBase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TypedAnnotationProxyBase.java 2 Apr 2004 02:41:06 -0000 1.3
+++ TypedAnnotationProxyBase.java 17 Jun 2004 17:56:04 -0000 1.4
@@ -16,9 +16,16 @@
import org.apache.xmlbeans.impl.jam.JAnnotationValue;
import org.apache.xmlbeans.impl.jam.JClass;
+import org.apache.xmlbeans.impl.jam.internal.elements.AnnotationValueImpl;
+import org.apache.xmlbeans.impl.jam.internal.elements.ElementContext;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Modifier;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
/**
@@ -33,6 +40,11 @@
public abstract class TypedAnnotationProxyBase extends AnnotationProxy {
// ========================================================================
+ // Variables
+
+ private List mValues = null;
+
+ // ========================================================================
// Constructors
protected TypedAnnotationProxyBase() {}
@@ -54,6 +66,12 @@
public void setValue(String name, Object value, JClass type) {
if (name == null) throw new IllegalArgumentException("null name");
if (value == null) throw new IllegalArgumentException("null value");
+ {
+ // hang onto it in case they ask for it later with getValues
+ if (mValues == null) mValues = new ArrayList();
+ mValues.add(new AnnotationValueImpl
+ ((ElementContext)mContext,name,value,type));
+ }
Method m = getSetterFor(name,value.getClass());
if (m == null) return;
try {
@@ -66,24 +84,20 @@
}
/**
- * <p>Returns an untyped view of the annotation's values. This is built
- * by searching for accessor methods on the extending class. JSR175-style
- * accessors (sans 'get') and java bean getters (with 'get') are both
- * looked for. If a given property has a method for each style, the
- * 175 style method wins.</p>
+ * <p>Returns an untyped view of the annotation's values. These simply
+ * reflect the values which have been passed into it from JAM via the
+ * setValue method. This means they will just be a direct reflection of
+ * whatever was found on 175 annotation or javadoc tag that is being
+ * proxied.</p>
*
- * <p>Extending classes are free to override this method if different
+ * <p>Extending classes are encouraged to override this method if different
* behavior is required.</p>
*/
public JAnnotationValue[] getValues() {
- //FIXME build it up via reflection, i guess. Or maybe we should
- //remember what got set via setMemberValue()? I dunno, it's kind of
- //a weird thing for them to be asking for an untyped version of this
- //annotation for which they've gone to the trouble of building a typed
- //proxy. Somebody will do it, though, so we need to think about what
- //the right thing to do is and do it. They can always override if
- //they dont like it.
- throw new UnsupportedOperationException("NYI");
+ if (mValues == null) return new JAnnotationValue[0];
+ JAnnotationValue[] out = new JAnnotationValue[mValues.size()];
+ mValues.toArray(out);
+ return out;
}
// ========================================================================
@@ -105,4 +119,4 @@
return null;
}
}
-}
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org