001// Copyright 2004, 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
015package org.apache.tapestry.engine;
016
017import java.util.List;
018
019import org.apache.hivemind.impl.MessageFormatter;
020import org.apache.tapestry.IComponent;
021import org.apache.tapestry.IPage;
022
023/**
024 * @author Howard M. Lewis Ship
025 * @since 4.0
026 */
027public class EngineMessages
028{
029    private final static MessageFormatter _formatter = new MessageFormatter(EngineMessages.class);
030
031    public static String serviceNoParameter(IEngineService service)
032    {
033        return _formatter.format("service-no-parameter", service.getName());
034    }
035
036    public static String wrongComponentType(IComponent component, Class expectedType)
037    {
038        return _formatter.format("wrong-component-type", component.getExtendedId(), expectedType
039                .getName());
040    }
041
042    public static String requestStateSession(IComponent component)
043    {
044        return _formatter.format("request-stale-session", component.getExtendedId());
045    }
046
047    public static String pageNotCompatible(IPage page, Class expectedType)
048    {
049        return _formatter.format("page-not-compatible", page.getPageName(), expectedType.getName());
050    }
051
052    static String exceptionDuringCleanup(Throwable cause)
053    {
054        return _formatter.format("exception-during-cleanup", cause);
055    }
056
057    public static String validateCycle(List pageNames)
058    {
059        StringBuffer buffer = new StringBuffer();
060        int count = pageNames.size();
061
062        for (int i = 0; i < count; i++)
063        {
064            if (i > 0)
065                buffer.append("; ");
066
067            buffer.append(pageNames.get(i));
068        }
069
070        return _formatter.format("validate-cycle", buffer);
071    }
072}