use of org.crosswire.jsword.passage.PassageKeyFactory in project step by STEPBible.
the class JSwordPassageServiceImpl method getAllReferencesAndCounts.
/**
* @param references a list of references to be parsed
* @param version the version against which the refs are parsed
* @return a String representing all the references
*/
@Override
public StringAndCount getAllReferencesAndCounts(final String references, final String version) {
int count = 0;
// TODO - can be refactored to optimize the reference query when used in subject searches...
final PassageKeyFactory keyFactory = PassageKeyFactory.instance();
final Versification av11n = this.versificationService.getVersificationForVersion(version);
final StringBuilder referenceString = new StringBuilder(1024);
try {
final Key k = keyFactory.getKey(av11n, references);
final Iterator<Key> iterator = k.iterator();
while (iterator.hasNext()) {
referenceString.append(iterator.next().getOsisID());
count++;
if (iterator.hasNext()) {
referenceString.append(' ');
}
}
return new StringAndCount(referenceString.toString(), count);
} catch (final NoSuchKeyException e) {
throw new TranslatedException(e, "invalid_reference_in_book", references, version);
}
}
Aggregations