001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.commons.jxpath;
018
019 /**
020 * A generic mechanism for accessing collections of name/value pairs.
021 * Examples of such collections are HashMap, Properties,
022 * ServletContext. In order to add support for a new such collection
023 * type to JXPath, perform the following two steps:
024 * <ol>
025 * <li>Build an implementation of the DynamicPropertyHandler interface
026 * for the desired collection type.</li>
027 * <li>Invoke the static method {@link JXPathIntrospector#registerDynamicClass
028 * JXPathIntrospector.registerDynamicClass(class, handlerClass)}</li>
029 * </ol>
030 * JXPath allows access to dynamic properties using these three formats:
031 * <ul>
032 * <li><code>"myMap/myKey"</code></li>
033 * <li><code>"myMap[@name = 'myKey']"</code></li>
034 * <li><code>"myMap[name(.) = 'myKey']"</code></li>
035 * </ul>
036 *
037 * @author Dmitri Plotnikov
038 * @version $Revision: 652845 $ $Date: 2008-05-02 12:46:46 -0500 (Fri, 02 May 2008) $
039 */
040 public interface DynamicPropertyHandler {
041
042 /**
043 * Returns a list of dynamic property names for the supplied object.
044 * @param object to inspect
045 * @return String[]
046 */
047 String[] getPropertyNames(Object object);
048
049 /**
050 * Returns the value of the specified dynamic property.
051 * @param object to search
052 * @param propertyName to retrieve
053 * @return Object
054 */
055 Object getProperty(Object object, String propertyName);
056
057 /**
058 * Modifies the value of the specified dynamic property.
059 * @param object to modify
060 * @param propertyName to modify
061 * @param value to set
062 */
063 void setProperty(Object object, String propertyName, Object value);
064 }