git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269269 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -219,8 +219,9 @@ public class IntrospectionHelper { | |||||
| throws BuildException { | throws BuildException { | ||||
| AttributeSetter as = (AttributeSetter) attributeSetters.get(attributeName); | AttributeSetter as = (AttributeSetter) attributeSetters.get(attributeName); | ||||
| if (as == null) { | if (as == null) { | ||||
| String msg = "Class " + element.getClass().getName() + | |||||
| " doesn't support the \"" + attributeName + "\" attribute"; | |||||
| String msg = getElementName(p, element) + | |||||
| //String msg = "Class " + element.getClass().getName() + | |||||
| " doesn't support the \"" + attributeName + "\" attribute."; | |||||
| throw new BuildException(msg); | throw new BuildException(msg); | ||||
| } | } | ||||
| try { | try { | ||||
| @@ -240,10 +241,11 @@ public class IntrospectionHelper { | |||||
| /** | /** | ||||
| * Adds PCDATA areas. | * Adds PCDATA areas. | ||||
| */ | */ | ||||
| public void addText(Object element, String text) { | |||||
| public void addText(Project project, Object element, String text) { | |||||
| if (addText == null) { | if (addText == null) { | ||||
| String msg = "Class " + element.getClass().getName() + | |||||
| " doesn't support nested text elements"; | |||||
| String msg = getElementName(project, element) + | |||||
| //String msg = "Class " + element.getClass().getName() + | |||||
| " doesn't support nested text data."; | |||||
| throw new BuildException(msg); | throw new BuildException(msg); | ||||
| } | } | ||||
| try { | try { | ||||
| @@ -263,12 +265,13 @@ public class IntrospectionHelper { | |||||
| /** | /** | ||||
| * Creates a named nested element. | * Creates a named nested element. | ||||
| */ | */ | ||||
| public Object createElement(Object element, String elementName) | |||||
| public Object createElement(Project project, Object element, String elementName) | |||||
| throws BuildException { | throws BuildException { | ||||
| NestedCreator nc = (NestedCreator) nestedCreators.get(elementName); | NestedCreator nc = (NestedCreator) nestedCreators.get(elementName); | ||||
| if (nc == null) { | if (nc == null) { | ||||
| String msg = "Class " + element.getClass().getName() + | |||||
| " doesn't support the nested \"" + elementName + "\" element"; | |||||
| String msg = getElementName(project, element) + | |||||
| //String msg = "Class " + element.getClass().getName() + | |||||
| " doesn't support the nested \"" + elementName + "\" element."; | |||||
| throw new BuildException(msg); | throw new BuildException(msg); | ||||
| } | } | ||||
| try { | try { | ||||
| @@ -296,7 +299,7 @@ public class IntrospectionHelper { | |||||
| Class nt = (Class) nestedTypes.get(elementName); | Class nt = (Class) nestedTypes.get(elementName); | ||||
| if (nt == null) { | if (nt == null) { | ||||
| String msg = "Class " + bean.getName() + | String msg = "Class " + bean.getName() + | ||||
| " doesn't support the nested \"" + elementName + "\" element"; | |||||
| " doesn't support the nested \"" + elementName + "\" element."; | |||||
| throw new BuildException(msg); | throw new BuildException(msg); | ||||
| } | } | ||||
| return nt; | return nt; | ||||
| @@ -310,7 +313,7 @@ public class IntrospectionHelper { | |||||
| Class at = (Class) attributeTypes.get(attributeName); | Class at = (Class) attributeTypes.get(attributeName); | ||||
| if (at == null) { | if (at == null) { | ||||
| String msg = "Class " + bean.getName() + | String msg = "Class " + bean.getName() + | ||||
| " doesn't support the \"" + attributeName + "\" attribute"; | |||||
| " doesn't support the \"" + attributeName + "\" attribute."; | |||||
| throw new BuildException(msg); | throw new BuildException(msg); | ||||
| } | } | ||||
| return at; | return at; | ||||
| @@ -500,6 +503,37 @@ public class IntrospectionHelper { | |||||
| return null; | return null; | ||||
| } | } | ||||
| protected String getElementName(Project project, Object element) | |||||
| { | |||||
| Hashtable elements = project.getTaskDefinitions(); | |||||
| String typeName = "task"; | |||||
| if (!elements.contains( element.getClass() )) | |||||
| { | |||||
| elements = project.getDataTypeDefinitions(); | |||||
| typeName = "data type"; | |||||
| if (!elements.contains( element.getClass() )) | |||||
| { | |||||
| elements = null; | |||||
| } | |||||
| } | |||||
| if (elements != null) | |||||
| { | |||||
| Enumeration e = elements.keys(); | |||||
| while (e.hasMoreElements()) | |||||
| { | |||||
| String elementName = (String) e.nextElement(); | |||||
| Class elementClass = (Class) elements.get( elementName ); | |||||
| if ( element.getClass().equals( elementClass ) ) | |||||
| { | |||||
| return "The <" + elementName + "> " + typeName; | |||||
| } | |||||
| } | |||||
| } | |||||
| return "Class " + element.getClass().getName(); | |||||
| } | |||||
| /** | /** | ||||
| * extract the name of a property from a method name - subtracting | * extract the name of a property from a method name - subtracting | ||||
| * a given prefix. | * a given prefix. | ||||
| @@ -490,7 +490,7 @@ public class ProjectHelper { | |||||
| public void characters(char[] buf, int start, int end) throws SAXParseException { | public void characters(char[] buf, int start, int end) throws SAXParseException { | ||||
| if (wrapper == null) { | if (wrapper == null) { | ||||
| try { | try { | ||||
| addText(task, buf, start, end); | |||||
| addText(project, task, buf, start, end); | |||||
| } catch (BuildException exc) { | } catch (BuildException exc) { | ||||
| throw new SAXParseException(exc.getMessage(), locator, exc); | throw new SAXParseException(exc.getMessage(), locator, exc); | ||||
| } | } | ||||
| @@ -536,7 +536,7 @@ public class ProjectHelper { | |||||
| child = new UnknownElement(propType.toLowerCase()); | child = new UnknownElement(propType.toLowerCase()); | ||||
| ((UnknownElement) target).addChild((UnknownElement) child); | ((UnknownElement) target).addChild((UnknownElement) child); | ||||
| } else { | } else { | ||||
| child = ih.createElement(target, propType.toLowerCase()); | |||||
| child = ih.createElement(project, target, propType.toLowerCase()); | |||||
| } | } | ||||
| configureId(child, attrs); | configureId(child, attrs); | ||||
| @@ -556,7 +556,7 @@ public class ProjectHelper { | |||||
| public void characters(char[] buf, int start, int end) throws SAXParseException { | public void characters(char[] buf, int start, int end) throws SAXParseException { | ||||
| if (parentWrapper == null) { | if (parentWrapper == null) { | ||||
| try { | try { | ||||
| addText(child, buf, start, end); | |||||
| addText(project, child, buf, start, end); | |||||
| } catch (BuildException exc) { | } catch (BuildException exc) { | ||||
| throw new SAXParseException(exc.getMessage(), locator, exc); | throw new SAXParseException(exc.getMessage(), locator, exc); | ||||
| } | } | ||||
| @@ -609,7 +609,7 @@ public class ProjectHelper { | |||||
| public void characters(char[] buf, int start, int end) throws SAXParseException { | public void characters(char[] buf, int start, int end) throws SAXParseException { | ||||
| try { | try { | ||||
| addText(element, buf, start, end); | |||||
| addText(project, element, buf, start, end); | |||||
| } catch (BuildException exc) { | } catch (BuildException exc) { | ||||
| throw new SAXParseException(exc.getMessage(), locator, exc); | throw new SAXParseException(exc.getMessage(), locator, exc); | ||||
| } | } | ||||
| @@ -648,15 +648,15 @@ public class ProjectHelper { | |||||
| /** | /** | ||||
| * Adds the content of #PCDATA sections to an element. | * Adds the content of #PCDATA sections to an element. | ||||
| */ | */ | ||||
| public static void addText(Object target, char[] buf, int start, int end) | |||||
| public static void addText(Project project, Object target, char[] buf, int start, int end) | |||||
| throws BuildException { | throws BuildException { | ||||
| addText(target, new String(buf, start, end)); | |||||
| addText(project, target, new String(buf, start, end)); | |||||
| } | } | ||||
| /** | /** | ||||
| * Adds the content of #PCDATA sections to an element. | * Adds the content of #PCDATA sections to an element. | ||||
| */ | */ | ||||
| public static void addText(Object target, String text) | |||||
| public static void addText(Project project, Object target, String text) | |||||
| throws BuildException { | throws BuildException { | ||||
| if (text == null || text.trim().length() == 0) { | if (text == null || text.trim().length() == 0) { | ||||
| @@ -666,7 +666,7 @@ public class ProjectHelper { | |||||
| if(target instanceof TaskAdapter) | if(target instanceof TaskAdapter) | ||||
| target = ((TaskAdapter) target).getProxy(); | target = ((TaskAdapter) target).getProxy(); | ||||
| IntrospectionHelper.getHelper(target.getClass()).addText(target, text); | |||||
| IntrospectionHelper.getHelper(target.getClass()).addText(project, target, text); | |||||
| } | } | ||||
| @@ -135,7 +135,7 @@ public class RuntimeConfigurable { | |||||
| attributes = null; | attributes = null; | ||||
| } | } | ||||
| if (characters.length() != 0) { | if (characters.length() != 0) { | ||||
| ProjectHelper.addText(wrappedObject, characters.toString()); | |||||
| ProjectHelper.addText(p, wrappedObject, characters.toString()); | |||||
| characters.setLength(0); | characters.setLength(0); | ||||
| } | } | ||||
| Enumeration enum = children.elements(); | Enumeration enum = children.elements(); | ||||
| @@ -140,7 +140,7 @@ public class UnknownElement extends Task { | |||||
| for (int i=0; i<children.size(); i++) { | for (int i=0; i<children.size(); i++) { | ||||
| UnknownElement child = (UnknownElement) children.elementAt(i); | UnknownElement child = (UnknownElement) children.elementAt(i); | ||||
| Object realChild = ih.createElement(parent, child.getTag()); | |||||
| Object realChild = ih.createElement(project, parent, child.getTag()); | |||||
| RuntimeConfigurable childWrapper = parentWrapper.getChild(i); | RuntimeConfigurable childWrapper = parentWrapper.getChild(i); | ||||
| childWrapper.setProxy(realChild); | childWrapper.setProxy(realChild); | ||||
| child.handleChildren(realChild, childWrapper); | child.handleChildren(realChild, childWrapper); | ||||