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

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

Best Java code snippets using org.crosswire.jsword.passage.PassageKeyFactory.createEmptyKeyList (Showing top 8 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 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: crosswire/jsword

public final Key createEmptyKeyList() {
  return keyf.createEmptyKeyList(Versifications.instance().getVersification(versification));
}
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

/**
 * Cast a Key to a Passage. Only those keys that are a Passage or can
 * be held by a Passage (i.e. Verse and VerseRange) may be cast to one.
 * If you pass a null key into this method, you get a null Passage out.
 * 
 * @param key The key to cast
 * @return The key cast to a Passage
 * @throws ClassCastException
 */
public static Passage getPassage(Key key) {
  if (key == null) {
    return null;
  }
  if (key instanceof Passage) {
    return (Passage) key;
  }
  if (key instanceof VerseKey) {
    VerseKey verseKey = (VerseKey) key;
    Key ref = PassageKeyFactory.instance().createEmptyKeyList(verseKey.getVersification());
    ref.addAll(verseKey);
    return (Passage) ref;
  }
  throw new ClassCastException("Expected key to be a Verse, VerseRange or Passage");
}
origin: crosswire/jsword

/**
 * Read a passage from a given stream
 * 
 * @param in
 *            The stream to read from
 * @return a newly built Passage
 * @throws IOException
 *             If there was trouble reading the stream
 * @throws NoSuchKeyException
 *             if the data was not a valid passage
 */
public static Passage readPassage(Reader in) throws IOException, NoSuchKeyException {
  // Get any versification. It does not matter. readDescripton will overwrite it.
  Versification rs = Versifications.instance().getVersification("KJV");
  Passage ref = (Passage) keyf.createEmptyKeyList(rs);
  ref.readDescription(in);
  return ref;
}
origin: AndBible/and-bible

/**
 * Flexible converter for the generic Key base class.  
 * Return the key in the required versification, mapping if necessary
 * Currently only handles Passage, RangedPassage, and Verse
 */
public Key convert(Key key, Versification toVersification) {
  try {
    if (key instanceof RangedPassage) {
      return convert((RangedPassage)key, toVersification);
    } else if (key instanceof VerseRange) {
      return convert((VerseRange)key, toVersification);
    } else if (key instanceof Passage) {
      return convert((Passage)key, toVersification);
    } else if (key instanceof Verse) {
      return convert((Verse)key, toVersification);
    }
  } catch (Exception e) {
    // unexpected problem during mapping
    Log.e(TAG, "JSword Versification mapper failed to map "+key.getOsisID()+" to "+toVersification.getName(), e);
  }
  return PassageKeyFactory.instance().createEmptyKeyList(toVersification);
}
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 = (Passage) keyf.createEmptyKeyList(rs);
org.crosswire.jsword.passagePassageKeyFactorycreateEmptyKeyList

Javadoc

Create an empty list of keys for the v11n

Popular methods of PassageKeyFactory

  • getKey
    Convert the passageReference into a Passage. This is the recommended form for understanding referenc
  • instance
    This PassageKeyFactory is accessed through this instance.
  • 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
  • compareTo (BigDecimal)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • runOnUiThread (Activity)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • SortedSet (java.util)
    A Set that further provides a total ordering on its elements. The elements are ordered using their C
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • ImageIO (javax.imageio)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
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