1. /*
  2. * $Header: /home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/Msg.java,v 1.12 2004/02/21 17:10:29 rleland Exp $
  3. * $Revision: 1.12 $
  4. * $Date: 2004/02/21 17:10:29 $
  5. *
  6. * ====================================================================
  7. * Copyright 2001-2004 The Apache Software Foundation
  8. *
  9. * Licensed under the Apache License, Version 2.0 (the "License");
  10. * you may not use this file except in compliance with the License.
  11. * You may obtain a copy of the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing, software
  16. * distributed under the License is distributed on an "AS IS" BASIS,
  17. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. * See the License for the specific language governing permissions and
  19. * limitations under the License.
  20. */
  21. package org.apache.commons.validator;
  22. import java.io.Serializable;
  23. /**
  24. * An alternative message can be associated with a <code>Field</code>
  25. * and a pluggable validator instead of using the default message
  26. * stored in the <code>ValidatorAction</code> (aka pluggable validator).
  27. * Instances of this class are configured with a <msg> xml element.
  28. */
  29. public class Msg implements Cloneable, Serializable {
  30. /**
  31. * The resource bundle name that this Msg's <code>key</code> should be
  32. * resolved in (optional).
  33. * @since Validator 1.1
  34. */
  35. protected String bundle = null;
  36. /**
  37. * The key or value of the argument.
  38. */
  39. protected String key = null;
  40. /**
  41. * The name dependency that this argument goes with (optional).
  42. */
  43. protected String name = null;
  44. /**
  45. * Returns the resource bundle name.
  46. * @since Validator 1.1
  47. */
  48. public String getBundle() {
  49. return this.bundle;
  50. }
  51. /**
  52. * Sets the resource bundle name.
  53. * @param bundle The new bundle name.
  54. * @since Validator 1.1
  55. */
  56. public void setBundle(String bundle) {
  57. this.bundle = bundle;
  58. }
  59. /**
  60. * Gets the name of the dependency.
  61. */
  62. public String getName() {
  63. return name;
  64. }
  65. /**
  66. * Sets the name of the dependency.
  67. */
  68. public void setName(String name) {
  69. this.name = name;
  70. }
  71. /**
  72. * Gets the key/value.
  73. */
  74. public String getKey() {
  75. return key;
  76. }
  77. /**
  78. * Sets the key/value.
  79. */
  80. public void setKey(String key) {
  81. this.key = key;
  82. }
  83. /**
  84. * Creates and returns a copy of this object.
  85. */
  86. public Object clone() {
  87. try {
  88. return super.clone();
  89. } catch(CloneNotSupportedException e) {
  90. throw new RuntimeException(e.toString());
  91. }
  92. }
  93. /**
  94. * Returns a string representation of the object.
  95. */
  96. public String toString() {
  97. StringBuffer results = new StringBuffer();
  98. results.append("Msg: name=");
  99. results.append(name);
  100. results.append(" key=");
  101. results.append(key);
  102. results.append("\n");
  103. return results.toString();
  104. }
  105. }