001    // Copyright 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.internal;
016    
017    import org.apache.tapestry5.EventContext;
018    
019    public abstract class AbstractEventContext implements EventContext
020    {
021        private String[] values;
022    
023        public String[] toStrings()
024        {
025            int count = getCount();
026    
027            String[] result = new String[count];
028    
029            for (int i = 0; i < count; i++)
030            {
031                result[i] = get(String.class, i);
032            }
033    
034            return result;
035        }
036    
037        @Override
038        public String toString()
039        {
040            StringBuilder builder = new StringBuilder("EventContext:");
041    
042            if (values == null)
043                return builder.append(" null").toString();
044    
045            for (int i = 0; i < values.length; i++)
046            {
047                if (i == 0)
048                    builder.append(" ");
049                else
050                    builder.append(",");
051    
052                builder.append(values[i]);
053            }
054    
055            return builder.toString();
056        }
057    }