< prev index next >

src/java.base/share/classes/com/sun/java/util/jar/pack/Driver.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD

@@ -277,11 +277,11 @@
 
         jpack.properties().putAll(engProps);
         junpack.properties().putAll(engProps);
         if (doRepack && newfile.equals(jarfile)) {
             String zipc = getZipComment(jarfile);
-            if (verbose && zipc.length() > 0)
+            if (verbose && !zipc.isEmpty())
                 System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.DETECTED_ZIP_COMMENT), zipc));
             if (zipc.indexOf(Utils.PACK_ZIP_ARCHIVE_MARKER_COMMENT) >= 0) {
                     System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.SKIP_FOR_REPACKED), jarfile));
                         doPack = false;
                         doUnpack = false;

@@ -550,11 +550,11 @@
         for (String optline : options.split("\n")) {
             String[] words = optline.split("\\p{Space}+");
             if (words.length == 0)    continue loadOptmap;
             String opt = words[0];
             words[0] = "";  // initial word is not a spec
-            if (opt.length() == 0 && words.length >= 1) {
+            if (opt.isEmpty() && words.length >= 1) {
                 opt = words[1];  // initial "word" is empty due to leading ' '
                 words[1] = "";
             }
             if (opt.length() == 0)    continue loadOptmap;
             String[] prevWords = optmap.put(opt, words);

@@ -620,11 +620,11 @@
                     // Deal with '+'/'*' prefixes (spec conditions).
                     boolean ok;
                     switch (specop) {
                     case '+':
                         // + means we want an non-empty val suffix.
-                        ok = (val.length() != 0);
+                        ok = !val.isEmpty();
                         specop = spec.charAt(sidx++);
                         break;
                     case '*':
                         // * means we accept empty or non-empty
                         ok = true;

@@ -639,32 +639,32 @@
                     if (!ok)  continue eachSpec;
 
                     String specarg = spec.substring(sidx);
                     switch (specop) {
                     case '.':  // terminate the option sequence
-                        resultString = (specarg.length() != 0)? specarg.intern(): opt;
+                        resultString = specarg.isEmpty() ? opt : specarg.intern();
                         break doArgs;
                     case '?':  // abort the option sequence
-                        resultString = (specarg.length() != 0)? specarg.intern(): arg;
+                        resultString = specarg.isEmpty() ? arg : specarg.intern();
                         isError = true;
                         break eachSpec;
                     case '@':  // change the effective opt name
                         opt = specarg.intern();
                         break;
                     case '>':  // shift remaining arg val to next arg
                         pbp.add(specarg + val);  // push a new argument
                         val = "";
                         break;
                     case '!':  // negation option
-                        String negopt = (specarg.length() != 0)? specarg.intern(): opt;
+                        String negopt = specarg.isEmpty() ? opt : specarg.intern();
                         properties.remove(negopt);
                         properties.put(negopt, null);  // leave placeholder
                         didAction = true;
                         break;
                     case '$':  // normal "boolean" option
                         String boolval;
-                        if (specarg.length() != 0) {
+                        if (!specarg.isEmpty()) {
                             // If there is a given spec token, store it.
                             boolval = specarg;
                         } else {
                             String old = properties.get(opt);
                             if (old == null || old.length() == 0) {
< prev index next >