|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.crosswire.jsword.passage.PassageKeyFactory
public final class PassageKeyFactory
The PassageKeyFactory constructs Passages of the default Passage type. This allows for tuning the application to specific time/space needs and it allows for the development of other types of Passages without needing to change the application.
It is strongly recommended to use this factory to create passages if there is no driving need to create them for a specific purpose.
Most of the methods take the same arguments:
Most of the methods will throw:
for license details.
The copyright to this program is held by it's authors.
Field Summary | |
---|---|
private static PassageType |
defaultType
The default type |
private static PassageKeyFactory |
keyf
How we create Passages |
Constructor Summary | |
---|---|
private |
PassageKeyFactory()
This class implements a Singleton pattern. |
Method Summary | |
---|---|
protected static int |
binarySize(int max)
Write to buffer (starting at index) the given number using a set of bytes as required by the max possible value for the number |
Key |
createEmptyKeyList(Versification v11n)
Create an empty list of keys for the v11n |
protected static int |
fromBinary(byte[] buffer,
int[] index,
int max)
Read and return an int from the buffer (starting at index[0]) using a set of bytes as required by the max possible value for the number, and incrementing index[0] by that number of bytes. |
(package private) static Passage |
fromBinaryRepresentation(byte[] buffer)
Write out the object to the given ObjectOutputStream |
static int |
getDefaultPassage()
Get the default passage type as the ordinal value of the PassageType. |
static PassageType |
getDefaultType()
Get the default PassageType. |
Key |
getGlobalKeyList(Versification v11n)
Get a Passage containing all the Verses in this Versification. |
Key |
getKey(Versification v11n,
String passageReference)
Convert the passageReference into a Passage. |
Key |
getKey(Versification v11n,
String passageReference,
Key basis)
Convert the passageReference into a Passage. |
static Passage |
getReadOnlyPassage(Passage ref,
boolean ignore)
Get a new Passage based on another Passage that synchronizes all access to its members. |
static Passage |
getSynchronizedPassage(Passage ref)
Get a new Passage based on another Passage that synchronizes all access to its members. |
Key |
getValidKey(Versification v11n,
String passageReference)
Convert the passageReference into a Passage or an empty Passage, if there is an error. |
Key |
getValidKey(Versification v11n,
String passageReference,
Key basis)
Convert the passageReference into a Passage or an empty Passage, if there is an error. |
static PassageKeyFactory |
instance()
This PassageKeyFactory is accessed through this instance. |
private String |
mungOsisRef(String passageReference)
Replace spaces with semi-colons, because the parser expects them. |
private String |
normalize(String passageReference)
The internals of a Passage require that references are separated with a reference delimiter. |
static Passage |
readPassage(Reader in)
Read a passage from a given stream |
static void |
setDefaultPassage(int newDefaultType)
Set the default PassageType. |
static void |
setDefaultType(PassageType newDefaultType)
Set the default PassageType |
protected static int |
toBinary(byte[] buffer,
int index,
int number,
int max)
Write to buffer (starting at index) the given number using a set of bytes as required by the max possible value for the number |
(package private) static byte[] |
toBinaryRepresentation(Passage ref)
Convert us to a binary representation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static PassageType defaultType
private static PassageKeyFactory keyf
Constructor Detail |
---|
private PassageKeyFactory()
Method Detail |
---|
public static PassageKeyFactory instance()
public Key createEmptyKeyList(Versification v11n)
v11n
- The Versification to which this Passage belongs.
public Key getGlobalKeyList(Versification v11n)
v11n
- The Versification to which this Passage belongs.
public Key getValidKey(Versification v11n, String passageReference, Key basis)
v11n
- The Versification to which this Passage belongs.passageReference
- A String containing the text of the Passagebasis
- The basis by which to interpret passageReference
public Key getValidKey(Versification v11n, String passageReference)
v11n
- The Versification to which this Passage belongs.passageReference
- A String containing the text for the Passage
public Key getKey(Versification v11n, String passageReference, Key basis) throws NoSuchKeyException
v11n
- The Versification to which this Passage belongs.passageReference
- A String containing the text for the Passagebasis
- The basis by which to interpret passageReference
NoSuchKeyException
- If the passageReference has anything that could not be understood as a Versepublic Key getKey(Versification v11n, String passageReference) throws NoSuchKeyException
v11n
- The Versification to which this Passage belongs.passageReference
- A String containing the text for the Passage
NoSuchKeyException
- If the passageReference has anything that could not be understood as a Versepublic static void setDefaultType(PassageType newDefaultType)
newDefaultType
- The new default PassageType.public static PassageType getDefaultType()
public static void setDefaultPassage(int newDefaultType)
newDefaultType
- The new default type.public static int getDefaultPassage()
setDefaultPassage(int)
public static Passage getSynchronizedPassage(Passage ref)
ref
- The passage to synchronize
public static Passage getReadOnlyPassage(Passage ref, boolean ignore)
ref
- The passage to synchronizeignore
- Do we throw up if someone tries to change us
static byte[] toBinaryRepresentation(Passage ref)
ref
- The Passage to convert
static Passage fromBinaryRepresentation(byte[] buffer) throws NoSuchKeyException
buffer
- The stream to read our state from
NoSuchKeyException
- If the buffer is invalidpublic static Passage readPassage(Reader in) throws IOException, NoSuchKeyException
in
- The stream to read from
IOException
- If there was trouble reading the stream
NoSuchKeyException
- if the data was not a valid passageprotected static int binarySize(int max)
max
- The number to write
protected static int toBinary(byte[] buffer, int index, int number, int max)
buffer
- Where to write toindex
- The offset to start atnumber
- The number to writemax
- The max size
protected static int fromBinary(byte[] buffer, int[] index, int max)
buffer
- The buffer to read fromindex
- The offset to start atmax
- The max number of bytes to read
private String mungOsisRef(String passageReference)
passageReference
-
private String normalize(String passageReference)
passageReference
-
|
Copyright ? 2003-2011 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |