KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > test > ScriptMessages


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.test;
16
17 import org.apache.hivemind.Location;
18 import org.apache.hivemind.impl.MessageFormatter;
19 import org.apache.hivemind.service.ClassFabUtils;
20
21 /**
22  * Container of static methods to format logging and exception messages, used within the
23  * org.apache.tapesty.test package (and a few sub-packages).
24  * <p>
25  * Technically, these are messages for the test package, and this class should be called
26  * TestMessages ... but that's always a bad idea (it makes the class look like a JUnit test suite).
27  * <p>
28  * This class is public, not package private, because some related sub-packages make use of it as
29  * well.
30  *
31  * @author Howard Lewis Ship
32  * @since 4.0
33  */

34 public class ScriptMessages
35 {
36     protected static MessageFormatter _formatter = new MessageFormatter(ScriptMessages.class,
37             "ScriptStrings");
38
39     public static String JavaDoc expectedSubstringMissing(String JavaDoc substring, Location location)
40     {
41         return _formatter.format("expected-substring-missing", substring, location);
42     }
43
44     public static String JavaDoc expectedRegexpMissing(String JavaDoc regexp, Location location)
45     {
46         return _formatter.format("expected-regexp-missing", regexp, location);
47     }
48
49     static String JavaDoc unexpectedAttributeInElement(String JavaDoc attributeName, String JavaDoc elementName)
50     {
51         return _formatter.format("unexpected-attribute-in-element", attributeName, elementName);
52     }
53
54     static String JavaDoc missingRequiredAttribute(String JavaDoc attributeName, String JavaDoc elementName)
55     {
56         return _formatter.format("missing-required-attribute", attributeName, elementName);
57     }
58
59     static String JavaDoc invalidIntAttribute(String JavaDoc attributeName, String JavaDoc elementName,
60             Location location, String JavaDoc attributeValue)
61     {
62         return _formatter.format("invalid-int-attribute", new Object JavaDoc[]
63         { attributeName, elementName, location, attributeValue });
64     }
65
66     public static String JavaDoc incorrectRegexpMatch(String JavaDoc expectedMatch, Location location,
67             String JavaDoc actualMatch)
68     {
69         return _formatter.format("incorrect-regexp-match", expectedMatch, location, actualMatch);
70     }
71
72     public static String JavaDoc incorrectRegexpMatchCount(String JavaDoc pattern, Location location,
73             int expectedCount, int actualCount)
74     {
75         return _formatter.format("incorrect-regexp-match-count", new Object JavaDoc[]
76         { pattern, location, new Integer JavaDoc(expectedCount), new Integer JavaDoc(actualCount) });
77     }
78
79     static String JavaDoc wrongTypeForEnhancement(Class JavaDoc type)
80     {
81         return _formatter
82                 .format("wrong-type-for-enhancement", ClassFabUtils.getJavaClassName(type));
83     }
84
85     static String JavaDoc unableToInstantiate(Class JavaDoc abstractClass, Throwable JavaDoc cause)
86     {
87         return _formatter.format("unable-to-instantiate", abstractClass.getName(), cause);
88     }
89 }
Popular Tags