[cvs] Expresso commit by mtraum: characters() is not guaranteed to
receive
JCorporate Ltd
jcorp at jcorp2.servlets.net
Mon Oct 4 13:25:45 PDT 2004
Log Message:
-----------
characters() is not guaranteed to receive all of the data in one call, so move the locid down to endElement
Modified Files:
--------------
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/xml/dbobj:
XMLImportDocument.java
Revision Data
-------------
Index: XMLImportDocument.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/xml/dbobj/XMLImportDocument.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/xml/dbobj/XMLImportDocument.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/xml/dbobj/XMLImportDocument.java -u -r1.14 -r1.15
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/xml/dbobj/XMLImportDocument.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/xml/dbobj/XMLImportDocument.java
@@ -69,6 +69,8 @@
import com.jcorporate.expresso.core.db.DBException;
import com.jcorporate.expresso.core.dbobj.DBObject;
import com.jcorporate.expresso.core.misc.URLUTF8Encoder;
+import com.jcorporate.expresso.kernel.util.FastStringBuffer;
+
import org.apache.log4j.Logger;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@@ -88,6 +90,7 @@
extends DefaultHandler {
private DataObject myDBObject = null;
private String currentItem = ("None");
+ private FastStringBuffer theData = new FastStringBuffer();
private static final String thisClass = XMLImportDocument.class.getName() + ".";
private String currentFieldName = ("None");
private Vector errorList = new Vector(3);
@@ -131,8 +134,7 @@
public void characters(char[] ch, int start, int length)
throws SAXException {
String myName = (thisClass + "characters(char[], int, int)");
- StringBuffer theData = new StringBuffer("");
-
+
for (int i = start; i < start + length; i++) {
theData.append(ch[i]);
}
@@ -141,8 +143,40 @@
log.debug("Data for " + currentItem + ":" +
theData.toString());
}
+ } /* characters(char[], int, int) */
+
+
+ /**
+ * DefaultHandler implementation for SAX parsing.
+ * Creation date: (4/6/00 8:27:22 PM)
+ *
+ * @throws SAXException
+ */
+ public void endDocument()
+ throws SAXException {
+ log.debug("End document");
+
+ if (myDBObject != null) {
+ saveDBObject();
+ } else {
+ throw new SAXException("Database object is null - Unable to save object");
+ }
+ } /* endDocument() */
+
- if (currentItem.equals("ObjectName")) {
+ /**
+ * DefaultHandler implementation for SAX parsing.
+ *
+ * @param uri
+ * @param localpart
+ * @param rawname
+ */
+ public void endElement(String uri, String localpart, String rawname)
+ throws SAXException {
+ String myName = (thisClass + "endElement(String, String, String)");
+ log.debug("End:" + rawname);
+
+ if (rawname.equals("ObjectName")) {
log.debug("Record count was " + recordCount);
/* New object */
@@ -166,9 +200,9 @@
} catch (Exception eeother) {
throw new SAXException(eeother.getMessage());
}
- } else if (currentItem.equals("FieldName")) {
+ } else if (rawname.equals("FieldName")) {
currentFieldName = theData.toString();
- } else if (currentItem.equals("FieldValue")) {
+ } else if (rawname.equals("FieldValue")) {
if (myDBObject != null) {
try {
myDBObject.set(currentFieldName,
@@ -182,39 +216,6 @@
}
}
- currentItem = ("None");
- } /* characters(char[], int, int) */
-
-
- /**
- * DefaultHandler implementation for SAX parsing.
- * Creation date: (4/6/00 8:27:22 PM)
- *
- * @throws SAXException
- */
- public void endDocument()
- throws SAXException {
- log.debug("End document");
-
- if (myDBObject != null) {
- saveDBObject();
- } else {
- throw new SAXException("Database object is null - Unable to save object");
- }
- } /* endDocument() */
-
-
- /**
- * DefaultHandler implementation for SAX parsing.
- *
- * @param uri
- * @param localpart
- * @param rawname
- */
- public void endElement(String uri, String localpart, String rawname)
- throws SAXException {
- log.debug("End:" + rawname);
-
if (rawname.equals("DataRecord")) {
log.debug("--> Saving datarecord");
@@ -224,6 +225,8 @@
throw new SAXException("DataObject was null - Error saving object");
}
}
+
+ theData.clear();
} /* endElement(String) */
More information about the cvs
mailing list