From fc9085997489296fefa9bf8994033cf6cb1f05f1 Mon Sep 17 00:00:00 2001 From: Conor MacNeill Date: Sat, 20 Jan 2001 13:41:56 +0000 Subject: [PATCH] Remove the concept of a factory method for creating nested elements git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268488 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/IntrospectionHelper.java | 37 +++---------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/src/main/org/apache/tools/ant/IntrospectionHelper.java b/src/main/org/apache/tools/ant/IntrospectionHelper.java index 862e82531..e358e37e3 100644 --- a/src/main/org/apache/tools/ant/IntrospectionHelper.java +++ b/src/main/org/apache/tools/ant/IntrospectionHelper.java @@ -95,13 +95,6 @@ public class IntrospectionHelper { */ private Method addText = null; - /** - * The method used to add nested elements which can't be added through - * nested creators. It allows a task to define a factory method for creating - * nested elements. - */ - private Method elementFactoryMethod = null; - /** * The Class that's been introspected. */ @@ -145,14 +138,6 @@ public class IntrospectionHelper { && java.lang.String.class.equals(args[0])) { addText = methods[i]; - - } else if ("createElement".equals(name) - && !returnType.isArray() - && !returnType.isPrimitive() - && args.length == 1 - && java.lang.String.class.equals(args[0])) { - - elementFactoryMethod = methods[i]; } else if (name.startsWith("set") && java.lang.Void.TYPE.equals(returnType) @@ -281,23 +266,13 @@ public class IntrospectionHelper { public Object createElement(Object element, String elementName) throws BuildException { NestedCreator nc = (NestedCreator) nestedCreators.get(elementName); + if (nc == null) { + String msg = "Class " + element.getClass().getName() + + " doesn't support the nested \"" + elementName + "\" element"; + throw new BuildException(msg); + } try { - if (nc == null) { - Object nestedElement = null; - if (elementFactoryMethod != null) { - nestedElement - = elementFactoryMethod.invoke(element, new Object[] {elementName}); - } - if (nestedElement == null) { - String msg = "Class " + element.getClass().getName() + - " doesn't support the nested \"" + elementName + "\" element"; - throw new BuildException(msg); - } - return nestedElement; - } - else { - return nc.create(element); - } + return nc.create(element); } catch (IllegalAccessException ie) { // impossible as getMethods should only return public methods throw new BuildException(ie);