View Javadoc
1 package xdoclet.sdk.ant; 2 3 import org.apache.commons.collections.Predicate; 4 import org.apache.tools.ant.IntrospectionHelper; 5 6 import xdoclet.XDocletException; 7 8 import xjavadoc.XClass; 9 import xjavadoc.XMethod; 10 11 import java.util.Enumeration; 12 import java.util.HashMap; 13 import java.util.Map; 14 15 /*** 16 * Predicate that lets through Ant tasks. 17 * 18 * @author <a href="mailto:aslak.hellesoy at bekk.no">Aslak Hellesøy</a> 19 * @version $Revision: 1.4 $ 20 */ 21 public class PropertyMethodPredicate implements Predicate { 22 private Map _attributeTypeMap = new HashMap(); 23 private IntrospectionHelper _introspectionHelper = null; 24 25 public PropertyMethodPredicate(XClass clazz) 26 throws XDocletException { 27 try { 28 _introspectionHelper = IntrospectionHelper.getHelper(Class.forName(clazz.getQualifiedName())); 29 30 // Regroup the attributes, since IntrospectionHelper 31 // doesn't give us the whole data structure directly 32 Enumeration enum = _introspectionHelper.getAttributes(); 33 34 while (enum.hasMoreElements()) { 35 String name = (String) enum.nextElement(); 36 Class type = _introspectionHelper.getAttributeType(name); 37 38 _attributeTypeMap.put(name, type.getName()); 39 } 40 } catch (ClassNotFoundException e) { 41 throw new XDocletException("The compiled classes must be on the classpath", e); 42 } 43 } 44 45 /*** 46 * Returns true if the method is a property method. 47 */ 48 public boolean evaluate(Object o) { 49 XMethod method = (XMethod) o; 50 51 return method.isPropertyAccessor() || method.isPropertyMutator(); 52 } 53 }

This page was automatically generated by Maven