View Javadoc

1   /*
2    * Copyright 2007-2013 smartics, Kronseder & Reiner GmbH
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   */
16  package de.smartics.exceptions.core;
17  
18  import java.io.Serializable;
19  
20  import de.smartics.exceptions.CoreException;
21  
22  /**
23   * Formatter for instances of {@link CoreException}.
24   */
25  public interface CodeMessageFormatter extends Serializable
26  {
27    // ********************************* Fields *********************************
28  
29    // --- constants ------------------------------------------------------------
30  
31    // ****************************** Initializer *******************************
32  
33    // ****************************** Inner Classes *****************************
34  
35    // ********************************* Methods ********************************
36  
37    // --- get&set --------------------------------------------------------------
38  
39    // --- business -------------------------------------------------------------
40  
41    /**
42     * Formats the given core exception.
43     * <p>
44     * Implementations must not use the <code>toString</code> method of the given
45     * {@code exception} since the instance delegates its <code>toString</code>
46     * method call to this instance.
47     * </p>
48     *
49     * @param exception the exception to transform to its string representation.
50     * @return the string representation of the exception.
51     */
52    String format(CoreException exception);
53  
54    /**
55     * Formats the given core exception.
56     * <p>
57     * Implementations must not use the <code>toString</code> method of the given
58     * {@code exception} since the instance delegates its <code>toString</code>
59     * method call to this instance.
60     * </p>
61     *
62     * @param exception the exception to transform to its string representation.
63     * @param message to message to include into the representation.
64     * @return the string representation of the exception.
65     */
66    String format(CoreException exception, final Object message);
67  
68    // --- object basics --------------------------------------------------------
69  
70  }