8276166: Remove dead code from MimeTable and MimeEntry

Reviewed-by: dfuchs
This commit is contained in:
Sergey Tsypanov 2022-01-20 09:14:49 +00:00 committed by Julia Boes
parent 0bf95a1a73
commit cf977e88ec
2 changed files with 3 additions and 44 deletions
src/java.base/share/classes/sun/net/www

@ -24,7 +24,6 @@
*/
package sun.net.www;
import java.net.URL;
import java.io.*;
import java.util.StringJoiner;
import java.util.StringTokenizer;
@ -63,34 +62,6 @@ public class MimeEntry implements Cloneable {
this(type, UNKNOWN, null, null, null);
}
//
// The next two constructors are used only by the deprecated
// PlatformMimeTable classes or, in last case, is called by the public
// constructor. They are kept here anticipating putting support for
// mailcap formatted config files back in (so BOTH the properties format
// and the mailcap formats are supported).
//
MimeEntry(String type, String imageFileName, String extensionString) {
typeName = type.toLowerCase();
action = UNKNOWN;
command = null;
this.imageFileName = imageFileName;
setExtensions(extensionString);
starred = isStarred(typeName);
}
// For use with MimeTable::parseMailCap
MimeEntry(String typeName, int action, String command,
String tempFileNameTemplate) {
this.typeName = typeName.toLowerCase();
this.action = action;
this.command = command;
this.imageFileName = null;
this.fileExtensions = null;
this.tempFileNameTemplate = tempFileNameTemplate;
}
// This is the one called by the public constructor.
MimeEntry(String typeName, int action, String command,
String imageFileName, String fileExtensions[]) {

@ -37,11 +37,11 @@ import java.util.StringTokenizer;
public class MimeTable implements FileNameMap {
/** Keyed by content type, returns MimeEntries */
private Hashtable<String, MimeEntry> entries
= new Hashtable<String, MimeEntry>();
= new Hashtable<>();
/** Keyed by file extension (with the .), returns MimeEntries */
private Hashtable<String, MimeEntry> extensionMap
= new Hashtable<String, MimeEntry>();
= new Hashtable<>();
// Will be reset if in the platform-specific data file
@SuppressWarnings("removal")
@ -55,7 +55,6 @@ public class MimeTable implements FileNameMap {
});
private static final String filePreamble = "sun.net.www MIME content-types table";
private static final String fileMagic = "#" + filePreamble;
MimeTable() {
load();
@ -67,7 +66,7 @@ public class MimeTable implements FileNameMap {
@SuppressWarnings("removal")
static MimeTable getDefaultInstance() {
return java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<MimeTable>() {
new java.security.PrivilegedAction<>() {
public MimeTable run() {
MimeTable instance = new MimeTable();
URLConnection.setFileNameMap(instance);
@ -349,17 +348,6 @@ public class MimeTable implements FileNameMap {
// else illegal name exception
}
String[] getExtensions(String list) {
StringTokenizer tokenizer = new StringTokenizer(list, ",");
int n = tokenizer.countTokens();
String[] extensions = new String[n];
for (int i = 0; i < n; i++) {
extensions[i] = tokenizer.nextToken();
}
return extensions;
}
int getActionCode(String action) {
for (int i = 0; i < MimeEntry.actionKeywords.length; i++) {
if (action.equalsIgnoreCase(MimeEntry.actionKeywords[i])) {