Package javolution.xml.stream

Examples of javolution.xml.stream.XMLStreamException


                && (chars.charAt(3) == 'n') && (chars.charAt(4) == 's');
    }

    private void processEndTag() throws XMLStreamException {
        if (!_qName.equals(_elemStack[_depth]))
            throw new XMLStreamException("Unexpected end tag for " + _qName,
                    _location);
    }
View Full Code Here


    //////////////////////////////////////////
    // Implements XMLStreamReader Interface.
    public void require(int type, CharSequence namespaceURI,
            CharSequence localName) throws XMLStreamException {
        if (_eventType != type)
            throw new XMLStreamException("Expected event: "
                    + NAMES_OF_EVENTS[type] + ", found event: "
                    + NAMES_OF_EVENTS[_eventType]);
        if ((namespaceURI != null) && !getNamespaceURI().equals(namespaceURI))
            throw new XMLStreamException("Expected namespace URI: "
                    + namespaceURI + ", found: " + getNamespaceURI());
        if ((localName != null) && !getLocalName().equals(localName))
            throw new XMLStreamException("Expected local name: " + localName
                    + ", found: " + getLocalName());
    }
View Full Code Here

    }

    // Implements XMLStreamReader Interface.
    public CharArray getElementText() throws XMLStreamException {
        // Derived from interface specification code.
        if (getEventType() != XMLStreamConstants.START_ELEMENT) { throw new XMLStreamException(
                "Parser must be on START_ELEMENT to read next text",
                getLocation()); }
        CharArray text = null;
        int eventType = next();
        while (eventType != XMLStreamConstants.END_ELEMENT) {
            if (eventType == XMLStreamConstants.CHARACTERS) {
                if (text == null) {
                    text = getText();
                } else { // Merge (adjacent text, comments and PI are not kept).
                    text.setArray(_data, text.offset(), text.length()
                            + getText().length());
                }
            } else if (eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
                    || eventType == XMLStreamConstants.COMMENT) {
                // Skips (not kept).
            } else if (eventType == XMLStreamConstants.END_DOCUMENT) {
                throw new XMLStreamException(
                        "Unexpected end of document when reading element text content",
                        getLocation());
            } else if (eventType == XMLStreamConstants.START_ELEMENT) {
                throw new XMLStreamException(
                        "Element text content may not contain START_ELEMENT",
                        getLocation());
            } else {
                throw new XMLStreamException("Unexpected event type "
                        + NAMES_OF_EVENTS[eventType], getLocation());
            }
            eventType = next();
        }
        return (text != null) ? text : newSeq(0, 0);
View Full Code Here

                || (eventType == XMLStreamConstants.CHARACTERS && isWhiteSpace())) {
            eventType = next();
        }
        if (eventType != XMLStreamConstants.START_ELEMENT
                && eventType != XMLStreamConstants.END_ELEMENT)
            throw new XMLStreamException("Tag expected (but found "
                    + NAMES_OF_EVENTS[_eventType] + ")");
        return eventType;
    }
View Full Code Here

        // Autodetect encoding (see http://en.wikipedia.org/wiki/UTF-16)
        int byte0;
        try {
            byte0 = input.read();
        } catch (IOException e) {
            throw new XMLStreamException(e);
        }
        if (byte0 == -1)
            throw new XMLStreamException("Premature End-Of-File");
        if (byte0 == '<') { // UTF-8 or compatible encoding.
            _readBuffer[_startOffset++] = '<';
            return "UTF-8";
        } else {
            int byte1;
            try {
                byte1 = input.read();
            } catch (IOException e) {
                throw new XMLStreamException(e);
            }
            if (byte1 == -1)
                throw new XMLStreamException("Premature End-Of-File");
            if ((byte0 == 0) && (byte1 == '<')) { // UTF-16 BIG ENDIAN
                _readBuffer[_startOffset++] = '<';
                return "UTF-16BE";
            } else if ((byte0 == '<') && (byte1 == 0)) { // UTF-16 LITTLE ENDIAN
                _readBuffer[_startOffset++] = '<';
View Full Code Here

            throws XMLStreamException {
            final Object value = getAttribute( name, xml );
            try {
                return _constructor.newInstance( value );
            } catch ( final Exception e ) {
                throw new XMLStreamException( e );
            }
        }
View Full Code Here

    @Override
    public T newInstance( final Class<T> clazz, final javolution.xml.XMLFormat.InputElement xml ) throws XMLStreamException {
        try {
            return _constructor.newInstance( INITARGS );
        } catch ( final Exception e ) {
            throw new XMLStreamException( e );
        }
    }
View Full Code Here

    private Character getAttribute( final InputElement input, final String name, final Character defaultValue ) throws XMLStreamException {
        final CharArray value = input.getAttribute( name );
        if ( value != null ) {
            if ( value.length() > 1 ) {
                throw new XMLStreamException( "The attribute '" + name + "' of type Character has illegal value (length > 1): " + value );
            }
            return Character.valueOf( value.charAt( 0 ) );
        }
        return defaultValue;
    }
View Full Code Here

            ? reader.getAttributeValue( null, CLASS )
            : reader.getLocalName();
        try {
            return Class.forName( className.toString(), true, _classLoader );
        } catch ( final ClassNotFoundException e ) {
            throw new XMLStreamException( e );
        }
    }
View Full Code Here

                        Arrays.asList( constructors ) );
            }
        } catch ( final SecurityException e ) {
            // ignore
        } catch ( final IllegalArgumentException e ) {
            throw new XMLStreamException( e ); // not expected
        } catch ( final InstantiationException e ) {
            throw new XMLStreamException( e ); // not expected
        } catch ( final IllegalAccessException e ) {
            throw new XMLStreamException( e ); // not expected
        } catch ( final InvocationTargetException e ) {
            // ignore - constructor threw exception
            LOG.info( "Tried to invoke int constructor on " + cls.getName() + ", this threw an exception.", e.getTargetException() );
        }
        return null;
View Full Code Here

TOP

Related Classes of javolution.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.