KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > PrefTest


1 /*
2  * @(#)PrefTest.java 1.4 02/03/10
3  *
4  * Copyright 1997-2002 Sun Microsystems, Inc. All Rights Reserved.
5  *
6  * This software is the proprietary information of Sun Microsystems, Inc.
7  * Use is subject to license terms.
8  *
9  */

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