Package org.languagetool.databroker
Interface ResourceDataBroker
- All Known Implementing Classes:
DefaultResourceDataBroker
public interface ResourceDataBroker
Is responsible for getting the necessary resources for the grammar checker
library. Following directories are currently needed by a couple of classes:
/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.
- Since:
- 1.0.1
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionGets any resource from the grammar checker's/resource
directory.Gets any resource from the grammar checker's/resource
directory.Gets any resource from the grammar checker's/rules
directory.getFromRulesDirAsUrl
(String path) Gets any resource from the grammar checker's/rules
directory.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.
-
Field Details
-
RESOURCE_DIR
The directory name of the/resource
directory.- See Also:
-
RULES_DIR
The directory name of the/rules
directory.- See Also:
-
-
Method Details
-
getFromResourceDirAsUrl
Gets any resource from the grammar checker's/resource
directory.- Parameters:
path
- Path to an item from the/resource
directory.- Returns:
- An
URL
object to the requested item - Throws:
RuntimeException
- if path cannot be found
-
resourceExists
Checks if a resource in the grammar checker's/resource
exists.- Parameters:
path
- Path to an item from the/resource
directory.- Returns:
true
if the resource file exists.
-
ruleFileExists
Checks if a resource in the grammar checker's/rules
exists.- Parameters:
path
- Path to an item from the/rules
directory.- Returns:
true
if the resource file exists.
-
getFromResourceDirAsStream
Gets any resource from the grammar checker's/resource
directory.- Parameters:
path
- Path to an item from the/resource
directory.- Returns:
- An
InputStream
object to the requested item - Throws:
RuntimeException
- if path cannot be found
-
getFromRulesDirAsUrl
Gets any resource from the grammar checker's/rules
directory.- Parameters:
path
- Path to an item from the/rules
directory.- Returns:
- An
URL
object to the requested item - Throws:
RuntimeException
- if path cannot be found
-
getFromRulesDirAsStream
Gets any resource from the grammar checker's/rules
directory.- Parameters:
path
- Path to an item from the/rules
directory.- Returns:
- An
InputStream
object to the requested item - Throws:
RuntimeException
- if path cannot be found
-
getResourceDir
String getResourceDir()- Returns:
- The currently set resource directory path as a string. Make sure
that you comply with the following format when setting this value:
/subdir/furtherdir/resourcedir
-
getRulesDir
String getRulesDir()- Returns:
- The currently set rules directory path as a string. Make sure
that you comply with the following format when setting this value:
/subdir/furtherdir/rulesdir
-