Package org.codehaus.stax2

Examples of org.codehaus.stax2.XMLStreamReader2.nextTag()


    }
    XMLInputFactory2 factory = getInputFactory();
    XMLStreamReader2 reader = (XMLStreamReader2) factory.createXMLStreamReader(getClass().getResourceAsStream("test-message.xml"), "utf-8");
    QName msgQName = new QName("http://server.hw.demo/", "sayHi");
    while (true) {
      int what = reader.nextTag();
      if (what == XMLStreamConstants.START_ELEMENT) {
        if (reader.getName().equals(msgQName)) {
          reader.validateAgainst(schema);
        }
      } else if (what == XMLStreamConstants.END_ELEMENT) {
View Full Code Here


        // note, should check 'if (conn.getResponseCode() != 200) ...'
       
        // Ok, let's read it then... (note: StaxMate could simplify a lot!)
        InputStream in = conn.getInputStream();
        XMLStreamReader2 sr = (XMLStreamReader2) _xmlInputFactory.createXMLStreamReader(in);
        sr.nextTag(); // to "files"
        byte[] buffer = new byte[4000];
       
        while (sr.nextTag() != XMLStreamConstants.END_ELEMENT) { // one more 'file'
            String filename = sr.getAttributeValue("", "name");
            String csumType = sr.getAttributeValue("", "checksumType");
View Full Code Here

        InputStream in = conn.getInputStream();
        XMLStreamReader2 sr = (XMLStreamReader2) _xmlInputFactory.createXMLStreamReader(in);
        sr.nextTag(); // to "files"
        byte[] buffer = new byte[4000];
       
        while (sr.nextTag() != XMLStreamConstants.END_ELEMENT) { // one more 'file'
            String filename = sr.getAttributeValue("", "name");
            String csumType = sr.getAttributeValue("", "checksumType");
            File outputFile = new File(toDir, filename);
            FileOutputStream out = new FileOutputStream(outputFile);
            files.add(outputFile);
View Full Code Here

                md.update(buffer, 0, count);
                out.write(buffer, 0, count);
            }
            out.close();
            // Then verify checksum
            sr.nextTag()
            byte[] expectedCsum = sr.getAttributeAsBinary(sr.getAttributeIndex("", "value"));
            byte[] actualCsum = md.digest();
            if (!Arrays.equals(expectedCsum, actualCsum)) {
                throw new IllegalArgumentException("File '"+filename+"' corrupt: content checksum does not match expected");
            }
View Full Code Here

            byte[] expectedCsum = sr.getAttributeAsBinary(sr.getAttributeIndex("", "value"));
            byte[] actualCsum = md.digest();
            if (!Arrays.equals(expectedCsum, actualCsum)) {
                throw new IllegalArgumentException("File '"+filename+"' corrupt: content checksum does not match expected");
            }
            sr.nextTag(); // to match closing "checksum"
        }
        return files;
    }

    public static void main(String[] args) throws Exception
View Full Code Here

  @Override
  @NotNull
  public T deserialize( @NotNull InputStream in, @Nullable Lookup context ) throws IOException {
    try {
      XMLStreamReader2 reader = StaxSupport.getSmInputFactory().createStax2Reader( in );
      reader.nextTag();
      T deserialized = deserialize( reader, context != null ? context : Lookups.emtyLookup() );

      if ( !reader.isEndElement() ) {
        throw new IllegalStateException( "Not consumed everything in <" + getClass().getName() + ">" );
      }
View Full Code Here

      Version version = Version.parse( getProcessingInstructionData( reader, PI_TARGET_FORMAT ) );
      if ( !getFormatVersionRange().contains( version ) ) {
        throw new VersionMismatchException( getFormatVersion(), version );
      }

      reader.nextTag();
      T deserialized = deserialize( reader, context != null ? context : Lookups.emtyLookup() );

      if ( !reader.isEndElement() ) {
        throw new IllegalStateException( "Not consumed everything in <" + getClass().getName() + ">" );
      }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.