1. /*
  2. * Copyright 2001-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. package org.apache.commons.beanutils;
  17. /**
  18. * <p>A <strong>DynaBean</strong> is a Java object that supports properties
  19. * whose names and data types, as well as values, may be dynamically modified.
  20. * To the maximum degree feasible, other components of the BeanUtils package
  21. * will recognize such beans and treat them as standard JavaBeans for the
  22. * purpose of retrieving and setting property values.</p>
  23. *
  24. * @author Craig McClanahan
  25. * @author Paulo Gaspar
  26. * @version $Revision: 1.9 $ $Date: 2004/02/28 13:18:33 $
  27. */
  28. public interface DynaBean {
  29. /**
  30. * Does the specified mapped property contain a value for the specified
  31. * key value?
  32. *
  33. * @param name Name of the property to check
  34. * @param key Name of the key to check
  35. *
  36. * @exception IllegalArgumentException if there is no property
  37. * of the specified name
  38. */
  39. public boolean contains(String name, String key);
  40. /**
  41. * Return the value of a simple property with the specified name.
  42. *
  43. * @param name Name of the property whose value is to be retrieved
  44. *
  45. * @exception IllegalArgumentException if there is no property
  46. * of the specified name
  47. */
  48. public Object get(String name);
  49. /**
  50. * Return the value of an indexed property with the specified name.
  51. *
  52. * @param name Name of the property whose value is to be retrieved
  53. * @param index Index of the value to be retrieved
  54. *
  55. * @exception IllegalArgumentException if there is no property
  56. * of the specified name
  57. * @exception IllegalArgumentException if the specified property
  58. * exists, but is not indexed
  59. * @exception IndexOutOfBoundsException if the specified index
  60. * is outside the range of the underlying property
  61. * @exception NullPointerException if no array or List has been
  62. * initialized for this property
  63. */
  64. public Object get(String name, int index);
  65. /**
  66. * Return the value of a mapped property with the specified name,
  67. * or <code>null</code> if there is no value for the specified key.
  68. *
  69. * @param name Name of the property whose value is to be retrieved
  70. * @param key Key of the value to be retrieved
  71. *
  72. * @exception IllegalArgumentException if there is no property
  73. * of the specified name
  74. * @exception IllegalArgumentException if the specified property
  75. * exists, but is not mapped
  76. */
  77. public Object get(String name, String key);
  78. /**
  79. * Return the <code>DynaClass</code> instance that describes the set of
  80. * properties available for this DynaBean.
  81. */
  82. public DynaClass getDynaClass();
  83. /**
  84. * Remove any existing value for the specified key on the
  85. * specified mapped property.
  86. *
  87. * @param name Name of the property for which a value is to
  88. * be removed
  89. * @param key Key of the value to be removed
  90. *
  91. * @exception IllegalArgumentException if there is no property
  92. * of the specified name
  93. */
  94. public void remove(String name, String key);
  95. /**
  96. * Set the value of a simple property with the specified name.
  97. *
  98. * @param name Name of the property whose value is to be set
  99. * @param value Value to which this property is to be set
  100. *
  101. * @exception ConversionException if the specified value cannot be
  102. * converted to the type required for this property
  103. * @exception IllegalArgumentException if there is no property
  104. * of the specified name
  105. * @exception NullPointerException if an attempt is made to set a
  106. * primitive property to null
  107. */
  108. public void set(String name, Object value);
  109. /**
  110. * Set the value of an indexed property with the specified name.
  111. *
  112. * @param name Name of the property whose value is to be set
  113. * @param index Index of the property to be set
  114. * @param value Value to which this property is to be set
  115. *
  116. * @exception ConversionException if the specified value cannot be
  117. * converted to the type required for this property
  118. * @exception IllegalArgumentException if there is no property
  119. * of the specified name
  120. * @exception IllegalArgumentException if the specified property
  121. * exists, but is not indexed
  122. * @exception IndexOutOfBoundsException if the specified index
  123. * is outside the range of the underlying property
  124. */
  125. public void set(String name, int index, Object value);
  126. /**
  127. * Set the value of a mapped property with the specified name.
  128. *
  129. * @param name Name of the property whose value is to be set
  130. * @param key Key of the property to be set
  131. * @param value Value to which this property is to be set
  132. *
  133. * @exception ConversionException if the specified value cannot be
  134. * converted to the type required for this property
  135. * @exception IllegalArgumentException if there is no property
  136. * of the specified name
  137. * @exception IllegalArgumentException if the specified property
  138. * exists, but is not mapped
  139. */
  140. public void set(String name, String key, Object value);
  141. }