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