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 specialized extension to <code>DynaClass</code> that allows properties
  19. * to be added or removed dynamically.</p>
  20. *
  21. * <p><strong>WARNING</strong> - No guarantees that this will be in the final
  22. * APIs ... it's here primarily to preserve some concepts that were in the
  23. * original proposal for further discussion.</p>
  24. *
  25. * @author Craig McClanahan
  26. * @author Michael Smith
  27. * @author Paulo Gaspar
  28. * @version $Revision: 1.8 $ $Date: 2004/02/28 13:18:33 $
  29. */
  30. public interface MutableDynaClass extends DynaClass {
  31. /**
  32. * Add a new dynamic property with no restrictions on data type,
  33. * readability, or writeability.
  34. *
  35. * @param name Name of the new dynamic property
  36. *
  37. * @exception IllegalArgumentException if name is null
  38. * @exception IllegalStateException if this DynaClass is currently
  39. * restricted, so no new properties can be added
  40. */
  41. public void add(String name);
  42. /**
  43. * Add a new dynamic property with the specified data type, but with
  44. * no restrictions on readability or writeability.
  45. *
  46. * @param name Name of the new dynamic property
  47. * @param type Data type of the new dynamic property (null for no
  48. * restrictions)
  49. *
  50. * @exception IllegalArgumentException if name is null
  51. * @exception IllegalStateException if this DynaClass is currently
  52. * restricted, so no new properties can be added
  53. */
  54. public void add(String name, Class type);
  55. /**
  56. * Add a new dynamic property with the specified data type, readability,
  57. * and writeability.
  58. *
  59. * @param name Name of the new dynamic property
  60. * @param type Data type of the new dynamic property (null for no
  61. * restrictions)
  62. * @param readable Set to <code>true</code> if this property value
  63. * should be readable
  64. * @param writeable Set to <code>true</code> if this property value
  65. * should be writeable
  66. *
  67. * @exception IllegalArgumentException if name is null
  68. * @exception IllegalStateException if this DynaClass is currently
  69. * restricted, so no new properties can be added
  70. */
  71. public void add(String name, Class type, boolean readable,
  72. boolean writeable);
  73. /**
  74. * Is this DynaClass currently restricted, if so, no changes to the
  75. * existing registration of property names, data types, readability, or
  76. * writeability are allowed.
  77. */
  78. public boolean isRestricted();
  79. /**
  80. * Remove the specified dynamic property, and any associated data type,
  81. * readability, and writeability, from this dynamic class.
  82. * <strong>NOTE</strong> - This does <strong>NOT</strong> cause any
  83. * corresponding property values to be removed from DynaBean instances
  84. * associated with this DynaClass.
  85. *
  86. * @param name Name of the dynamic property to remove
  87. *
  88. * @exception IllegalArgumentException if name is null
  89. * @exception IllegalStateException if this DynaClass is currently
  90. * restricted, so no properties can be removed
  91. */
  92. public void remove(String name);
  93. /**
  94. * Set the restricted state of this DynaClass to the specified value.
  95. *
  96. * @param restricted The new restricted state
  97. */
  98. public void setRestricted(boolean restricted);
  99. }