|
@@ -2,6 +2,7 @@ package one.shandan;
|
|
|
|
|
|
import java.lang.String;
|
|
|
import java.lang.Boolean;
|
|
|
+import java.security.AccessControlException;
|
|
|
import org.crosswire.jsword.passage.VerseRangeFactory;
|
|
|
import org.crosswire.jsword.versification.system.SystemDefault;
|
|
|
import org.crosswire.jsword.versification.BibleBook;
|
|
@@ -12,18 +13,27 @@ import org.crosswire.jsword.versification.system.Versifications;
|
|
|
import org.postgresql.pljava.annotation.Function;
|
|
|
import static org.postgresql.pljava.annotation.Function.Effects.IMMUTABLE;
|
|
|
import static org.postgresql.pljava.annotation.Function.OnNullInput.RETURNS_NULL;
|
|
|
+import static org.postgresql.pljava.annotation.Function.Trust.SANDBOXED;
|
|
|
|
|
|
public class PlJavaJSword {
|
|
|
private static Versification kjv = Versifications.instance().getVersification("KJV");
|
|
|
|
|
|
- @Function(language="javau", onNullInput=RETURNS_NULL, effects=IMMUTABLE)
|
|
|
+ @Function(onNullInput=RETURNS_NULL, effects=IMMUTABLE, trust=SANDBOXED)
|
|
|
public static Boolean isValidVerse(String reference) {
|
|
|
try {
|
|
|
VerseRangeFactory.fromString(kjv, reference);
|
|
|
+ return true;
|
|
|
} catch (NoSuchVerseException ex) {
|
|
|
- return false;
|
|
|
}
|
|
|
- return true;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ @Function(onNullInput=RETURNS_NULL, effects=IMMUTABLE, trust=SANDBOXED)
|
|
|
+ public static String normalizeVerse(String reference){
|
|
|
+ try {
|
|
|
+ return VerseRangeFactory.fromString(kjv, reference).getName();
|
|
|
+ } catch (NoSuchVerseException ex) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|