//# 0 errors, 95 messages
//#
/*
    //#PopupMenuItem.java:1:1: class: com.dmdirc.commandparser.PopupMenuItem
    //#PopupMenuItem.java:1:1: method: com.dmdirc.commandparser.PopupMenuItem.com.dmdirc.commandparser.PopupMenuItem__static_init
 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.dmdirc.commandparser;

/**
 * Represents an abstract, UI-independent popup menu item.
 * 
 * @author chris
 */
public class PopupMenuItem {
   
    /** Whether this item is a divider. */
    private boolean divider = false;
    /** The submenu for this item, if any. */
    private PopupMenu submenu = null;
    /** The name of this item, if any. */
    private String name;
    /** The command for this item, if any. */
    private String command;
    
    /**
     * Creates a new PopupMenuItem that is used as a divider.
     */
    public PopupMenuItem() {
    //#PopupMenuItem.java:44: method: void com.dmdirc.commandparser.PopupMenuItem.com.dmdirc.commandparser.PopupMenuItem()
    //#input(void com.dmdirc.commandparser.PopupMenuItem()): this
    //#output(void com.dmdirc.commandparser.PopupMenuItem()): this.divider
    //#output(void com.dmdirc.commandparser.PopupMenuItem()): this.submenu
    //#post(void com.dmdirc.commandparser.PopupMenuItem()): this.divider == 1
    //#post(void com.dmdirc.commandparser.PopupMenuItem()): this.submenu == null
        divider = true;
    }
    //#PopupMenuItem.java:46: end of method: void com.dmdirc.commandparser.PopupMenuItem.com.dmdirc.commandparser.PopupMenuItem()
    
    /**
     * Creates a new PopupMenuItem that is used as a submenu.
     * 
     * @param name The name of the menu item
     * @param submenu The submenu of this item
     */
    public PopupMenuItem(final String name, final PopupMenu submenu) {
    //#PopupMenuItem.java:54: method: void com.dmdirc.commandparser.PopupMenuItem.com.dmdirc.commandparser.PopupMenuItem(String, PopupMenu)
    //#input(void com.dmdirc.commandparser.PopupMenuItem(String, PopupMenu)): name
    //#input(void com.dmdirc.commandparser.PopupMenuItem(String, PopupMenu)): submenu
    //#input(void com.dmdirc.commandparser.PopupMenuItem(String, PopupMenu)): this
    //#output(void com.dmdirc.commandparser.PopupMenuItem(String, PopupMenu)): this.divider
    //#output(void com.dmdirc.commandparser.PopupMenuItem(String, PopupMenu)): this.name
    //#output(void com.dmdirc.commandparser.PopupMenuItem(String, PopupMenu)): this.submenu
    //#post(void com.dmdirc.commandparser.PopupMenuItem(String, PopupMenu)): this.divider == 0
    //#post(void com.dmdirc.commandparser.PopupMenuItem(String, PopupMenu)): this.name == name
    //#post(void com.dmdirc.commandparser.PopupMenuItem(String, PopupMenu)): init'ed(this.name)
    //#post(void com.dmdirc.commandparser.PopupMenuItem(String, PopupMenu)): this.submenu == submenu
    //#post(void com.dmdirc.commandparser.PopupMenuItem(String, PopupMenu)): init'ed(this.submenu)
        this.name = name;
        this.submenu = submenu;
    }
    //#PopupMenuItem.java:57: end of method: void com.dmdirc.commandparser.PopupMenuItem.com.dmdirc.commandparser.PopupMenuItem(String, PopupMenu)
    
    /**
     * Creates a new PopupMenuItem that executes a command.
     * 
     * @param name The name of the menu item
     * @param command The command to be executed
     */
    public PopupMenuItem(final String name, final String command) {
    //#PopupMenuItem.java:65: method: void com.dmdirc.commandparser.PopupMenuItem.com.dmdirc.commandparser.PopupMenuItem(String, String)
    //#input(void com.dmdirc.commandparser.PopupMenuItem(String, String)): command
    //#input(void com.dmdirc.commandparser.PopupMenuItem(String, String)): name
    //#input(void com.dmdirc.commandparser.PopupMenuItem(String, String)): this
    //#output(void com.dmdirc.commandparser.PopupMenuItem(String, String)): this.command
    //#output(void com.dmdirc.commandparser.PopupMenuItem(String, String)): this.divider
    //#output(void com.dmdirc.commandparser.PopupMenuItem(String, String)): this.name
    //#output(void com.dmdirc.commandparser.PopupMenuItem(String, String)): this.submenu
    //#post(void com.dmdirc.commandparser.PopupMenuItem(String, String)): this.command == command
    //#post(void com.dmdirc.commandparser.PopupMenuItem(String, String)): init'ed(this.command)
    //#post(void com.dmdirc.commandparser.PopupMenuItem(String, String)): this.divider == 0
    //#post(void com.dmdirc.commandparser.PopupMenuItem(String, String)): this.name == name
    //#post(void com.dmdirc.commandparser.PopupMenuItem(String, String)): init'ed(this.name)
    //#post(void com.dmdirc.commandparser.PopupMenuItem(String, String)): this.submenu == null
        this.name = name;
        this.command = command;
    }
    //#PopupMenuItem.java:68: end of method: void com.dmdirc.commandparser.PopupMenuItem.com.dmdirc.commandparser.PopupMenuItem(String, String)
    
    /**
     * Determines if this menu item is a divider or not.
     * 
     * @return True if this item is a divider, false otherwise.
     */
    public boolean isDivider() {
        return divider;
    //#PopupMenuItem.java:76: method: bool com.dmdirc.commandparser.PopupMenuItem.isDivider()
    //#input(bool isDivider()): this
    //#input(bool isDivider()): this.divider
    //#output(bool isDivider()): return_value
    //#pre[2] (bool isDivider()): init'ed(this.divider)
    //#post(bool isDivider()): return_value == this.divider
    //#post(bool isDivider()): init'ed(return_value)
    //#PopupMenuItem.java:76: end of method: bool com.dmdirc.commandparser.PopupMenuItem.isDivider()
    }

    /**
     * Determines if this menu item contains a submenu or not.
     * 
     * @return True if this item contains a submenu, false otherwise.
     */    
    public boolean isSubMenu() {
        return submenu != null;
    //#PopupMenuItem.java:85: method: bool com.dmdirc.commandparser.PopupMenuItem.isSubMenu()
    //#input(bool isSubMenu()): this
    //#input(bool isSubMenu()): this.submenu
    //#output(bool isSubMenu()): return_value
    //#pre[2] (bool isSubMenu()): init'ed(this.submenu)
    //#post(bool isSubMenu()): init'ed(return_value)
    //#PopupMenuItem.java:85: end of method: bool com.dmdirc.commandparser.PopupMenuItem.isSubMenu()
    }
    
    /**
     * Retrieves the submenu associated with this item.
     * 
     * @return This menu item's submenu.
     */
    public PopupMenu getSubMenu() {
        return submenu;
    //#PopupMenuItem.java:94: method: PopupMenu com.dmdirc.commandparser.PopupMenuItem.getSubMenu()
    //#input(PopupMenu getSubMenu()): this
    //#input(PopupMenu getSubMenu()): this.submenu
    //#output(PopupMenu getSubMenu()): return_value
    //#pre[2] (PopupMenu getSubMenu()): init'ed(this.submenu)
    //#post(PopupMenu getSubMenu()): return_value == this.submenu
    //#post(PopupMenu getSubMenu()): init'ed(return_value)
    //#PopupMenuItem.java:94: end of method: PopupMenu com.dmdirc.commandparser.PopupMenuItem.getSubMenu()
    }
    
    /**
     * Retrieves the name of this menu item.
     * 
     * @return This menu item's name.
     */
    public String getName() {
        return name;
    //#PopupMenuItem.java:103: method: String com.dmdirc.commandparser.PopupMenuItem.getName()
    //#input(String getName()): this
    //#input(String getName()): this.name
    //#output(String getName()): return_value
    //#pre[2] (String getName()): init'ed(this.name)
    //#post(String getName()): return_value == this.name
    //#post(String getName()): init'ed(return_value)
    //#PopupMenuItem.java:103: end of method: String com.dmdirc.commandparser.PopupMenuItem.getName()
    }
    
    /**
     * Retrieves the command for this menu item, with the specified argumenwits
     * substituted in.
     * 
     * @param arguments The arguments needed for this command
     * @return The command to be passed to a command parser
     */
    public String getCommand(final Object... arguments) {
        return CommandManager.getCommandChar() + String.format(command, arguments);
    //#PopupMenuItem.java:114: method: String com.dmdirc.commandparser.PopupMenuItem.getCommand(Object[])
    //#input(String getCommand(Object[])): arguments
    //#input(String getCommand(Object[])): com/dmdirc/commandparser/CommandManager.commandChar
    //#input(String getCommand(Object[])): this
    //#input(String getCommand(Object[])): this.command
    //#output(String getCommand(Object[])): java.lang.StringBuilder:toString(...)._tainted
    //#output(String getCommand(Object[])): return_value
    //#new obj(String getCommand(Object[])): java.lang.StringBuilder:toString(...)
    //#pre[2] (String getCommand(Object[])): init'ed(com/dmdirc/commandparser/CommandManager.commandChar)
    //#pre[4] (String getCommand(Object[])): init'ed(this.command)
    //#post(String getCommand(Object[])): java.lang.StringBuilder:toString(...)._tainted == 0
    //#post(String getCommand(Object[])): return_value == &java.lang.StringBuilder:toString(...)
    //#PopupMenuItem.java:114: end of method: String com.dmdirc.commandparser.PopupMenuItem.getCommand(Object[])
    }

}
    //#output(com.dmdirc.commandparser.PopupMenuItem__static_init): __Descendant_Table[com/dmdirc/commandparser/PopupMenuItem]
    //#output(com.dmdirc.commandparser.PopupMenuItem__static_init): __Dispatch_Table.getCommand([Ljava/lang/Object;)Ljava/lang/String;
    //#output(com.dmdirc.commandparser.PopupMenuItem__static_init): __Dispatch_Table.getName()Ljava/lang/String;
    //#output(com.dmdirc.commandparser.PopupMenuItem__static_init): __Dispatch_Table.getSubMenu()Lcom/dmdirc/commandparser/PopupMenu;
    //#output(com.dmdirc.commandparser.PopupMenuItem__static_init): __Dispatch_Table.isDivider()Z
    //#output(com.dmdirc.commandparser.PopupMenuItem__static_init): __Dispatch_Table.isSubMenu()Z
    //#post(com.dmdirc.commandparser.PopupMenuItem__static_init): __Descendant_Table[com/dmdirc/commandparser/PopupMenuItem] == &__Dispatch_Table
    //#post(com.dmdirc.commandparser.PopupMenuItem__static_init): __Dispatch_Table.getCommand([Ljava/lang/Object;)Ljava/lang/String; == &getCommand
    //#post(com.dmdirc.commandparser.PopupMenuItem__static_init): __Dispatch_Table.getName()Ljava/lang/String; == &getName
    //#post(com.dmdirc.commandparser.PopupMenuItem__static_init): __Dispatch_Table.getSubMenu()Lcom/dmdirc/commandparser/PopupMenu; == &getSubMenu
    //#post(com.dmdirc.commandparser.PopupMenuItem__static_init): __Dispatch_Table.isDivider()Z == &isDivider
    //#post(com.dmdirc.commandparser.PopupMenuItem__static_init): __Dispatch_Table.isSubMenu()Z == &isSubMenu
    //#PopupMenuItem.java:: end of method: com.dmdirc.commandparser.PopupMenuItem.com.dmdirc.commandparser.PopupMenuItem__static_init
    //#PopupMenuItem.java:: end of class: com.dmdirc.commandparser.PopupMenuItem
