User: ara_e_w
Date: 02/02/22 10:14:49
Modified: src/xjavadoc AbstractClass.java ClassDump.java
FieldImpl.java ProxyClass.java SourceClass.java
XClass.java XField.java XJavaDocTest.java
Log:
support for fields: XField/FieldImpl/... and a test case
Revision Changes Path
1.4 +51 -1 xjavadoc/src/xjavadoc/AbstractClass.java
Index: AbstractClass.java
===================================================================
RCS file: /cvsroot/xdoclet/xjavadoc/src/xjavadoc/AbstractClass.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -r1.3 -r1.4
--- AbstractClass.java 20 Feb 2002 00:12:01 -0000 1.3
+++ AbstractClass.java 22 Feb 2002 18:14:49 -0000 1.4
@@ -96,7 +96,7 @@
/**
* @todo-javadoc Describe the field
*/
- private HashMap _fields = new HashMap();
+ private XField[] _xfields;
/**
* @todo-javadoc Describe the field
@@ -120,6 +120,15 @@
/**
* @todo-javadoc Describe the field
*/
+ private ArrayList _fields = new ArrayList();
+ /**
+ * @todo-javadoc Describe the field
+ */
+ private HashMap _namedFields = new HashMap();
+
+ /**
+ * @todo-javadoc Describe the field
+ */
private String _containingPackage = "";
/**
@@ -225,6 +234,18 @@
/**
+ * Returns an XField with the given name. Example: getField("id");
+ *
+ * @param name Describe what the parameter does
+ * @return The Field value
+ * @todo-javadoc Write javadocs for method parameter
+ */
+ public final XField getField(String name) {
+ return (XField)_namedFields.get(name);
+ }
+
+
+ /**
* Describe what the method does
*
* @return Describe the return value
@@ -324,6 +345,22 @@
/**
+ * Describe what the method does
+ *
+ * @return Describe the return value
+ * @todo-javadoc Write javadocs for method
+ * @todo-javadoc Write javadocs for return value
+ */
+ public final XField[] fields() {
+ if (_xfields == null) {
+ _xfields = new XField[_fields.size()];
+ _xfields = (XField[])_fields.toArray(_xfields);
+ }
+ return _xfields;
+ }
+
+
+ /**
* Gets the constructors.
*
* @todo If there are no constructors in the source code, we must add a public
@@ -380,6 +417,19 @@
_methods.add(method);
String methodWithSignature = new
StringBuffer(method.name()).append(method.signature()).toString();
_namedMethods.put(methodWithSignature, method);
+ }
+
+
+ /**
+ * Describe the method
+ *
+ * @param field Describe the method parameter
+ * @todo-javadoc Describe the method
+ * @todo-javadoc Describe the method parameter
+ */
+ public final void addField(XField field) {
+ _fields.add(field);
+ _namedFields.put(field.name(), field);
}
1.6 +7 -1 xjavadoc/src/xjavadoc/ClassDump.java
Index: ClassDump.java
===================================================================
RCS file: /cvsroot/xdoclet/xjavadoc/src/xjavadoc/ClassDump.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -r1.5 -r1.6
--- ClassDump.java 20 Feb 2002 00:12:01 -0000 1.5
+++ ClassDump.java 22 Feb 2002 18:14:49 -0000 1.6
@@ -44,7 +44,7 @@
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @author <a href="mailto:[EMAIL PROTECTED]">Aslak Helles�y</a>
* @created Feb 2, 2002
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public class ClassDump extends Task {
@@ -149,6 +149,12 @@
for (int i = 0; i < constructors.length; i++) {
XConstructor constructor = constructors[i];
System.out.println("constructor=" + constructor);
+ }
+
+ XField[] fields = clazz.fields();
+ for (int i = 0; i < fields.length; i++) {
+ XField field = fields[i];
+ System.out.println("field=" + field);
}
XMethod[] methods = clazz.methods();
1.3 +88 -1 xjavadoc/src/xjavadoc/FieldImpl.java
Index: FieldImpl.java
===================================================================
RCS file: /cvsroot/xdoclet/xjavadoc/src/xjavadoc/FieldImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- FieldImpl.java 20 Feb 2002 00:12:01 -0000 1.2
+++ FieldImpl.java 22 Feb 2002 18:14:49 -0000 1.3
@@ -41,9 +41,20 @@
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @author <a href="mailto:[EMAIL PROTECTED]">Aslak Helles�y</a>
* @created Feb 15, 2002
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
class FieldImpl extends AbstractProgramElement implements XField {
+
+ /**
+ * @todo-javadoc Describe the field
+ */
+ private String _type;
+ /**
+ * @todo-javadoc Describe the field
+ */
+ private int _dimension;
+
+
/**
* Describe what the SourceMethod constructor does
*
@@ -60,6 +71,46 @@
/**
+ * Sets the Type attribute of the FieldImpl object
+ *
+ * @param type The new Type value
+ */
+ public void setType(String type) {
+ _type = type;
+ }
+
+
+ /**
+ * Sets the TypeDimension attribute of the FieldImpl object
+ *
+ * @param dimension The new TypeDimension value
+ */
+ public void setDimension(int dimension) {
+ _dimension = dimension;
+ }
+
+
+ /**
+ * Gets the Type attribute of the FieldImpl object
+ *
+ * @return The Type value
+ */
+ public String getType() {
+ return _type;
+ }
+
+
+ /**
+ * Gets the TypeDimension attribute of the FieldImpl object
+ *
+ * @return The TypeDimension value
+ */
+ public int getDimension() {
+ return _dimension;
+ }
+
+
+ /**
* Gets the Transient attribute of the FieldImpl object
*
* @return The Transient value
@@ -76,5 +127,41 @@
*/
public final boolean isVolatile() {
return (modifierSpecifier() & Modifier.VOLATILE) != 0;
+ }
+
+
+ /**
+ * Describe what the method does
+ *
+ * @return Describe the return value
+ * @todo-javadoc Write javadocs for method
+ * @todo-javadoc Write javadocs for return value
+ */
+ public XClass type() {
+ return containingClass().qualify(_type);
+ }
+
+
+ /**
+ * Describe what the method does
+ *
+ * @return Describe the return value
+ * @todo-javadoc Write javadocs for method
+ * @todo-javadoc Write javadocs for return value
+ */
+ public int dimension() {
+ return _dimension;
+ }
+
+
+ /**
+ * Describe what the method does
+ *
+ * @return Describe the return value
+ * @todo-javadoc Write javadocs for method
+ * @todo-javadoc Write javadocs for return value
+ */
+ public String toString() {
+ return name();
}
}
1.3 +26 -0 xjavadoc/src/xjavadoc/ProxyClass.java
Index: ProxyClass.java
===================================================================
RCS file: /cvsroot/xdoclet/xjavadoc/src/xjavadoc/ProxyClass.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- ProxyClass.java 20 Feb 2002 00:12:01 -0000 1.2
+++ ProxyClass.java 22 Feb 2002 18:14:49 -0000 1.3
@@ -155,6 +155,19 @@
/**
+ * Gets the Method attribute of the ProxyClass object
+ *
+ * @param name Describe what the parameter does
+ * @return The Method value
+ * @todo-javadoc Write javadocs for method parameter
+ */
+ public XField getField(String name) {
+ resolve();
+ return _subject.getField(name);
+ }
+
+
+ /**
* Gets the Abstract attribute of the ProxyClass object
*
* @return The Abstract value
@@ -334,6 +347,19 @@
public XMethod[] methods() {
resolve();
return _subject.methods();
+ }
+
+
+ /**
+ * Describe what the method does
+ *
+ * @return Describe the return value
+ * @todo-javadoc Write javadocs for method
+ * @todo-javadoc Write javadocs for return value
+ */
+ public XField[] fields() {
+ resolve();
+ return _subject.fields();
}
1.3 +0 -5 xjavadoc/src/xjavadoc/SourceClass.java
Index: SourceClass.java
===================================================================
RCS file: /cvsroot/xdoclet/xjavadoc/src/xjavadoc/SourceClass.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- SourceClass.java 20 Feb 2002 00:12:01 -0000 1.2
+++ SourceClass.java 22 Feb 2002 18:14:49 -0000 1.3
@@ -52,11 +52,6 @@
/**
* @todo-javadoc Describe the field
*/
- private final HashMap _methodMap = new HashMap();
-
- /**
- * @todo-javadoc Describe the field
- */
// private ASTCompilationUnit _compilationUnit;
private SimpleNode _compilationUnit;
1.13 +20 -0 xjavadoc/src/xjavadoc/XClass.java
Index: XClass.java
===================================================================
RCS file: /cvsroot/xdoclet/xjavadoc/src/xjavadoc/XClass.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -w -r1.12 -r1.13
--- XClass.java 20 Feb 2002 00:12:01 -0000 1.12
+++ XClass.java 22 Feb 2002 18:14:49 -0000 1.13
@@ -57,6 +57,16 @@
/**
+ * Gets the Field attribute of the XClass object
+ *
+ * @param name Describe what the parameter does
+ * @return The Method value
+ * @todo-javadoc Write javadocs for method parameter
+ */
+ public XField getField(String name);
+
+
+ /**
* Gets the Abstract attribute of the XClass object
*
* @return The Abstract value
@@ -140,6 +150,16 @@
* @todo-javadoc Write javadocs for return value
*/
public XMethod[] methods();
+
+
+ /**
+ * Describe what the method does
+ *
+ * @return Describe the return value
+ * @todo-javadoc Write javadocs for method
+ * @todo-javadoc Write javadocs for return value
+ */
+ public XField[] fields();
/**
1.3 +19 -0 xjavadoc/src/xjavadoc/XField.java
Index: XField.java
===================================================================
RCS file: /cvsroot/xdoclet/xjavadoc/src/xjavadoc/XField.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- XField.java 20 Feb 2002 00:12:01 -0000 1.2
+++ XField.java 22 Feb 2002 18:14:49 -0000 1.3
@@ -58,4 +58,23 @@
* @return The Volatile value
*/
public boolean isVolatile();
+
+
+ /**
+ * Get type of this field.
+ *
+ * @return Describe the return value
+ * @todo-javadoc Write javadocs for return value
+ */
+ public XClass type();
+
+
+ /**
+ * Describe what the method does
+ *
+ * @return Describe the return value
+ * @todo-javadoc Write javadocs for method
+ * @todo-javadoc Write javadocs for return value
+ */
+ public int dimension();
}
1.11 +15 -0 xjavadoc/src/xjavadoc/XJavaDocTest.java
Index: XJavaDocTest.java
===================================================================
RCS file: /cvsroot/xdoclet/xjavadoc/src/xjavadoc/XJavaDocTest.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -w -r1.10 -r1.11
--- XJavaDocTest.java 20 Feb 2002 00:12:01 -0000 1.10
+++ XJavaDocTest.java 22 Feb 2002 18:14:49 -0000 1.11
@@ -107,6 +107,21 @@
/**
+ * A unit test for JUnit
+ */
+ public void testField() {
+
+ XClass clazz = XJavaDoc.getInstance().getXClass("Hello", true);
+ XField name_field = clazz.getField("name");
+ XDoc doc = name_field.doc();
+ assertEquals("Braba papa, barba mama, baraba brother, barba sister",
doc.firstSentence());
+ assertEquals("name", name_field.name());
+ assertEquals(0, name_field.dimension());
+ assertEquals("java.lang.String", name_field.type().qualifiedName());
+ }
+
+
+ /**
* Read a class, modify it, reread it and see if change was successful.
*
* @todo reread
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel