Package org.codehaus.stax2

Examples of org.codehaus.stax2.XMLInputFactory2


    protected TypedXMLStreamException _constructTypeException(String msg, String lexicalValue)
    {
        Location loc = getStartLocation();
        if (loc == null) {
            return new TypedXMLStreamException(lexicalValue, msg);
        }
        return new TypedXMLStreamException(lexicalValue, msg, loc);
    }
View Full Code Here


            // Need to convert to a checked stream exception
            /* Hmmh. This is not an accurate location... but it's
             * about the best we can do
             */
            Location loc = getLocation();
            throw new TypedXMLStreamException(value, iae.getMessage(), loc, iae);
        } finally {
            int len = end-ptr;
            // null works well as the marker for complete processing
            _typedContent = (len < 1) ? null : input.substring(ptr);
        }
View Full Code Here

                }
            }
        } catch (IllegalArgumentException iae) {
            // Need to convert to a checked stream exception
            Location loc = getLocation();
            throw new TypedXMLStreamException(lexical, iae.getMessage(), loc, iae);
        }
        return count;
    }
View Full Code Here

        final StringBase64Decoder dec = _base64Decoder();
        dec.init(v, true, lexical);
        try {
            return dec.decodeCompletely();
        } catch (IllegalArgumentException iae) {
            throw new TypedXMLStreamException(lexical, iae.getMessage(), getLocation(), iae);
        }
    }
View Full Code Here

        if (msg == null) {
            msg = "";
        }
        Location loc = getStartLocation();
        if (loc == null) {
            return new TypedXMLStreamException(lexicalValue, msg, iae);
        }
        return new TypedXMLStreamException(lexicalValue, msg, loc, iae);
    }
View Full Code Here

    protected TypedXMLStreamException _constructTypeException(String msg, String lexicalValue)
    {
        Location loc = getStartLocation();
        if (loc == null) {
            return new TypedXMLStreamException(lexicalValue, msg);
        }
        return new TypedXMLStreamException(lexicalValue, msg, loc);
    }
View Full Code Here

        return _decoderFactory;
    }

    protected TypedXMLStreamException _constructTypeException(IllegalArgumentException iae, String lexicalValue)
    {
        return new TypedXMLStreamException(lexicalValue, iae.getMessage(), getStartLocation(), iae);
    }
View Full Code Here

            +"1 2 3 4 5 61111 -9832<?pi?> 15\n\r <child /> <!-- yay   -->  4\n"
            + "</root>";

        int[] result = new int[20];

        TypedXMLStreamReader r = (TypedXMLStreamReader) f.createXMLStreamReader(new StringReader(xml));
        r.next();

        int count = r.readElementAsIntArray(result, 0, 20);

        System.out.println("Pass 1, Ints found: "+count);
        for (int i = 0; i < count; ++i) {
            System.out.println(" #"+i+" -> "+result[i]);
        }
        r.close();

        // Then one by one:
        r = (TypedXMLStreamReader) f.createXMLStreamReader(new StringReader(xml));
        r.next();
        int index = 0;

        System.out.println("Pass 2, one by one access...");
        while (true) {
            count = r.readElementAsIntArray(result, 0, 1);
            if (count < 0) {
                System.out.println("EOF");
                break;
            }
            if (count != 1) {
                throw new IllegalStateException("Weird return value: "+count);
            }
            System.out.println(" #"+index+" -> "+result[0]);
            ++index;
        }
        r.close();
    }
View Full Code Here

        throws Exception
    {
        Document doc = createDomDoc(false);
        // let's use namespace-aware just because some impls might not support non-ns
        XMLOutputFactory of = getFactory(TYPE_NS);
        TypedXMLStreamWriter sw = (TypedXMLStreamWriter) of.createXMLStreamWriter(new DOMResult(doc));

        sw.writeStartDocument();
        sw.writeStartElement("root");
        sw.writeIntAttribute(null, null, "attr", -900);
        sw.writeInt(123);
        sw.writeEndElement();
        sw.writeEndDocument();
        sw.close();

        Element root = doc.getDocumentElement();

        assertNotNull(root);
        assertEquals("root", root.getTagName());
View Full Code Here

        assertTokenType(DTD, sr.next());

        DTDInfo info = sr.getDTDInfo();
        assertNotNull(info);
        DTDValidationSchema dtd = info.getProcessedDTDSchema();
        assertNotNull(dtd);

        // 4 entities, but one is parameter entity...
        assertEquals(3, dtd.getEntityCount());

        // 2 notations:
        assertEquals(2, dtd.getNotationCount());

        // Also, don't want a creepy exception afterwards...
        assertTokenType(START_ELEMENT, sr.next());
    }
View Full Code Here

TOP

Related Classes of org.codehaus.stax2.XMLInputFactory2

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.