KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > cli > framework > ValidCommandsList


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.cli.framework;
25
26 import java.util.HashMap JavaDoc;
27 import java.util.Iterator JavaDoc;
28 import java.io.Serializable JavaDoc;
29
30 /**
31  * The class holds the list of ValidCommand's
32  * @version $Revision: 1.3 $
33  */

34 public class ValidCommandsList implements Serializable JavaDoc
35 {
36
37     private HashMap JavaDoc validCommands = null;
38     
39     /** Creates new ValidCommandsList */
40     public ValidCommandsList()
41     {
42         validCommands = new HashMap JavaDoc();
43     }
44
45     
46     /**
47      * Returns the ValidCommand that macthes the parameter command name
48      * @param commandName The name of the command that should be checked in the list
49      * @return ValidCommand The ValidCommand object
50      */

51     public ValidCommand getValidCommand(String JavaDoc commandName)
52     {
53         return (ValidCommand) validCommands.get(commandName);
54     }
55  
56     
57     /**
58      * Return the list of ValidCommand's
59      */

60     public Iterator JavaDoc getCommands()
61     {
62         return validCommands.values().iterator();
63     }
64     
65     
66     /**
67      * Return the number of commands in the list
68     **/

69     public int size()
70     {
71         return validCommands.size();
72     }
73  
74     
75      /** Adds the ValidCommand to ValidCommandsList
76      * @param command The Valid command to be added to the list
77      */

78     public void addCommand(ValidCommand command)
79     {
80         validCommands.put(command.getName(), command);
81     }
82
83     
84     /** Removes all commands from this list
85      */

86     public void removeAllCommands()
87     {
88         validCommands.clear();
89     }
90 }
91
Popular Tags