public String getName(Key base) { return keys.getName(base); }
public String getName() { return keys.getName(); }
@Override public void visitLeaf(Key key) { buffer.append(key.getName()); buffer.append(AbstractPassage.REF_PREF_DELIM); }
@NotNull @Override public String getStatusText(int showFlag) { if(keyList != null && keyList.size() > 0) { return keyList.get(0).getName(); } else { return ""; } }
public String getReadingsDesc() { checkKeysGenerated(); StringBuilder readingsBldr = new StringBuilder(); for (int i=0; i<mReadingKeys.size(); i++) { if (i>0) { readingsBldr.append(", "); } readingsBldr.append(mReadingKeys.get(i).getName()); } return readingsBldr.toString(); }
public String readRawContent(RawLDBackendState state, Key key) throws IOException { return doReadRawContent(state, key.getName()); }
@Override public String getOsisID() { StringBuilder b = new StringBuilder(100); b.append(getName()); for (Key parentKey = this.getParent(); parentKey != null && parentKey.getName().length() > 0; parentKey = parentKey.getParent()) { b.insert(0, "/"); b.insert(0, parentKey.getName()); } // Remove the leading . return b.toString(); }
public void writeDescription(Writer out) throws IOException { BufferedWriter bout = new BufferedWriter(out); bout.write(v11n.getName()); bout.newLine(); Iterator<VerseRange> it = rangeIterator(RestrictionType.NONE); while (it.hasNext()) { Key range = it.next(); bout.write(range.getName()); bout.newLine(); } bout.flush(); }
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; }
/** user has typed something so show keys starting with user's text * @param searchText */ private void showPossibleDictionaryKeys(String searchText) { Log.d(TAG, "Search for:"+searchText); try { if (mDictionaryGlobalList!=null) { searchText = searchText.toLowerCase(); Iterator<Key> iter = mDictionaryGlobalList.iterator(); mMatchingKeyList.clear(); while (iter.hasNext()) { Key key = iter.next(); if (key.getName().toLowerCase().contains(searchText)) { mMatchingKeyList.add(key); } } Log.d(TAG, "matches found:"+mMatchingKeyList.size()); notifyDataSetChanged(); Log.d(TAG, "Finished searching for:"+searchText); } else { Log.d(TAG, "Cached global key list is null"); } } catch (Exception e) { Log.e(TAG, "Error finding matching keys", e); Dialogs.getInstance().showErrorMsg(R.string.error_occurred, e); } }
/** * Perform a test read on an iterator over a set of keys */ private static void readBook(Book book, Key set) { int[] stats = new int[] { 0, 0 }; boolean first = true; for (Key key : set) { // skip the root of a TreeKey as it often is not addressable. if (first) { first = false; if (key instanceof TreeKey && key.getName().length() == 0) { continue; } } readKey(book, key, stats); } log.warn(book.getInitials() + ':' + stats[0] + ':' + stats[1]); }
/** * If note is reference specific then return the reference otherwise return the text within the note */ public String getNoteText() { String text=null; if (noteType.equals(NoteType.TYPE_REFERENCE)) { Key key = getReferenceKey(); if (key!=null) { text = key.getName(); } } // if not a reference or if reference was invalid return the notes text content if (text==null) { text = noteText; } return text; }
public Iterator<Content> getOsisIterator(final Key key, boolean allowEmpty, final boolean allowGenTitles) throws BookException { assert key != null; List<Content> content = new ArrayList<Content>(); Element title = OSISUtil.factory().createGeneratedTitle(); title.addContent(key.getName()); content.add(title); String txt = getBackend().getRawText(key); List<Content> osisContent = filter.toOSIS(this, key, txt); content.addAll(osisContent); return content.iterator(); }
/** * If non-null, currentKey is used to throw the exception, other, masterKey * is used instead, which will be more general. * * @param masterKey * the key containing currentKey * @param currentKey * the currentKey * @param e * the exception that occured * @throws BookException * always thrown, a {@link BookException} */ private void throwFailedKeyException(Key masterKey, Key currentKey, IOException e) throws BookException { // TRANSLATOR: Common error condition: The file could not be read. // There can be many reasons. // {0} is a placeholder for the key. if (currentKey == null) { throw new BookException(JSMsg.gettext("Error reading {0}", masterKey.getName()), e); } throw new BookException(JSMsg.gettext("Error reading {0}", currentKey.getName()), e); }
/** * 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); } } }
@Override public View getView(int position, View convertView, ViewGroup parent) { Key item = getItem(position); // Pick up the TwoLineListItem defined in the xml file TwoLineListItem view; if (convertView == null) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = (TwoLineListItem) inflater.inflate(resource, parent, false); } else { view = (TwoLineListItem) convertView; } // Set value for the first text field if (view.getText1() != null) { String key = item.getName(); view.getText1().setText(key); } // set value for the second text field if (view.getText2() != null) { String verseText = searchControl.getSearchResultVerseText(item); view.getText2().setText(verseText); } return view; } }
public int indexOf(Key that) { RawLDBackendState state = null; try { state = initState(); return search(state, that.getName()); } catch (IOException e) { return -getCardinality() - 1; } catch (BookException e) { return -getCardinality() - 1; } finally { OpenFileStateManager.instance().release(state); } }
/** * Get a reference list for a search result against a book. * * @param bookInitials * @param searchRequest * @return The reference for the matching. * @throws BookException */ public String search(String bookInitials, String searchRequest) throws BookException { Book book = BookInstaller.getInstalledBook(bookInitials); if (isBookIndexed(book) && searchRequest != null) { if (BookCategory.BIBLE.equals(book.getBookCategory())) { BookName.setFullBookName(false); } return book.find(searchRequest).getName(); } return ""; }
public String readRawContent(GenBookBackendState state, Key key) throws IOException, BookException { TreeNode node = find(key); if (node == null) { // TRANSLATOR: Error condition: Indicates that something could // not be found in the book. // {0} is a placeholder for the unknown key. // {1} is the short name of the book throw new BookException(JSMsg.gettext("No entry for '{0}' in {1}.", key.getName(), getBookMetaData().getInitials())); } byte[] userData = node.getUserData(); // Some entries may be empty. if (userData.length == 8) { int start = SwordUtil.decodeLittleEndian32(userData, 0); int size = SwordUtil.decodeLittleEndian32(userData, 4); byte[] data = SwordUtil.readRAF(state.getBdtRaf(), start, size); decipher(data); return SwordUtil.decode(key.getName(), data, getBookMetaData().getBookCharset()); } return ""; }