1. /*
  2. * Copyright 1999-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.jxpath;
  17. /**
  18. * A generic mechanism for accessing collections of name/value pairs.
  19. * Examples of such collections are HashMap, Properties,
  20. * ServletContext. In order to add support for a new such collection
  21. * type to JXPath, perform the following two steps:
  22. * <ol>
  23. * <li>Build an implementation of the DynamicPropertyHandler interface
  24. * for the desired collection type.</li>
  25. * <li>Invoke the static method {@link JXPathIntrospector#registerDynamicClass
  26. * JXPathIntrospector.registerDynamicClass(class, handlerClass)}</li>
  27. * </ol>
  28. * JXPath allows access to dynamic properties using these three formats:
  29. * <ul>
  30. * <li><code>"myMap/myKey"</code></li>
  31. * <li><code>"myMap[@name = 'myKey']"</code></li>
  32. * <li><code>"myMap[name(.) = 'myKey']"</code></li>
  33. * </ul>
  34. *
  35. * @author Dmitri Plotnikov
  36. * @version $Revision: 1.5 $ $Date: 2004/02/29 14:17:42 $
  37. */
  38. public interface DynamicPropertyHandler {
  39. /**
  40. * Returns a list of dynamic property names for the supplied object.
  41. */
  42. String[] getPropertyNames(Object object);
  43. /**
  44. * Returns the value of the specified dynamic property.
  45. */
  46. Object getProperty(Object object, String propertyName);
  47. /**
  48. * Modifies the value of the specified dynamic property.
  49. */
  50. void setProperty(Object object, String propertyName, Object value);
  51. }