1/*
2 * Copyright 2003-2009 OFFIS, Henri Tremblay
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.easymock.internal;
17
18public class ErrorMessage {
19
20    private final boolean matching;
21
22    private final String message;
23
24    private final int actualCount;
25
26    public ErrorMessage(boolean matching, String message, int actualCount) {
27        this.matching = matching;
28        this.message = message;
29        this.actualCount = actualCount;
30    }
31
32    public boolean isMatching() {
33        return matching;
34    }
35
36    public String getMessage() {
37        return message;
38    }
39
40    public int getActualCount() {
41        return actualCount;
42    }
43
44    public void appendTo(StringBuilder buffer, int matches) {
45        buffer.append("\n    ").append(message).append(", actual: ");
46        if (matching) {
47            if (matches == 1) {
48                buffer.append(getActualCount() + 1);
49            } else {
50                buffer.append(getActualCount());
51                buffer.append(" (+1)");
52            }
53        }
54        else {
55            buffer.append(getActualCount());
56        }
57    }
58}
59