Package javolution.xml.stream

Examples of javolution.xml.stream.XMLStreamException


            int blockLength = end - blockStart;
            if (blockLength > 0) {
                _writer.write(_buffer, blockStart, blockLength);
            }
        } catch (IOException e) {
            throw new XMLStreamException(e);
        }
    }
View Full Code Here


    private void flushBuffer() throws XMLStreamException {
        try {
            _writer.write(_buffer, 0, _index);
        } catch (IOException e) {
            throw new XMLStreamException(e);
        } finally {
            _index = 0;
        }
    }
View Full Code Here

        // Searches user defined entities.
        _tmp.setArray(buffer, start + 1, length - 2);
        CharSequence replacementText = (_entitiesMapping != null) ?  _entitiesMapping
                .get(_tmp) : null;
        if (replacementText == null)
            throw new XMLStreamException("Entity " + _tmp + " not recognized");
        int replacementTextLength = replacementText.length();
        for (int i = 0; i < replacementTextLength; i++) {
            buffer[start + i] = replacementText.charAt(i);
        }
        return replacementTextLength;
View Full Code Here

            setInput(_utf8StreamReader.setInput(in));
        } else {
            try {
                setInput(new InputStreamReader(in, encoding));
            } catch (UnsupportedEncodingException e) {
                throw new XMLStreamException(e);
            }
        }
    }
View Full Code Here

                _index = _prolog.offset() + _prolog.length(); // Keep prolog.
                _start = _index; // Default state.
                _eventType = START_DOCUMENT; // Resets to START_DOCUMENT.
            }
        } catch (IOException e) {
            throw new XMLStreamException(e);
        }
    }
View Full Code Here

                case STATE_OPEN_TAGxATTR_NAME_READ:
                    if (c == '=') {
                        --_index;
                        _state = STATE_OPEN_TAGxEQUAL_READ;
                    } else if (c > ' ') { throw new XMLStreamException(
                            "'=' expected", _location); }
                    break;

                case STATE_OPEN_TAGxEQUAL_READ:
                    if (c == '\'') {
                        _start = --_index;
                        _state = STATE_OPEN_TAGxREAD_ATTR_VALUE_SIMPLE_QUOTE;
                    } else if (c == '\"') {
                        _start = --_index;
                        _state = STATE_OPEN_TAGxREAD_ATTR_VALUE_DOUBLE_QUOTE;
                    } else if (c > ' ') { throw new XMLStreamException(
                            "Quotes expected", _location); }
                    break;

                case STATE_OPEN_TAGxREAD_ATTR_VALUE_SIMPLE_QUOTE:
                    while (true) { // Read attribute value all at once.

                        if (c == '\'') {
                            _attrValue = newSeq(_start, --_index - _start);
                            processAttribute();
                            _state = STATE_OPEN_TAGxELEM_NAME_READ;
                            break;
                        }

                        // Local character reading block.
                        if (_readIndex >= _readCount)
                            reloadBuffer();
                        c = _readBuffer[_readIndex++];
                        if (c == '&')
                            c = replaceEntity();
                        _data[_index++] = c;
                    }
                    break;

                case STATE_OPEN_TAGxREAD_ATTR_VALUE_DOUBLE_QUOTE:
                    while (true) { // Read attribute value all at once.

                        if (c == '\"') {
                            _attrValue = newSeq(_start, --_index - _start);
                            processAttribute();
                            _state = STATE_OPEN_TAGxELEM_NAME_READ;
                            break;
                        }

                        // Local character reading block.
                        if (_readIndex >= _readCount)
                            reloadBuffer();
                        c = _readBuffer[_readIndex++];
                        if (c == '&')
                            c = replaceEntity();
                        _data[_index++] = c;
                    }
                    break;

                case STATE_OPEN_TAGxEMPTY_TAG:
                    if (c == '>') {
                        _start = --_index;
                        _state = STATE_CHARACTERS;
                        processStartTag();
                        _isEmpty = true;
                        return _eventType = START_ELEMENT;
                    } else {
                        throw new XMLStreamException("'>' expected", _location);
                    }

                    // CLOSE_TAG:
                case STATE_CLOSE_TAGxREAD_ELEM_NAME:
                    while (true) { // Element name can be read all at once.

                        if (c < '@') { // Else avoid multiple checks.
                            if (c == '>') {
                                _qName = newSeq(_start, --_index - _start);
                                _start = _index;
                                _state = STATE_CHARACTERS;
                                processEndTag();
                                return _eventType = END_ELEMENT;
                            } else if (c == ':') {
                                _prefixSep = _index - 1;
                            } else if (c <= ' ') {
                                _qName = newSeq(_start, --_index - _start);
                                _state = STATE_CLOSE_TAGxELEM_NAME_READ;
                                break;
                            }
                        }

                        if (_readIndex >= _readCount)
                            reloadBuffer();
                        c = _data[_index++] = _readBuffer[_readIndex++];
                    }
                    break;

                case STATE_CLOSE_TAGxELEM_NAME_READ:
                    if (c == '>') {
                        _start = --_index;
                        _state = STATE_CHARACTERS;
                        processEndTag();
                        return _eventType = END_ELEMENT;
                    } else if (c > ' ') { throw new XMLStreamException(
                            "'>' expected", _location); }
                    break;

                default:
                    throw new XMLStreamException("State unknown: " + _state,
                            _location);
            }
        }
    }
View Full Code Here

     *         <code>false</code> if the end of stream has being reached
     *         and the event type (CHARACTERS or END_DOCUMENT) has been set.
     */
    private void reloadBuffer() throws XMLStreamException {
        if (_reader == null)
            throw new XMLStreamException("Input not specified");
        _location._column += _readIndex;
        _location._charactersRead += _readIndex;
        _readIndex = 0;
        try {
            _readCount = _reader.read(_readBuffer, 0, _readBuffer.length);
            if ((_readCount <= 0)
                    && ((_depth != 0) || (_state != STATE_CHARACTERS)))
                throw new XMLStreamException("Unexpected end of document",
                        _location);
        } catch (IOException e) {
            throw new XMLStreamException(e);
        }
        while ((_index + _readCount) >= _data.length) { // Potential overflow.
            increaseDataBuffer();
        }
    }
View Full Code Here

        if (_readIndex >= _readCount)
            reloadBuffer();
        if (_readCount <= 0) {
            // _state == STATE_CHARACTERS (otherwise reloadBuffer() exception)
            if (_eventType == END_DOCUMENT)
                throw new XMLStreamException(
                        "End document has already been reached");
            int length = _index - _start;
            if (length > 0) { // Flushes trailing characters.
                if (_charactersPending) {
                    _text.setArray(_data, _text.offset(), _text.length()
View Full Code Here

            c = (char) 0xA;
        }
        if (c == 0xA) {
            _location._line++;
            _location._column = -_readIndex; // column = 0
        } else if (c == 0x0) { throw new XMLStreamException(
                "Illegal XML character U+0000", _location); }
        return c;
    }
View Full Code Here

                reloadBuffer();
            char c = _data[_index++] = _readBuffer[_readIndex++];
            if (c == ';')
                break;
            if (c <= ' ')
                throw new XMLStreamException("';' expected", _location);
        }
        // Ensures that the replacement string holds in the data buffer.
        while (start + _entities.getMaxLength() >= _data.length) {
            increaseDataBuffer();
        }
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.