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.lang.reflect.Constructor; 021 import java.util.Iterator; 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 */ 030 public interface Uberspect { 031 /** Sets the class loader to use when getting a constructor with 032 * a class name parameter. 033 * @param loader the class loader 034 */ 035 void setClassLoader(ClassLoader loader); 036 037 /** 038 * Returns a class constructor. 039 * @param ctorHandle a class or class name 040 * @param args constructor arguments 041 * @param info contextual information 042 * @return a {@link Constructor} 043 */ 044 @Deprecated 045 Constructor<?> getConstructor(Object ctorHandle, Object[] args, JexlInfo info); 046 047 /** 048 * Returns a class constructor wrapped in a JexlMethod. 049 * @param ctorHandle a class or class name 050 * @param args constructor arguments 051 * @param info contextual information 052 * @return a {@link Constructor} 053 * @since 2.1 054 */ 055 JexlMethod getConstructorMethod(Object ctorHandle, Object[] args, JexlInfo info); 056 057 /** 058 * Returns a JexlMethod. 059 * @param obj the object 060 * @param method the method name 061 * @param args method arguments 062 * @param info contextual information 063 * @return a {@link JexlMethod} 064 */ 065 JexlMethod getMethod(Object obj, String method, Object[] args, JexlInfo info); 066 067 /** 068 * Property getter. 069 * <p>Returns JexlPropertyGet appropos for ${bar.woogie}. 070 * @param obj the object to get the property from 071 * @param identifier property name 072 * @param info contextual information 073 * @return a {@link JexlPropertyGet} 074 */ 075 JexlPropertyGet getPropertyGet(Object obj, Object identifier, JexlInfo info); 076 077 /** 078 * Property setter. 079 * <p>returns JelPropertySet appropos for ${foo.bar = "geir"}</p>. 080 * @param obj the object to get the property from. 081 * @param identifier property name 082 * @param arg value to set 083 * @param info contextual information 084 * @return a {@link JexlPropertySet}. 085 */ 086 JexlPropertySet getPropertySet(Object obj, Object identifier, Object arg, JexlInfo info); 087 088 /** 089 * Gets an iterator from an object. 090 * @param obj to get the iterator for 091 * @param info contextual information 092 * @return an iterator over obj 093 */ 094 Iterator<?> getIterator(Object obj, JexlInfo info); 095 096 }