public static URIParsedResult parse(Result result) { String rawText = result.getText(); if (rawText == null || (!rawText.startsWith("urlto:") && !rawText.startsWith("URLTO:"))) { return null; } int titleEnd = rawText.indexOf(':', 6); if (titleEnd < 0) { return null; } String title = titleEnd <= 6 ? null : rawText.substring(6, titleEnd); String uri = rawText.substring(titleEnd + 1); return new URIParsedResult(uri, title); }
public static URIParsedResult parse(Result result) { String rawText = result.getText(); // We specifically handle the odd "URL" scheme here for simplicity if (rawText != null && rawText.startsWith("URL:")) { rawText = rawText.substring(4); } if (!isBasicallyValidURI(rawText)) { return null; } return new URIParsedResult(rawText, null); }
public static URIParsedResult parse(Result result) { String rawText = result.getText(); if (rawText == null || !rawText.startsWith("MEBKM:")) { return null; } String title = matchSingleDoCoMoPrefixedField("TITLE:", rawText, true); String[] rawUri = matchDoCoMoPrefixedField("URL:", rawText, true); if (rawUri == null) { return null; } String uri = rawUri[0]; if (!URIResultParser.isBasicallyValidURI(uri)) { return null; } return new URIParsedResult(uri, title); }
public static URIParsedResult parse(Result result) { byte[] bytes = result.getRawBytes(); if (bytes == null) { return null; } NDEFRecord ndefRecord = NDEFRecord.readRecord(bytes, 0); if (ndefRecord == null || !ndefRecord.isMessageBegin() || !ndefRecord.isMessageEnd()) { return null; } if (!ndefRecord.getType().equals(NDEFRecord.URI_WELL_KNOWN_TYPE)) { return null; } String fullURI = decodeURIPayload(ndefRecord.getPayload()); return new URIParsedResult(fullURI, null); }