public int getCardinality() { int cardinality = 1; // count this node for (Key child : children) { cardinality += child.getCardinality(); } return cardinality; }
/** * Utility to remove all the keys from alter that are not in base * * @param alter * The key to remove keys from * @param base * The check key */ protected static void retain(Key alter, Key base) { Iterator<Key> it = alter.iterator(); while (it.hasNext()) { Key sublist = it.next(); if (sublist.canHaveChildren()) { retain(sublist, base); if (sublist.isEmpty()) { it.remove(); } } else { if (!base.contains(sublist)) { it.remove(); } } } }
public int indexOf(Key that) { int index = 0; for (Key key : this) { if (key.equals(that)) { return index; } index++; } return -1; }
public static String getKeyDescription(Key key) { String name; try { name = key.getName(); // do not show verse 0 if (key instanceof Verse) { Verse verseKey = (Verse)key; if (verseKey.getVerse()==0 && name.endsWith("0")) { final String verse0 = "[\\W]0$"; name = name.replaceAll(verse0, ""); } } } catch (Exception e) { Log.e(TAG, "Error getting key name - could that Versification does not contain book"); // but this normally works name = key.getOsisRef().replace('.', ' '); } return name; }
public String getName() { return keys.getName(); }
Field morphologyField = new Field(FIELD_MORPHOLOGY , "", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.NO); int size = key.getCardinality(); int subCount = count; log.debug("Number of keys = {}", Integer.toString(size)); if (subkey.canHaveChildren()) { generateSearchIndexImpl(job, errors, writer, subkey, subCount, policy); continue; keyField.setValue(subkey.getOsisRef()); doc.add(keyField); rootName = subkey.getRootName(); if (!rootName.equals(oldRootName)) { oldRootName = rootName;
public String getOsisID() { return keys.getOsisID(); }
/** * This is a heuristic that tries out the key. * * @return true if there were no exceptions in reading the enciphered * module. */ private boolean isUnlockKeyValid() { try { Key key = getGlobalKeyList(); if (key == null) { // weird key == null, assume it is valid return true; } if (key.getCardinality() > 0) { key = key.get(0); } getOsis(key, new NoOpRawTextProcessor()); return true; } catch (BookException ex) { return false; } }
/** * Perform a test read on a single key */ private static void testReadSingle(Book book, Key key, int entry) { Throwable oops = null; try { log.debug("reading: {}/{}:{}", book.getInitials(), Integer.toString(entry), key.getName()); BookData data = new BookData(book, key); if (data.getOsisFragment() == null) { log.warn("No output from: {},{}", book.getInitials(), key.getOsisID()); } // This might be a useful extra test, except that a failure gives // you no help at all. // data.validate(); } catch (BookException ex) { oops = ex; } if (oops != null) { ++count; if (count < 5) { log.error("Unexpected error reading: {}, {}, {}, {}", book.getInitials(), Integer.toString(entry), key.getOsisID(), key.getClass().getName(), oops); } } }
orig = book.getRawText(key); } catch (BookException ex) { log.warn("Failed to read: {}({}):{}", book.getInitials(), key.getOsisID(), ex.getMessage(), ex); return; String rawRef = matcher.group(2); stats[0]++; String message = book.getInitials() + ':' + key.getOsisRef() + '/' + rawRef;
public Iterator<Key> iterator() { return keys.iterator(); }
public String getOsisRef() { return keys.getOsisRef(); }
result.append("<a href='").append(Constants.BIBLE_PROTOCOL).append(":").append(key.iterator().next().getOsisRef()).append("'>"); result.append(key); result.append("</a>");
public boolean contains(Key key) { return keys.contains(key); }
if (start > 0 || key.getCardinality() > count) { key = book.createEmptyKeyList(); int i = 0; break; key.addAll(aKey);
/** * A space separate string containing osisID from the reference element. * We pass book and key because the xref may not be valid and it needs to be reported. * * @param book the book to which the references refer * @param key the verse containing the cross references * @param v11n the versification * @param root the osis element in question * @return The references in the text */ public static String getReferences(Book book, Key key, Versification v11n, Element root) { PassageKeyFactory keyf = PassageKeyFactory.instance(); Key collector = keyf.createEmptyKeyList(v11n); for (Content content : getDeepContent(root, OSISUtil.OSIS_ELEMENT_REFERENCE)) { Element ele = (Element) content; String attr = ele.getAttributeValue(OSISUtil.OSIS_ATTR_REF); if (attr != null) { try { collector.addAll(keyf.getKey(v11n, attr)); } catch (NoSuchKeyException e) { DataPolice.report(book, key, "Unable to parse: " + attr + " - No such reference:" + e.getMessage()); } } } return collector.getOsisID(); }
@Override public int hashCode() { return keys.hashCode(); }
public Key get(int index) { return keys.get(index); }