use of org.xmlpull.v1.XmlPullParserFactory in project android_frameworks_base by crdroidandroid.
the class TtmlRenderingWidget method loadParser.
private void loadParser(String ttmlFragment) throws XmlPullParserException {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(false);
mParser = factory.newPullParser();
StringReader in = new StringReader(ttmlFragment);
mParser.setInput(in);
}
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 processdash by dtuma.
the class ArchiveMetricsFileImporter method readAndProcessArchive.
private void readAndProcessArchive() throws IOException, XmlPullParserException {
shouldDeleteArchiveFileOnCompletion = false;
zipFile = new ZipFile(file);
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
XmlPullParser parser = factory.newPullParser();
InputStream manifestIn = openEntry(zipFile, MANIFEST_FILE_NAME);
parser.setInput(manifestIn, ENCODING);
parser.nextTag();
parser.require(XmlPullParser.START_TAG, null, ARCHIVE_ELEM);
if (!FILE_TYPE_ARCHIVE.equals(parser.getAttributeValue(null, TYPE_ATTR)))
error("expected archive of type " + FILE_TYPE_ARCHIVE);
parser.nextTag();
parser.require(XmlPullParser.START_TAG, null, EXPORTED_TAG);
owner = parser.getAttributeValue(null, OWNER_ATTR);
exportTimestamp = XMLUtils.parseDate(parser.getAttributeValue(null, WHEN_ATTR));
ImportedDefectManager.closeDefects(prefix);
ImportedTimeLogManager.getInstance().closeTimeLogs(prefix);
ImportedEVManager.getInstance().closeTaskLists(prefix);
defns = new HashMap();
Map<String, String> packageIDs = new HashMap<String, String>();
while (parser.next() != XmlPullParser.END_DOCUMENT) {
if (parser.getEventType() == XmlPullParser.START_TAG) {
if (PACKAGE_ELEM.equals(parser.getName())) {
String id = parser.getAttributeValue(null, PACKAGE_ID_ATTR);
String version = parser.getAttributeValue(null, VERSION_ATTR);
packageIDs.put(id, version);
} else if (FROM_DATASET_TAG.equals(parser.getName())) {
srcDatasetID = parser.getAttributeValue(null, FROM_DATASET_ID_ATTR);
} else if (FILE_ELEM.equals(parser.getName())) {
String name = parser.getAttributeValue(null, FILE_NAME_ATTR);
String type = parser.getAttributeValue(null, TYPE_ATTR);
String version = parser.getAttributeValue(null, VERSION_ATTR);
readFile(zipFile, name, type, version);
}
}
}
// make a note of the individual who exported this data
recordKnownPerson();
// Protect this data from being viewed via external http requests.
defns.put("_Password_", ImmutableDoubleData.READ_ONLY_ZERO);
// Save metadata about the import
addImportMetadata(packageIDs);
try {
data.mountImportedData(prefix, defns);
} catch (InvalidDatafileFormat idf) {
}
}
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);
}
Aggregations