View Javadoc

1   // Copyright (C) 2005 Philip Aston
2   // All rights reserved.
3   //
4   // This file is part of The Grinder software distribution. Refer to
5   // the file LICENSE which is part of The Grinder distribution for
6   // licensing details. The Grinder distribution is available on the
7   // Internet at http://grinder.sourceforge.net/
8   //
9   // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
10  // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
11  // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
12  // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
13  // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
14  // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
15  // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
16  // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
17  // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
18  // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
19  // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
20  // OF THE POSSIBILITY OF SUCH DAMAGE.
21  
22  package net.grinder.console.common;
23  
24  import javax.swing.ImageIcon;
25  
26  /**
27   * Type safe interface to resource bundle.
28   *
29   * @author Philip Aston
30   */
31  public interface Resources {
32  
33    /**
34     * Overloaded version of {@link #getString(String, boolean)} which
35     * writes out a waning if the resource is missing.
36     * @param key The resource key.
37     * @return The string.
38     */
39    String getString(String key);
40  
41    /**
42     * Use key to look up resource which names image URL. Return the image.
43     * @param key The resource key.
44     * @param warnIfMissing true => write out an error message if the
45     * resource is missing.
46     * @return The string.
47     */
48    String getString(String key, boolean warnIfMissing);
49  
50    /**
51     * Overloaded version of {@link #getImageIcon(String, boolean)}
52     * which doesn't write out a waning if the resource is missing.
53     *
54     * @param key The resource key.
55     * @return The image.
56     */
57    ImageIcon getImageIcon(String key);
58  
59    /**
60     * Use key to look up resource which names image URL. Return the image.
61     *
62     * @param key The resource key.
63     * @param warnIfMissing true => write out an error message if the
64     * resource is missing.
65     * @return The image
66     */
67    ImageIcon getImageIcon(String key, boolean warnIfMissing);
68  
69    /**
70     * Use <code>key</code> to identify a file by URL. Return contents
71     * of file as a String.
72     *
73     * @param key Resource key used to look up URL of file.
74     * @param warnIfMissing true => write out an error message if the
75     * resource is missing.
76     * @return Contents of file.
77     */
78    String getStringFromFile(String key, boolean warnIfMissing);
79  }