You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/02/26 11:20:26 UTC
svn commit: r631157 -
/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/BcelHelper.java
Author: skitching
Date: Tue Feb 26 02:20:23 2008
New Revision: 631157
URL: http://svn.apache.org/viewvc?rev=631157&view=rev
Log:
Minor code optimisation, documentation improvements
Modified:
myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/BcelHelper.java
Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/BcelHelper.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/BcelHelper.java?rev=631157&r1=631156&r2=631157&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/BcelHelper.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/BcelHelper.java Tue Feb 26 02:20:23 2008
@@ -33,11 +33,25 @@
import java.util.List;
/**
- * Extracts fields/method of the given class using BCEL. <br />
- * This allows us to keep the ordering.
+ * Reimplement the reflection facilities provided by Class.class,
+ * but preserving the order in which the properties exist within
+ * the .class file.
+ * <p>
+ * Presumably the field order in the .class file is the same as the order they are
+ * declared within the source file. And presumably the code author arranged
+ * those in some logical order.
+ * <p>
+ * This class uses the BCEL library to inspect the class data.
*/
public class BcelHelper implements ClassHelper
{
+ /**
+ * Return a list of all the static and non-static fields of the specified
+ * class, regardless of their accessability.
+ * <p>
+ * The array order matches the order in which the fields were declared within
+ * the original source file.
+ */
public Field[] getFields(Class clazz)
{
JavaClass javaClass = Repository.lookupClass(clazz);
@@ -62,6 +76,13 @@
return ret.toArray(new Field[ret.size()]);
}
+ /**
+ * Return a list of all the get*, set* and is* method on the specified class,
+ * regardless of their accessability.
+ * <p>
+ * The array order matches the order in which the methods were declared within
+ * the original source file.
+ */
public Method[] getMethods(Class clazz)
{
JavaClass javaClass = Repository.lookupClass(clazz);
@@ -70,11 +91,8 @@
List<Method> ret = new ArrayList<Method>(methods.length);
for (org.apache.bcel.classfile.Method method : methods)
{
- if ("<init>".equals(method.getName()))
- {
- continue;
- }
- if (!method.getName().startsWith("set") && !method.getName().startsWith("get") && !method.getName().startsWith("is"))
+ String methodName = method.getName();
+ if (!methodName.startsWith("set") && !methodName.startsWith("get") && !methodName.startsWith("is"))
{
continue;
}
@@ -88,7 +106,7 @@
try
{
- ret.add(clazz.getDeclaredMethod(method.getName(), args));
+ ret.add(clazz.getDeclaredMethod(methodName, args));
}
catch (SecurityException e)
{