public String getInitials() { return bmd.getInitials(); }
private void buildDocumentOpen(StringBuffer buf, BookMetaData bmd, String range, boolean force) { if (!force) { return; } MessageFormat msgFormat = new MessageFormat( "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<osis\n xmlns=\"http://www.bibletechnologies.net/2003/OSIS/namespace\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://www.bibletechnologies.net/2003/OSIS/namespace http://www.bibletechnologies.net/osisCore.2.1.1.xsd\">\n<osisText osisIDWork=\"{0}\" osisRefWork=\"defaultReferenceScheme\" xml:lang=\"en\">\n<header>\n <work osisWork=\"{0}\">\n <title>{1}</title>\n <identifier type=\"OSIS\">Bible.{0}</identifier>\n <scope>{2}</scope>\n <refSystem>Bible.KJV</refSystem>\n </work>\n <work osisWork=\"defaultReferenceScheme\">\n <refSystem>Bible.KJV</refSystem>\n </work>\n <work osisWork=\"strong\">\n <refSystem>Dict.Strongs</refSystem>\n </work>\n <work osisWork=\"robinson\">\n <refSystem>Dict.Robinsons</refSystem>\n </work>\n <work osisWork=\"strongMorph\">\n <refSystem>Dict.strongMorph</refSystem>\n </work>\n</header>\n"); msgFormat.format(new Object[] { bmd.getInitials(), bmd.getName(), range }, buf, pos); }
private void buildDocumentOpen(StringBuffer buf, BookMetaData bmd) { MessageFormat msgFormat = new MessageFormat( "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<osis\n xmlns=\"http://www.bibletechnologies.net/2003/OSIS/namespace\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://www.bibletechnologies.net/2003/OSIS/namespace osisCore.2.1.xsd\">\n<osisText osisIDWork=\"{0}\" osisRefWork=\"defaultReferenceScheme\" xml:lang=\"en\">\n <header>\n <work osisWork=\"{0}\">\n <title>{1}</title>\n <identifier type=\"OSIS\">Dict.{0}</identifier>\n <refSystem>Dict.{0}</refSystem>\n </work>\n <work osisWork=\"defaultReferenceScheme\">\n <refSystem>Dict.{0}</refSystem>\n </work>\n </header>\n<div>\n"); msgFormat.format(new Object[] { bmd.getInitials(), bmd.getName() }, buf, pos); }
public String getName() { return getBookMetaData().getInitials(); }
public GenBookBackendState getGenBookBackendState(BookMetaData metadata) throws BookException { ensureNotShuttingDown(); GenBookBackendState state = getInstance(metadata); if (state == null) { LOGGER.trace("Initializing: {}", metadata.getInitials()); return new GenBookBackendState(metadata); } LOGGER.trace("Reusing: {}", metadata.getInitials()); return state; }
public RawBackendState getRawBackendState(BookMetaData metadata) throws BookException { ensureNotShuttingDown(); RawBackendState state = getInstance(metadata); if (state == null) { LOGGER.trace("Initializing: {}", metadata.getInitials()); return new RawBackendState(metadata); } LOGGER.trace("Reusing: {}", metadata.getInitials()); return state; }
public ZLDBackendState getZLDBackendState(BookMetaData metadata) throws BookException { ensureNotShuttingDown(); ZLDBackendState state = getInstance(metadata); if (state == null) { LOGGER.trace("Initializing: {}", metadata.getInitials()); return new ZLDBackendState(metadata); } LOGGER.trace("Reusing: {}", metadata.getInitials()); return state; }
public RawFileBackendState getRawFileBackendState(BookMetaData metadata) throws BookException { ensureNotShuttingDown(); RawFileBackendState state = getInstance(metadata); if (state == null) { LOGGER.trace("Initializing: {}", metadata.getInitials()); return new RawFileBackendState(metadata); } LOGGER.trace("Reusing: {}", metadata.getInitials()); return state; }
public ZVerseBackendState getZVerseBackendState(BookMetaData metadata, BlockType blockType) throws BookException { ensureNotShuttingDown(); ZVerseBackendState state = getInstance(metadata); if (state == null) { LOGGER.trace("Initializing: {}", metadata.getInitials()); return new ZVerseBackendState(metadata, blockType); } LOGGER.trace("Reusing: {}", metadata.getInitials()); return state; }
public RawLDBackendState getRawLDBackendState(BookMetaData metadata) throws BookException { ensureNotShuttingDown(); RawLDBackendState state = getInstance(metadata); if (state == null) { LOGGER.trace("Initializing: {}", metadata.getInitials()); return new RawLDBackendState(metadata); } LOGGER.trace("Reusing: {}", metadata.getInitials()); return state; }
public void release(OpenFileState fileState) { if (fileState == null) { // can't release anything. JSword has failed to open a file state, // and a finally block is trying to close this return; } fileState.setLastAccess(System.currentTimeMillis()); // instead of releasing, we add to our queue BookMetaData bmd = fileState.getBookMetaData(); Queue<OpenFileState> queueForMeta = getQueueForMeta(bmd); LOGGER.trace("Offering to releasing: {}", bmd.getInitials()); boolean offered = queueForMeta.offer(fileState); // ignore if we couldn't offer to the queue if (!offered) { LOGGER.trace("Released: {}", bmd.getInitials()); fileState.releaseResources(); } }
public static String getBookIdentifierPropSuffix(BookMetaData meta) { String moduleVer = null; if (meta.getProperty("Version") != null) { moduleVer = '[' + meta.getProperty("Version") + ']'; } return meta.getInitials() + moduleVer; }
@Override public boolean equals(Object obj) { // Since this can not be null if (obj == null) { return false; } // We might consider checking for equality against all BookMetaDatas? // However currently we don't. // Check that that is the same as this // Don't use instanceof since that breaks inheritance if (!obj.getClass().equals(this.getClass())) { return false; } // The real bit ... BookMetaData that = (BookMetaData) obj; return getBookCategory().equals(that.getBookCategory()) && getName().equals(that.getName()) && getInitials().equals(that.getInitials()); }
/** * Clients can use this to determine if book's index is stale and needs to re-indexed or downloaded. * Assumes index exists: Client must use isIndexed() prior to using this method * * @return true, if Latest.Index.Version.xxx > Installed.Index.Version.xxx * @see org.crosswire.jsword.index.IndexManager#needsReindexing(org.crosswire.jsword.book.Book) */ public boolean needsReindexing(Book book) { //check for index version //should Clients use IndexStatus.INVALID float installedV = InstalledIndex.instance().getInstalledIndexVersion(book); if (installedV < IndexMetadata.instance().getLatestIndexVersion(book)) { log.info("{}: needs reindexing, Installed index version @{}", book.getBookMetaData().getInitials(), Float.toString(installedV)); return true; } return false; }
public int compareTo(BookMetaData obj) { int result = this.getBookCategory().compareTo(obj.getBookCategory()); if (result == 0) { result = this.getAbbreviation().compareTo(obj.getAbbreviation()); } if (result == 0) { result = this.getInitials().compareTo(obj.getInitials()); } if (result == 0) { result = this.getName().compareTo(obj.getName()); } return result; }
/** * Determine where an index should be stored * * @param book * The book to be indexed * @return A URI to store stuff in * @throws IOException * If there is a problem in finding where to store stuff */ protected URI getStorageArea(Book book) throws IOException { BookMetaData bmd = book.getBookMetaData(); String driverName = bmd.getDriverName(); String bookName = bmd.getInitials(); assert driverName != null; assert bookName != null; //URI driver = NetUtil.lengthenURI(baseFolderURI, driverName); return NetUtil.lengthenURI(baseFolderURI, driverName + NetUtil.SEPARATOR + bookName); }
public Key get(int index) { RawLDBackendState state = null; try { state = initState(); if (index < getCardinality()) { DataIndex dataIndex = getIndex(state, index); DataEntry entry = getEntry(state, getBookMetaData().getInitials(), dataIndex); String keytitle = internal2external(entry.getKey()); return new DefaultLeafKeyList(keytitle); } } catch (BookException e) { // This is allowed // Fall through to throw an AIOOBE. } catch (IOException e) { // This is allowed // Fall through to throw an AIOOBE. } finally { OpenFileStateManager.instance().release(state); } throw new ArrayIndexOutOfBoundsException(index); }
public LuceneAnalyzer(Book book) { // The default analysis analyzer = new PerFieldAnalyzerWrapper(new SimpleAnalyzer()); if (InstalledIndex.instance().getInstalledIndexDefaultVersion() > IndexMetadata.INDEX_VERSION_1_1) { // Content is analyzed using natural language analyzer // (stemming, stopword etc) Analyzer myNaturalLanguageAnalyzer = AnalyzerFactory.getInstance().createAnalyzer(book); analyzer.addAnalyzer(LuceneIndex.FIELD_BODY, myNaturalLanguageAnalyzer); //analyzer.addAnalyzer(LuceneIndex.FIELD_HEADING, myNaturalLanguageAnalyzer); //heading to use same analyzer as BODY //analyzer.addAnalyzer(LuceneIndex.FIELD_INTRO, myNaturalLanguageAnalyzer); log.debug("{}: Using languageAnalyzer: {}", book.getBookMetaData().getInitials(), myNaturalLanguageAnalyzer.getClass().getName()); } // Keywords are normalized to osisIDs analyzer.addAnalyzer(LuceneIndex.FIELD_KEY, new KeyAnalyzer()); // Strong's Numbers are normalized to a consistent representation analyzer.addAnalyzer(LuceneIndex.FIELD_STRONG, new StrongsNumberAnalyzer()); // Strong's Numbers and Robinson's morphological codes are normalized to a consistent representation analyzer.addAnalyzer(LuceneIndex.FIELD_MORPHOLOGY, new MorphologyAnalyzer()); // XRefs are normalized from ranges into a list of osisIDs analyzer.addAnalyzer(LuceneIndex.FIELD_XREF, new XRefAnalyzer()); }
/** * Helper method to create the boilerplate headers in an OSIS document from * the current metadata object * * @param bmd the book's meta data * @return the root of an OSIS document */ public static Element createOsisFramework(BookMetaData bmd) { Element osis = factory().createOsis(); String osisid = bmd.getInitials(); Element work = factory().createWork(); work.setAttribute(ATTRIBUTE_WORK_OSISWORK, osisid); Element header = factory().createHeader(); header.addContent(work); Element text = factory().createOsisText(); text.setAttribute(ATTRIBUTE_TEXT_OSISIDWORK, OSISID_PREFIX_BIBLE + osisid); text.addContent(header); osis.addContent(text); return osis; }
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 ""; }