001    // Copyright 2008, 2010 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.tapestry5;
016    
017    /**
018     * A collection of parameters that may eventually be passed to an event handler method. Includes the
019     * ability to coerce
020     * or encode parameters as needed.
021     * 
022     * @see org.apache.tapestry5.ioc.services.TypeCoercer
023     * @see org.apache.tapestry5.ValueEncoder
024     */
025    public interface EventContext
026    {
027        /**
028         * Returns the number of parameter values that can be extracted.
029         */
030        int getCount();
031    
032        /**
033         * Extracts a parameter value and coerces or decodes it to the desired type.
034         * 
035         * @param desiredType
036         *            the type of value required
037         * @param index
038         *            identifies which parameter value to extract
039         * @return the value extracted and converted or coerced
040         * @throws RuntimeException
041         *             if the value can't be converted or the index is out of range
042         */
043        <T> T get(Class<T> desiredType, int index);
044    
045        /**
046         * Extracts the value of each context value as a string.
047         * 
048         * @return context values
049         * @since 5.2.0
050         */
051        String[] toStrings();
052    }