Debian Codegraph @

demo/src/main/java/PrefTest.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 jakarta.activation.*;
14
15 public class PrefTest {
16
17 public static void main(String args[]) {
18 MailcapCommandMap mcf = null;
19
20 if (args.length > 0) {
21 try {
22 mcf = new MailcapCommandMap(args[0]);
23 } catch (Exception e) {
24 e.printStackTrace();
25 System.exit(1);
26 }
27 } else
28 mcf = new MailcapCommandMap();
29
30 CommandInfo cmdinfo[] = mcf.getAllCommands("text/plain");
31
32 if (cmdinfo != null) {
33 System.out.println("ALL Commands for text/plain:");
34 for (int i = 0; i < cmdinfo.length; i++) {
35 System.out.println("Verb: " + cmdinfo[i].getCommandName() +
36 " Class: " + cmdinfo[i].getCommandClass());
37 }
38 System.out.println("done");
39 } else {
40 System.out.println("no commands");
41 }
42 System.out.println();
43
44 cmdinfo = mcf.getPreferredCommands("text/plain");
45 if (cmdinfo != null) {
46 System.out.println("PREFERRED Commands for text/plain:");
47 for (int i = 0; i < cmdinfo.length; i++) {
48 System.out.println("Verb: " + cmdinfo[i].getCommandName() +
49 " Class: " + cmdinfo[i].getCommandClass());
50 }
51 System.out.println("done");
52 } else {
53 System.out.println("no commands");
54 }
55 System.out.println();
56 }
57 }