luetzkendorf 2005/06/10 05:34:11
Modified: src/share/org/apache/slide/util/conf Populate.java
Log:
fix for problem with variable substitution; dont call getData while parsing
Revision Changes Path
1.10 +13 -20
jakarta-slide/src/share/org/apache/slide/util/conf/Populate.java
Index: Populate.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/share/org/apache/slide/util/conf/Populate.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Populate.java 8 Nov 2004 09:25:02 -0000 1.9
+++ Populate.java 10 Jun 2005 12:34:11 -0000 1.10
@@ -24,6 +24,7 @@
package org.apache.slide.util.conf;
import java.io.IOException;
+import java.util.Stack;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
@@ -42,7 +43,8 @@
private Element _root;
private Element _current;
- private Locator _locator;
+ private Locator _locator;
+ private Stack _content = new Stack();
public Element load(InputSource is, XMLReader parser)
@@ -103,6 +105,8 @@
_current.setName( qName );
for ( i = 0 ; i < attr.getLength() ; ++i )
_current.setAttribute( attr.getQName( i ), attr.getValue( i ) );
+
+ _content.push(new StringBuffer());
}
@@ -125,6 +129,8 @@
qName + " when the element " + _current.getName() +
" should be closed.", _locator );
+ _current.setData(((StringBuffer)_content.pop()).toString());
+
// All we have to do is go back to the parent.
_current = _current.getParent();
}
@@ -136,10 +142,9 @@
*/
public void characters( char[] ch, int start, int length )
throws SAXParseException {
- Object data;
- StringBuffer buf;
-
+
if ( ch == null || length == 0 ) return;
+
// Attempt to place character before or after the root element.
// Should never happen.
if ( _current == null )
@@ -147,19 +152,7 @@
"Attempt to place character before or after the root
element.",
_locator );
- // I am assuming that initially data may be just an empty string, or
a
- // null. I am assuming that multiple calls to character can occur
- // inside the element and that all the character data should be
- // collected as one.
- data = _current.getData();
- if ( data == null || ! ( data instanceof String ) ||
- ( (String) data ).length() == 0 )
- _current.setData( new String( ch, start, length ) );
- else {
- buf = new StringBuffer( (String) data );
- buf.append( ch, start, length );
- _current.setData( buf.toString() );
- }
+ ((StringBuffer)this._content.peek()).append(ch, start, length);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]