KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > tools > ToolContext


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.tools;
18
19
20 /**
21  * Tool Context
22  *
23  * @author David Caruana
24  */

25 /*package*/ class ToolContext
26 {
27     /** Help required? */
28     private boolean help = false;
29     /** Login required? */
30     private boolean login = false;
31     /** Username */
32     private String JavaDoc username = null;
33     /** Password */
34     private String JavaDoc password = "";
35     /** Log messages whilst importing? */
36     private boolean quiet = false;
37     /** Verbose logging */
38     private boolean verbose = false;
39     
40     
41     /**
42      * Is help required?
43      *
44      * @return true => help is required
45      */

46     /*package*/ final boolean isHelp()
47     {
48         return help;
49     }
50     
51     /**
52      * Sets whether help is required
53      *
54      * @param help
55      */

56     /*package*/ final void setHelp(boolean help)
57     {
58         this.help = help;
59     }
60     
61     /**
62      * Is login required?
63      *
64      * @return true => login is required
65      */

66     /*package*/ final boolean isLogin()
67     {
68         return login;
69     }
70     
71     /**
72      * Sets whether login is required
73      *
74      * @param login
75      */

76     /*package*/ final void setLogin(boolean login)
77     {
78         this.login = login;
79     }
80     
81     /**
82      * Get the password
83      *
84      * @return the password
85      */

86     /*package*/ final String JavaDoc getPassword()
87     {
88         return password;
89     }
90     
91     /**
92      * Set the password
93      *
94      * @param password
95      */

96     /*package*/ final void setPassword(String JavaDoc password)
97     {
98         this.password = password;
99     }
100     
101     /**
102      * Is output is required?
103      *
104      * @return true => output is required
105      */

106     /*package*/ final boolean isQuiet()
107     {
108         return quiet;
109     }
110     
111     /**
112      * Sets whether output is required
113      *
114      * @param quiet
115      */

116     /*package*/ final void setQuiet(boolean quiet)
117     {
118         this.quiet = quiet;
119     }
120     
121     /**
122      * Get the username
123      *
124      * @return the username
125      */

126     /*package*/ final String JavaDoc getUsername()
127     {
128         return username;
129     }
130     
131     /**
132      * Set the username
133      *
134      * @param username
135      */

136     /*package*/ final void setUsername(String JavaDoc username)
137     {
138         this.username = username;
139     }
140     
141     /**
142      * Is verbose logging required?
143      *
144      * @return true => verbose logging is required
145      */

146     /*package*/ final boolean isVerbose()
147     {
148         return verbose;
149     }
150     
151     /**
152      * Sets whether verbose logging is required
153      *
154      * @param verbose
155      */

156     /*package*/ final void setVerbose(boolean verbose)
157     {
158         this.verbose = verbose;
159     }
160     
161     /**
162      * Validate Tool Context
163      */

164     /*package*/ void validate()
165         throws ToolException
166     {
167         if (login)
168         {
169             if (username == null || username.length() == 0)
170             {
171                 throw new ToolException("Username for login has not been specified.");
172             }
173         }
174     }
175     
176 }
177
Popular Tags