Skip to content

Commit 2d3ef10

Browse files
committed
TIKA-4397: use isEmpty()
1 parent f313174 commit 2d3ef10

File tree

29 files changed

+37
-37
lines changed

29 files changed

+37
-37
lines changed

tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ public void process(String arg) throws Exception {
446446
String dirPath = arg.substring("--extract-dir=".length());
447447
//if the user accidentally doesn't include
448448
//a directory, set the directory to the cwd
449-
if (dirPath.length() == 0) {
449+
if (dirPath.isEmpty()) {
450450
dirPath = ".";
451451
}
452452
extractDir = new File(dirPath);

tika-batch/src/main/java/org/apache/tika/batch/builders/CommandLineParserBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private Option buildOption(Node optionNode) {
8888
String longOpt = getString(map, "longOpt", "");
8989
boolean isRequired = getBoolean(map, "required", false);
9090
boolean hasArg = getBoolean(map, "hasArg", false);
91-
if (opt.trim().length() == 0 || description.trim().length() == 0) {
91+
if (opt.trim().isEmpty() || description.trim().isEmpty()) {
9292
throw new IllegalArgumentException("Must specify at least option and description");
9393
}
9494
Option option = new Option(opt, description);

tika-batch/src/main/java/org/apache/tika/batch/fs/builders/FSCrawlerBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public FileResourceCrawler build(Node node, Map<String, String> runtimeAttribute
118118
}
119119

120120
private FSDirectoryCrawler.CRAWL_ORDER getCrawlOrder(String s) {
121-
if (s == null || s.trim().length() == 0 || s.equals("os")) {
121+
if (s == null || s.trim().isEmpty() || s.equals("os")) {
122122
return FSDirectoryCrawler.CRAWL_ORDER.OS_ORDER;
123123
} else if (s.toLowerCase(Locale.ROOT).contains("rand")) {
124124
return FSDirectoryCrawler.CRAWL_ORDER.RANDOM;

tika-batch/src/main/java/org/apache/tika/util/PropsUtil.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class PropsUtil {
3535
* @return parsed value
3636
*/
3737
public static Boolean getBoolean(String v, Boolean defaultMissing) {
38-
if (v == null || v.length() == 0) {
38+
if (v == null || v.isEmpty()) {
3939
return defaultMissing;
4040
}
4141
if (v.toLowerCase(Locale.ROOT).equals("true")) {
@@ -55,7 +55,7 @@ public static Boolean getBoolean(String v, Boolean defaultMissing) {
5555
* @return parsed value
5656
*/
5757
public static Integer getInt(String v, Integer defaultMissing) {
58-
if (v == null || v.length() == 0) {
58+
if (v == null || v.isEmpty()) {
5959
return defaultMissing;
6060
}
6161
try {
@@ -74,7 +74,7 @@ public static Integer getInt(String v, Integer defaultMissing) {
7474
* @return parsed value
7575
*/
7676
public static Long getLong(String v, Long defaultMissing) {
77-
if (v == null || v.length() == 0) {
77+
if (v == null || v.isEmpty()) {
7878
return defaultMissing;
7979
}
8080
try {
@@ -96,7 +96,7 @@ public static Long getLong(String v, Long defaultMissing) {
9696
*/
9797
@Deprecated
9898
public static File getFile(String v, File defaultMissing) {
99-
if (v == null || v.length() == 0) {
99+
if (v == null || v.isEmpty()) {
100100
return defaultMissing;
101101
}
102102
//trim initial and final " if they exist
@@ -133,7 +133,7 @@ public static String getString(String v, String defaultMissing) {
133133
* @see #getPath(String, Path)
134134
*/
135135
public static Path getPath(String v, Path defaultMissing) {
136-
if (v == null || v.length() == 0) {
136+
if (v == null || v.isEmpty()) {
137137
return defaultMissing;
138138
}
139139
//trim initial and final " if they exist

tika-batch/src/test/java/org/apache/tika/batch/fs/FSBatchTestBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public String[] getDefaultCommandLineArgsArr(String inputSubDir, Path outputDir,
172172

173173
public Path getInputRoot(String subdir) throws Exception {
174174
String path =
175-
(subdir == null || subdir.length() == 0) ? "/test-input" : "/test-input/" + subdir;
175+
(subdir == null || subdir.isEmpty()) ? "/test-input" : "/test-input/" + subdir;
176176
return Paths.get(getResourceAsUri(path));
177177
}
178178

tika-core/src/main/java/org/apache/tika/io/FilenameUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public static String normalize(final String name) {
9696
*/
9797
public static String getName(final String path) {
9898

99-
if (path == null || path.length() == 0) {
99+
if (path == null || path.isEmpty()) {
100100
return StringUtils.EMPTY;
101101
}
102102
int unix = path.lastIndexOf("/");

tika-core/src/main/java/org/apache/tika/mime/MediaType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ private static boolean isSimpleName(String name) {
294294
}
295295

296296
private static Map<String, String> parseParameters(String string) {
297-
if (string.length() == 0) {
297+
if (string.isEmpty()) {
298298
return Collections.emptyMap();
299299
}
300300

tika-core/src/main/java/org/apache/tika/pipes/fetcher/FetcherManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static FetcherManager load(Path p) throws IOException, TikaConfigExceptio
4848
public FetcherManager(List<Fetcher> fetchers) throws TikaConfigException {
4949
for (Fetcher fetcher : fetchers) {
5050
String name = fetcher.getName();
51-
if (name == null || name.trim().length() == 0) {
51+
if (name == null || name.trim().isEmpty()) {
5252
throw new TikaConfigException("fetcher name must not be blank");
5353
}
5454
if (fetcherMap.containsKey(fetcher.getName())) {

tika-core/src/main/java/org/apache/tika/pipes/fetcher/fs/FileSystemFetcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public void initialize(Map<String, Param> params) throws TikaConfigException {
147147
@Override
148148
public void checkInitialization(InitializableProblemHandler problemHandler)
149149
throws TikaConfigException {
150-
if (basePath == null || basePath.toString().trim().length() == 0) {
150+
if (basePath == null || basePath.toString().trim().isEmpty()) {
151151
LOG.warn("'basePath' has not been set. " +
152152
"This means that client code or clients can read from any file that this " +
153153
"process has permissions to read. If you are running tika-server, make " +

tika-core/src/main/java/org/apache/tika/sax/ToXMLContentHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public String getPrefix(String uri) throws SAXException {
250250
return prefix;
251251
} else if (parent != null) {
252252
return parent.getPrefix(uri);
253-
} else if (uri == null || uri.length() == 0) {
253+
} else if (uri == null || uri.isEmpty()) {
254254
return "";
255255
} else {
256256
throw new SAXException("Namespace " + uri + " not declared");

0 commit comments

Comments
 (0)