Example usage for javax.activation CommandInfo getCommandClass

List of usage examples for javax.activation CommandInfo getCommandClass

Introduction

In this page you can find the example usage for javax.activation CommandInfo getCommandClass.

Prototype

public String getCommandClass() 

Source Link

Document

Return the command's class name.

Usage

From source file:Main.java

public static void main(String[] args) {
    MailcapCommandMap mailcapCommandMap = new MailcapCommandMap();
    String mailcap = "text/plain;" + "x-java-content-handler=beans.TextHandler;"
            + "x-java-view=beans.TextViewer;" + "x-java-edit=beans.TextEditor";
    mailcapCommandMap.addMailcap(mailcap);

    String[] mimeTypes = mailcapCommandMap.getMimeTypes();
    for (String mimeType : mimeTypes) {
        System.out.println(mimeType);
        CommandInfo[] commandInfos = mailcapCommandMap.getAllCommands(mimeType);
        for (CommandInfo info : commandInfos) {
            System.out.println(" " + info.getCommandName() + " : " + info.getCommandClass());
        }// w  w  w. jav  a2 s . co m
    }
}

From source file:MailcapCommandMapDemo1.java

public static void main(String[] args) {
    MailcapCommandMap mailcapCommandMap = new MailcapCommandMap();

    String[] mimeTypes = mailcapCommandMap.getMimeTypes();
    for (String mimeType : mimeTypes) {
        System.out.println(mimeType);
        CommandInfo[] commandInfos = mailcapCommandMap.getAllCommands(mimeType);
        for (CommandInfo info : commandInfos) {
            System.out.println(" " + info.getCommandName() + " : " + info.getCommandClass());
        }/*from   www . j  a va  2s  .  co m*/
    }
}

From source file:MailcapCommandMapDemo2.java

public static void main(String[] args) {
    MailcapCommandMap mailcapCommandMap = new MailcapCommandMap();
    String mailcap = "text/plain;; " + "x-java-content-handler=beans.TextHandler;"
            + "x-java-view=beans.TextViewer;" + "x-java-edit=beans.TextEditor";
    mailcapCommandMap.addMailcap(mailcap);
    // Get all MIME types
    String[] mimeTypes = mailcapCommandMap.getMimeTypes();
    for (String mimeType : mimeTypes) {
        System.out.println(mimeType);
        CommandInfo[] commandInfos = mailcapCommandMap.getAllCommands(mimeType);
        for (CommandInfo info : commandInfos) {
            System.out.println(" " + info.getCommandName() + " : " + info.getCommandClass());
        }//from w w w.  ja  v a 2  s .c  o m
    }
}

From source file:MultipartViewer.java

protected Component getComponent(BodyPart bp) {

    try {// www.  ja  v a  2 s.  co m
        DataHandler dh = bp.getDataHandler();
        CommandInfo ci = dh.getCommand("view");
        if (ci == null) {
            throw new MessagingException("view command failed on: " + bp.getContentType());
        }

        Object bean = dh.getBean(ci);

        if (bean instanceof Component) {
            return (Component) bean;
        } else {
            if (bean == null)
                throw new MessagingException(
                        "bean is null, class " + ci.getCommandClass() + " , command " + ci.getCommandName());
            else
                throw new MessagingException("bean is not a awt.Component" + bean.getClass().toString());
        }
    } catch (MessagingException me) {
        return new Label(me.toString());
    }
}