01: /*
02: * Copyright 2005 Paul Hinds
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: */
16: package org.tp23.antinstaller.input;
17:
18: import org.tp23.antinstaller.InstallerContext;
19: import org.tp23.antinstaller.ValidationException;
20:
21: /**
22: *
23: * <p>This "Input type" is strictly for Output! Unlike all the other
24: * concrete classes in this package CommentOutputs refer to text
25: * that will be printed but nothing will be collected from
26: * the user.</p>
27: * The text outputted in Comments will have property values resolved
28: * if they are in the format ${property.name}
29: * @author Paul Hinds
30: * @version $Id: CommentOutput.java,v 1.2 2006/03/24 18:25:58 teknopaul Exp $
31: */
32: public class CommentOutput extends OutputField {
33:
34: private String bold;
35: private String title;
36:
37: public CommentOutput() {
38: }
39:
40: public String getBold() {
41: return bold;
42: }
43:
44: public void setBold(String bold) {
45: this .bold = bold;
46: }
47:
48: public String getTitle() {
49: return title;
50: }
51:
52: public void setTitle(String title) {
53: this .title = title;
54: }
55:
56: public String getDisplayText() {
57: return resultContainer.getDefaultValue(super .getDisplayText());
58: }
59:
60: public String getExplanatoryText() {
61: return resultContainer.getDefaultValue(super
62: .getExplanatoryText());
63: }
64:
65: /**
66: * Called to validate the user input
67: */
68: public boolean validate(InstallerContext cxt)
69: throws ValidationException {
70: return true;
71: }
72:
73: /**
74: * Used by checkConfig to validate the configuration file.
75: * Not used at runtime.
76: * @return boolean
77: */
78: public boolean validateObject() {
79: // null accepted now if only using explanatory text
80: // if(getDisplayText() == null){
81: // System.out.println("Comment:displayText must be set");
82: // return false;
83: // }
84: if (!InputField.optionalBoolean(getBold())) {
85: System.out
86: .println("Comment:bold must be true or false or null:"
87: + getBold());
88: return false;
89: }
90: if (!InputField.optionalBoolean(getTitle())) {
91: System.out
92: .println("Comment:title must be true or false or null:"
93: + getTitle());
94: return false;
95: }
96: return true;
97: }
98: }
|