User: ara_e_w
Date: 02/02/22 10:44:41
Modified: src/xjavadoc AbstractExecutableMember.java
Log:
a mini optimization
Revision Changes Path
1.3 +75 -11 xjavadoc/src/xjavadoc/AbstractExecutableMember.java
Index: AbstractExecutableMember.java
===================================================================
RCS file: /cvsroot/xdoclet/xjavadoc/src/xjavadoc/AbstractExecutableMember.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- AbstractExecutableMember.java 20 Feb 2002 00:12:01 -0000 1.2
+++ AbstractExecutableMember.java 22 Feb 2002 18:44:41 -0000 1.3
@@ -35,6 +35,8 @@
*/
package xjavadoc;
+import xjavadoc.XParameter;
+
import java.util.ArrayList;
import java.lang.reflect.Modifier;
@@ -50,11 +52,28 @@
/**
* @todo-javadoc Describe the field
*/
- private final ArrayList _parameters = new ArrayList();
+ private ArrayList _parameters;
+ /**
+ * @todo-javadoc Describe the field
+ */
+ private XParameter[] _xparameters;
+
+ /**
+ * @todo-javadoc Describe the field
+ */
+ private ArrayList _thrownExceptions;
+ /**
+ * @todo-javadoc Describe the field
+ */
+ private XClass[] _xthrownExceptions;
/**
* @todo-javadoc Describe the field
*/
- private final ArrayList _thrownExceptions = new ArrayList();
+ private final static XParameter[] NULL_PARAMETERS = new XParameter[0];
+ /**
+ * @todo-javadoc Describe the field
+ */
+ private final static XClass[] NULL_THROWN_EXCEPTIONS = new XClass[0];
/**
@@ -108,8 +127,17 @@
* @todo-javadoc Write javadocs for return value
*/
public XParameter[] parameters() {
- XParameter[] result = new XParameter[_parameters.size()];
- return (XParameter[])_parameters.toArray(result);
+
+ if (_parameters == null) {
+ return NULL_PARAMETERS;
+ }
+
+ if (_xparameters == null) {
+ _xparameters = new XParameter[_parameters.size()];
+ _xparameters = (XParameter[])_parameters.toArray(_xparameters);
+ }
+
+ return _xparameters;
}
@@ -121,12 +149,20 @@
* @todo-javadoc Write javadocs for return value
*/
public XClass[] thrownExceptions() {
- XClass[] thrownExceptions = new XClass[_thrownExceptions.size()];
- for (int i = 0; i < thrownExceptions.length; i++) {
+
+ if (_thrownExceptions == null) {
+ return NULL_THROWN_EXCEPTIONS;
+ }
+
+ if (_xthrownExceptions == null) {
+ _xthrownExceptions = new XClass[_thrownExceptions.size()];
+ for (int i = 0; i < _xthrownExceptions.length; i++) {
String exceptionName = (String)_thrownExceptions.get(i);
- thrownExceptions[i] = containingClass().qualify(exceptionName);
+ _xthrownExceptions[i] =
containingClass().qualify(exceptionName);
}
- return thrownExceptions;
+ }
+
+ return _xthrownExceptions;
}
@@ -138,7 +174,7 @@
* @todo-javadoc Describe the method parameter
*/
public void addParameter(XParameter parameter) {
- _parameters.add(parameter);
+ getParameters().add(parameter);
}
@@ -150,7 +186,7 @@
* @todo-javadoc Describe the method parameter
*/
public void addThrownException(String thrownException) {
- _thrownExceptions.add(thrownException);
+ getThrownException().add(thrownException);
}
@@ -171,6 +207,34 @@
}
}
return sb.append(")").toString();
+ }
+
+
+ /**
+ * Gets the Parameters attribute of the AbstractExecutableMember object
+ *
+ * @return The Parameters value
+ */
+ protected ArrayList getParameters() {
+ if (_parameters == null) {
+ _parameters = new ArrayList();
+ }
+
+ return _parameters;
+ }
+
+
+ /**
+ * Gets the ThrownException attribute of the AbstractExecutableMember object
+ *
+ * @return The ThrownException value
+ */
+ protected ArrayList getThrownException() {
+ if (_thrownExceptions == null) {
+ _thrownExceptions = new ArrayList();
+ }
+
+ return _thrownExceptions;
}
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel