X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FPlatform.java;h=a1412f2ac7efa1591eb2f1398da97e17672d5509;hb=990ed4ffbaa7a95b2ebb6bf6ab0440310f6e83ab;hp=9b57a5a3e1b8ff644e06eb5ddcef38b3a12f49c7;hpb=a8e0667a62546cdd95d44a45cf14a629cfa416a6;p=jalview.git diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index 9b57a5a..a1412f2 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -41,6 +41,8 @@ import javax.swing.SwingUtilities; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; +import com.stevesoft.pat.Regex; + /** * System platform information used by Applet and Application * @@ -657,4 +659,42 @@ public class Platform return null; } + /** + * load a resource -- probably a core file -- if and only if a particular + * class has not been instantialized. We use a String here because if we used + * a .class object, that reference itself would simply load the class, and we + * want the core package to include that as well. + * + * @param resourcePath + * @param className + */ + public static void loadStaticResource(Object resourcePath, + String className) + { + /** + * + * @j2sNative if (!swingjs.JSUtil.isClassLoaded$S(className)) + * swingjs.JSUtil.loadStaticResource$S(resourcePath); + */ + } + + public static void ensureRegex() + { + loadStaticResource("core/core_stevesoft.z.js", + "com.stevesoft.pat.Regex"); + } + + public static Regex newRegex(String searchString, String replaceString) + { + ensureRegex(); + return (replaceString == null ? new Regex(searchString) + : new Regex(searchString, replaceString)); + } + + public static Regex newRegexPerl(String code) + { + ensureRegex(); + return Regex.perlCode(code); + } + }