Package com.ctc.wstx.exc

Examples of com.ctc.wstx.exc.WstxException


                 */
                if (r instanceof StreamReaderImpl) {
                    StreamReaderImpl sr = (StreamReaderImpl) r;
                    BaseStartElement be = (BaseStartElement) sr.withStartElement(this, loc);
                    if (be == null) { // incorrect state
                        throw new WstxException("Trying to create START_ELEMENT when current event is "
                                                +ErrorConsts.tokenTypeDesc(sr.getEventType()),
                                                loc);
                    }
                    return be;
                }
                /* Ok, not woodstox impl, will be bit more work (plus less
                 * efficient, and may miss some info)... but can be done.
                 */
                NamespaceContext nsCtxt = null;
                if (r instanceof XMLStreamReader2) {
                    nsCtxt = ((XMLStreamReader2) r).getNonTransientNamespaceContext();
                }
                Map<QName,Attribute> attrs;
                {
                    int attrCount = r.getAttributeCount();
                    if (attrCount < 1) {
                        attrs = null;
                    } else {
                        attrs = new LinkedHashMap<QName, Attribute>();
                        for (int i = 0; i < attrCount; ++i) {
                            QName aname = r.getAttributeName(i);
                            attrs.put(aname, new AttributeEventImpl(loc, aname, r.getAttributeValue(i), r.isAttributeSpecified(i)));
                        }
                    }
                }
                List<Namespace> ns;
                {
                    int nsCount = r.getNamespaceCount();
                    if (nsCount < 1) {
                        ns = null;
                    } else {
                        ns = new ArrayList<Namespace>(nsCount);
                        for (int i = 0; i < nsCount; ++i) {
                            ns.add(NamespaceEventImpl.constructNamespace(loc, r.getNamespacePrefix(i), r.getNamespaceURI(i)));
                        }
                    }
                }
               
                return SimpleStartElement.construct(loc, r.getName(), attrs, ns, nsCtxt);
            }

        case ENTITY_REFERENCE:
            {
                /* 19-Jul-2006, TSa: Let's also allow other impls, although
                 *   we can't get actual declaration if so...
                 */
                if (r instanceof StreamReaderImpl) {
                    EntityDecl ed = ((StreamReaderImpl) r).getCurrentEntityDecl();
                    if (ed == null) { // undefined?
                    // We'll still know the name though...
                        return new WEntityReference(loc, r.getLocalName());
                    }
                    return new WEntityReference(loc, ed);
                }
                return new WEntityReference(loc, r.getLocalName());
            }


            /* Following 2 types should never get in here; they are directly
             * handled by DTDReader, and can only be accessed via DTD event
             * element.
             */
        case ENTITY_DECLARATION:
        case NOTATION_DECLARATION:
            /* Following 2 types should never get in here; they are directly
             * handled by the reader, and can only be accessed via start
             * element.
             */
        case NAMESPACE:
        case ATTRIBUTE:
            throw new WstxException("Internal error: should not get "
                                    +ErrorConsts.tokenTypeDesc(r.getEventType()));
        default:
            throw new IllegalStateException("Unrecognized event type "+r.getEventType()+".");
        }
    }
View Full Code Here


                 */
                if (r instanceof StreamReaderImpl) {
                    StreamReaderImpl sr = (StreamReaderImpl) r;
                    BaseStartElement be = (BaseStartElement) sr.withStartElement(this, loc);
                    if (be == null) { // incorrect state
                        throw new WstxException("Trying to create START_ELEMENT when current event is "
                                                +ErrorConsts.tokenTypeDesc(sr.getEventType()),
                                                loc);
                    }
                    return be;
                }
                /* Ok, not woodstox impl, will be bit more work (plus less
                 * efficient, and may miss some info)... but can be done.
                 */
                NamespaceContext nsCtxt = null;
                if (r instanceof XMLStreamReader2) {
                    nsCtxt = ((XMLStreamReader2) r).getNonTransientNamespaceContext();
                }
                Map attrs;
                {
                    int attrCount = r.getAttributeCount();
                    if (attrCount < 1) {
                        attrs = null;
                    } else {
                        attrs = JdkFeatures.getInstance().getInsertOrderedMap();
                        for (int i = 0; i < attrCount; ++i) {
                            QName aname = r.getAttributeName(i);
                            attrs.put(aname, new WAttribute(loc, aname, r.getAttributeValue(i), r.isAttributeSpecified(i)));
                        }
                    }
                }
                List ns;
                {
                    int nsCount = r.getNamespaceCount();
                    if (nsCount < 1) {
                        ns = null;
                    } else {
                        ns = new ArrayList(nsCount);
                        for (int i = 0; i < nsCount; ++i) {
                            ns.add(WNamespace.constructFor(loc, r.getNamespacePrefix(i), r.getNamespaceURI(i)));
                        }
                    }
                }
               
                return SimpleStartElement.construct(loc, r.getName(), attrs, ns, nsCtxt);
            }

        case ENTITY_REFERENCE:
            {
                /* 19-Jul-2006, TSa: Let's also allow other impls, although
                 *   we can't get actual declaration if so...
                 */
                if (r instanceof StreamReaderImpl) {
                    EntityDecl ed = ((StreamReaderImpl) r).getCurrentEntityDecl();
                    if (ed == null) { // undefined?
                    // We'll still know the name though...
                        return new WEntityReference(loc, r.getLocalName());
                    }
                    return new WEntityReference(loc, ed);
                }
                return new WEntityReference(loc, r.getLocalName());
            }


            /* Following 2 types should never get in here; they are directly
             * handled by DTDReader, and can only be accessed via DTD event
             * element.
             */
        case ENTITY_DECLARATION:
        case NOTATION_DECLARATION:
            /* Following 2 types should never get in here; they are directly
             * handled by the reader, and can only be accessed via start
             * element.
             */
        case NAMESPACE:
        case ATTRIBUTE:
            throw new WstxException("Internal error: should not get "
                                    +ErrorConsts.tokenTypeDesc(r.getEventType()));
        default:
            throw new Error("Unrecognized event type "+r.getEventType()+".");
        }
    }
View Full Code Here

                 */
                if (r instanceof StreamReaderImpl) {
                    StreamReaderImpl sr = (StreamReaderImpl) r;
                    BaseStartElement be = (BaseStartElement) sr.withStartElement(this, loc);
                    if (be == null) { // incorrect state
                        throw new WstxException("Trying to create START_ELEMENT when current event is "
                                                +ErrorConsts.tokenTypeDesc(sr.getEventType()),
                                                loc);
                    }
                    return be;
                }
                /* Ok, not woodstox impl, will be bit more work (plus less
                 * efficient, and may miss some info)... but can be done.
                 */
                NamespaceContext nsCtxt = null;
                if (r instanceof XMLStreamReader2) {
                    nsCtxt = ((XMLStreamReader2) r).getNonTransientNamespaceContext();
                }
                Map attrs;
                {
                    int attrCount = r.getAttributeCount();
                    if (attrCount < 1) {
                        attrs = null;
                    } else {
                        attrs = new LinkedHashMap();
                        for (int i = 0; i < attrCount; ++i) {
                            QName aname = r.getAttributeName(i);
                            attrs.put(aname, new AttributeEventImpl(loc, aname, r.getAttributeValue(i), r.isAttributeSpecified(i)));
                        }
                    }
                }
                List ns;
                {
                    int nsCount = r.getNamespaceCount();
                    if (nsCount < 1) {
                        ns = null;
                    } else {
                        ns = new ArrayList(nsCount);
                        for (int i = 0; i < nsCount; ++i) {
                            ns.add(NamespaceEventImpl.constructNamespace(loc, r.getNamespacePrefix(i), r.getNamespaceURI(i)));
                        }
                    }
                }
               
                return SimpleStartElement.construct(loc, r.getName(), attrs, ns, nsCtxt);
            }

        case ENTITY_REFERENCE:
            {
                /* 19-Jul-2006, TSa: Let's also allow other impls, although
                 *   we can't get actual declaration if so...
                 */
                if (r instanceof StreamReaderImpl) {
                    EntityDecl ed = ((StreamReaderImpl) r).getCurrentEntityDecl();
                    if (ed == null) { // undefined?
                    // We'll still know the name though...
                        return new WEntityReference(loc, r.getLocalName());
                    }
                    return new WEntityReference(loc, ed);
                }
                return new WEntityReference(loc, r.getLocalName());
            }


            /* Following 2 types should never get in here; they are directly
             * handled by DTDReader, and can only be accessed via DTD event
             * element.
             */
        case ENTITY_DECLARATION:
        case NOTATION_DECLARATION:
            /* Following 2 types should never get in here; they are directly
             * handled by the reader, and can only be accessed via start
             * element.
             */
        case NAMESPACE:
        case ATTRIBUTE:
            throw new WstxException("Internal error: should not get "
                                    +ErrorConsts.tokenTypeDesc(r.getEventType()));
        default:
            throw new IllegalStateException("Unrecognized event type "+r.getEventType()+".");
        }
    }
View Full Code Here

            reader.mInputEnd = 0;
            if (count == 0) {
                /* Sanity check; should never happen with correctly written
                 * Readers:
                 */
                throw new WstxException("Reader (of type "+mReader.getClass().getName()+") returned 0 characters, even when asked to read up to "+mBuffer.length, getLocation());
            }
            return -1;
        }
        reader.mInputBuffer = mBuffer;
        reader.mInputPtr = 0;
View Full Code Here

        while (minAmount > 0) {
            int amount = mBuffer.length - currAmount;
            int actual = mReader.read(mBuffer, currAmount, amount);
            if (actual < 1) {
                if (actual == 0) { // sanity check:
        throw new WstxException("Reader (of type "+mReader.getClass().getName()+") returned 0 characters, even when asked to read up to "+amount, getLocation());
                }
                reader.mInputEnd = mInputLast = currAmount;
                return false;
            }
            currAmount += actual;
View Full Code Here

TOP

Related Classes of com.ctc.wstx.exc.WstxException

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.