KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > extension > ExtraAttribute


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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 JavaDoc name;
30     private String JavaDoc 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 JavaDoc 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 JavaDoc value) {
47         this.value = value;
48     }
49
50     /**
51      * Retrieve name of parameter.
52      *
53      * @return the name of parameter.
54      */

55     String JavaDoc getName() {
56         return name;
57     }
58
59     /**
60      * Retrieve the value of parameter.
61      *
62      * @return the value of parameter.
63      */

64     String JavaDoc 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 JavaDoc message = "Missing name from parameter.";
77             throw new BuildException(message);
78         } else if (null == value) {
79             final String JavaDoc message = "Missing value from parameter " + name + ".";
80             throw new BuildException(message);
81         }
82     }
83 }
84
Popular Tags