KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > sun > appserv > SunONEInput


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 org.apache.tools.ant.taskdefs.optional.sun.appserv;
25
26 import org.apache.tools.ant.Task;
27 import org.apache.tools.ant.BuildException;
28 import org.apache.tools.ant.Project;
29 import org.apache.tools.ant.AntClassLoader;
30 import org.apache.tools.ant.types.Path;
31
32 import java.io.*;
33 import java.util.*;
34
35 /**
36     SunONEInput is used to get Inputs from the Users.
37     Inspired by Ant 1.5 input task.
38     This task is very useful to get inputs from the users.
39     This will get deprecated when we move to Ant 1.5
40 */

41
42 public class SunONEInput extends Task {
43
44          private String JavaDoc msg;
45          private String JavaDoc value;
46          private String JavaDoc addproperty;
47
48          private BufferedReader keyboard;
49
50          LocalStringsManager lsm = new LocalStringsManager();
51
52      public void init ()
53      {
54          keyboard = new BufferedReader(new InputStreamReader(System.in));
55      }
56          // The method executing the task
57
public void execute() throws BuildException {
58
59         try{
60
61             System.out.println( msg);
62         value = keyboard.readLine();
63         }
64         catch ( IOException ioe )
65         {
66                System.out.println(lsm.getString("IOExceptionMsg", new Object JavaDoc[] {msg}));
67         }
68             if (addproperty != null) {
69               project.setProperty(addproperty, value);
70             }
71          }
72
73          // The setter for the "message" attribute
74

75          public void setMessage(String JavaDoc msg) {
76              this.msg = msg;
77          }
78
79
80     public void setAddproperty (String JavaDoc addproperty) {
81         this.addproperty = addproperty;
82     }
83
84
85 } //end of SunONEInput
86
Popular Tags