blob: eac263ba18a4b65a1dd778dc36286c528a7a037b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
/* LanguageTool, a natural language style checker
* Copyright (C) 2006 Daniel Naber (http://www.danielnaber.de)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
package de.danielnaber.languagetool.databroker;
import java.io.InputStream;
import java.net.URL;
import de.danielnaber.languagetool.JLanguageTool;
/**
* Is responsible for getting the necessary resources for the grammar checker
* library. Following directories are currently needed by a couple of classes:
*
* <ul style="list-type: circle">
* <li>{@code /resource}</li>
* <li>{@code /rules}</li>
* </ul>
*
* This interface determines methods to obtain any contents from these
* directories.
* <p>
*
* Make sure that you never obtain any grammar checker resources by calling
* {@code Object.class.getResource(String)} or {@code
* Object.class.getResourceAsStream(String)} directly. If you would like to
* obtain something from these directories do always use
* {@link JLanguageTool#getDataBroker()} which provides proper methods for
* reading the directories above.
* <p>
*
* For example, if you want to get the {@link URL} of {@code
* /rules/de/grammar.xml} just invoke
* {@link ResourceDataBroker#getFromRulesDirAsUrl(String)} and pass {@code
* /de/grammar.xml} as a string. Note: The {@code /rules} directory's name isn't
* passed, because its name might have changed. The same usage does apply for the
* {@code /resource} directory.
*
* @author PAX
* @since 1.0.1
*/
public interface ResourceDataBroker {
/**
* The directory name of the {@code /resource} directory.
*/
public static final String RESOURCE_DIR = "/resource";
/**
* The directory name of the {@code /rules} directory.
*/
public static final String RULES_DIR = "/rules";
/**
* Gets any resource from the grammar checker's {@code /resource} directory.
*
* @param path Path to an item from the {@code /resource} directory.
* @return An {@link URL} object to the requested item or {@code null} if it
* wasn't found.
*/
public URL getFromResourceDirAsUrl(String path);
/**
* Gets any resource from the grammar checker's {@code /resource} directory.
*
* @param path Path to an item from the {@code /resource} directory.
* @return An {@link InputStream} object to the requested item or {@code null}
* if it wasn't found.
*/
public InputStream getFromResourceDirAsStream(String path);
/**
* Gets any resource from the grammar checker's {@code /rules} directory.
*
* @param path
* Path to an item from the {@code /rules} directory.
* @return An {@link URL} object to the requested item or {@code null} if it
* wasn't found.
*/
public URL getFromRulesDirAsUrl(String path);
/**
* Gets any resource from the grammar checker's {@code /rules} directory.
*
* @param path Path to an item from the {@code /rules} directory.
* @return An {@link InputStream} object to the requested item or {@code
* null} if it wasn't found.
*/
public InputStream getFromRulesDirAsStream(String path);
/**
* @return The currently set resource directory path as a string. Make sure
* that you comply with the following format when setting this value:
* <p>
* {@code /subdir/furtherdir/resourcedir}
*/
public String getResourceDir();
/**
* @param resourceDir The used directory path to the {@code /resource} directory.
* Make sure that you comply with the following format when setting
* this value:
* <p>
* {@code /subdir/furtherdir/resourcedir}
*/
public void setResourceDir(String resourceDir);
/**
* @return The currently set rules directory path as a string. Make sure
* that you comply with the following format when setting this value:
* <p>
* {@code /subdir/furtherdir/rulesdir}
*/
public String getRulesDir();
/**
* @param rulesDir The used directory path to the {@code /rules} directory. Make
* sure that you comply with the following format when setting this
* value:
* <p>
* {@code /subdir/furtherdir/rulesdir}
*/
public void setRulesDir(String rulesDir);
}
|