use of org.xmlpull.v1.XmlPullParserFactory in project processdash by dtuma.
the class ArchiveMetricsFileExporter method writeManifest.
private void writeManifest(ZipOutputStream zipOut, boolean includeTaskLists) throws IOException {
zipOut.putNextEntry(new ZipEntry(MANIFEST_FILE_NAME));
XmlSerializer xml = null;
try {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
xml = factory.newSerializer();
} catch (XmlPullParserException xppe) {
throw new RuntimeException("Couldn't obtain xml serializer", xppe);
}
xml.setOutput(zipOut, ENCODING);
xml.startDocument(ENCODING, Boolean.TRUE);
xml.ignorableWhitespace(NEWLINE + NEWLINE);
xml.startTag(null, ARCHIVE_ELEM);
xml.attribute(null, TYPE_ATTR, FILE_TYPE_ARCHIVE);
xml.ignorableWhitespace(NEWLINE);
writeManifestMetaData(xml);
writeManifestFileEntry(xml, DATA_FILE_NAME, FILE_TYPE_METRICS, "1");
writeManifestFileEntry(xml, DEFECT_FILE_NAME, FILE_TYPE_DEFECTS, "1");
writeManifestFileEntry(xml, TIME_FILE_NAME, FILE_TYPE_TIME_LOG, "1");
if (includeTaskLists)
writeManifestFileEntry(xml, EV_FILE_NAME, FILE_TYPE_EARNED_VALUE, "1");
if (additionalEntries != null)
for (Iterator i = additionalEntries.iterator(); i.hasNext(); ) {
ExportFileEntry file = (ExportFileEntry) i.next();
writeManifestFileEntry(xml, file.getFilename(), file.getType(), file.getVersion());
}
xml.endTag(null, ARCHIVE_ELEM);
xml.ignorableWhitespace(NEWLINE);
xml.endDocument();
zipOut.closeEntry();
}
use of org.xmlpull.v1.XmlPullParserFactory in project processdash by dtuma.
the class DataImporterXMLv1 method handle.
public void handle(ArchiveMetricsFileImporter caller, InputStream in, String type, String version) throws Exception {
Map defns = caller.getDefns();
if (shouldImportRootValuesOnly(caller))
defns.put(ROOT_VALUES_ONLY_TAG, "true");
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
XmlPullParser parser = factory.newPullParser();
parser.setInput(in, ENCODING);
parser.nextTag();
parser.require(XmlPullParser.START_TAG, null, DATA_ELEM);
importData(parser, defns, null);
parser.require(XmlPullParser.END_TAG, null, DATA_ELEM);
defns.remove(ROOT_VALUES_ONLY_TAG);
}
use of org.xmlpull.v1.XmlPullParserFactory in project android_frameworks_base by crdroidandroid.
the class DaylightHeaderProvider method loadHeaders.
private void loadHeaders() throws XmlPullParserException, IOException {
mHeadersList = new ArrayList<DaylightHeaderInfo>();
InputStream in = null;
XmlPullParser parser = null;
try {
if (mHeaderName == null) {
if (DEBUG)
Log.i(TAG, "Load header pack config daylight_header.xml");
in = mRes.getAssets().open("daylight_header.xml");
} else {
int idx = mHeaderName.lastIndexOf(".");
String headerConfigFile = mHeaderName.substring(idx + 1) + ".xml";
if (DEBUG)
Log.i(TAG, "Load header pack config " + headerConfigFile);
in = mRes.getAssets().open(headerConfigFile);
}
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
parser = factory.newPullParser();
parser.setInput(in, "UTF-8");
loadResourcesFromXmlParser(parser);
} finally {
// Cleanup resources
if (parser instanceof XmlResourceParser) {
((XmlResourceParser) parser).close();
}
if (in != null) {
try {
in.close();
} catch (IOException e) {
}
}
}
}
use of org.xmlpull.v1.XmlPullParserFactory in project Taskbar by farmerbb.
the class IconPack method load.
private void load(Context mContext) {
if (!mIsLoading) {
mIsLoading = true;
SharedPreferences pref = U.getSharedPreferences(mContext);
boolean loadMasks = pref.getBoolean("icon_pack_use_mask", false);
// Load appfilter.xml from the icon pack package
try {
XmlPullParser xpp = null;
int appfilterid = getResources(mContext).getIdentifier("appfilter", "xml", packageName);
if (appfilterid > 0) {
xpp = getResources(mContext).getXml(appfilterid);
} else {
// No resource found, try to open it from assets folder
try {
InputStream appfilterstream = getResources(mContext).getAssets().open("appfilter.xml");
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
xpp = factory.newPullParser();
xpp.setInput(appfilterstream, "utf-8");
} catch (IOException e) {
/* Gracefully fail */
}
}
if (xpp != null) {
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) {
if (loadMasks) {
if (xpp.getName().equals("iconback")) {
for (int i = 0; i < xpp.getAttributeCount(); i++) {
if (xpp.getAttributeName(i).startsWith("img")) {
String drawableName = xpp.getAttributeValue(i);
Bitmap iconback = loadBitmap(mContext, drawableName);
if (iconback != null)
mBackImages.add(iconback);
}
}
} else if (xpp.getName().equals("iconmask")) {
if (xpp.getAttributeCount() > 0 && xpp.getAttributeName(0).equals("img1")) {
String drawableName = xpp.getAttributeValue(0);
mMaskImage = loadBitmap(mContext, drawableName);
}
} else if (xpp.getName().equals("iconupon")) {
if (xpp.getAttributeCount() > 0 && xpp.getAttributeName(0).equals("img1")) {
String drawableName = xpp.getAttributeValue(0);
mFrontImage = loadBitmap(mContext, drawableName);
}
} else if (xpp.getName().equals("scale")) {
if (xpp.getAttributeCount() > 0 && xpp.getAttributeName(0).equals("factor")) {
mFactor = Float.valueOf(xpp.getAttributeValue(0));
}
}
}
if (xpp.getName().equals("item")) {
String componentName = null;
String drawableName = null;
for (int i = 0; i < xpp.getAttributeCount(); i++) {
if (xpp.getAttributeName(i).equals("component")) {
componentName = xpp.getAttributeValue(i);
} else if (xpp.getAttributeName(i).equals("drawable")) {
drawableName = xpp.getAttributeValue(i);
}
}
if (!mPackagesDrawables.containsKey(componentName)) {
mPackagesDrawables.put(componentName, drawableName);
totalIcons = totalIcons + 1;
}
}
}
eventType = xpp.next();
}
}
mLoaded = true;
} catch (XmlPullParserException | IOException e) {
/* Gracefully fail */
}
mIsLoading = false;
}
}
use of org.xmlpull.v1.XmlPullParserFactory in project LibreraReader by foobnix.
the class XmlParser method buildPullParser.
public static XmlPullParser buildPullParser() throws XmlPullParserException {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setValidating(false);
factory.setFeature(Xml.FEATURE_RELAXED, true);
// factory.setFeature(XmlPullParser.FEATURE_PROCESS_DOCDECL, false);
// factory.setFeature(XmlPullParser.FEATURE_VALIDATION, false);
XmlPullParser newPullParser = factory.newPullParser();
return newPullParser;
}
Aggregations