/** * Deals with real keys found in the versification. * * @param versification the versification of the passed in key * @param versesKey the text of the reference we are trying to parse * @return the qualified key representing this */ private QualifiedKey getExistingQualifiedKey(final Versification versification, final String versesKey) { return new QualifiedKey(osisParser.parseOsisRef(versification, versesKey)); }
/** * Strict OSIS ID parsers, case-sensitive * @param v11n the versification to use when constructing the verse * @param osisID the ID we want to parse * @return the verse that matches the OSIS ID */ public Verse parseOsisID(final Versification v11n, final String osisID) { if (osisID == null) { return null; } final List<String> osisIDParts = splitOsisId(osisID); if (osisIDParts.size() != 3 || isAnEmptyPart(osisIDParts)) { return null; } return parseOsisID(v11n, osisIDParts); }
List<String> startOsisIDParts = splitOsisId(startOsisID); if (isAnEmptyPart(startOsisIDParts) || startOsisIDParts.size() > 3) { return null; List<String> endOsisIDParts = splitOsisId(endOsisID); if (isAnEmptyPart(endOsisIDParts)) { return null; Verse start = parseOsisID(v11n, startOsisIDParts); if (start == null) { return null; Verse end = parseOsisID(v11n, endOsisIDParts); if (end == null) { return null;
/** * Return a Key representing the passage passed in or an empty passage if it can't be parsed. * @param passage Textual ref * @return */ public Key getKey(String passage) { Key key = null; try { // spaces confuse the osis parser passage = passage.trim(); // If expecting OSIS then use OSIS parser key = osisParser.parseOsisRef(v11n, passage); // OSIS parser is strict so try treating as normal ref if osis parser fails if (key==null) { Log.d(TAG, "Non OSIS Reading plan passage:"+passage); key = PassageKeyFactory.instance().getKey(v11n, passage); } } catch (Exception e) { Log.e(TAG, "Invalid passage reference in reading plan:"+passage); } // If all else fails return an empty passage to prevent NPE if (key==null) { key = PassageKeyFactory.instance().createEmptyKeyList(v11n); } return key; } }