View Javadoc

1   /*
2    * $Id: CommandParameterImpl.java 113 2004-10-22 19:22:56Z josem $
3    *
4    * Tarsis
5    * Copyright (C) 2002 Talika Open Source Group
6    *
7    * This program is free software; you can redistribute it and/or modify
8    * it under the terms of the GNU General Public License as published by
9    * the Free Software Foundation; either version 2 of the License, or
10   * (at your option) any later version.
11   *
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Public License for more details.
16   *
17   * You should have received a copy of the GNU General Public License
18   * along with this program; if not, write to the Free Software
19   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20   *
21   */
22  
23  package org.talika.tarsis.command;
24  
25  /**
26   * Implementation of <code>CommandParameter</code> interface.
27   *
28   * @author  Jose M. Palomar
29   * @version $Revision: 113 $
30   * @see CommandParameter
31   */
32  public final class CommandParameterImpl implements CommandParameter {
33  
34      // Fields
35      /**
36       * Name of parameter.
37       */
38      private final String name;
39  
40      /**
41       * Type of parameter.
42       */
43      private final Class type;
44  
45      /**
46       * Parameter is required?.
47       */
48      private final boolean required;
49  
50      /**
51       * Can parameter have multiple values?.
52       */
53      private final boolean multiple;
54  
55      /**
56       * Default value of parameter.
57       */
58      private final Object defaultValue;
59  
60      // Constructors
61      /**
62       * Constructs a new <code>CommandParameterImpl</code> with specified parameters.
63       *
64       * @param name String name of parameter.
65       * @param type Class type of parameter.
66       * @param required boolean is parameter required?.
67       * @param multiple boolean can multiple have multiple values?.
68       * @param defaultValue Object default value of parameter.
69       */
70      public CommandParameterImpl(String name, Class type, boolean required,
71      boolean multiple, Object defaultValue) {
72  
73          this.name = name;
74          this.type = type;
75          this.required = required;
76          this.multiple = multiple;
77          this.defaultValue = defaultValue;
78  
79      }
80  
81      /**
82       * Returns name of parameter.
83       *
84       * @return String name of parameter.
85       * @see org.talika.tarsis.command.CommandParameter#getName()
86       */
87      public String getName() {
88          return name;
89      }
90  
91      /**
92       * Returns type of parameter.
93       *
94       * @return Class type of parameter.
95       * @see org.talika.tarsis.command.CommandParameter#getType()
96       */
97      public Class getType() {
98          return type;
99      }
100 
101     /**
102      * Returns <code>true</code> if parameter is required.
103      *
104      * @return boolean <code>true</code> if parameter is required.
105      * @see org.talika.tarsis.command.CommandParameter#isRequired()
106      */
107     public boolean isRequired() {
108         return required;
109     }
110 
111     /**
112      * Returns <code>true</code> if parameter can have multiple values.
113      *
114      * @return boolean <code>true</code> if parameter can have multiple values.
115      * @see org.talika.tarsis.command.CommandParameter#isMultiple()
116      */
117     public boolean isMultiple() {
118         return multiple;
119     }
120 
121     /**
122      * Returns the default value of parameter if no other is provided.
123      *
124      * @return Object default value of parameter.
125      * @see org.talika.tarsis.command.CommandParameter#defaultValue()
126      */
127     public Object defaultValue() {
128         return defaultValue;
129     }
130 
131 }