use of org.xmlpull.v1.XmlPullParserException in project AsmackService by rtreffer.
the class XmppInputStream method attach.
/**
* Attach to an underlying input stream, usually done during feature
* negotiation as some features require stream resets.
* @param in InputStream The new underlying input stream.
* @throws XmppTransportException In case of a transport error.
*/
public void attach(InputStream in) throws XmppTransportException {
this.inputStream = in;
try {
parser = XMLUtils.getXMLPullParser();
parser.setInput(in, "UTF-8");
} catch (XmlPullParserException e) {
throw new XmppTransportException("Can't initialize pull parser", e);
}
}
use of org.xmlpull.v1.XmlPullParserException in project platform_frameworks_base by android.
the class VectorDrawablePerformance method create.
public static VectorDrawable create(Resources resources, int rid) {
try {
final XmlPullParser parser = resources.getXml(rid);
final AttributeSet attrs = Xml.asAttributeSet(parser);
int type;
while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) {
// Empty loop
}
if (type != XmlPullParser.START_TAG) {
throw new XmlPullParserException("No start tag found");
}
final VectorDrawable drawable = new VectorDrawable();
drawable.inflate(resources, parser, attrs);
return drawable;
} catch (XmlPullParserException e) {
Log.e(LOGCAT, "parser error", e);
} catch (IOException e) {
Log.e(LOGCAT, "parser error", e);
}
return null;
}
use of org.xmlpull.v1.XmlPullParserException in project platform_frameworks_base by android.
the class Resources_Delegate method getAnimation.
@LayoutlibDelegate
static XmlResourceParser getAnimation(Resources resources, int id) throws NotFoundException {
Pair<String, ResourceValue> v = getResourceValue(resources, id, mPlatformResourceFlag);
if (v != null) {
ResourceValue value = v.getSecond();
XmlPullParser parser;
try {
File xml = new File(value.getValue());
if (xml.isFile()) {
// we need to create a pull parser around the layout XML file, and then
// give that to our XmlBlockParser
parser = ParserFactory.create(xml);
return new BridgeXmlBlockParser(parser, resources.mContext, mPlatformResourceFlag[0]);
}
} catch (XmlPullParserException e) {
Bridge.getLog().error(LayoutLog.TAG_BROKEN, "Failed to configure parser for " + value.getValue(), e, null);
// we'll return null below.
} catch (FileNotFoundException e) {
// this shouldn't happen since we check above.
}
}
// id was not found or not resolved. Throw a NotFoundException.
throwException(resources, id);
// this is not used since the method above always throws
return null;
}
use of org.xmlpull.v1.XmlPullParserException in project platform_frameworks_base by android.
the class ConfigGenerator method getEnumMap.
public static Map<String, Map<String, Integer>> getEnumMap(File path) {
Map<String, Map<String, Integer>> map = Maps.newHashMap();
try {
XmlPullParser xmlPullParser = XmlPullParserFactory.newInstance().newPullParser();
xmlPullParser.setInput(new FileInputStream(path), null);
int eventType = xmlPullParser.getEventType();
String attr = null;
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) {
if (TAG_ATTR.equals(xmlPullParser.getName())) {
attr = xmlPullParser.getAttributeValue(null, ATTR_NAME);
} else if (TAG_ENUM.equals(xmlPullParser.getName()) || TAG_FLAG.equals(xmlPullParser.getName())) {
String name = xmlPullParser.getAttributeValue(null, ATTR_NAME);
String value = xmlPullParser.getAttributeValue(null, ATTR_VALUE);
// Integer.decode cannot handle "ffffffff", see JDK issue 6624867
int i = (int) (long) Long.decode(value);
assert attr != null;
Map<String, Integer> attributeMap = map.get(attr);
if (attributeMap == null) {
attributeMap = Maps.newHashMap();
map.put(attr, attributeMap);
}
attributeMap.put(name, i);
}
} else if (eventType == XmlPullParser.END_TAG) {
if (TAG_ATTR.equals(xmlPullParser.getName())) {
attr = null;
}
}
eventType = xmlPullParser.next();
}
} catch (XmlPullParserException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return map;
}
use of org.xmlpull.v1.XmlPullParserException in project platform_frameworks_base by android.
the class ParserFactory method create.
@NonNull
private static XmlPullParser create(@NonNull InputStream stream, @Nullable String name, long size, boolean isLayout) throws XmlPullParserException {
XmlPullParser parser = instantiateParser(name);
stream = readAndClose(stream, name, size);
parser.setInput(stream, ENCODING);
if (isLayout) {
try {
return new LayoutParserWrapper(parser).peekTillLayoutStart();
} catch (IOException e) {
throw new XmlPullParserException(null, parser, e);
}
}
return parser;
}
Aggregations