コード例 #1
0
ファイル: XMLDom.java プロジェクト: albertoanguita/jacuzzi
 public static Element parseWithCRC(InputStream inputStream)
     throws XMLStreamException, CRCMismatchException {
   XMLInputFactory xif = XMLInputFactory.newFactory();
   Element element = parse(xif.createXMLStreamReader(inputStream));
   checkCRC(element);
   element.removeChildren(CRC_ELEMENT);
   return element;
 }
コード例 #2
0
ファイル: XMLDom.java プロジェクト: albertoanguita/jacuzzi
 //    public static void write(OutputStream stream, Element element, int hashLength) throws
 // XMLStreamException {
 //        XMLOutputFactory xof = XMLOutputFactory.newInstance();
 //        IndentingXMLStreamWriter xtw = new
 // IndentingXMLStreamWriter(xof.createXMLStreamWriter(stream));
 //        writeXMLStreamWriter(xtw, element, hashLength);
 //    }
 //
 private static void writeXMLStreamWriter(XMLStreamWriter xtw, Element element, int hashLength)
     throws XMLStreamException {
   if (hashLength > 0) {
     String hash = element.getHash(hashLength);
     Element hashElement = new Element(CRC_ELEMENT);
     hashElement.setText(hash);
     element.addChild(hashElement);
   }
   writeElement(xtw, element);
   xtw.writeEndDocument();
   xtw.flush();
   xtw.close();
   if (hashLength > 0) {
     element.removeChildren(CRC_ELEMENT);
   }
 }