< prev index next >

src/java.base/share/classes/sun/net/www/MimeEntry.java

Print this page
rev 51919 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: dfuchs, alanb


 184             }
 185         }
 186 
 187         return extensionsAsString;
 188     }
 189 
 190     public synchronized void setExtensions(String extensionString) {
 191         StringTokenizer extTokens = new StringTokenizer(extensionString, ",");
 192         int numExts = extTokens.countTokens();
 193         String extensionStrings[] = new String[numExts];
 194 
 195         for (int i = 0; i < numExts; i++) {
 196             String ext = (String)extTokens.nextElement();
 197             extensionStrings[i] = ext.trim();
 198         }
 199 
 200         fileExtensions = extensionStrings;
 201     }
 202 
 203     private boolean isStarred(String typeName) {
 204         return (typeName != null)
 205             && (typeName.length() > 0)
 206             && (typeName.endsWith("/*"));
 207     }
 208 
 209     /**
 210      * Invoke the MIME type specific behavior for this MIME type.
 211      * Returned value can be one of several types:
 212      * <ol>
 213      * <li>A thread -- the caller can choose when to launch this thread.
 214      * <li>A string -- the string is loaded into the browser directly.
 215      * <li>An input stream -- the caller can read from this byte stream and
 216      *     will typically store the results in a file.
 217      * <li>A document (?) --
 218      * </ol>
 219      */
 220     public Object launch(java.net.URLConnection urlc, InputStream is, MimeTable mt) throws ApplicationLaunchException {
 221         switch (action) {
 222         case SAVE_TO_FILE:
 223             // REMIND: is this really the right thing to do?
 224             try {
 225                 return is;
 226             } catch(Exception e) {


 283 
 284     public synchronized String toProperty() {
 285         StringJoiner sj = new StringJoiner("; ");
 286 
 287         int action = getAction();
 288         if (action != MimeEntry.UNKNOWN) {
 289             sj.add("action=" + actionKeywords[action]);
 290         }
 291 
 292         String command = getLaunchString();
 293         if (command != null && command.length() > 0) {
 294             sj.add("application=" + command);
 295         }
 296 
 297         String image = getImageFileName();
 298         if (image != null) {
 299             sj.add("icon=" + image);
 300         }
 301 
 302         String extensions = getExtensionsAsList();
 303         if (extensions.length() > 0) {
 304             sj.add("file_extensions=" + extensions);
 305         }
 306 
 307         String description = getDescription();
 308         if (description != null && !description.equals(getType())) {
 309             sj.add("description=" + description);
 310         }
 311 
 312         return sj.toString();
 313     }
 314 
 315     public String toString() {
 316         return "MimeEntry[contentType=" + typeName
 317             + ", image=" + imageFileName
 318             + ", action=" + action
 319             + ", command=" + command
 320             + ", extensions=" + getExtensionsAsList()
 321             + "]";
 322     }
 323 }


 184             }
 185         }
 186 
 187         return extensionsAsString;
 188     }
 189 
 190     public synchronized void setExtensions(String extensionString) {
 191         StringTokenizer extTokens = new StringTokenizer(extensionString, ",");
 192         int numExts = extTokens.countTokens();
 193         String extensionStrings[] = new String[numExts];
 194 
 195         for (int i = 0; i < numExts; i++) {
 196             String ext = (String)extTokens.nextElement();
 197             extensionStrings[i] = ext.trim();
 198         }
 199 
 200         fileExtensions = extensionStrings;
 201     }
 202 
 203     private boolean isStarred(String typeName) {
 204         return typeName != null && typeName.endsWith("/*");


 205     }
 206 
 207     /**
 208      * Invoke the MIME type specific behavior for this MIME type.
 209      * Returned value can be one of several types:
 210      * <ol>
 211      * <li>A thread -- the caller can choose when to launch this thread.
 212      * <li>A string -- the string is loaded into the browser directly.
 213      * <li>An input stream -- the caller can read from this byte stream and
 214      *     will typically store the results in a file.
 215      * <li>A document (?) --
 216      * </ol>
 217      */
 218     public Object launch(java.net.URLConnection urlc, InputStream is, MimeTable mt) throws ApplicationLaunchException {
 219         switch (action) {
 220         case SAVE_TO_FILE:
 221             // REMIND: is this really the right thing to do?
 222             try {
 223                 return is;
 224             } catch(Exception e) {


 281 
 282     public synchronized String toProperty() {
 283         StringJoiner sj = new StringJoiner("; ");
 284 
 285         int action = getAction();
 286         if (action != MimeEntry.UNKNOWN) {
 287             sj.add("action=" + actionKeywords[action]);
 288         }
 289 
 290         String command = getLaunchString();
 291         if (command != null && command.length() > 0) {
 292             sj.add("application=" + command);
 293         }
 294 
 295         String image = getImageFileName();
 296         if (image != null) {
 297             sj.add("icon=" + image);
 298         }
 299 
 300         String extensions = getExtensionsAsList();
 301         if (!extensions.isEmpty()) {
 302             sj.add("file_extensions=" + extensions);
 303         }
 304 
 305         String description = getDescription();
 306         if (description != null && !description.equals(getType())) {
 307             sj.add("description=" + description);
 308         }
 309 
 310         return sj.toString();
 311     }
 312 
 313     public String toString() {
 314         return "MimeEntry[contentType=" + typeName
 315             + ", image=" + imageFileName
 316             + ", action=" + action
 317             + ", command=" + command
 318             + ", extensions=" + getExtensionsAsList()
 319             + "]";
 320     }
 321 }
< prev index next >