Debian Codegraph @

demo/src/main/java/MCDump.java

raw
1 /*
2 * Copyright (c) 1997, 2019 Oracle and/or its affiliates. All rights reserved.
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Distribution License v. 1.0, which is available at
6 * http://www.eclipse.org/org/documents/edl-v10.php.
7 *
8 * SPDX-License-Identifier: BSD-3-Clause
9 */
10
11 import java.io.*;
12 import java.beans.*;
13 import com.sun.activation.registries.*;
14 import jakarta.activation.*;
15
16 /**
17 * Dump out everything we know about a MailcapCommandMap.
18 */
19 public class MCDump {
20 static MailcapCommandMap mcf = null;
21
22 public static void main(String args[]) {
23
24 try {
25 if (args.length == 0)
26 mcf = new MailcapCommandMap();
27 else
28 mcf = new MailcapCommandMap(args[0]);
29 } catch (Exception e){
30 e.printStackTrace();
31 System.exit(1);
32 }
33
34 String[] types = mcf.getMimeTypes();
35 if (types == null) {
36 System.out.println("No known MIME types");
37 System.exit(0);
38 } else {
39 System.out.println("Known MIME types:");
40 for (int i = 0; i < types.length; i++)
41 System.out.println("\t" + types[i]);
42 }
43
44 System.out.println();
45 System.out.println("All commands for each MIME type:");
46 for (int i = 0; i < types.length; i++) {
47 System.out.println(" " + types[i]);
48 CommandInfo[] cmdinfo = mcf.getAllCommands(types[i]);
49 if (cmdinfo == null) {
50 System.out.println("\tNONE");
51 } else {
52 for (int k = 0; k < cmdinfo.length; k++)
53 System.out.println("\t" + cmdinfo[k].getCommandName() +
54 ": " + cmdinfo[k].getCommandClass());
55 }
56 }
57
58 System.out.println();
59 System.out.println("Preferred commands for each MIME type:");
60 for (int i = 0; i < types.length; i++) {
61 System.out.println(" " + types[i]);
62 CommandInfo[] cmdinfo = mcf.getPreferredCommands(types[i]);
63 if (cmdinfo == null) {
64 System.out.println("\tNONE");
65 } else {
66 for (int k = 0; k < cmdinfo.length; k++)
67 System.out.println("\t" + cmdinfo[k].getCommandName() +
68 ": " + cmdinfo[k].getCommandClass());
69 }
70 }
71
72 System.out.println();
73 System.out.println("Native commands for each MIME type:");
74 for (int i = 0; i < types.length; i++) {
75 System.out.println(" " + types[i]);
76 String[] cmds = mcf.getNativeCommands(types[i]);
77 if (cmds.length == 0) {
78 System.out.println("\tNONE");
79 } else {
80 for (int k = 0; k < cmds.length; k++)
81 System.out.println("\t" + cmds[k]);
82 }
83 }
84 }
85 }