Package org.xmlpull.v1

Examples of org.xmlpull.v1.XmlPullParser


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


    }

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

        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(true);
        factory.setValidating(false);

        //parse root element
        XmlPullParser parser = factory.newPullParser();
        //parser.setInput(input, "UTF-8");
        parser.setInput(input);
        parser.nextTag();

        String namespace = (parser.getNamespace() != null) ? parser.getNamespace() : "";
        String element = parser.getName();
        String version = null;
        String service = null;

        for (int i = 0; i < parser.getAttributeCount(); i++) {
            if ("version".equals(parser.getAttributeName(i))) {
                version = parser.getAttributeValue(i);
            }
            if ("service".equals(parser.getAttributeName(i))) {
                service = parser.getAttributeValue(i);
            }
        }
       
       

        parser.setInput(null);

        //reset input stream
        input.reset();

        XmlRequestReader xmlReader = findXmlReader(namespace, element, service, version);
View Full Code Here

        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(true);
        factory.setValidating(false);

        //parse root element
        XmlPullParser parser = factory.newPullParser();
        parser.setInput(input);
        parser.nextTag();

        Map map = new HashMap();
        map.put("request", parser.getName());

        for (int i = 0; i < parser.getAttributeCount(); i++) {
            String attName = parser.getAttributeName(i);

            if ("service".equals(attName)) {
                map.put("service", parser.getAttributeValue(i));
            }

            if ("version".equals(parser.getAttributeName(i))) {
                map.put("version", parser.getAttributeValue(i));
            }

            if ("outputFormat".equals(attName)) {
                map.put("outputFormat", parser.getAttributeValue(i));
            }
        }

        //close parser + release resources
        parser.setInput(null);

        //reset the input stream
        input.reset();

        return map;
View Full Code Here

        Map defns = caller.getDefns();
        if (shouldImportRootValuesOnly(caller))
            defns.put(ROOT_VALUES_ONLY_TAG, "true");

        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        XmlPullParser parser = factory.newPullParser();

        parser.setInput(in, ENCODING);
        parser.nextTag();
        parser.require(XmlPullParser.START_TAG, null, DATA_ELEM);
        importData(parser, defns, null);
        parser.require(XmlPullParser.END_TAG, null, DATA_ELEM);

        defns.remove(ROOT_VALUES_ONLY_TAG);
    }
View Full Code Here

    private void readAndProcessArchive() throws IOException,
            XmlPullParserException {
        shouldDeleteArchiveFileOnCompletion = false;
        zipFile = new ZipFile(file);
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        XmlPullParser parser = factory.newPullParser();

        InputStream manifestIn = openEntry(zipFile, MANIFEST_FILE_NAME);
        parser.setInput(manifestIn, ENCODING);

        parser.nextTag();
        parser.require(XmlPullParser.START_TAG, null, ARCHIVE_ELEM);
        if (!FILE_TYPE_ARCHIVE
                .equals(parser.getAttributeValue(null, TYPE_ATTR)))
            error("expected archive of type " + FILE_TYPE_ARCHIVE);

        parser.nextTag();
        parser.require(XmlPullParser.START_TAG, null, EXPORTED_TAG);
        owner = parser.getAttributeValue(null, OWNER_ATTR);
        exportTimestamp = XMLUtils.parseDate(parser.getAttributeValue(null,
                WHEN_ATTR));

        ImportedDefectManager.closeDefects(prefix);
        ImportedTimeLogManager.getInstance().closeTimeLogs(prefix);
        ImportedEVManager.getInstance().closeTaskLists(prefix);
        defns = new HashMap();
        Map<String, String> packageIDs = new HashMap<String, String>();

        while (parser.next() != XmlPullParser.END_DOCUMENT) {
            if (parser.getEventType() == XmlPullParser.START_TAG) {
                if (PACKAGE_ELEM.equals(parser.getName())) {
                    String id = parser.getAttributeValue(null, PACKAGE_ID_ATTR);
                    String version = parser.getAttributeValue(null, VERSION_ATTR);
                    packageIDs.put(id, version);
                } else if (FILE_ELEM.equals(parser.getName())) {
                    String name = parser.getAttributeValue(null, FILE_NAME_ATTR);
                    String type = parser.getAttributeValue(null, TYPE_ATTR);
                    String version = parser.getAttributeValue(null, VERSION_ATTR);
                    readFile(zipFile, name, type, version);
                }
            }
        }
View Full Code Here

     * @throws java.io.IOException error rms
     */
    public void fromXml(String xml) throws XmlPullParserException, IOException
    {
        XmlPullParserFactory fabrica=XmlPullParserFactory.newInstance();
        XmlPullParser analiazador=fabrica.newPullParser();
        fromXml(xml,analiazador);
    }
View Full Code Here

    public static void roundTrip(Reader reader, Writer writer, String indent)
            throws XmlPullParserException, IOException {
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(true);
        XmlPullParser pp = factory.newPullParser();
        pp.setInput(reader);
        XmlSerializer serializer = factory.newSerializer();
        serializer.setOutput(writer);
        if (indent != null) {
            serializer.setProperty(PROPERTY_SERIALIZER_INDENTATION, indent);
        }
View Full Code Here

     * @throws org.xmlpull.v1.XmlPullParserException if an error occurs while parsing the XML.
     * @throws java.io.IOException if an input/output error occurs while using the connection.
     */
    public static LocalIncomingServerSession createSession(String serverName, XMPPPacketReader reader,
            SocketConnection connection) throws XmlPullParserException, IOException {
        XmlPullParser xpp = reader.getXPPParser();
        String version = xpp.getAttributeValue("", "version");
        int[] serverVersion = version != null ? decodeVersion(version) : new int[] {0,0};
        if (serverVersion[0] >= 1) {
            // Remote server is XMPP 1.0 compliant so offer TLS and SASL to establish the connection (and server dialback)
            try {
                return createIncomingSession(connection, serverName);
            }
            catch (Exception e) {
                Log.error("Error establishing connection from remote server", e);
            }
        }
        else if (xpp.getNamespace("db") != null) {
            // Server is trying to establish connection and authenticate using server dialback (pre XMPP 1.0)
            if (ServerDialback.isEnabled()) {
                ServerDialback method = new ServerDialback(connection, serverName);
                return method.createIncomingSession(reader);
            }
View Full Code Here

            XMPPPacketReader reader = new XMPPPacketReader();
            reader.getXPPParser().setInput(new InputStreamReader(socket.getInputStream(),
                    CHARSET));
            // Get the answer from the Receiving Server
            XmlPullParser xpp = reader.getXPPParser();
            for (int eventType = xpp.getEventType(); eventType != XmlPullParser.START_TAG;) {
                eventType = xpp.next();
            }

            String serverVersion = xpp.getAttributeValue("", "version");
            String id = xpp.getAttributeValue("", "id");

            // Check if the remote server is XMPP 1.0 compliant
            if (serverVersion != null && decodeVersion(serverVersion)[0] >= 1) {
                // Restore default timeout
                socket.setSoTimeout(soTimeout);
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.