當前位置: 首頁>>代碼示例>>Java>>正文


Java XmlPullParser.getAttributeValue方法代碼示例

本文整理匯總了Java中org.xmlpull.v1.XmlPullParser.getAttributeValue方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlPullParser.getAttributeValue方法的具體用法?Java XmlPullParser.getAttributeValue怎麽用?Java XmlPullParser.getAttributeValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.xmlpull.v1.XmlPullParser的用法示例。


在下文中一共展示了XmlPullParser.getAttributeValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleStartTag

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private void handleStartTag(XmlPullParser xml) {
  String strNode = xml.getName();
  if (strNode.equals(Constants.TAG_FEATURE)) {
    mInsideFeature = true;
    mService = xml.getAttributeValue(null, Constants.ATTR_NAME);
  } else if (mInsideFeature && strNode.equals(Constants.TAG_PARAM)) {
    mParamType = xml.getAttributeValue(null, Constants.ATTR_NAME);
    if (mParamType.equals(Constants.ATTR_SERVICE)) // check if it is using the older mService param
      mService = xml.getAttributeValue(null, Constants.ATTR_VALUE);
    else if (mParamType.equals(Constants.ATTR_PACKAGE) || mParamType.equals(Constants.ATTR_ANDROID_PACKAGE))
      mPluginClass = xml.getAttributeValue(null, Constants.ATTR_VALUE);
    else if (mParamType.equals(Constants.ATTR_ONLOAD))
      mOnLoad = "true".equals(xml.getAttributeValue(null, Constants.ATTR_VALUE));
    else if (mParamType.equals(Constants.ATTR_CATEGORY))
      mCategory = xml.getAttributeValue(null, Constants.ATTR_VALUE);
    else if (mParamType.equals(Constants.ATTR_API))
      mApi = xml.getAttributeValue(null, Constants.ATTR_VALUE);
  }
}
 
開發者ID:osmartian,項目名稱:martian-cli,代碼行數:20,代碼來源:ConfigXmlParser.java

示例2: parseStreamElementStartTag

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private void parseStreamElementStartTag(XmlPullParser parser) throws ParserException {
  type = parseType(parser);
  putNormalizedAttribute(KEY_TYPE, type);
  if (type == StreamElement.TYPE_TEXT) {
    subType = parseRequiredString(parser, KEY_SUB_TYPE);
  } else {
    subType = parser.getAttributeValue(null, KEY_SUB_TYPE);
  }
  name = parser.getAttributeValue(null, KEY_NAME);
  qualityLevels = parseInt(parser, KEY_QUALITY_LEVELS, -1);
  url = parseRequiredString(parser, KEY_URL);
  maxWidth = parseInt(parser, KEY_MAX_WIDTH, -1);
  maxHeight = parseInt(parser, KEY_MAX_HEIGHT, -1);
  displayWidth = parseInt(parser, KEY_DISPLAY_WIDTH, -1);
  displayHeight = parseInt(parser, KEY_DISPLAY_HEIGHT, -1);
  language = parser.getAttributeValue(null, KEY_LANGUAGE);
  putNormalizedAttribute(KEY_LANGUAGE, language);
  timescale = parseInt(parser, KEY_TIME_SCALE, -1);
  if (timescale == -1) {
    timescale = (Long) getNormalizedAttribute(KEY_TIME_SCALE);
  }
  startTimes = new ArrayList<>();
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:24,代碼來源:SmoothStreamingManifestParser.java

示例3: handleStartTag

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
public void handleStartTag(XmlPullParser xml) {
    String strNode = xml.getName();
    if (strNode.equals("feature")) {
        //Check for supported feature sets  aka. plugins (Accelerometer, Geolocation, etc)
        //Set the bit for reading params
        insideFeature = true;
        service = xml.getAttributeValue(null, "name");
    }
    else if (insideFeature && strNode.equals("param")) {
        paramType = xml.getAttributeValue(null, "name");
        if (paramType.equals("service")) // check if it is using the older service param
            service = xml.getAttributeValue(null, "value");
        else if (paramType.equals("package") || paramType.equals("android-package"))
            pluginClass = xml.getAttributeValue(null,"value");
        else if (paramType.equals("onload"))
            onload = "true".equals(xml.getAttributeValue(null, "value"));
    }
    else if (strNode.equals("preference")) {
        String name = xml.getAttributeValue(null, "name").toLowerCase(Locale.ENGLISH);
        String value = xml.getAttributeValue(null, "value");
        prefs.set(name, value);
    }
    else if (strNode.equals("content")) {
        String src = xml.getAttributeValue(null, "src");
        if (src != null) {
            setStartUrl(src);
        }
    }
}
 
開發者ID:Andy-Ta,項目名稱:COB,代碼行數:30,代碼來源:ConfigXmlParser.java

示例4: action

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void action( Dsmlv2Container container ) throws XmlPullParserException
{
    PresentFilter presentFilter = new PresentFilter();

    XmlPullParser xpp = container.getParser();

    // Adding the filter to the Search Filter
    SearchRequestDsml searchRequestDecorator = ( SearchRequestDsml )
        container.getBatchRequest().getCurrentRequest();

    try
    {
        searchRequestDecorator.addCurrentFilter( presentFilter );
    }
    catch ( DecoderException de )
    {
        throw new XmlPullParserException( de.getMessage(), xpp, de );
    }

    // Checking and adding the filter's attributes
    String attributeValue;
    // name
    attributeValue = xpp.getAttributeValue( "", NAME );

    if ( attributeValue != null )
    {
        presentFilter.setAttributeDescription( attributeValue );
    }
    else
    {
        throw new XmlPullParserException( "name attribute is required", xpp, null );
    }
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:38,代碼來源:Dsmlv2Grammar.java

示例5: handleStartTag

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private void handleStartTag(XmlPullParser xml) {
  String strNode = xml.getName();
  if (strNode.equals("preference")) {
    String name = xml.getAttributeValue(null, "name").toLowerCase(Locale.ENGLISH);
    String value = xml.getAttributeValue(null, "value");
    prefs.set(name, value);
  }
}
 
開發者ID:wangwei123,項目名稱:my-weex,代碼行數:9,代碼來源:AppConfigXmlParser.java

示例6: readLongAttribute

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private long readLongAttribute(XmlPullParser parser, String attr, long defaultValue) {
    String valueString = parser.getAttributeValue(null, attr);
    if (valueString == null) return defaultValue;
    try {
        return Long.parseLong(valueString);
    } catch (NumberFormatException nfe) {
        return defaultValue;
    }
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:10,代碼來源:VUserManagerService.java

示例7: processACL

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
 * Process ACL definition
 * 
 * @param xpp XmlPullParser
 * @param parserContext ParserContext
 */
private void processACL(XmlPullParser xpp, ParserContext parserContext)
{
    NodeContext node = peekNodeContext(parserContext.elementStack);
    
    String strInherit = xpp.getAttributeValue(NamespaceService.REPOSITORY_VIEW_1_0_URI, VIEW_INHERIT_PERMISSIONS_ATTR);
    if (strInherit != null)
    {
        Boolean inherit = Boolean.valueOf(strInherit);
        if (!inherit)
        {
            node.setInheritPermissions(false);
        }
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:21,代碼來源:ViewParser.java

示例8: onStartReadXmlTag

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
 * XML interface: callback on start of an xml tag reading
 */
public boolean onStartReadXmlTag(XmlPullParser parser)
{
    if (getBaseType().toString().equalsIgnoreCase(parser.getName()))
    {
        String attr = parser.getAttributeValue(null, FormulaList.XML_PROP_INRIGHTOFPREVIOUS);
        if (attr != null)
        {
            inRightOfPrevious = Boolean.valueOf(attr);
        }
    }
    return false;
}
 
開發者ID:mkulesh,項目名稱:microMathematics,代碼行數:16,代碼來源:FormulaBase.java

示例9: readFromXml

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
public void readFromXml(XmlPullParser parser)
{
    final DecimalFormat df = CompatUtils.getDecimalFormat("0.00000");
    String attr = parser.getAttributeValue(null, XML_PROP_VERSION);
    documentVersion = (attr != null)? Integer.parseInt(attr) : DEFAULT_DOCUMENT_VERSION;
    attr = parser.getAttributeValue(null, XML_PROP_TEXT_WIDTH);
    if (attr != null)
    {
        textWidth = Integer.parseInt(attr);
    }
    attr = parser.getAttributeValue(null, XML_PROP_SIGNIFICANT_DIGITS);
    if (attr != null)
    {
        significantDigits = Integer.parseInt(attr);
    }
    attr = parser.getAttributeValue(null, XML_PROP_SCALE);
    if (attr != null)
    {
        try
        {
            scaledDimensions.setScaleFactor(df.parse(attr).floatValue());
        }
        catch (ParseException e)
        {
            scaledDimensions.setScaleFactor(1.0f);
        }
    }
    attr = parser.getAttributeValue(null, XML_PROP_REDEFINE_ALLOWED);
    if (attr != null)
    {
        redefineAllowed = Boolean.parseBoolean(attr);
    }
}
 
開發者ID:mkulesh,項目名稱:microMathematics,代碼行數:34,代碼來源:DocumentProperties.java

示例10: action

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void action( Dsmlv2Container container ) throws XmlPullParserException
{
    ModDNResponseDsml modDNResponse = new ModDNResponseDsml(
        container.getLdapCodecService(), new ModifyDnResponseImpl() );
    container.getBatchResponse().addResponse( modDNResponse );

    LdapResult ldapResult = modDNResponse.getLdapResult();

    XmlPullParser xpp = container.getParser();

    // Checking and adding the batchRequest's attributes
    String attributeValue;
    // requestID
    attributeValue = xpp.getAttributeValue( "", "requestID" );

    if ( attributeValue != null )
    {
        modDNResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
    }

    // MatchedDN
    attributeValue = xpp.getAttributeValue( "", "matchedDN" );

    if ( attributeValue != null )
    {
        try
        {
            ldapResult.setMatchedDn( new Dn( attributeValue ) );
        }
        catch ( LdapInvalidDnException lide )
        {
            throw new XmlPullParserException( lide.getMessage(), xpp, lide );
        }
    }
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:40,代碼來源:Dsmlv2ResponseGrammar.java

示例11: parseRequiredString

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
protected final String parseRequiredString(XmlPullParser parser, String key)
    throws MissingFieldException {
  String value = parser.getAttributeValue(null, key);
  if (value != null) {
    return value;
  } else {
    throw new MissingFieldException(key);
  }
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:10,代碼來源:SmoothStreamingManifestParser.java

示例12: readIntAttribute

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
public static int readIntAttribute(XmlPullParser in, String name, int defaultValue) {
    final String value = in.getAttributeValue(null, name);
    if (TextUtils.isEmpty(value)) {
        return defaultValue;
    }
    try {
        return Integer.parseInt(value);
    } catch (NumberFormatException e) {
        return defaultValue;
    }
}
 
開發者ID:ukanth,項目名稱:XPrivacy,代碼行數:12,代碼來源:XmlUtils.java

示例13: readUrl

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private static void readUrl(XmlPullParser parser, SearchEngine searchEngine) throws XmlPullParserException, IOException {
    parser.require(XmlPullParser.START_TAG, null, "Url");

    final String type = parser.getAttributeValue(null, "type");
    final String template = parser.getAttributeValue(null, "template");
    final String rel = parser.getAttributeValue(null, "rel");

    Uri uri = Uri.parse(template);

    while (parser.next() != XmlPullParser.END_TAG) {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }

        final String tag = parser.getName();

        if (tag.equals("Param")) {
            final String name = parser.getAttributeValue(null, "name");
            final String value = parser.getAttributeValue(null, "value");
            uri = uri.buildUpon().appendQueryParameter(name, value).build();
            parser.nextTag();
        } else {
            skip(parser);
        }
    }

    if (type.equals(URLTYPE_SEARCH_HTML)) {
        // Prefer mobile URIs.
        if (rel != null && rel.equals(URL_REL_MOBILE)) {
            searchEngine.resultsUris.add(0, uri);
        } else {
            searchEngine.resultsUris.add(uri);
        }
    } else if (type.equals(URLTYPE_SUGGEST_JSON)) {
        searchEngine.suggestUri = uri;
    }
}
 
開發者ID:mozilla-mobile,項目名稱:firefox-tv,代碼行數:38,代碼來源:SearchEngineParser.java

示例14: parseAccount

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private static ImportedAccount parseAccount(XmlPullParser xpp, List<String> accountUuids, boolean overview)
        throws XmlPullParserException, IOException {

    String uuid = xpp.getAttributeValue(null, SettingsExporter.UUID_ATTRIBUTE);

    try {
        UUID.fromString(uuid);
    } catch (Exception e) {
        skipToEndTag(xpp, SettingsExporter.ACCOUNT_ELEMENT);
        Timber.w("Skipping account with invalid UUID %s", uuid);
        return null;
    }

    ImportedAccount account = new ImportedAccount();
    account.uuid = uuid;

    if (overview || accountUuids.contains(uuid)) {
        int eventType = xpp.next();
        while (!(eventType == XmlPullParser.END_TAG && SettingsExporter.ACCOUNT_ELEMENT.equals(xpp.getName()))) {
            if (eventType == XmlPullParser.START_TAG) {
                String element = xpp.getName();
                if (SettingsExporter.NAME_ELEMENT.equals(element)) {
                    account.name = getText(xpp);
                } else if (SettingsExporter.INCOMING_SERVER_ELEMENT.equals(element)) {
                    if (overview) {
                        skipToEndTag(xpp, SettingsExporter.INCOMING_SERVER_ELEMENT);
                    } else {
                        account.incoming = parseServerSettings(xpp, SettingsExporter.INCOMING_SERVER_ELEMENT);
                    }
                } else if (SettingsExporter.OUTGOING_SERVER_ELEMENT.equals(element)) {
                    if (overview) {
                        skipToEndTag(xpp, SettingsExporter.OUTGOING_SERVER_ELEMENT);
                    } else {
                        account.outgoing = parseServerSettings(xpp, SettingsExporter.OUTGOING_SERVER_ELEMENT);
                    }
                } else if (SettingsExporter.SETTINGS_ELEMENT.equals(element)) {
                    if (overview) {
                        skipToEndTag(xpp, SettingsExporter.SETTINGS_ELEMENT);
                    } else {
                        account.settings = parseSettings(xpp, SettingsExporter.SETTINGS_ELEMENT);
                    }
                } else if (SettingsExporter.IDENTITIES_ELEMENT.equals(element)) {
                    account.identities = parseIdentities(xpp);
                } else if (SettingsExporter.FOLDERS_ELEMENT.equals(element)) {
                    if (overview) {
                        skipToEndTag(xpp, SettingsExporter.FOLDERS_ELEMENT);
                    } else {
                        account.folders = parseFolders(xpp);
                    }
                } else {
                    Timber.w("Unexpected start tag: %s", xpp.getName());
                }
            }
            eventType = xpp.next();
        }
    } else {
        skipToEndTag(xpp, SettingsExporter.ACCOUNT_ELEMENT);
        Timber.i("Skipping account with UUID %s", uuid);
    }

    // If we couldn't find an account name use the UUID
    if (account.name == null) {
        account.name = uuid;
    }

    return account;
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:68,代碼來源:SettingsImporter.java

示例15: readTrkPoint

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private LocSample readTrkPoint(XmlPullParser parser) {
    String szLat = parser.getAttributeValue(null, "lat");
    String szLon = parser.getAttributeValue(null, "lon");

    return new LocSample(Double.parseDouble(szLat), Double.parseDouble(szLon), 0, 0, 1.0, "");
}
 
開發者ID:ericberman,項目名稱:MyFlightbookAndroid,代碼行數:7,代碼來源:GPX.java


注:本文中的org.xmlpull.v1.XmlPullParser.getAttributeValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。