Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * For license please see accompanying LICENSE.txt file (available also at http://www.xmlpull.org/).
 * According to www.xmlpull.org, this code is in the public domain.
 */

import org.xmlpull.v1.XmlPullParser;

public class Main {
    public static void requireAttr(final XmlPullParser pp, final String attrName, final String requiredValue) {
        if (!requiredValue.equals(attr(pp, attrName)))
            throw new IllegalStateException("cannot find " + attrName + "=\"" + requiredValue + "\" />");
    }

    public static String attr(final XmlPullParser pp, final String attrName) {
        return pp.getAttributeValue(null, attrName).trim();
    }

    /**
     * Return value of attribute with given name and no namespace.
     */
    public static String getAttributeValue(final XmlPullParser pp, final String name) {
        return pp.getAttributeValue(XmlPullParser.NO_NAMESPACE, name);
    }
}