本文整理汇总了Java中org.xmlpull.v1.XmlPullParserException类的典型用法代码示例。如果您正苦于以下问题:Java XmlPullParserException类的具体用法?Java XmlPullParserException怎么用?Java XmlPullParserException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlPullParserException类属于org.xmlpull.v1包,在下文中一共展示了XmlPullParserException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.xmlpull.v1.XmlPullParserException; //导入依赖的package包/类
private void parse() {
try {
parser.next();
int eventType = parser.getEventType();
while (eventType != XmlResourceParser.END_DOCUMENT) {
if(eventType == XmlResourceParser.START_TAG) {
parseNewTab(parser);
} else if(eventType == XmlResourceParser.END_TAG) {
if (parser.getName().equals("tab")) {
if (workingTab != null) {
tabs.add(workingTab);
workingTab = null;
}
}
}
eventType = parser.next();
}
} catch (IOException | XmlPullParserException e) {
e.printStackTrace();
throw new TabParserException();
}
}
示例2: readScriptId
import org.xmlpull.v1.XmlPullParserException; //导入依赖的package包/类
static int readScriptId(final Resources resources, final InputMethodSubtype subtype) {
final String layoutSetName = KEYBOARD_LAYOUT_SET_RESOURCE_PREFIX
+ SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype);
final int xmlId = getXmlId(resources, layoutSetName);
final XmlResourceParser parser = resources.getXml(xmlId);
try {
while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
// Bovinate through the XML stupidly searching for TAG_FEATURE, and read
// the script Id from it.
parser.next();
final String tag = parser.getName();
if (TAG_FEATURE.equals(tag)) {
return readScriptIdFromTagFeature(resources, parser);
}
}
} catch (final IOException | XmlPullParserException e) {
throw new RuntimeException(e.getMessage() + " in " + layoutSetName, e);
} finally {
parser.close();
}
// If the tag is not found, then the default script is Latin.
return ScriptUtils.SCRIPT_LATIN;
}
示例3: parseAndAdd
import org.xmlpull.v1.XmlPullParserException; //导入依赖的package包/类
@Override
public long parseAndAdd(XmlResourceParser parser) throws XmlPullParserException,
IOException {
final int groupDepth = parser.getDepth();
int type;
long addedId = -1;
while ((type = parser.next()) != XmlPullParser.END_TAG ||
parser.getDepth() > groupDepth) {
if (type != XmlPullParser.START_TAG || addedId > -1) {
continue;
}
final String fallback_item_name = parser.getName();
if (TAG_FAVORITE.equals(fallback_item_name)) {
addedId = mChildParser.parseAndAdd(parser);
} else {
Log.e(TAG, "Fallback groups can contain only favorites, found "
+ fallback_item_name);
}
}
return addedId;
}
示例4: inflate
import org.xmlpull.v1.XmlPullParserException; //导入依赖的package包/类
public void inflate(int menuRes, Menu menu) {
if (menu instanceof SupportMenu) {
XmlResourceParser parser = null;
try {
parser = this.mContext.getResources().getLayout(menuRes);
parseMenu(parser, Xml.asAttributeSet(parser), menu);
if (parser != null) {
parser.close();
}
} catch (XmlPullParserException e) {
throw new InflateException("Error inflating menu XML", e);
} catch (IOException e2) {
throw new InflateException("Error inflating menu XML", e2);
} catch (Throwable th) {
if (parser != null) {
parser.close();
}
}
} else {
super.inflate(menuRes, menu);
}
}
示例5: getPIData
import org.xmlpull.v1.XmlPullParserException; //导入依赖的package包/类
public static String getPIData(XmlPullParser var0) throws IllegalStateException {
int var1;
try {
var1 = var0.getEventType();
} catch (XmlPullParserException var5) {
throw new IllegalStateException("could not determine parser state: " + var5 + var0.getPositionDescription());
}
if(var1 != 8) {
throw new IllegalStateException("parser must be on processing instruction and not " + XmlPullParser.TYPES[var1] + var0.getPositionDescription());
} else {
String var2 = var0.getText();
int var3 = -1;
for(int var4 = 0; var4 < var2.length(); ++var4) {
if(isS(var2.charAt(var4))) {
var3 = var4;
} else if(var3 > 0) {
return var2.substring(var4);
}
}
return "";
}
}
示例6: writeSetXml
import org.xmlpull.v1.XmlPullParserException; //导入依赖的package包/类
public static final void writeSetXml(Set val, String name, XmlSerializer out)
throws XmlPullParserException, java.io.IOException {
if (val == null) {
out.startTag(null, "null");
out.endTag(null, "null");
return;
}
out.startTag(null, "set");
if (name != null) {
out.attribute(null, "name", name);
}
for (Object v : val) {
writeValueXml(v, null, out);
}
out.endTag(null, "set");
}
示例7: parseServerSettings
import org.xmlpull.v1.XmlPullParserException; //导入依赖的package包/类
private static ImportedServer parseServerSettings(XmlPullParser xpp, String endTag)
throws XmlPullParserException, IOException {
ImportedServer server = new ImportedServer();
server.type = xpp.getAttributeValue(null, SettingsExporter.TYPE_ATTRIBUTE);
int eventType = xpp.next();
while (!(eventType == XmlPullParser.END_TAG && endTag.equals(xpp.getName()))) {
if (eventType == XmlPullParser.START_TAG) {
String element = xpp.getName();
if (SettingsExporter.HOST_ELEMENT.equals(element)) {
server.host = getText(xpp);
} else if (SettingsExporter.PORT_ELEMENT.equals(element)) {
server.port = getText(xpp);
} else if (SettingsExporter.CONNECTION_SECURITY_ELEMENT.equals(element)) {
server.connectionSecurity = getText(xpp);
} else if (SettingsExporter.AUTHENTICATION_TYPE_ELEMENT.equals(element)) {
String text = getText(xpp);
server.authenticationType = AuthType.valueOf(text);
} else if (SettingsExporter.USERNAME_ELEMENT.equals(element)) {
server.username = getText(xpp);
} else if (SettingsExporter.CLIENT_CERTIFICATE_ALIAS_ELEMENT.equals(element)) {
server.clientCertificateAlias = getText(xpp);
} else if (SettingsExporter.PASSWORD_ELEMENT.equals(element)) {
server.password = getText(xpp);
} else if (SettingsExporter.EXTRA_ELEMENT.equals(element)) {
server.extras = parseSettings(xpp, SettingsExporter.EXTRA_ELEMENT);
} else {
Timber.w("Unexpected start tag: %s", xpp.getName());
}
}
eventType = xpp.next();
}
return server;
}
示例8: skip
import org.xmlpull.v1.XmlPullParserException; //导入依赖的package包/类
private static void skip(final XmlPullParser parser) throws XmlPullParserException,
IOException {
if (parser.getEventType() != XmlPullParser.START_TAG) {
throw new IllegalStateException();
}
int depth = 1;
while (depth != 0) {
switch (parser.next()) {
case XmlPullParser.END_TAG:
depth--;
break;
case XmlPullParser.START_TAG:
depth++;
break;
default:
break;
}
}
}
示例9: action
import org.xmlpull.v1.XmlPullParserException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void action( Dsmlv2Container container ) throws XmlPullParserException
{
XmlPullParser xpp = container.getParser();
SearchResponse searchResponse;
// Checking and adding the batchRequest's attributes
String attributeValue = xpp.getAttributeValue( "", "requestID" );
if ( attributeValue != null )
{
searchResponse = new SearchResponse(
ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
}
else
{
searchResponse = new SearchResponse();
}
container.getBatchResponse().addResponse( new SearchResponseDsml(
container.getLdapCodecService(), searchResponse ) );
}
示例10: skip
import org.xmlpull.v1.XmlPullParserException; //导入依赖的package包/类
private void skip(XmlPullParser parser) throws XmlPullParserException, IOException {
if (parser.getEventType() != XmlPullParser.START_TAG) {
throw new IllegalStateException();
}
int depth = 1;
while (depth != 0) {
switch (parser.next()) {
case XmlPullParser.END_TAG:
depth--;
break;
case XmlPullParser.START_TAG:
depth++;
break;
}
}
}
示例11: parseRowAttributes
import org.xmlpull.v1.XmlPullParserException; //导入依赖的package包/类
private KeyboardRow parseRowAttributes(final XmlPullParser parser)
throws XmlPullParserException {
final AttributeSet attr = Xml.asAttributeSet(parser);
final TypedArray keyboardAttr = mResources.obtainAttributes(attr, R.styleable.Keyboard);
try {
if (keyboardAttr.hasValue(R.styleable.Keyboard_horizontalGap)) {
throw new XmlParseUtils.IllegalAttribute(parser, TAG_ROW, "horizontalGap");
}
if (keyboardAttr.hasValue(R.styleable.Keyboard_verticalGap)) {
throw new XmlParseUtils.IllegalAttribute(parser, TAG_ROW, "verticalGap");
}
return new KeyboardRow(mResources, mParams, parser, mCurrentY);
} finally {
keyboardAttr.recycle();
}
}
示例12: getXmlPullParser
import org.xmlpull.v1.XmlPullParserException; //导入依赖的package包/类
/**
* Creates a pull parser with the given input and gobbles up to the first start tag that equals
* {@code returnFirstInstanceOf}.
*/
private XmlPullParser getXmlPullParser(String input, String returnFirstInstanceOf) {
try {
xmlPullParserFactory.setNamespaceAware(true);
XmlPullParser parser = xmlPullParserFactory.newPullParser();
parser.setInput(new ByteArrayInputStream(input.getBytes()), null);
int eventType = parser.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG
&& parser.getName().equalsIgnoreCase(returnFirstInstanceOf)) {
return parser;
}
eventType = parser.next();
}
} catch (XmlPullParserException | IOException e) {
throw new IllegalStateException(e);
}
return null;
}
示例13: parseMerge
import org.xmlpull.v1.XmlPullParserException; //导入依赖的package包/类
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);
}
}
}
示例14: writeBooleanArrayXml
import org.xmlpull.v1.XmlPullParserException; //导入依赖的package包/类
private static void writeBooleanArrayXml(boolean[] val, String name, XmlSerializer out)
throws XmlPullParserException, IOException {
if (val == null) {
out.startTag(null, "null");
out.endTag(null, "null");
return;
}
out.startTag(null, "boolean-array");
if (name != null) {
out.attribute(null, "name", name);
}
final int N = val.length;
out.attribute(null, "num", Integer.toString(N));
for (int i = 0; i < N; i++) {
out.startTag(null, "item");
out.attribute(null, "value", Boolean.toString(val[i]));
out.endTag(null, "item");
}
out.endTag(null, "boolean-array");
}
示例15: skipXmlTagParse
import org.xmlpull.v1.XmlPullParserException; //导入依赖的package包/类
private void skipXmlTagParse(XmlPullParser parser) throws XmlPullParserException, IOException {
if (parser.getEventType() != XmlPullParser.START_TAG) {
throw new IllegalStateException();
}
int depth = 1;
while (depth != 0) {
switch (parser.next()) {
case XmlPullParser.END_TAG:
depth--;
break;
case XmlPullParser.START_TAG:
depth++;
break;
}
}
}