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(); } }
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; }
@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; }
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); } }
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 ""; } }
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"); }
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; }
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; } } }
/** * {@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 ) ); }
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; } } }
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(); } }
/** * 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; }
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); } } }
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"); }
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; } } }
@Override public long parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, IOException { // Folder contents come from an external XML resource final Partner partner = Partner.get(mPackageManager); if (partner != null) { final Resources partnerRes = partner.getResources(); final int resId = partnerRes.getIdentifier(Partner.RES_FOLDER, "xml", partner.getPackageName()); if (resId != 0) { final XmlResourceParser partnerParser = partnerRes.getXml(resId); beginDocument(partnerParser, TAG_FOLDER); FolderParser folderParser = new FolderParser(getFolderElementsMap(partnerRes)); return folderParser.parseAndAdd(partnerParser); } } return -1; }
/** * 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; }
/** * Parses the layout and returns the number of elements added on the homescreen. */ protected 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; }
private void readDevice(XmlPullParser parser) throws XmlPullParserException, IOException { parser.require(XmlPullParser.START_TAG, ns, mDeviceName); mDevice = new OTADevice(); while (parser.next() != XmlPullParser.END_TAG) { if (parser.getEventType() != XmlPullParser.START_TAG) { continue; } String tagName = parser.getName(); if (tagName.equalsIgnoreCase(FILENAME_TAG)) { String tagValue = readTag(parser, tagName); mDevice.setLatestVersion(tagValue); } else if (isUrlTag(tagName)) { OTALink link = readLink(parser, tagName); mDevice.addLink(link); } else { skip(parser); } } }
static Drawable createFromXmlInner(Context context, XmlPullParser parser, AttributeSet attrs) throws IOException, XmlPullParserException { final DrawableUtils drawableUtils; final String name = parser.getName(); switch (name) { case "selector": drawableUtils = new StateListDrawableUtils(); break; case "shape": drawableUtils = new GradientDrawableUtils(); break; case "layer-list": drawableUtils = new LayerDrawableUtils(); break; default: drawableUtils = null; } return drawableUtils == null ? null : drawableUtils.inflateDrawable(context, parser, attrs); }
IntentFilter(XmlStartElementChunk intent, XmlChunk manifest) throws XmlPullParserException, IOException { actions = new LinkedList<>(); categories = new LinkedList<>(); data = new LinkedList<>(); icon = intent.getAttribute(AttributeId.ICON); label = intent.getAttribute(AttributeId.LABEL); priority = intent.getAttribute(AttributeId.PRIORITY,0); List<Chunk> componentChunks = manifest.getChunksWithin(intent); for (Chunk c : componentChunks) { if (!(c instanceof XmlStartElementChunk)) { continue; } XmlStartElementChunk chunk = (XmlStartElementChunk) c; String name = chunk.getName(); if (ACTION.equals(name)) { actions.add(chunk.getAttribute(AttributeId.NAME)); } else if (CATEGORY.equals(name)) { categories.add(chunk.getAttribute(AttributeId.NAME)); } else if (DATA.equals(name)) { data.add(new Data(chunk)); } } }
/** * Flatten a boolean[] into an XmlSerializer. The list can later be read back * with readThisBooleanArrayXml(). * * @param val The boolean array to be flattened. * @param name Name attribute to include with this array's tag, or null for * none. * @param out XmlSerializer to write the array into. * * @see #writeMapXml * @see #writeValueXml * @see #readThisIntArrayXml */ public static final void writeBooleanArrayXml(boolean[] 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, "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"); }
@Override public long parseAndAdd(XmlResourceParser parser) throws XmlPullParserException, IOException { final String packageName = getAttributeValue(parser, ATTR_PACKAGE_NAME); final String className = getAttributeValue(parser, ATTR_CLASS_NAME); if (TextUtils.isEmpty(packageName) || TextUtils.isEmpty(className)) { if (LOGD) Log.d(TAG, "Skipping invalid <appwidget> with no component"); return -1; } mValues.put(Favorites.SPANX, getAttributeValue(parser, ATTR_SPAN_X)); mValues.put(Favorites.SPANY, getAttributeValue(parser, ATTR_SPAN_Y)); mValues.put(Favorites.ITEM_TYPE, Favorites.ITEM_TYPE_APPWIDGET); // Read the extras Bundle extras = new Bundle(); int widgetDepth = parser.getDepth(); int type; while ((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > widgetDepth) { if (type != XmlPullParser.START_TAG) { continue; } if (TAG_EXTRA.equals(parser.getName())) { String key = getAttributeValue(parser, ATTR_KEY); String value = getAttributeValue(parser, ATTR_VALUE); if (key != null && value != null) { extras.putString(key, value); } else { throw new RuntimeException("Widget extras must have a key and value"); } } else { throw new RuntimeException("Widgets can contain only extras"); } } return verifyAndInsert(new ComponentName(packageName, className), extras); }
/** * Parse the text content of an element. * Precondition: behind the opening tag * Postcondition: on the closing tag */ private void parseTextContentToString(StringBuilder sb) throws IOException, XmlPullParserException { while (input.getEventType() != XmlPullParser.END_TAG) { switch(input.getEventType()) { case XmlPullParser.START_TAG: input.next(); parseTextContentToString(sb); input.next(); break; case XmlPullParser.TEXT: if (sb != null) { sb.append(input.getText()); } input.next(); break; default: throw new RuntimeException("Unexpected event: " + input.getPositionDescription()); } } }
/** * {@link PackageManager} doesn't give us {@code minSdkVersion}, {@code targetSdkVersion}, * and {@code maxSdkVersion}, so we have to parse it straight from {@code <uses-sdk>} in * {@code AndroidManifest.xml}. If {@code targetSdkVersion} is not set, then it is * equal to {@code minSdkVersion} * * @see <a href="https://developer.android.com/guide/topics/manifest/uses-sdk-element.html"><uses-sdk></a> */ private static int[] getMinTargetMaxSdkVersions(Context context, String packageName) { int minSdkVersion = Apk.SDK_VERSION_MIN_VALUE; int targetSdkVersion = Apk.SDK_VERSION_MIN_VALUE; int maxSdkVersion = Apk.SDK_VERSION_MAX_VALUE; try { AssetManager am = context.createPackageContext(packageName, 0).getAssets(); XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml"); int eventType = xml.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG && "uses-sdk".equals(xml.getName())) { for (int j = 0; j < xml.getAttributeCount(); j++) { if (xml.getAttributeName(j).equals("minSdkVersion")) { minSdkVersion = Integer.parseInt(xml.getAttributeValue(j)); } else if (xml.getAttributeName(j).equals("targetSdkVersion")) { targetSdkVersion = Integer.parseInt(xml.getAttributeValue(j)); } else if (xml.getAttributeName(j).equals("maxSdkVersion")) { maxSdkVersion = Integer.parseInt(xml.getAttributeValue(j)); } } break; } eventType = xml.nextToken(); } } catch (PackageManager.NameNotFoundException | IOException | XmlPullParserException e) { Log.e(TAG, "Could not get min/max sdk version", e); } if (targetSdkVersion < minSdkVersion) { targetSdkVersion = minSdkVersion; } return new int[]{minSdkVersion, targetSdkVersion, maxSdkVersion}; }
@Override public void loadFile( File file ) throws XmlPullParserException, IOException, SAXException, ParserConfigurationException { String fileName = file.getName().toLowerCase( Locale.US ); NLog.d( "[MetadataCtrl] load file : " + fileName ); if ( !fileName.endsWith( ".nproj" ) ) { return; } InputStream is = new FileInputStream( file ); this.parseBySAX( is ); }
private static PathStrategy getPathStrategy(Context context, String authority) { PathStrategy strat; synchronized (sCache) { strat = (PathStrategy) sCache.get(authority); if (strat == null) { try { strat = parsePathStrategy(context, authority); sCache.put(authority, strat); } catch (IOException e) { throw new IllegalArgumentException("Failed to parse android.support.FILE_PROVIDER_PATHS meta-data", e); } catch (XmlPullParserException e2) { throw new IllegalArgumentException("Failed to parse android.support.FILE_PROVIDER_PATHS meta-data", e2); } } } return strat; }
private void parseKey(final XmlPullParser parser, final KeyboardRow row, final boolean skip) throws XmlPullParserException, IOException { if (skip) { XmlParseUtils.checkEndTag(TAG_KEY, parser); if (DEBUG) startEndTag("<%s /> skipped", TAG_KEY); return; } final TypedArray keyAttr = mResources.obtainAttributes( Xml.asAttributeSet(parser), R.styleable.Keyboard_Key); final KeyStyle keyStyle = mParams.mKeyStyles.getKeyStyle(keyAttr, parser); final String keySpec = keyStyle.getString(keyAttr, R.styleable.Keyboard_Key_keySpec); if (TextUtils.isEmpty(keySpec)) { throw new ParseException("Empty keySpec", parser); } final Key key = new Key(keySpec, keyAttr, keyStyle, mParams, row); keyAttr.recycle(); if (DEBUG) { startEndTag("<%s%s %s moreKeys=%s />", TAG_KEY, (key.isEnabled() ? "" : " disabled"), key, Arrays.toString(key.getMoreKeys())); } XmlParseUtils.checkEndTag(TAG_KEY, parser); endKey(key); }
private List<String> readCodeFiles(XmlPullParser parser) throws XmlPullParserException { final List<String> result = new ArrayList<>(); try { parser.require(XmlPullParser.START_TAG, null, CODE_FILES); while(parser.next() != XmlPullParser.END_TAG){ if(parser.getEventType() != XmlPullParser.START_TAG) { continue; } final String name = parser.getName(); if (name.equals("string")) { result.add(readText(parser)); } } } catch (IOException e) { e.printStackTrace(); } return result; }
public void digestion(int missedcleave, int minlength, int maxlength, String Decoytag) throws XmlPullParserException, IOException { PeptideList = new HashMap<>(); for (ProteinEntry protein : ProteinList.values()) { if (protein.ACC.startsWith(Decoytag) | protein.ACC.endsWith(Decoytag)) { continue; } String Sequence = protein.Seq; ArrayList<String> TheoPeptides = EnzymeManager.GetInstance().GetTrypsinNoP().digest(Sequence, missedcleave, minlength, maxlength); AddFirstMetDroppedPep(Sequence, missedcleave, minlength, maxlength, TheoPeptides); for (String pep : TheoPeptides) { if (!PeptideList.containsKey(pep)) { PeptideEntry pepentry = new PeptideEntry(); pepentry.Sequence = pep; String rev = new StringBuilder(pepentry.Sequence.subSequence(0, pepentry.Sequence.length() - 1)).reverse().toString(); if (Sequence.indexOf(pepentry.Sequence) > 0) { rev += String.valueOf(Sequence.charAt(Sequence.indexOf(pepentry.Sequence) - 1)); } pepentry.Decoy = rev; PeptideList.put(pep, pepentry); } PeptideList.get(pep).Proteins.add(protein.ACC); protein.Peptides.add(pep); } } }
/** * {@inheritDoc} */ @Override public void action( Dsmlv2Container container ) throws XmlPullParserException { BatchResponseDsml batchResponse = new BatchResponseDsml(); container.setBatchResponse( batchResponse ); XmlPullParser xpp = container.getParser(); // Checking and adding the batchRequest's attributes String attributeValue; // requestID attributeValue = xpp.getAttributeValue( "", "requestID" ); if ( attributeValue != null ) { batchResponse.setRequestID( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) ); } }
private static Map<String, ImportedAccount> parseAccounts(XmlPullParser xpp, List<String> accountUuids, boolean overview) throws XmlPullParserException, IOException { Map<String, ImportedAccount> accounts = null; int eventType = xpp.next(); while (!(eventType == XmlPullParser.END_TAG && SettingsExporter.ACCOUNTS_ELEMENT.equals(xpp.getName()))) { if (eventType == XmlPullParser.START_TAG) { String element = xpp.getName(); if (SettingsExporter.ACCOUNT_ELEMENT.equals(element)) { if (accounts == null) { accounts = new HashMap<>(); } ImportedAccount account = parseAccount(xpp, accountUuids, overview); if (account == null) { // Do nothing - parseAccount() already logged a message } else if (!accounts.containsKey(account.uuid)) { accounts.put(account.uuid, account); } else { Timber.w("Duplicate account entries with UUID %s. Ignoring!", account.uuid); } } else { Timber.w("Unexpected start tag: %s", xpp.getName()); } } eventType = xpp.next(); } return accounts; }
private void ParseSAX() throws ParserConfigurationException, SAXException, IOException, XmlPullParserException { File fXmlFile = new File(FileName); if (!fXmlFile.exists()) { Logger.getRootLogger().info("File :" + FileName + " cannot be found\n"); return; } FileInputStream inputStream = new FileInputStream(FileName); SolnaParser parser = new SolnaParser(); ProtXMLParseHandler handler = new ProtXMLParseHandler(SingleLCMSID, threshold); parser.addHandler("/protein_summary/protein_group", handler); parser.parse(inputStream); }
static int lenientNext(XmlPullParser xpp) throws IOException, XmlPullParserException { try { return xpp.next(); } catch (XmlPullParserException e) { return xpp.getEventType(); } }
private static String getText(final XmlPullParser parser) throws XmlPullParserException, IOException { if (parser.next() == XmlPullParser.TEXT) { final String text = parser.getText(); parser.nextTag(); return text; } return null; }
public TtmlParser() { try { xmlParserFactory = XmlPullParserFactory.newInstance(); xmlParserFactory.setNamespaceAware(true); } catch (XmlPullParserException e) { throw new RuntimeException("Couldn't create XmlPullParserFactory instance", e); } }
private String readText(@NonNull XmlPullParser parser) throws IOException, XmlPullParserException { String text = ""; if (parser.next() == XmlPullParser.TEXT) { text = parser.getText(); parser.next(); } return text; }
private Long readLong(XmlPullParser parser) throws IOException, XmlPullParserException { Long result = null; if (parser.next() == XmlPullParser.TEXT) { final String text = parser.getText(); if (text != null && !text.isEmpty()) { result = Long.valueOf(text); } parser.nextTag(); } return result; }
public static Gpx parseGpx(InputStream in) { GPXParser mParser = new GPXParser(); try { Gpx gpx = mParser.parse(in); Log.d(TAG, "parseGpx: parsed succeed"); return gpx; } catch (IOException | XmlPullParserException e) { e.printStackTrace(); Log.d(TAG, "parseGpx: parsed failed"); return null; } }
/** * {@inheritDoc} */ @Override public void action( Dsmlv2Container container ) throws XmlPullParserException { SearchResponse response = ( SearchResponse ) ( ( SearchResponseDsml ) container.getBatchResponse() .getCurrentResponse() ).getDecorated(); createAndAddControl( container, response.getCurrentSearchResultEntry() ); }