001 // Copyright 2005 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.tapestry.listener; 016 017 import java.util.Collection; 018 019 import org.apache.hivemind.ApplicationRuntimeException; 020 import org.apache.tapestry.IActionListener; 021 import org.apache.tapestry.IComponent; 022 023 /** 024 * @author Howard M. Lewis Ship 025 */ 026 public interface ListenerMap 027 { 028 029 /** 030 * Gets a listener for the given name (which is both a property name and a 031 * method name). The listener is created as needed, but is also cached for 032 * later use. The returned object implements the 033 * {@link org.apache.tapestry.IActionListener}. 034 * 035 * @param name 036 * the name of the method to invoke (the most appropriate method 037 * will be selected if there are multiple overloadings of the 038 * same method name) 039 * @returns an object implementing {@link IActionListener}. 040 * @throws ApplicationRuntimeException 041 * if the listener can not be created. 042 */ 043 IActionListener getListener(String name); 044 045 /** 046 * Gets a listener on the given component generated from the capitalized 047 * component id, prefixed by "do". For example, jwcid="clear@DirectLink" 048 * would have a listener called doClear(). 049 * 050 * @param component 051 * the component whose id is used to make up the name of the 052 * expected listener 053 * @returns an object implementing {@link IActionListener}. 054 * @throws ApplicationRuntimeException 055 * if the listener can not be found on the component 056 */ 057 IActionListener getImplicitListener(IComponent component); 058 059 /** 060 * Returns an unmodifiable collection of the names of the listeners 061 * implemented by the target class. 062 * 063 * @since 1.0.6 064 */ 065 Collection getListenerNames(); 066 067 /** 068 * Returns true if this ListenerMapImpl can provide a listener with the 069 * given name. 070 * 071 * @since 2.2 072 */ 073 boolean canProvideListener(String name); 074 }