Package org.languagetool.databroker
Interface ResourceDataBroker
-
- All Known Implementing Classes:
DefaultResourceDataBroker
public interface ResourceDataBrokerIs 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)orObject.class.getResourceAsStream(String)directly. If you would like to obtain something from these directories do always useJLanguageTool.getDataBroker()which provides proper methods for reading the directories above.For example, if you want to get the
URLof/rules/de/grammar.xmljust invokegetFromRulesDirAsUrl(String)and pass/de/grammar.xmlas a string. Note: The/rulesdirectory's name isn't passed, because its name might have changed. The same usage does apply for the/resourcedirectory.- Since:
- 1.0.1
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringRESOURCE_DIRThe directory name of the/resourcedirectory.static java.lang.StringRULES_DIRThe directory name of the/rulesdirectory.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.io.InputStreamgetFromResourceDirAsStream(java.lang.String path)Gets any resource from the grammar checker's/resourcedirectory.java.net.URLgetFromResourceDirAsUrl(java.lang.String path)Gets any resource from the grammar checker's/resourcedirectory.java.io.InputStreamgetFromRulesDirAsStream(java.lang.String path)Gets any resource from the grammar checker's/rulesdirectory.java.net.URLgetFromRulesDirAsUrl(java.lang.String path)Gets any resource from the grammar checker's/rulesdirectory.java.lang.StringgetResourceDir()java.lang.StringgetRulesDir()booleanresourceExists(java.lang.String path)Checks if a resource in the grammar checker's/resourceexists.booleanruleFileExists(java.lang.String path)Checks if a resource in the grammar checker's/rulesexists.
-
-
-
Field Detail
-
RESOURCE_DIR
static final java.lang.String RESOURCE_DIR
The directory name of the/resourcedirectory.- See Also:
- Constant Field Values
-
RULES_DIR
static final java.lang.String RULES_DIR
The directory name of the/rulesdirectory.- See Also:
- Constant Field Values
-
-
Method Detail
-
getFromResourceDirAsUrl
java.net.URL getFromResourceDirAsUrl(java.lang.String path)
Gets any resource from the grammar checker's/resourcedirectory.- Parameters:
path- Path to an item from the/resourcedirectory.- Returns:
- An
URLobject to the requested item - Throws:
java.lang.RuntimeException- if path cannot be found
-
resourceExists
boolean resourceExists(java.lang.String path)
Checks if a resource in the grammar checker's/resourceexists.- Parameters:
path- Path to an item from the/resourcedirectory.- Returns:
trueif the resource file exists.
-
ruleFileExists
boolean ruleFileExists(java.lang.String path)
Checks if a resource in the grammar checker's/rulesexists.- Parameters:
path- Path to an item from the/rulesdirectory.- Returns:
trueif the resource file exists.
-
getFromResourceDirAsStream
java.io.InputStream getFromResourceDirAsStream(java.lang.String path)
Gets any resource from the grammar checker's/resourcedirectory.- Parameters:
path- Path to an item from the/resourcedirectory.- Returns:
- An
InputStreamobject to the requested item - Throws:
java.lang.RuntimeException- if path cannot be found
-
getFromRulesDirAsUrl
java.net.URL getFromRulesDirAsUrl(java.lang.String path)
Gets any resource from the grammar checker's/rulesdirectory.- Parameters:
path- Path to an item from the/rulesdirectory.- Returns:
- An
URLobject to the requested item - Throws:
java.lang.RuntimeException- if path cannot be found
-
getFromRulesDirAsStream
java.io.InputStream getFromRulesDirAsStream(java.lang.String path)
Gets any resource from the grammar checker's/rulesdirectory.- Parameters:
path- Path to an item from the/rulesdirectory.- Returns:
- An
InputStreamobject to the requested item - Throws:
java.lang.RuntimeException- if path cannot be found
-
getResourceDir
java.lang.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
java.lang.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
-
-