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    
018    package org.apache.commons.jexl2.introspection;
019    
020    import java.util.Iterator;
021    import java.lang.reflect.Constructor;
022    import org.apache.commons.jexl2.JexlInfo;
023    
024    /**
025     * 'Federated' introspection/reflection interface to allow the introspection
026     * behavior in JEXL to be customized.
027     * 
028     * @since 1.0
029     * @author <a href="mailto:geirm@apache.org">Geir Magusson Jr.</a>
030     * @version $Id: Uberspect.java 896952 2010-01-07 18:21:29Z henrib $
031     */
032    public interface Uberspect {
033        /** Sets the class loader to use when getting a constructor with
034         * a class name parameter.
035         * @param loader the class loader
036         */
037        void setClassLoader(ClassLoader loader);
038    
039        /**
040         * Returns a class constructor.
041         * @param ctorHandle a class or class name
042         * @param args constructor arguments
043         * @param info contextual information
044         * @return a {@link Constructor}
045         */
046        Constructor<?> getConstructor(Object ctorHandle, Object[] args, JexlInfo info);
047        /**
048         * Returns a JexlMethod.
049         * @param obj the object
050         * @param method the method name
051         * @param args method arguments
052         * @param info contextual information
053         * @return a {@link JexlMethod}
054         */
055        JexlMethod getMethod(Object obj, String method, Object[] args, JexlInfo info);
056    
057        /**
058         * Property getter.
059         * <p>Returns JexlPropertyGet appropos for ${bar.woogie}.
060         * @param obj the object to get the property from
061         * @param identifier property name
062         * @param info contextual information
063         * @return a {@link JexlPropertyGet}
064         */
065        JexlPropertyGet getPropertyGet(Object obj, Object identifier, JexlInfo info);
066    
067        /**
068         * Property setter.
069         * <p>returns JelPropertySet appropos for ${foo.bar = "geir"}</p>.
070         * @param obj the object to get the property from.
071         * @param identifier property name
072         * @param arg value to set
073         * @param info contextual information
074         * @return a {@link JexlPropertySet}.
075         */
076        JexlPropertySet getPropertySet(Object obj, Object identifier, Object arg, JexlInfo info);
077    
078        /**
079         * Gets an iterator from an object.
080         * @param obj to get the iterator for
081         * @param info contextual information
082         * @return an iterator over obj
083         */
084        Iterator<?> getIterator(Object obj, JexlInfo info);
085    
086    }