Package org.xmlpull.v1

Examples of org.xmlpull.v1.XmlPullParser


     * @throws XmlPullParserException
     *      if an error occurs in the parser
     */
    public void parseBatchRequest() throws XmlPullParserException
    {
        XmlPullParser xpp = container.getParser();

        int eventType = xpp.getEventType();
        do
        {
            if ( eventType == XmlPullParser.START_DOCUMENT )
            {
                container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
            }
            else if ( eventType == XmlPullParser.END_DOCUMENT )
            {
                container.setState( Dsmlv2StatesEnum.END_STATE );
            }
            else if ( eventType == XmlPullParser.START_TAG )
            {
                processTag( container, Tag.START );
            }
            else if ( eventType == XmlPullParser.END_TAG )
            {
                processTag( container, Tag.END );
            }
            try
            {
                eventType = xpp.next();
            }
            catch ( IOException e )
            {
                throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp,
                    null );
View Full Code Here


     * @throws XmlPullParserException
     *      when an error occurs during the parsing
     */
    private void processTag( Dsmlv2Container container, int tagType ) throws XmlPullParserException
    {
        XmlPullParser xpp = container.getParser();

        String tagName = xpp.getName().toLowerCase();

        GrammarTransition transition = container.getTransition( container.getState(), new Tag( tagName, tagType ) );

        if ( transition != null )
        {
View Full Code Here

        if ( container.getBatchRequest() == null )
        {
            parseBatchRequest();
        }

        XmlPullParser xpp = container.getParser();

        int eventType = xpp.getEventType();
        do
        {
            while ( eventType == XmlPullParser.TEXT )
            {
                try
                {
                    xpp.next();
                }
                catch ( IOException e )
                {
                    throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp,
                        null );
                }
                eventType = xpp.getEventType();
            }

            if ( eventType == XmlPullParser.START_DOCUMENT )
            {
                container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
            }
            else if ( eventType == XmlPullParser.END_DOCUMENT )
            {
                container.setState( Dsmlv2StatesEnum.END_STATE );
                return null;
            }
            else if ( eventType == XmlPullParser.START_TAG )
            {
                processTag( container, Tag.START );
            }
            else if ( eventType == XmlPullParser.END_TAG )
            {
                processTag( container, Tag.END );
            }
            try
            {
                eventType = xpp.next();
            }
            catch ( IOException e )
            {
                throw new XmlPullParserException( "An IOException ocurred during parsing : " + e.getMessage(), xpp,
                    null );
View Full Code Here

    /* (non-Javadoc)
     * @see org.apache.directory.ldapstudio.dsmlv2.IGrammar#executeAction(org.apache.directory.ldapstudio.dsmlv2.Dsmlv2Container)
     */
    public void executeAction( Dsmlv2Container container ) throws XmlPullParserException, IOException
    {
        XmlPullParser xpp = container.getParser();

        int eventType = xpp.getEventType();
        do
        {
            if ( eventType == XmlPullParser.START_DOCUMENT )
            {
                container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
            }
            else if ( eventType == XmlPullParser.END_DOCUMENT )
            {
                container.setState( Dsmlv2StatesEnum.END_STATE );
            }
            else if ( eventType == XmlPullParser.START_TAG )
            {
                processTag( container, Tag.START );
            }
            else if ( eventType == XmlPullParser.END_TAG )
            {
                processTag( container, Tag.END );
            }
            eventType = xpp.next();
        }
        while ( eventType != XmlPullParser.END_DOCUMENT );
    }
View Full Code Here

     * @throws XmlPullParserException
     *      when an error occurs during the parsing
     */
    private void processTag( Dsmlv2Container container, int tagType ) throws XmlPullParserException
    {
        XmlPullParser xpp = container.getParser();

        String tagName = xpp.getName().toLowerCase();

        GrammarTransition transition = getTransition( container.getState(), new Tag( tagName, tagType ) );

        if ( transition != null )
        {
View Full Code Here

    {
        Control control = new Control();

        parent.addControl( control );

        XmlPullParser xpp = container.getParser();

        // Checking and adding the Control's attributes
        String attributeValue;
        // TYPE
        attributeValue = xpp.getAttributeValue( "", "type" );
        if ( attributeValue != null )
        {
            if ( !OID.isOID( attributeValue ) )
            {
                throw new XmlPullParserException( "Incorrect value for 'type' attribute. This is not an OID.", xpp, null );
            }
            control.setControlType( attributeValue );
        }
        else
        {
            throw new XmlPullParserException( "type attribute is required", xpp, null );
        }
        // CRITICALITY
        attributeValue = xpp.getAttributeValue( "", "criticality" );
        if ( attributeValue != null )
        {
            if ( attributeValue.equals( "true" ) )
            {
                control.setCriticality( true );
View Full Code Here

    private void createAndAddControlValue( Dsmlv2Container container, LdapMessage parent )
        throws XmlPullParserException
    {
        Control control = parent.getCurrentControl();

        XmlPullParser xpp = container.getParser();
        try
        {
            // We have to catch the type Attribute Value before going to the next Text node
            String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp );
           
            // Getting the value
            String nextText = xpp.nextText();
            if ( !nextText.equals( "" ) )
            {
                if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
                {
                    control.setControlValue( Base64.decode( nextText.trim().toCharArray() ) );
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public HierarchicalStreamReader createReader(Reader in) {
        try {
            XmlPullParser parser = createParser();
            parser.setInput(in);
            return new XppDomReader(XppDom.build(parser), getNameCoder());
        } catch (XmlPullParserException e) {
            throw new StreamException(e);
        } catch (IOException e) {
            throw new StreamException(e);
View Full Code Here

public class Xpp3DomBuilder {
    /**
     * @deprecated As of 1.4, use {@link XppDom#build(XmlPullParser)} instead
     */
    public static Xpp3Dom build(Reader reader) throws Exception {
        XmlPullParser parser = new MXParser();
        parser.setInput(reader);
        try {
            return (Xpp3Dom)XppDom.build(parser);
        } finally {
            reader.close();
        }
View Full Code Here

        List values = new ArrayList();

        Xpp3Dom node = null;

        XmlPullParser parser = new MXParser();

        parser.setInput(reader);

        int eventType = parser.getEventType();

        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                String rawName = parser.getName();

                Xpp3Dom child = new Xpp3Dom(rawName);

                int depth = elements.size();

                if (depth > 0) {
                    Xpp3Dom parent = (Xpp3Dom) elements.get(depth - 1);

                    parent.addChild(child);
                }

                elements.add(child);

                values.add(new StringBuffer());

                int attributesSize = parser.getAttributeCount();

                for (int i = 0; i < attributesSize; i++) {
                    String name = parser.getAttributeName(i);

                    String value = parser.getAttributeValue(i);

                    child.setAttribute(name, value);
                }
            } else if (eventType == XmlPullParser.TEXT) {
                int depth = values.size() - 1;

                StringBuffer valueBuffer = (StringBuffer) values.get(depth);

                valueBuffer.append(parser.getText());
            } else if (eventType == XmlPullParser.END_TAG) {
                int depth = elements.size() - 1;

                Xpp3Dom finalNode = (Xpp3Dom) elements.remove(depth);

                String accumulatedValue = (values.remove(depth)).toString();

                String finishedValue;

                if (0 == accumulatedValue.length()) {
                    finishedValue = null;
                } else {
                    finishedValue = accumulatedValue;
                }

                finalNode.setValue(finishedValue);

                if (0 == depth) {
                    node = finalNode;
                }
            }

            eventType = parser.next();
        }

        reader.close();

        return node;
View Full Code Here

TOP

Related Classes of org.xmlpull.v1.XmlPullParser

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.