From 8de9e2154d49bf4cdedd5e3841759f8d4c030546 Mon Sep 17 00:00:00 2001 From: Costin Manolache Date: Sun, 29 Dec 2002 07:31:26 +0000 Subject: [PATCH] Fix the CRLF failure. The test relies on the order of attributes ( cr set before eol ). Probably other tasks are in the same situation. The original change tried to reduce the dependencies on SAX - we may use DOM or direct API calls in future, and the code will become very complex. I just used the same thing that SAX is using ( 2 Vectors to preserve the order ). We could also pick one ( SAX2 attributes ) and use it in all cases. PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273725 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/RuntimeConfigurable.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/org/apache/tools/ant/RuntimeConfigurable.java b/src/main/org/apache/tools/ant/RuntimeConfigurable.java index d3a203a7a..c6cc6239d 100644 --- a/src/main/org/apache/tools/ant/RuntimeConfigurable.java +++ b/src/main/org/apache/tools/ant/RuntimeConfigurable.java @@ -87,8 +87,14 @@ public class RuntimeConfigurable implements Serializable { * XML attributes for the element. */ private transient AttributeList attributes; - /** Attributes are stored in the attMap. + /** Attribute names and values. While the XML spec doesn't require + * preserving the order ( AFAIK ), some ant tests do rely on the + * exact order. The following code is copied from AttributeImpl. + * We could also just use SAX2 Attributes and convert to SAX1 ( DOM + * attribute Nodes can also be stored in SAX2 Attributges ) */ + private Vector attNames=new Vector(); + private Vector attValues=new Vector(); private Hashtable attMap=new Hashtable(); /** Text appearing within the element. */ @@ -141,6 +147,8 @@ public class RuntimeConfigurable implements Serializable { } public void setAttribute( String name, String value ) { + attNames.addElement( name ); + attValues.addElement( value ); attMap.put( name, value ); } @@ -294,10 +302,9 @@ public class RuntimeConfigurable implements Serializable { IntrospectionHelper ih = IntrospectionHelper.getHelper(p, target.getClass()); - Enumeration attNames=attMap.keys(); - while( attNames.hasMoreElements() ) { - String name=(String) attNames.nextElement(); - String value=(String) attMap.get(name); + for( int i=0; i< attNames.size(); i++ ) { + String name=(String) attNames.elementAt(i); + String value=(String) attValues.elementAt(i); // reflect these into the target value = p.replaceProperties(value);