public interface ResourceDataBroker
/resource
/rules
Make sure that you never obtain any LanguageTool 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 |
getAsStream(String path)
Get from resource broker by a path file
|
URL |
getAsURL(String path)
Get from resource broker by a path file
|
List<URL> |
getAsURLs(String path)
Get URLs from resource broker by a path file
|
List<String> |
getFromResourceDirAsLines(String path)
Gets any resource from the
/resource directory. |
InputStream |
getFromResourceDirAsStream(String path)
Gets any resource from LanguageTool's
/resource directory. |
URL |
getFromResourceDirAsUrl(String path)
Gets any resource from LanguageTool's
/resource directory. |
List<URL> |
getFromResourceDirAsUrls(String path)
Gets all resources in a form of URL from LanguageTool's
/resource
directory with the same path . |
InputStream |
getFromRulesDirAsStream(String path)
Gets any resource from LanguageTool's
/rules directory. |
URL |
getFromRulesDirAsUrl(String path)
Gets any resource from LanguageTool's
/rules directory. |
ResourceBundle |
getResourceBundle(String baseName,
Locale locale)
Gets a resource bundle using the specified base name and locale, and the caller module.
|
String |
getResourceDir() |
String |
getRulesDir() |
boolean |
resourceExists(String path)
Checks if a resource in LanguageTool's
/resource exists. |
boolean |
ruleFileExists(String path)
Checks if a resource in LanguageTool'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 foundList<URL> getFromResourceDirAsUrls(String path)
/resource
directory with the same path
.path
- Path to an items from the /resource
directory.URL
objects 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 foundList<String> getFromResourceDirAsLines(String path)
/resource
directory.path
- The relative path to the item inside of the /resource
, e.g. /xx/filename
RuntimeException
- if path cannot be foundInputStream getAsStream(String path)
path
- Path to an itemInputStream
object to the requested itemURL getAsURL(String path)
path
- Path to an itemURL
object to the requested itemList<URL> getAsURLs(String path)
path
- Path to an itemURL
objects to the requested itemURL 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
ResourceBundle getResourceBundle(String baseName, Locale locale)
baseName
- the base name of the resource bundle, a fully qualified class namelocale
- the locale for which a resource bundle is desired