openamf/src/java/org/openamf/util XMLUtils.java,1.5,1.6
[email protected] Sat, 16 Aug 2003 06:11:18 -0700
| Newsgroups | gmane.comp.java.openamf.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/openamf/openamf/src/java/org/openamf/util
In directory sc8-pr-cvs1:/tmp/cvs-serv26881/java/org/openamf/util
Modified Files:
XMLUtils.java
Log Message:
Serializer/Deserializer cleanup
Index: XMLUtils.java
===================================================================
RCS file: /cvsroot/openamf/openamf/src/java/org/openamf/util/XMLUtils.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** XMLUtils.java 9 Aug 2003 16:59:23 -0000 1.5
--- XMLUtils.java 16 Aug 2003 13:11:16 -0000 1.6
***************
*** 8,15 ****
--- 8,22 ----
package org.openamf.util;
+ import java.io.IOException;
+ import java.io.InputStream;
+ import javax.xml.parsers.DocumentBuilder;
+ import javax.xml.parsers.DocumentBuilderFactory;
+
+ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+ import org.xml.sax.InputSource;
/**
***************
*** 37,43 ****
sb.append(node.getNodeValue());
}
!
appendChildren(node, sb);
!
appendEndTag(sb, currentTag);
}
--- 44,50 ----
sb.append(node.getNodeValue());
}
!
appendChildren(node, sb);
!
appendEndTag(sb, currentTag);
}
***************
*** 74,78 ****
sb.append('>');
}
!
!
}
--- 81,103 ----
sb.append('>');
}
!
! /**
! * Reads XML Document from input stream
! *
! * @param is
! * @return Document
! * @throws IOException
! */
! public static Document convertToDOM(InputStream is) throws IOException {
! Document document = null;
! DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
! is.skip(4); // skip length
! try {
! DocumentBuilder builder = factory.newDocumentBuilder();
! document = builder.parse(new InputSource(is));
! } catch (Exception e) {
! throw new IOException("Error while parsing xml: " + e.getMessage());
! }
! return document;
! }
}
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01