Codota Logo
PassageKeyFactory.getKey
Code IndexAdd Codota to your IDE (free)

How to use
getKey
method
in
org.crosswire.jsword.passage.PassageKeyFactory

Best Java code snippets using org.crosswire.jsword.passage.PassageKeyFactory.getKey (Showing top 11 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Charset c =
  • Codota IconString charsetName;Charset.forName(charsetName)
  • Codota IconCharset.defaultCharset()
  • Codota IconContentType contentType;contentType.getCharset()
  • Smart code suggestions by Codota
}
origin: crosswire/jsword

/**
 * Convert the passageReference into a Passage. This is the recommended
 * form for application constructed references and user input. Both of
 * these should have a fully qualified first reference.
 * 
 * @param v11n
 *            The Versification to which this Passage belongs.
 * @param passageReference
 *            A String containing the text for the Passage
 * @return a new Passage filled with the desired Verses
 * @throws NoSuchKeyException
 *             If the passageReference has anything that could not be understood as a Verse
 */
public Passage getKey(Versification v11n, String passageReference) throws NoSuchKeyException {
  return getKey(v11n, passageReference, null);
}
origin: crosswire/jsword

/**
 * Convert the passageReference into a Passage or an empty Passage,
 * if there is an error. Note, this is not recommended as it throws
 * away the error.
 * 
 * @param v11n
 *            The Versification to which this Passage belongs.
 * @param passageReference
 *            A String containing the text of the Passage
 * @param basis
 *           The basis by which to interpret passageReference
 * @return a new Passage filled with the desired Verses or an empty Passage
 */
public Key getValidKey(Versification v11n, String passageReference, Key basis) {
  try {
    return getKey(v11n, passageReference, basis);
  } catch (NoSuchKeyException e) {
    return createEmptyKeyList(v11n);
  }
}
origin: AndBible/and-bible

  /**
   * 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;
  }
}
origin: crosswire/jsword

public final Key getKey(String text) throws NoSuchKeyException {
  return PassageKeyFactory.instance().getKey(Versifications.instance().getVersification(versification), text);
}
origin: AndBible/and-bible

  result.append("</a>");
} else {
  Passage ref = (Passage) PassageKeyFactory.instance().getKey(parameters.getDocumentVersification(), reference);
  boolean isSingleVerse = ref.countVerses()==1;
  boolean hasContent = content.length()>0;
origin: crosswire/jsword

  @Override
  public void processContent(Book book, Key key, Element ele) {
    String refstr = ele.getValue();
    try {
      if (ele.getAttribute(OSISUtil.OSIS_ATTR_REF) == null) {
        Passage ref = PassageKeyFactory.instance().getKey(KeyUtil.getVersification(key), refstr, key);
        String osisname = ref.getOsisRef();
        ele.setAttribute(OSISUtil.OSIS_ATTR_REF, osisname);
      }
    } catch (NoSuchKeyException ex) {
      DataPolice.report(book, key, "scripRef has no passage attribute, unable to guess: (" + refstr + ") due to " + ex.getMessage());
    }
  }
}
origin: crosswire/jsword

@Override
public Element processTag(Book book, Key key, Element ele, Attributes attrs) {
  Element reference = null;
  String refstr = attrs.getValue("passage");
  if (refstr != null) {
    Passage ref = null;
    try {
      ref = PassageKeyFactory.instance().getKey(KeyUtil.getVersification(key), refstr, key);
    } catch (NoSuchKeyException ex) {
      DataPolice.report(book, key, "Unparsable passage: (" + refstr + ") due to " + ex.getMessage());
    }
    // If we don't have a Passage then use the original string
    String osisname = ref != null ? ref.getOsisRef() : refstr;
    reference = OSISUtil.factory().createReference();
    reference.setAttribute(OSISUtil.OSIS_ATTR_REF, osisname);
  } else {
    // The reference will be filled in by processContent
    reference = OSISUtil.factory().createReference();
  }
  if (ele != null) {
    ele.addContent(reference);
  }
  return reference;
}
origin: crosswire/jsword

/**
 * 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();
}
origin: crosswire/jsword

Passage ref = keyf.getKey(Versifications.instance().getVersification("KJV"), readings);
origin: AndBible/and-bible

/** user has selected a Bible verse link
 */
private void showBible(String keyText) throws NoSuchKeyException {
  CurrentPageManager pageManager = getCurrentPageManager();
  Book bible = pageManager.getCurrentBible().getCurrentDocument();
  // get source versification
  Versification sourceDocumentVersification;
  Book currentDoc = pageManager.getCurrentPage().getCurrentDocument();
  if (currentDoc instanceof AbstractPassageBook) {
    sourceDocumentVersification = ((AbstractPassageBook)currentDoc).getVersification();
  } else {
    // default to v11n of current Bible.  
    //TODO av11n issue.  GenBooks have no v11n and this default would be used for links from GenBooks which would only sometimes be correct
    sourceDocumentVersification = ((AbstractPassageBook)bible).getVersification();
  }
  
  // create Passage with correct source Versification 
  Key key = PassageKeyFactory.instance().getKey(sourceDocumentVersification, keyText);
  
  // Bible not specified so use the default Bible version
  showLink(null, key);
  
  return;
}
origin: AndBible/and-bible

public void testTrickyWebChapters() throws Exception {
  {
    OSISInputStream osisInputStream = new OSISInputStream(webBook, PassageKeyFactory.instance().getKey(Versifications.instance().getVersification("KJV"), "Ps 1"));
    String chapter = convertStreamToString(osisInputStream);
    int numOpeningLs = count(chapter, "<l>") + count(chapter, "<l ");
    int numClosingLs = count(chapter, "</l>");
    System.out.println(chapter);
    assertThat("wrong number of Ls", numOpeningLs, equalTo(numClosingLs));
  }
  {
    OSISInputStream osisInputStream = new OSISInputStream(webBook, PassageKeyFactory.instance().getKey(Versifications.instance().getVersification("KJV"), "Gen 49"));
    String chapter = convertStreamToString(osisInputStream);
    int numOpeningLs = count(chapter, "<l>") + count(chapter, "<l ");
    int numClosingLs = count(chapter, "</l>");
    System.out.println(chapter);
    assertThat("wrong number of Ls", numOpeningLs, equalTo(numClosingLs));
  }
}
org.crosswire.jsword.passagePassageKeyFactorygetKey

Javadoc

Convert the passageReference into a Passage. This is the recommended form for application constructed references and user input. Both of these should have a fully qualified first reference.

Popular methods of PassageKeyFactory

  • instance
    This PassageKeyFactory is accessed through this instance.
  • createEmptyKeyList
    Create an empty list of keys for the v11n
  • getValidKey
    Convert the passageReference into a Passage or an empty Passage, if there is an error. Note, this is
  • setDefaultType
    Set the default PassageType
  • binarySize
    Write to buffer (starting at index) the given number using a set of bytes as required by the max pos
  • fromBinary
    Read and return an int from the buffer (starting at index[0]) using a set of bytes as required by th
  • getGlobalKeyList
    Get a Passage containing all the Verses in this Versification. This differs from org.crosswire.jswor
  • mungOsisRef
    Replace spaces with semi-colons, because the parser expects them.
  • normalize
    The internals of a Passage require that references are separated with a reference delimiter. However
  • toBinary
    Write to buffer (starting at index) the given number using a set of bytes as required by the max pos

Popular in Java

  • Finding current android device location
  • getExternalFilesDir (Context)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • notifyDataSetChanged (ArrayAdapter)
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • ResourceBundle (java.util)
    Resource bundles contain locale-specific objects. When your program needs a locale-specific resource
  • Pattern (java.util.regex)
    A compiled representation of a regular expression. A regular expression, specified as a string, must
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now