01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.tools.ant.taskdefs.optional.extension;
19:
20: import org.apache.tools.ant.BuildException;
21:
22: /**
23: * Simple holder for extra attributes in main section of manifest.
24: *
25: * @todo Refactor this and all the other parameter, sysproperty,
26: * property etc into a single class in framework
27: */
28: public class ExtraAttribute {
29: private String name;
30: private String value;
31:
32: /**
33: * Set the name of the parameter.
34: *
35: * @param name the name of parameter
36: */
37: public void setName(final String name) {
38: this .name = name;
39: }
40:
41: /**
42: * Set the value of the parameter.
43: *
44: * @param value the parameter value
45: */
46: public void setValue(final String value) {
47: this .value = value;
48: }
49:
50: /**
51: * Retrieve name of parameter.
52: *
53: * @return the name of parameter.
54: */
55: String getName() {
56: return name;
57: }
58:
59: /**
60: * Retrieve the value of parameter.
61: *
62: * @return the value of parameter.
63: */
64: String getValue() {
65: return value;
66: }
67:
68: /**
69: * Make sure that neither the name or the value
70: * is null.
71: *
72: * @throws BuildException if the attribute is invalid.
73: */
74: public void validate() throws BuildException {
75: if (null == name) {
76: final String message = "Missing name from parameter.";
77: throw new BuildException(message);
78: } else if (null == value) {
79: final String message = "Missing value from parameter "
80: + name + ".";
81: throw new BuildException(message);
82: }
83: }
84: }
|