本文整理匯總了Java中org.xmlpull.v1.XmlPullParser.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlPullParser.getName方法的具體用法?Java XmlPullParser.getName怎麽用?Java XmlPullParser.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.xmlpull.v1.XmlPullParser
的用法示例。
在下文中一共展示了XmlPullParser.getName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleEndTag
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private void handleEndTag(XmlPullParser xml) {
String strNode = xml.getName();
if (strNode.equals(Constants.TAG_FEATURE)) {
if (TextUtils.equals(Constants.CATEGORY_MODULE, mCategory)) {
mModules.put(mApi, new PluginEntry(mApi, mPluginClass, mOnLoad, Constants.CATEGORY_MODULE));
} else if (TextUtils.equals(Constants.CATEGORY_COMPONENT, mCategory)) {
mComponents.put(mApi, new PluginEntry(mApi, mPluginClass, mOnLoad, Constants.CATEGORY_COMPONENT));
}
mService = "";
mPluginClass = "";
mInsideFeature = false;
mOnLoad = false;
mCategory = Constants.CATEGORY_MODULE;
mApi = "";
mParamType = "";
}
}
示例2: readRecommendationConfig
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private Map<String, String> readRecommendationConfig(XmlPullParser parser) throws XmlPullParserException, IOException {
Map<String, String> retValue = new HashMap<>();
while (parser.next() != XmlPullParser.END_TAG) {
if (parser.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = parser.getName();
if (name.equals("recommendation"))
{
parser.require(XmlPullParser.START_TAG, ns, "recommendation");
String recName = parser.getAttributeValue(ns, "name");
String value = readText(parser);
if (recName == null || value == null || !HelperFunctions.testIsValidURL(value)) {
WebtrekkLogging.log("invalid parameter configuration while reading recommendation value, missing name or value or value URL incorrect");
} else {
retValue.put(recName, value);
}
}
}
return retValue;
}
示例3: readCodeFiles
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private List<String> readCodeFiles(XmlPullParser parser) throws XmlPullParserException {
final List<String> result = new ArrayList<>();
try {
parser.require(XmlPullParser.START_TAG, null, CODE_FILES);
while(parser.next() != XmlPullParser.END_TAG){
if(parser.getEventType() != XmlPullParser.START_TAG) {
continue;
}
final String name = parser.getName();
if (name.equals("string")) {
result.add(readText(parser));
}
}
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
示例4: parse
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
Podcasts parse(InputStream input, @Nullable String charset, String baseUri) throws IOException {
try {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(false);
XmlPullParser xpp = factory.newPullParser();
xpp.setInput(input, charset);
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) {
String tag = xpp.getName();
if (LayoutUtils.isDiv(tag) && hasClass(xpp, PODCAST_LIST_CLASS)) {
return parsePodcasts(xpp, NetworkUtils.toOptURI(baseUri));
}
}
eventType = lenientNext(xpp);
}
return new Podcasts();
} catch (XmlPullParserException e) {
throw new IOException(e);
}
}
示例5: beginDocument
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
protected static final void beginDocument(XmlPullParser parser, String firstElementName)
throws XmlPullParserException, IOException {
int type;
while ((type = parser.next()) != XmlPullParser.START_TAG
&& type != XmlPullParser.END_DOCUMENT);
if (type != XmlPullParser.START_TAG) {
throw new XmlPullParserException("No start tag found");
}
if (!parser.getName().equals(firstElementName)) {
throw new XmlPullParserException("Unexpected start tag: found " + parser.getName() +
", expected " + firstElementName);
}
}
示例6: handleEndTag
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
public void handleEndTag(XmlPullParser xml) {
String strNode = xml.getName();
if (strNode.equals("feature")) {
pluginEntries.add(new PluginEntry(service, pluginClass, onload));
service = "";
pluginClass = "";
insideFeature = false;
onload = false;
}
}
示例7: 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);
}
}
}
示例8: handleEndTag
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
@Override
public void handleEndTag(final XmlPullParser xml) {
if (didParseChcpBlock) {
return;
}
final String name = xml.getName();
if (XmlTags.MAIN_TAG.equals(name)) {
didParseChcpBlock = true;
isInsideChcpBlock = false;
}
}
示例9: setParameterConfigurationFromXml
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private void setParameterConfigurationFromXml(XmlPullParser parser, Map<String, String> values, Map<String, String> constValues) throws XmlPullParserException, IOException {
while (parser.next() != XmlPullParser.END_TAG) {
if (parser.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = parser.getName();
if (name.equals("parameter")) {
parser.require(XmlPullParser.START_TAG, ns, "parameter");
// the id from the parameter identifies the parameter
String id = parser.getAttributeValue(ns, "id");
// the key is the key in the custom parameter object
String key = parser.getAttributeValue(ns, "key");
String value = readText(parser);
if (id == null || (value == null && key == null)) {
WebtrekkLogging.log("invalid parameter configuration while reading parameter, missing key or value");
} else {
// if no key is set, it is a const value
if(key == null) {
constValues.put(id, value);
} else {
// else its a mapped value which will be replaced at runtime
values.put(id, key);
//parser.nextTag();
}
}
} else {
WebtrekkLogging.log("parameter: unknown xml tag: " + name);
skip(parser);
}
}
}
示例10: parseRecords
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private static Records parseRecords(XmlPullParser xpp, @Nullable URI uri) throws IOException, XmlPullParserException {
Records records = new Records();
LayoutUtils.Stack path = new LayoutUtils.Stack(3);
push(path, xpp);
int eventType = lenientNext(xpp);
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) {
String tag = xpp.getName();
if (LayoutUtils.isDiv(tag) && hasClass(xpp, RECORD_ITEM_CLASS)) {
Record record = parseRecord(xpp, uri);
if (record != null) {
records.add(record);
}
} else {
push(path, xpp);
}
} else if (eventType == XmlPullParser.END_TAG) {
pop(path, xpp);
if (path.isEmpty()) {
break;
}
}
eventType = lenientNext(xpp);
}
return records;
}
示例11: parserSimples
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
public static List<String> parserSimples(String rssFeed) throws XmlPullParserException, IOException {
// pegando instancia da XmlPullParserFactory [singleton]
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
// criando novo objeto do tipo XmlPullParser
XmlPullParser parser = factory.newPullParser();
// Definindo a entrada do nosso parser - argumento passado como parametro
parser.setInput(new StringReader(rssFeed));
// Definindo retorno
List<String> items = new ArrayList<String>();
while (parser.next() != XmlPullParser.END_DOCUMENT) {
if (parser.getEventType() == XmlPullParser.START_TAG) {
String tag = parser.getName();
//delimitando que estamos apenas interessados em tags <item>
if (tag.equals("item")) {
String title = "";
while (parser.next() != XmlPullParser.END_TAG) {
if (parser.getEventType() == XmlPullParser.START_TAG) {
String tagAberta = parser.getName();
//pegando as tags <title>
if (tagAberta.equals("title")) {
title = parser.nextText();
items.add(title);
} else {
parser.next();
}
parser.nextTag();
}
}
}
}
}
return items;
}
示例12: readStable
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
private void readStable(XmlPullParser parser) throws XmlPullParserException, IOException {
while (parser.next() != XmlPullParser.END_TAG) {
if (parser.getEventType() != XmlPullParser.START_TAG) {
continue;
}
String name = parser.getName();
if (name.equalsIgnoreCase(mDeviceName)) {
readDevice(parser);
} else {
skip(parser);
}
}
}
示例13: 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);
}
}
示例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;
}
示例15: parse
import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
public final Object parse(XmlPullParser xmlParser) throws XmlPullParserException, IOException,
ParserException {
String tagName;
boolean foundStartTag = false;
int skippingElementDepth = 0;
while (true) {
int eventType = xmlParser.getEventType();
switch (eventType) {
case XmlPullParser.START_TAG:
tagName = xmlParser.getName();
if (tag.equals(tagName)) {
foundStartTag = true;
parseStartTag(xmlParser);
} else if (foundStartTag) {
if (skippingElementDepth > 0) {
skippingElementDepth++;
} else if (handleChildInline(tagName)) {
parseStartTag(xmlParser);
} else {
ElementParser childElementParser = newChildParser(this, tagName, baseUri);
if (childElementParser == null) {
skippingElementDepth = 1;
} else {
addChild(childElementParser.parse(xmlParser));
}
}
}
break;
case XmlPullParser.TEXT:
if (foundStartTag && skippingElementDepth == 0) {
parseText(xmlParser);
}
break;
case XmlPullParser.END_TAG:
if (foundStartTag) {
if (skippingElementDepth > 0) {
skippingElementDepth--;
} else {
tagName = xmlParser.getName();
parseEndTag(xmlParser);
if (!handleChildInline(tagName)) {
return build();
}
}
}
break;
case XmlPullParser.END_DOCUMENT:
return null;
default:
// Do nothing.
break;
}
xmlParser.next();
}
}