1. /*
  2. * Copyright 2002,2004 The Apache Software Foundation
  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. *
  16. */
  17. package org.apache.tools.ant.taskdefs.optional.extension;
  18. import org.apache.tools.ant.BuildException;
  19. /**
  20. * Simple holder for extra attributes in main section of manifest.
  21. *
  22. * @version $Revision: 1.3.2.4 $ $Date: 2004/03/09 17:01:45 $
  23. * @todo Refactor this and all the other parameter, sysproperty,
  24. * property etc into a single class in framework
  25. */
  26. public class ExtraAttribute {
  27. private String name;
  28. private String value;
  29. /**
  30. * Set the name of the parameter.
  31. *
  32. * @param name the name of parameter
  33. */
  34. public void setName(final String name) {
  35. this.name = name;
  36. }
  37. /**
  38. * Set the value of the parameter.
  39. *
  40. * @param value the parameter value
  41. */
  42. public void setValue(final String value) {
  43. this.value = value;
  44. }
  45. /**
  46. * Retrieve name of parameter.
  47. *
  48. * @return the name of parameter.
  49. */
  50. String getName() {
  51. return name;
  52. }
  53. /**
  54. * Retrieve the value of parameter.
  55. *
  56. * @return the value of parameter.
  57. */
  58. String getValue() {
  59. return value;
  60. }
  61. /**
  62. * Make sure that neither the name or the value
  63. * is null.
  64. *
  65. * @throws BuildException if the attribute is invalid.
  66. */
  67. public void validate() throws BuildException {
  68. if (null == name) {
  69. final String message = "Missing name from parameter.";
  70. throw new BuildException(message);
  71. } else if (null == value) {
  72. final String message = "Missing value from parameter " + name + ".";
  73. throw new BuildException(message);
  74. }
  75. }
  76. }