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 org.apache.hivemind.ApplicationRuntimeException; 018 import org.apache.tapestry.IActionListener; 019 import org.apache.tapestry.IComponent; 020 021 import java.util.Collection; 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 * @return 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 * @return 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 * @return List of known listener names. 064 * @since 1.0.6 065 */ 066 Collection getListenerNames(); 067 068 /** 069 * Returns true if this ListenerMapImpl can provide a listener with the 070 * given name. 071 * 072 * @param name Name of the method to check listener existance of. 073 * @return True if there is a matching listener of that name, false otherwise. 074 * @since 2.2 075 */ 076 boolean canProvideListener(String name); 077 }