source: release-kits/lirk3/bin/ant-installer/src/org/tp23/antinstaller/renderer/text/TextMessageRenderer.java@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 2.2 KB
Line 
1/*
2 * Copyright 2005 Paul Hinds
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.tp23.antinstaller.renderer.text;
17
18import java.io.BufferedReader;
19import java.io.IOException;
20import java.io.InputStreamReader;
21
22import org.tp23.antinstaller.InstallerContext;
23import org.tp23.antinstaller.renderer.MessageRenderer;
24
25/**
26 *
27 * <p>Render user messages to the console </p>
28 * <p> </p>
29 * <p>Copyright: Copyright (c) 2004</p>
30 * <p>Company: tp23</p>
31 * @author Paul Hinds
32 * @version $Id: TextMessageRenderer.java,v 1.3 2007/01/09 22:41:40 teknopaul Exp $
33 */
34public class TextMessageRenderer
35 implements MessageRenderer {
36
37 private InstallerContext ctx = null;
38
39 public TextMessageRenderer() {
40 }
41
42 public void setInstallerContext(InstallerContext ctx){
43 this.ctx = ctx;
44 }
45 public void printMessage(String message){
46 System.out.println(message);
47 }
48
49 public boolean prompt(String message){
50 try {
51 System.out.println(message);
52 // FIXME need to read directly from InputStreamReader and stop at first \n or \r
53 // test the following
54// InputStreamReader isr = new InputStreamReader(System.in);
55// int intChar = -1;
56// StringBuffer sb = new StringBuffer();
57// while((intChar = isr.read()) != -1 && intChar != '\n' && intChar != '\r'){
58// sb.append((char)intChar);
59// }
60// String line = sb.toString();
61
62 BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
63 String line = reader.readLine();
64 if (line != null && !line.equals("") && line.trim().length() > 0) {
65 return Character.toUpperCase(line.trim().charAt(0)) == 'Y' ||
66 Character.toUpperCase(line.trim().charAt(0)) == 'T' ;
67 }
68 return false;
69 }
70 catch (IOException ex) {
71 throw new RuntimeException("IOException", ex);
72 }
73 }
74}
Note: See TracBrowser for help on using the repository browser.