Package javolution.xml.stream

Examples of javolution.xml.stream.XMLStreamException


         * @return the value for the specified attribute or <code>null</code>
         *         if the attribute is not found.
         */
        public CharArray getAttribute(String name) throws XMLStreamException {
            if (_isReaderAtNext)
                throw new XMLStreamException(
                        "Attributes should be read before reading content");
            return _reader.getAttributeValue(null, toCsq(name));
        }
View Full Code Here


                throws XMLStreamException {
            CharArray value = getAttribute(name);
            if (value == null)
                return defaultValue;
            if (value.length() != 1)
                throw new XMLStreamException(
                        "Single character expected (read '" + value + "')");
            return value.charAt(0);
        }
View Full Code Here

                return defaultValue;
            // Parses attribute value.
            Class type = defaultValue.getClass();
            TextFormat format = TextFormat.getInstance(type);
            if (!format.isParsingSupported())
                throw new XMLStreamException("No TextFormat instance for " + type);
            return ( T ) format.parse(value);
        }
View Full Code Here

            throws XMLStreamException {
        try {
            QName classQName;
            if (useAttributes) {
                if (_classAttribute == null)
                    throw new XMLStreamException(
                            "Binding has no class attribute defined, cannot retrieve class");
                classQName = QName.valueOf(reader.getAttributeValue(
                        _classAttribute.getNamespaceURI(),
                        _classAttribute.getLocalName()));
                if (classQName == null)
                    throw new XMLStreamException(
                            "Cannot retrieve class (class attribute not found)");
            } else {
                classQName = QName.valueOf(reader.getNamespaceURI(),
                        reader.getLocalName());
            }

            // Searches aliases with namespace URI.
            Class<?> cls = _aliasToClass.get(classQName);
            if (cls != null)
                return cls;

            // Searches aliases without namespace URI.
            cls = _aliasToClass.get(QName.valueOf(classQName.getLocalName()));
            if (cls != null)
                return cls;

            // Finally convert the qualified name to a class (ignoring namespace URI).
            cls = Class.forName(classQName.getLocalName().toString());
            if (cls == null)
                throw new XMLStreamException(
                        "Class "
                                + classQName.getLocalName()
                                + " not found (see javolution.lang.Reflection to support additional class loader)");
            _aliasToClass.put(classQName, cls);
            return cls;
View Full Code Here

        CharArray value = xml._reader.getAttributeValue(_refURI, _refName);
        if (value == null)
            return null;
        int ref = value.toInt();
        if (ref >= _idToObject.size())
            throw new XMLStreamException("Reference: " + value + " not found");
        return _idToObject.get(ref);
    }
View Full Code Here

        CharArray value = xml._reader.getAttributeValue(_idURI, _idName);
        if (value == null)
            return;
        int i = value.toInt();
        if (_idToObject.size() != i)
            throw new XMLStreamException("Identifier discontinuity detected "
                    + "(expected " + _idToObject.size() + " found " + i + ")");
        _idToObject.add(obj);
    }
View Full Code Here

    public T newInstance(Class<? extends T> cls, InputElement xml)
            throws XMLStreamException {
        try {
            return cls.newInstance();
        } catch (InstantiationException e) {
            throw new XMLStreamException(e);
        } catch (IllegalAccessException e) {
            throw new XMLStreamException(e);
        }
    }
View Full Code Here

         * @return the next nested object which can be <code>null</code>.
         * @throws XMLStreamException if <code>hasNext() == false</code>.
         */
        public <T> T getNext() throws XMLStreamException {
            if (!hasNext()) // Asserts isReaderAtNext == true
                throw new XMLStreamException("No more element to read",
                        _reader.getLocation());

            // Checks for null.
            if (_reader.getLocalName().equals(NULL)) {
                if (_reader.next() != XMLStreamReader.END_ELEMENT)
                    throw new XMLStreamException("Non Empty Null Element");
                _isReaderAtNext = false;
                return null;
            }

            Object ref = readReference();
View Full Code Here

                return null;
            Object ref = _referenceResolver.readReference(this);
            if (ref == null)
                return null;
            if (_reader.next() != XMLStreamReader.END_ELEMENT)
                throw new XMLStreamException("Non Empty Reference Element");
            _isReaderAtNext = false;
            return ref;
        }
View Full Code Here

            }

            // Parses xml.
            xmlFormat.read(this, obj);
            if (hasNext()) // Asserts _isReaderAtNext == true
                throw new XMLStreamException("Incomplete element reading",
                        _reader.getLocation());
            _isReaderAtNext = false; // Skips end element.
            return (T) obj;
        }
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.