public interface ResourceDataBroker
/resource/rules
Make sure that you never obtain any grammar checker resources by calling
Object.class.getResource(String) or Object.class.getResourceAsStream(String) directly. If you would like to
obtain something from these directories do always use
JLanguageTool.getDataBroker() which provides proper methods for
reading the directories above.
For example, if you want to get the URL of /rules/de/grammar.xml just invoke
getFromRulesDirAsUrl(String) and pass /de/grammar.xml as a string. Note: The /rules directory's name isn't
passed, because its name might have changed. The same usage does apply for the
/resource directory.
| Modifier and Type | Field and Description |
|---|---|
static String |
RESOURCE_DIR
The directory name of the
/resource directory. |
static String |
RULES_DIR
The directory name of the
/rules directory. |
| Modifier and Type | Method and Description |
|---|---|
InputStream |
getFromResourceDirAsStream(String path)
Gets any resource from the grammar checker's
/resource directory. |
URL |
getFromResourceDirAsUrl(String path)
Gets any resource from the grammar checker's
/resource directory. |
InputStream |
getFromRulesDirAsStream(String path)
Gets any resource from the grammar checker's
/rules directory. |
URL |
getFromRulesDirAsUrl(String path)
Gets any resource from the grammar checker's
/rules directory. |
String |
getResourceDir() |
String |
getRulesDir() |
boolean |
resourceExists(String path)
Checks if a resource in the grammar checker's
/resource exists. |
boolean |
ruleFileExists(String path)
Checks if a resource in the grammar checker's
/rules exists. |
static final String RESOURCE_DIR
/resource directory.static final String RULES_DIR
/rules directory.URL getFromResourceDirAsUrl(String path)
/resource directory.path - Path to an item from the /resource directory.URL object to the requested itemRuntimeException - if path cannot be foundboolean resourceExists(String path)
/resource exists.path - Path to an item from the /resource directory.true if the resource file exists.boolean ruleFileExists(String path)
/rules exists.path - Path to an item from the /rules directory.true if the resource file exists.InputStream getFromResourceDirAsStream(String path)
/resource directory.path - Path to an item from the /resource directory.InputStream object to the requested itemRuntimeException - if path cannot be foundURL getFromRulesDirAsUrl(String path)
/rules directory.path - Path to an item from the /rules directory.URL object to the requested itemRuntimeException - if path cannot be foundInputStream getFromRulesDirAsStream(String path)
/rules directory.path - Path to an item from the /rules directory.InputStream object to the requested itemRuntimeException - if path cannot be foundString getResourceDir()
/subdir/furtherdir/resourcedir
String getRulesDir()
/subdir/furtherdir/rulesdir