Java Code Examples for javax.xml.stream.XMLStreamReader#START_DOCUMENT

The following examples show how to use javax.xml.stream.XMLStreamReader#START_DOCUMENT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamReaderBufferCreator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void store(XMLStreamReader reader) throws XMLStreamException {
    if (!reader.hasNext()) {
        return;
    }

    _eventType = reader.getEventType();
    switch (_eventType) {
        case XMLStreamReader.START_DOCUMENT:
            storeDocumentAndChildren(reader);
            break;
        case XMLStreamReader.START_ELEMENT:
            storeElementAndChildren(reader);
            break;
        default:
            throw new XMLStreamException("XMLStreamReader not positioned at a document or element");
    }

    increaseTreeCount();
}
 
Example 2
Source File: SAAJMessage.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected XMLStreamReader soapBodyFirstChildReader() {
    if (soapBodyFirstChildReader != null) return soapBodyFirstChildReader;
    soapBodyFirstChild();
    if (soapBodyFirstChild != null) {
        soapBodyFirstChildReader = getXMLStreamReader(soapBodyFirstChild);
        if (soapBodyFirstChildReader == null) soapBodyFirstChildReader =
            createXMLStreamReader(soapBodyFirstChild);
        if (soapBodyFirstChildReader.getEventType() == XMLStreamReader.START_DOCUMENT) {
            try {
                while(soapBodyFirstChildReader.getEventType() != XMLStreamReader.START_ELEMENT)
                    soapBodyFirstChildReader.next();
            } catch (XMLStreamException e) {
                throw new RuntimeException(e);
            }
        }
        return soapBodyFirstChildReader;
    } else {
        payloadLocalName = null;
        payloadNamespace = null;
        return null;
    }
}
 
Example 3
Source File: StreamReaderBufferCreator.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private void store(XMLStreamReader reader) throws XMLStreamException {
    if (!reader.hasNext()) {
        return;
    }

    _eventType = reader.getEventType();
    switch (_eventType) {
        case XMLStreamReader.START_DOCUMENT:
            storeDocumentAndChildren(reader);
            break;
        case XMLStreamReader.START_ELEMENT:
            storeElementAndChildren(reader);
            break;
        default:
            throw new XMLStreamException("XMLStreamReader not positioned at a document or element");
    }

    increaseTreeCount();
}
 
Example 4
Source File: SAAJMessage.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
protected XMLStreamReader soapBodyFirstChildReader() {
    if (soapBodyFirstChildReader != null) return soapBodyFirstChildReader;
    soapBodyFirstChild();
    if (soapBodyFirstChild != null) {
        soapBodyFirstChildReader = getXMLStreamReader(soapBodyFirstChild);
        if (soapBodyFirstChildReader == null) soapBodyFirstChildReader =
            createXMLStreamReader(soapBodyFirstChild);
        if (soapBodyFirstChildReader.getEventType() == XMLStreamReader.START_DOCUMENT) {
            try {
                while(soapBodyFirstChildReader.getEventType() != XMLStreamReader.START_ELEMENT)
                    soapBodyFirstChildReader.next();
            } catch (XMLStreamException e) {
                throw new RuntimeException(e);
            }
        }
        return soapBodyFirstChildReader;
    } else {
        payloadLocalName = null;
        payloadNamespace = null;
        return null;
    }
}
 
Example 5
Source File: StreamReaderBufferCreator.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private void store(XMLStreamReader reader) throws XMLStreamException {
    if (!reader.hasNext()) {
        return;
    }

    _eventType = reader.getEventType();
    switch (_eventType) {
        case XMLStreamReader.START_DOCUMENT:
            storeDocumentAndChildren(reader);
            break;
        case XMLStreamReader.START_ELEMENT:
            storeElementAndChildren(reader);
            break;
        default:
            throw new XMLStreamException("XMLStreamReader not positioned at a document or element");
    }

    increaseTreeCount();
}
 
Example 6
Source File: SAAJMessage.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
protected XMLStreamReader soapBodyFirstChildReader() {
    if (soapBodyFirstChildReader != null) return soapBodyFirstChildReader;
    soapBodyFirstChild();
    if (soapBodyFirstChild != null) {
        soapBodyFirstChildReader = getXMLStreamReader(soapBodyFirstChild);
        if (soapBodyFirstChildReader == null) soapBodyFirstChildReader =
            createXMLStreamReader(soapBodyFirstChild);
        if (soapBodyFirstChildReader.getEventType() == XMLStreamReader.START_DOCUMENT) {
            try {
                while(soapBodyFirstChildReader.getEventType() != XMLStreamReader.START_ELEMENT)
                    soapBodyFirstChildReader.next();
            } catch (XMLStreamException e) {
                throw new RuntimeException(e);
            }
        }
        return soapBodyFirstChildReader;
    } else {
        payloadLocalName = null;
        payloadNamespace = null;
        return null;
    }
}
 
Example 7
Source File: StreamReaderBufferCreator.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private void store(XMLStreamReader reader) throws XMLStreamException {
    if (!reader.hasNext()) {
        return;
    }

    _eventType = reader.getEventType();
    switch (_eventType) {
        case XMLStreamReader.START_DOCUMENT:
            storeDocumentAndChildren(reader);
            break;
        case XMLStreamReader.START_ELEMENT:
            storeElementAndChildren(reader);
            break;
        default:
            throw new XMLStreamException("XMLStreamReader not positioned at a document or element");
    }

    increaseTreeCount();
}
 
Example 8
Source File: SAAJMessage.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
protected XMLStreamReader soapBodyFirstChildReader() {
    if (soapBodyFirstChildReader != null) return soapBodyFirstChildReader;
    soapBodyFirstChild();
    if (soapBodyFirstChild != null) {
        soapBodyFirstChildReader = getXMLStreamReader(soapBodyFirstChild);
        if (soapBodyFirstChildReader == null) soapBodyFirstChildReader =
            createXMLStreamReader(soapBodyFirstChild);
        if (soapBodyFirstChildReader.getEventType() == XMLStreamReader.START_DOCUMENT) {
            try {
                while(soapBodyFirstChildReader.getEventType() != XMLStreamReader.START_ELEMENT)
                    soapBodyFirstChildReader.next();
            } catch (XMLStreamException e) {
                throw new RuntimeException(e);
            }
        }
        return soapBodyFirstChildReader;
    } else {
        payloadLocalName = null;
        payloadNamespace = null;
        return null;
    }
}
 
Example 9
Source File: TimeStaxReading.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
static String eventName(int type) {
  switch (type) {
    case XMLStreamReader.START_DOCUMENT:
      return " startDoc";
    case XMLStreamReader.START_ELEMENT:
      return "startElem";
    case XMLStreamReader.END_DOCUMENT:
      return "   endDoc";
    case XMLStreamReader.END_ELEMENT:
      return "  endElem";
    case XMLStreamReader.ATTRIBUTE:
      return "attribute";
    case XMLStreamReader.CHARACTERS:
      return "    chars";
    default:
      return " " + type;
  }
}
 
Example 10
Source File: SAAJMessage.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
protected XMLStreamReader soapBodyFirstChildReader() {
    if (soapBodyFirstChildReader != null) return soapBodyFirstChildReader;
    soapBodyFirstChild();
    if (soapBodyFirstChild != null) {
        soapBodyFirstChildReader = getXMLStreamReader(soapBodyFirstChild);
        if (soapBodyFirstChildReader == null) soapBodyFirstChildReader =
            createXMLStreamReader(soapBodyFirstChild);
        if (soapBodyFirstChildReader.getEventType() == XMLStreamReader.START_DOCUMENT) {
            try {
                while(soapBodyFirstChildReader.getEventType() != XMLStreamReader.START_ELEMENT)
                    soapBodyFirstChildReader.next();
            } catch (XMLStreamException e) {
                throw new RuntimeException(e);
            }
        }
        return soapBodyFirstChildReader;
    } else {
        payloadLocalName = null;
        payloadNamespace = null;
        return null;
    }
}
 
Example 11
Source File: StreamReaderBufferCreator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void store(XMLStreamReader reader) throws XMLStreamException {
    if (!reader.hasNext()) {
        return;
    }

    _eventType = reader.getEventType();
    switch (_eventType) {
        case XMLStreamReader.START_DOCUMENT:
            storeDocumentAndChildren(reader);
            break;
        case XMLStreamReader.START_ELEMENT:
            storeElementAndChildren(reader);
            break;
        default:
            throw new XMLStreamException("XMLStreamReader not positioned at a document or element");
    }

    increaseTreeCount();
}
 
Example 12
Source File: SAAJMessage.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected XMLStreamReader soapBodyFirstChildReader() {
    if (soapBodyFirstChildReader != null) return soapBodyFirstChildReader;
    soapBodyFirstChild();
    if (soapBodyFirstChild != null) {
        soapBodyFirstChildReader = getXMLStreamReader(soapBodyFirstChild);
        if (soapBodyFirstChildReader == null) soapBodyFirstChildReader =
            createXMLStreamReader(soapBodyFirstChild);
        if (soapBodyFirstChildReader.getEventType() == XMLStreamReader.START_DOCUMENT) {
            try {
                while(soapBodyFirstChildReader.getEventType() != XMLStreamReader.START_ELEMENT)
                    soapBodyFirstChildReader.next();
            } catch (XMLStreamException e) {
                throw new RuntimeException(e);
            }
        }
        return soapBodyFirstChildReader;
    } else {
        payloadLocalName = null;
        payloadNamespace = null;
        return null;
    }
}
 
Example 13
Source File: StreamReaderBufferCreator.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void store(XMLStreamReader reader) throws XMLStreamException {
    if (!reader.hasNext()) {
        return;
    }

    _eventType = reader.getEventType();
    switch (_eventType) {
        case XMLStreamReader.START_DOCUMENT:
            storeDocumentAndChildren(reader);
            break;
        case XMLStreamReader.START_ELEMENT:
            storeElementAndChildren(reader);
            break;
        default:
            throw new XMLStreamException("XMLStreamReader not positioned at a document or element");
    }

    increaseTreeCount();
}
 
Example 14
Source File: SAAJMessage.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected XMLStreamReader soapBodyFirstChildReader() {
    if (soapBodyFirstChildReader != null) return soapBodyFirstChildReader;
    soapBodyFirstChild();
    if (soapBodyFirstChild != null) {
        soapBodyFirstChildReader = getXMLStreamReader(soapBodyFirstChild);
        if (soapBodyFirstChildReader == null) soapBodyFirstChildReader =
            createXMLStreamReader(soapBodyFirstChild);
        if (soapBodyFirstChildReader.getEventType() == XMLStreamReader.START_DOCUMENT) {
            try {
                while(soapBodyFirstChildReader.getEventType() != XMLStreamReader.START_ELEMENT)
                    soapBodyFirstChildReader.next();
            } catch (XMLStreamException e) {
                throw new RuntimeException(e);
            }
        }
        return soapBodyFirstChildReader;
    } else {
        payloadLocalName = null;
        payloadNamespace = null;
        return null;
    }
}
 
Example 15
Source File: StreamReaderBufferCreator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private void store(XMLStreamReader reader) throws XMLStreamException {
    if (!reader.hasNext()) {
        return;
    }

    _eventType = reader.getEventType();
    switch (_eventType) {
        case XMLStreamReader.START_DOCUMENT:
            storeDocumentAndChildren(reader);
            break;
        case XMLStreamReader.START_ELEMENT:
            storeElementAndChildren(reader);
            break;
        default:
            throw new XMLStreamException("XMLStreamReader not positioned at a document or element");
    }

    increaseTreeCount();
}
 
Example 16
Source File: SAAJMessage.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected XMLStreamReader soapBodyFirstChildReader() {
    if (soapBodyFirstChildReader != null) return soapBodyFirstChildReader;
    soapBodyFirstChild();
    if (soapBodyFirstChild != null) {
        soapBodyFirstChildReader = getXMLStreamReader(soapBodyFirstChild);
        if (soapBodyFirstChildReader == null) soapBodyFirstChildReader =
            createXMLStreamReader(soapBodyFirstChild);
        if (soapBodyFirstChildReader.getEventType() == XMLStreamReader.START_DOCUMENT) {
            try {
                while(soapBodyFirstChildReader.getEventType() != XMLStreamReader.START_ELEMENT)
                    soapBodyFirstChildReader.next();
            } catch (XMLStreamException e) {
                throw new RuntimeException(e);
            }
        }
        return soapBodyFirstChildReader;
    } else {
        payloadLocalName = null;
        payloadNamespace = null;
        return null;
    }
}
 
Example 17
Source File: StreamReaderBufferCreator.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void store(XMLStreamReader reader) throws XMLStreamException {
    if (!reader.hasNext()) {
        return;
    }

    _eventType = reader.getEventType();
    switch (_eventType) {
        case XMLStreamReader.START_DOCUMENT:
            storeDocumentAndChildren(reader);
            break;
        case XMLStreamReader.START_ELEMENT:
            storeElementAndChildren(reader);
            break;
        default:
            throw new XMLStreamException("XMLStreamReader not positioned at a document or element");
    }

    increaseTreeCount();
}
 
Example 18
Source File: XMLStreamReaderTest.java    From FHIR with Apache License 2.0 6 votes vote down vote up
private static void debug(XMLStreamReader reader) throws XMLStreamException {
    int eventType = reader.getEventType();
    switch (eventType) {
    case XMLStreamReader.START_DOCUMENT:
        System.out.println("START_DOCUMENT");
        break;
    case XMLStreamReader.START_ELEMENT:
        System.out.println("START_ELEMENT: " + reader.getLocalName());
        break;
    case XMLStreamReader.SPACE:
        System.out.println("SPACE");
        break;
    case XMLStreamReader.CHARACTERS:
        System.out.println("CHARACTERS");
        break;
    case XMLStreamReader.END_ELEMENT:
        System.out.println("END_ELEMENT: " + reader.getLocalName());
        break;
    case XMLStreamReader.END_DOCUMENT:
        System.out.println("END_DOCUMENT");
        break;
    default:
        System.out.println("OTHER: " + eventType);
        break;
    }
}
 
Example 19
Source File: JDBC4MysqlSQLXML.java    From r-course with MIT License 5 votes vote down vote up
private Reader binaryInputStreamStreamToReader(ByteArrayOutputStream out) {

        try {
            // There's got to be an easier way to do this, but I don't feel like coding up Appendix F of the XML Spec myself, when there's a reusable way to do
            // it, and we can warn folks away from BINARY xml streams that have to be parsed to determine the character encoding :P

            String encoding = "UTF-8";

            try {
                ByteArrayInputStream bIn = new ByteArrayInputStream(out.toByteArray());
                XMLStreamReader reader = this.inputFactory.createXMLStreamReader(bIn);

                int eventType = 0;

                while ((eventType = reader.next()) != XMLStreamReader.END_DOCUMENT) {
                    if (eventType == XMLStreamReader.START_DOCUMENT) {
                        String possibleEncoding = reader.getEncoding();

                        if (possibleEncoding != null) {
                            encoding = possibleEncoding;
                        }

                        break;
                    }
                }
            } catch (Throwable t) {
                // ignore, dealt with later when the string can't be parsed into valid XML
            }

            return new StringReader(new String(out.toByteArray(), encoding));
        } catch (UnsupportedEncodingException badEnc) {
            throw new RuntimeException(badEnc);
        }
    }
 
Example 20
Source File: JDBC4MysqlSQLXML.java    From Komondor with GNU General Public License v3.0 5 votes vote down vote up
private Reader binaryInputStreamStreamToReader(ByteArrayOutputStream out) {

        try {
            // There's got to be an easier way to do this, but I don't feel like coding up Appendix F of the XML Spec myself, when there's a reusable way to do
            // it, and we can warn folks away from BINARY xml streams that have to be parsed to determine the character encoding :P

            String encoding = "UTF-8";

            try {
                ByteArrayInputStream bIn = new ByteArrayInputStream(out.toByteArray());
                XMLStreamReader reader = this.inputFactory.createXMLStreamReader(bIn);

                int eventType = 0;

                while ((eventType = reader.next()) != XMLStreamReader.END_DOCUMENT) {
                    if (eventType == XMLStreamReader.START_DOCUMENT) {
                        String possibleEncoding = reader.getEncoding();

                        if (possibleEncoding != null) {
                            encoding = possibleEncoding;
                        }

                        break;
                    }
                }
            } catch (Throwable t) {
                // ignore, dealt with later when the string can't be parsed into valid XML
            }

            return new StringReader(new String(out.toByteArray(), encoding));
        } catch (UnsupportedEncodingException badEnc) {
            throw new RuntimeException(badEnc);
        }
    }