Package javax.xml.stream

Examples of javax.xml.stream.XMLStreamException


        }
        if (event == START_ELEMENT
                && super.getLocalName().equals(XOPConstants.INCLUDE)
                && super.getNamespaceURI().equals(XOPConstants.NAMESPACE_URI)) {
            if (!wasStartElement) {
                throw new XMLStreamException(SOLE_CHILD_MSG);
            }
            dh = new DataHandlerProviderImpl(mimePartProvider, processXopInclude());
            return CHARACTERS;
        } else {
            return event;
View Full Code Here


        }
    }

    public String getElementText() throws XMLStreamException {
        if (super.getEventType() != START_ELEMENT) {
            throw new XMLStreamException("The current event is not a START_ELEMENT event");
        }
        int event = super.next();
        // Note that an xop:Include must be the first child of the element
        if (event == START_ELEMENT
                && super.getLocalName().equals(XOPConstants.INCLUDE)
                && super.getNamespaceURI().equals(XOPConstants.NAMESPACE_URI)) {
            String contentID = processXopInclude();
            try {
                return toBase64(mimePartProvider.getDataHandler(contentID));
            } catch (IOException ex) {
                throw new XMLStreamException("Failed to load MIME part '" + contentID + "'", ex);
            }
        } else {
            String text = null;
            StringBuffer buffer = null;
            while (event != END_ELEMENT) {
                switch (event) {
                    case CHARACTERS:
                    case CDATA:
                    case SPACE:
                    case ENTITY_REFERENCE:
                        if (text == null && buffer == null) {
                            text = super.getText();
                        } else {
                            String thisText = super.getText();
                            if (buffer == null) {
                                buffer = new StringBuffer(text.length() + thisText.length());
                                buffer.append(text);
                            }
                            buffer.append(thisText);
                        }
                        break;
                    case PROCESSING_INSTRUCTION:
                    case COMMENT:
                        // Skip this event
                        break;
                    default:
                        throw new XMLStreamException("Unexpected event " +
                                XMLEventUtils.getEventTypeString(event) +
                                " while reading element text");
                }
                event = super.next();
            }
View Full Code Here

    private static String toBase64(DataHandler dh) throws XMLStreamException {
        try {
            return Base64Utils.encode(dh);
        } catch (IOException ex) {
            throw new XMLStreamException("Exception when encoding data handler as base64", ex);
        }
    }
View Full Code Here

    private String toBase64() throws XMLStreamException {
        if (base64 == null) {
            try {
                base64 = toBase64(dh.getDataHandler());
            } catch (IOException ex) {
                throw new XMLStreamException("Failed to load MIME part '" + dh.getContentID() + "'", ex);
            }
        }
        return base64;
    }
View Full Code Here

    public void require(int type, String namespaceURI, String localName)
            throws XMLStreamException {
        if (dh != null) {
            if (type != CHARACTERS) {
                throw new XMLStreamException("Expected CHARACTERS event");
            }
        } else {
            super.require(type, namespaceURI, localName);
        }
    }
View Full Code Here

    public DataHandler getDataHandler() throws XMLStreamException{
        try {
            return dh.getDataHandler();
        } catch (IOException ex) {
            throw new XMLStreamException("Failed to load MIME part '" + dh.getContentID() + "'");
        }
    }
View Full Code Here

        // read as this will reveal secure information to the client.
        if (log.isDebugEnabled()) {
            log.debug("resolveEntity is disabled because this is a secure XMLStreamReader(" +
                    publicID + ") (" + systemID + ") (" + baseURI + ") (" + namespace + ")");
        }
        throw new XMLStreamException("Reading external entities is disabled");
    }
View Full Code Here

    }

    public int next() throws XMLStreamException {
        int event = super.next();
        if (event == DTD) {
            throw new XMLStreamException("DOCTYPE is not allowed");
        }
        return event;
    }
View Full Code Here

        OMFactory omFactory = OMAbstractFactory.getOMFactory();
        JAXBContext context = JAXBContext.newInstance(DocumentBean.class);
        DocumentBean object = new DocumentBean();
        object.setId("test");
        OMSourcedElement element = omFactory.createOMElement(new JAXBOMDataSource(context, object));
        XMLStreamException exception = new XMLStreamException("TEST");
        try {
            element.serialize(new ExceptionXMLStreamWriterWrapper(StAXUtils.createXMLStreamWriter(new ByteArrayOutputStream()), exception));
            fail("Expected XMLStreamException");
        } catch (XMLStreamException ex) {
            assertSame(exception, ex);
View Full Code Here

            }
            if(log.isDebugEnabled()){
                log.debug("Exit ParserInputStreamDataSource.serialize(OutputStream, OMOutputFormat");
            }
        } catch (UnsupportedEncodingException e) {
            throw new XMLStreamException(e);
        } catch (IOException e) {
            throw new XMLStreamException(e);
        }
    }
View Full Code Here

TOP

Related Classes of javax.xml.stream.XMLStreamException

Copyright © 2018 www.massapicom. 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.