Package com.ctc.wstx.util

Examples of com.ctc.wstx.util.TextAccumulator


public class TestTextAccumulator
    extends TestCase
{
    public void testBasic()
    {
        TextAccumulator acc = new TextAccumulator();

        acc.addText("foo");
        assertEquals("foo", acc.getAndClear());

        acc.addText("foo".toCharArray(), 0, 3);
        acc.addText("bar");
        assertEquals("foobar", acc.getAndClear());
    }
View Full Code Here


    }

    // as per [WSTX-349]
    public void testBasicWithCharArray()
    {
        TextAccumulator acc = new TextAccumulator();

        acc.addText("foobar".toCharArray(), 3, 5);
        assertEquals("ba", acc.getAndClear());

        acc.addText("xxfoo".toCharArray(), 2, 5);
        acc.addText("bar".toCharArray(), 2, 3);
        acc.addText(new char[] { '1', '2', '3' }, 2, 3);
        assertEquals("foor3", acc.getAndClear());

        acc.addText("a");
        acc.addText(new char[] { '1', '2', '3' }, 2, 3);
        assertEquals("a3", acc.getAndClear());
    }
View Full Code Here

        throws XMLStreamException
    {
        if (mCurrEvent != START_ELEMENT) {
            throwParseError(ErrorConsts.ERR_STATE_NOT_STELEM);
        }
        TextAccumulator acc = new TextAccumulator();

        /**
         * Need to loop to get rid of PIs, comments
         */
        while (true) {
            int type = next();
            if (type == END_ELEMENT) {
                break;
            }
            if (type == COMMENT || type == PROCESSING_INSTRUCTION) {
                continue;
            }
            if (((1 << type) & MASK_GET_ELEMENT_TEXT) == 0) {
                throwParseError("Expected a text token, got "+ErrorConsts.tokenTypeDesc(type)+".");
            }
            acc.addText(getText());
        }
        return acc.getAndClear();
    }
View Full Code Here

        throws XMLStreamException
    {
        if (mCurrToken != START_ELEMENT) {
            throwParseError(ErrorConsts.ERR_STATE_NOT_STELEM);
        }
        TextAccumulator acc = new TextAccumulator();

        /**
         * Need to loop to get rid of PIs, comments
         */
        while (true) {
            int type = next();
            if (type == END_ELEMENT) {
                break;
            }
            if (type == COMMENT || type == PROCESSING_INSTRUCTION) {
                continue;
            }
            if (((1 << type) & MASK_GET_ELEMENT_TEXT) == 0) {
                throwParseError("Expected a text token, got "+tokenTypeDesc(type)+".");
            }
            acc.addText(getText());
        }
        return acc.getAndClear();
    }
View Full Code Here

        throws XMLStreamException
    {
        if (mCurrEvent != START_ELEMENT) {
            throwParseError(ErrorConsts.ERR_STATE_NOT_STELEM);
        }
        TextAccumulator acc = new TextAccumulator();

        /**
         * Need to loop to get rid of PIs, comments
         */
        while (true) {
            int type = next();
            if (type == END_ELEMENT) {
                break;
            }
            if (type == COMMENT || type == PROCESSING_INSTRUCTION) {
                continue;
            }
            if (((1 << type) & MASK_GET_ELEMENT_TEXT) == 0) {
                throwParseError("Expected a text token, got "+ErrorConsts.tokenTypeDesc(type)+".");
            }
            acc.addText(getText());
        }
        return acc.getAndClear();
    }
View Full Code Here

public class TestTextAccumulator
    extends TestCase
{
    public void testBasic()
    {
        TextAccumulator acc = new TextAccumulator();

        acc.addText("foo");
        assertEquals("foo", acc.getAndClear());

        acc.addText("foo".toCharArray(), 0, 3);
        acc.addText("bar");
        assertEquals("foobar", acc.getAndClear());
    }
View Full Code Here

        throws XMLStreamException
    {
        if (mCurrToken != START_ELEMENT) {
            throwParseError(ErrorConsts.ERR_STATE_NOT_STELEM);
        }
        TextAccumulator acc = new TextAccumulator();

        /**
         * Need to loop to get rid of PIs, comments
         */
        while (true) {
            int type = next();
            if (type == END_ELEMENT) {
                break;
            }
            if (type == COMMENT || type == PROCESSING_INSTRUCTION) {
                continue;
            }
            if (((1 << type) & MASK_GET_ELEMENT_TEXT) == 0) {
                throwParseError("Expected a text token, got "+tokenTypeDesc(type)+".");
            }
            acc.addText(getText());
        }
        return acc.getAndClear();
    }
View Full Code Here

TOP

Related Classes of com.ctc.wstx.util.TextAccumulator

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.