1 /*
2 Copyright (C) 2000 - 2007 Grid Systems, S.A.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2, as
6 published by the Free Software Foundation.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18 /*
19 * Project: KernelConfigurator
20 * Created on 12-mar-2004
21 *
22 * Copyright (c)2003 Grid Systems
23 */
24 package com.gridsystems.config.tools.console;
25
26 import java.util.ArrayList;
27 import java.util.List;
28
29 /**
30 * A message display field.
31 *
32 * @author <a href="mailto:rruiz@gridsystems.com">Rodrigo Ruiz Aguayo</a>
33 * @version 1.0
34 */
35 public class MessageField extends Field {
36 /**
37 * The list of message lines.
38 */
39 private List<String> lines = new ArrayList<String>();
40
41 /**
42 * Creates a new instance. Messages are not internationalized, so there is no bundle.
43 */
44 public MessageField() {
45 super(null);
46 }
47
48 /**
49 * Resets the message contents.
50 */
51 public void reset() {
52 lines.clear();
53 }
54
55 /**
56 * Adds a message line.
57 *
58 * @param line The message line
59 */
60 public void addLine(String line) {
61 lines.add(line);
62 }
63
64 /**
65 * {@inheritDoc}
66 */
67 public String[] getContents() {
68 int count = lines.size();
69 String[] contents = new String[count];
70 if (count > 0) {
71 lines.toArray(contents);
72 }
73
74 return contents;
75 }
76 }