本文整理汇总了Java中org.xmlpull.v1.XmlPullParser.END_DOCUMENT属性的典型用法代码示例。如果您正苦于以下问题:Java XmlPullParser.END_DOCUMENT属性的具体用法?Java XmlPullParser.END_DOCUMENT怎么用?Java XmlPullParser.END_DOCUMENT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.xmlpull.v1.XmlPullParser
的用法示例。
在下文中一共展示了XmlPullParser.END_DOCUMENT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readThisListXml
@SuppressWarnings("unchecked")
private static ArrayList readThisListXml(XmlPullParser parser, String endTag, String[] name)
throws XmlPullParserException, IOException {
ArrayList list = new ArrayList();
int eventType = parser.getEventType();
do {
if (eventType == XmlPullParser.START_TAG) {
Object val = readThisValueXml(parser, name);
list.add(val);
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals(endTag)) {
return list;
}
throw new XmlPullParserException("Expected " + endTag + " end tag at: " + parser.getName());
}
eventType = parser.next();
} while (eventType != XmlPullParser.END_DOCUMENT);
throw new XmlPullParserException("Document ended before " + endTag + " end tag");
}
示例2: parseTbodyXml
private static List<SupportedLanguage> parseTbodyXml(@NonNull XmlPullParser parser) throws Throwable {
List<SupportedLanguage> tableRows = new LinkedList<>();
int eventType = parser.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
switch (eventType) {
case XmlPullParser.START_TAG: {
if ("tr".equalsIgnoreCase(parser.getName())) {
List<String> tableRow = parseTableRow(parser);
SupportedLanguage convertedEntry = convertElementsToSupportedLanguage(tableRow);
tableRows.add(convertedEntry);
}
break;
}
}
eventType = parser.next();
}
return tableRows;
}
示例3: parseLayout
/**
* Parses the layout and returns the number of elements added on the homescreen.
*/
private int parseLayout(int layoutId, ArrayList<Long> screenIds)
throws XmlPullParserException, IOException {
XmlResourceParser parser = mSourceRes.getXml(layoutId);
beginDocument(parser, mRootTag);
final int depth = parser.getDepth();
int type;
HashMap<String, TagParser> tagParserMap = getLayoutElementsMap();
int count = 0;
while (((type = parser.next()) != XmlPullParser.END_TAG ||
parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
if (type != XmlPullParser.START_TAG) {
continue;
}
count += parseAndAddNode(parser, tagParserMap, screenIds);
}
return count;
}
示例4: parseMerge
private void parseMerge(final XmlPullParser parser, final KeyboardRow row, final boolean skip)
throws XmlPullParserException, IOException {
if (DEBUG) startTag("<%s>", TAG_MERGE);
while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
final int event = parser.next();
if (event == XmlPullParser.START_TAG) {
final String tag = parser.getName();
if (TAG_MERGE.equals(tag)) {
if (row == null) {
parseKeyboardContent(parser, skip);
} else {
parseRowContent(parser, row, skip);
}
return;
}
throw new XmlParseUtils.ParseException(
"Included keyboard layout must have <merge> root element", parser);
}
}
}
示例5: parse
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);
}
}
示例6: generateServicesMap
private void generateServicesMap(List<ResolveInfo> services, Map<String, SyncAdapterInfo> map,
RegisteredServicesParser accountParser) {
for (ResolveInfo info : services) {
XmlResourceParser parser = accountParser.getParser(mContext, info.serviceInfo, "android.content.SyncAdapter");
if (parser != null) {
try {
AttributeSet attributeSet = Xml.asAttributeSet(parser);
int type;
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) {
// Nothing to do
}
if ("sync-adapter".equals(parser.getName())) {
SyncAdapterType adapterType = parseSyncAdapterType(
accountParser.getResources(mContext, info.serviceInfo.applicationInfo), attributeSet);
if (adapterType != null) {
String key = adapterType.accountType + "/" + adapterType.authority;
map.put(key, new SyncAdapterInfo(adapterType, info.serviceInfo));
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
示例7: beginDocument
private static void beginDocument(XmlPullParser parser, String firstElementName)
throws XmlPullParserException, IOException {
int type;
while ((type = parser.next()) != XmlPullParser.START_TAG &&
type != XmlPullParser.END_DOCUMENT) {
// Empty
}
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);
}
}
示例8: skipCurrentTag
public static void skipCurrentTag(XmlPullParser parser)
throws XmlPullParserException, IOException {
int outerDepth = parser.getDepth();
int type;
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
&& (type != XmlPullParser.END_TAG
|| parser.getDepth() > outerDepth)) {
}
}
示例9: parseApplicationNameByManifest
/**
* get application name by manifest
*
* @param parser parser
* @return application name
*/
private static String parseApplicationNameByManifest(XmlPullParser parser) {
try {
int eventType = parser.getEventType();
String namespaceAndroid = null;
do {
switch (eventType) {
case XmlPullParser.START_DOCUMENT: {
break;
}
case XmlPullParser.START_TAG: {
String tag = parser.getName();
if (tag.equals("manifest")) {
namespaceAndroid = parser.getNamespace("android");
} else if ("application".equals(parser.getName())) {
String applicationName = parser.getAttributeValue("", "name");
if (applicationName == null || "".equals(applicationName)) {
applicationName = parser.getAttributeValue(namespaceAndroid, "name");
}
return applicationName;
}
break;
}
case XmlPullParser.END_TAG: {
break;
}
}
eventType = parser.next();
} while (eventType != XmlPullParser.END_DOCUMENT);
} catch (Exception e1) {
}
return "";
}
示例10: getPredefinedDeviceProfiles
ArrayList<InvariantDeviceProfile> getPredefinedDeviceProfiles(Context context) {
ArrayList<InvariantDeviceProfile> profiles = new ArrayList<>();
try (XmlResourceParser parser = context.getResources().getXml(R.xml.device_profiles)) {
final int depth = parser.getDepth();
int type;
while (((type = parser.next()) != XmlPullParser.END_TAG ||
parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
if ((type == XmlPullParser.START_TAG) && "profile".equals(parser.getName())) {
TypedArray a = context.obtainStyledAttributes(
Xml.asAttributeSet(parser), R.styleable.InvariantDeviceProfile);
int numRows = a.getInt(R.styleable.InvariantDeviceProfile_numRows, 0);
int numColumns = a.getInt(R.styleable.InvariantDeviceProfile_numColumns, 0);
float iconSize = a.getFloat(R.styleable.InvariantDeviceProfile_iconSize, 0);
profiles.add(new InvariantDeviceProfile(
a.getString(R.styleable.InvariantDeviceProfile_name),
a.getFloat(R.styleable.InvariantDeviceProfile_minWidthDps, 0),
a.getFloat(R.styleable.InvariantDeviceProfile_minHeightDps, 0),
numRows,
numColumns,
a.getInt(R.styleable.InvariantDeviceProfile_numFolderRows, numRows),
a.getInt(R.styleable.InvariantDeviceProfile_numFolderColumns, numColumns),
a.getInt(R.styleable.InvariantDeviceProfile_minAllAppsPredictionColumns, numColumns),
iconSize,
a.getFloat(R.styleable.InvariantDeviceProfile_iconTextSize, 0),
a.getInt(R.styleable.InvariantDeviceProfile_numHotseatIcons, numColumns),
a.getFloat(R.styleable.InvariantDeviceProfile_hotseatIconSize, iconSize),
a.getResourceId(R.styleable.InvariantDeviceProfile_defaultLayoutId, 0)));
a.recycle();
}
}
} catch (IOException|XmlPullParserException e) {
throw new RuntimeException(e);
}
return profiles;
}
示例11: nextElementWithin
public static boolean nextElementWithin(XmlPullParser parser, int outerDepth)
throws IOException, XmlPullParserException {
for (;;) {
int type = parser.next();
if (type == XmlPullParser.END_DOCUMENT
|| (type == XmlPullParser.END_TAG && parser.getDepth() == outerDepth)) {
return false;
}
if (type == XmlPullParser.START_TAG
&& parser.getDepth() == outerDepth + 1) {
return true;
}
}
}
示例12: parserSimples
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;
}
示例13: parseImpl
public static ProcedureInfo parseImpl(XmlPullParser parser)
throws BlockLoadingException, IOException, XmlPullParserException {
List<String> argNames = new ArrayList<>();
String procedureName = null;
boolean hasStatementInput = HAS_STATEMENTS_DEFAULT;
int tokenType = parser.next();
if (tokenType != XmlPullParser.END_DOCUMENT) {
parser.require(XmlPullParser.START_TAG, null, Mutator.TAG_MUTATION);
String attrValue = parser.getAttributeValue(null, ATTR_NAME);
if (!TextUtils.isEmpty(attrValue)) {
procedureName = attrValue;
}
attrValue = parser.getAttributeValue(null, ATTR_STATEMENTS);
if (!TextUtils.isEmpty(attrValue)) {
hasStatementInput = Boolean.getBoolean(attrValue);
}
tokenType = parser.next();
while (tokenType != XmlPullParser.END_DOCUMENT) {
if (tokenType == XmlPullParser.START_TAG) {
parser.require(XmlPullParser.START_TAG, null, TAG_ARG);
String argName = parser.getAttributeValue(null, ATTR_ARG_NAME);
if (argName == null) {
throw new BlockLoadingException(
"Function argument #" + argNames.size() + " missing name.");
}
argNames.add(argName);
} else if (tokenType == XmlPullParser.END_TAG
&& parser.getName().equals(Mutator.TAG_MUTATION)) {
break;
}
tokenType = parser.next();
}
}
return new ProcedureInfo(procedureName, argNames, hasStatementInput);
}
示例14: loadAllDrawables
private void loadAllDrawables(String packageName) {
mDrawables.clear();
XmlPullParser xpp;
try {
Resources res = mPackageManager.getResourcesForApplication(packageName);
mCurrentIconPackRes = res;
int resource = res.getIdentifier("drawable", "xml", packageName);
if (resource < 0) {
return;
}
xpp = res.getXml(resource);
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) {
if (xpp.getName().equals("item")) {
String drawableName = xpp.getAttributeValue(null, "drawable");
if (!mDrawables.contains(drawableName) &&
getIdentifier(packageName, drawableName, true) > 0) {
mDrawables.add(drawableName);
}
}
}
eventType = xpp.next();
}
} catch (Exception e) {
e.printStackTrace();
// fallback onto appfilter if drawable xml fails
loadIconPack(packageName, true, mContext);
}
}
示例15: retrieveSupportedDevices
private static void retrieveSupportedDevices(final Resources resources) {
final String tag = "retrieveDeviceData - ";
if (supportedDevices == null) {
final List<SupportedDevice> result = new ArrayList<>();
final XmlResourceParser xml = resources.getXml(R.xml.supported_devices);
try {
xml.next();
int eventType;
while ((eventType = xml.getEventType()) != XmlPullParser.END_DOCUMENT) {
switch (eventType) {
case XmlPullParser.START_TAG:
if (xml.getName().equals("usb-device")) {
final AttributeSet as = Xml.asAttributeSet(xml);
final Integer vendorId = parseInt(as.getAttributeValue(null, "vendor-id"));
final Integer productId = parseInt(as.getAttributeValue(null, "product-id"));
// Read description
String description=null;
xml.next();
if (xml.getName().equals("description")) {
xml.require(XmlPullParser.START_TAG, null, "description");
if (xml.next() == XmlPullParser.TEXT) {
description = xml.getText();
xml.nextTag();
}
xml.require(XmlPullParser.END_TAG, null, "description");
}
result.add(new SupportedDevice(new Pair<>(vendorId, productId), description));
}
break;
}
xml.next();
}
} catch (XmlPullParserException | IOException e) {
Log.e(TAG, tag, e);
}
supportedDevices = result;
}
}