View Javadoc

1   /*
2    * This file is part of Pease Plate Template Engine.
3    * 
4    * Pease Plate Template Engine is free software: you can redistribute
5    * it and/or modify it under the terms of the GNU Lesser General 
6    * Public License as published by the Free Software Foundation, 
7    * either version 3 of the License, or any later version.
8    * 
9    * Pease Plate Template Engine is distributed in the hope that it 
10   * will be useful, but WITHOUT ANY WARRANTY; without even the implied
11   * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12   * See the GNU Lesser General Public License for more details.
13   * 
14   * You should have received a copy of the GNU Lesser General Public 
15   * License along with Pease Plate Template Engine. If not, see 
16   * <http://www.gnu.org/licenses/>.
17   * 
18   * Copyright (c) 2008 Manfred HANTSCHEL
19   */
20  package org.peaseplate.internal;
21  
22  import java.io.Serializable;
23  import java.util.Locale;
24  
25  /**
26   * A unique key that describes the resource 
27   * using the specified name and the locale.
28   * The additional encoding is used for loading
29   * the resource, but is not part of the key itself,
30   * which means that it is not part of the hashCode 
31   * and equals methods. These two methods must be 
32   * implemented but only target the name and the locale.
33   * 
34   * @author Manfred HANTSCHEL
35   */
36  public interface ResourceKey extends Serializable {
37  
38  	/**
39  	 * Returns the name of the resource
40  	 * @return the name of the resource
41  	 */
42  	public String getName();
43  	
44  	/**
45  	 * Returns the locale of the resource
46  	 * @return the locale of the resource
47  	 */
48  	public Locale getLocale();
49  
50  	/**
51  	 * Returns the encoding of the resource
52  	 * @return the encoding of the resource
53  	 */
54  	public String getEncoding();
55  	
56  	/**
57  	 * Returns a resource key with the same name and the parent locale
58  	 * If the locale is already null, there is no parent and it returns null.
59  	 * @return the parent or null
60  	 */
61  	public ResourceKey getParent();
62  	
63  	/**
64  	 * Must implement the hashCode method
65  	 * @return the hashCode
66  	 */
67  	public int hashCode();
68  	
69  	/**
70  	 * Must implement the equals method
71  	 * @param object the object to compare
72  	 * @return true if equal
73  	 */
74  	public boolean equals(Object object);
75  	
76  	/**
77  	 * Returns a textual representation
78  	 * @return a textual representation
79  	 */
80  	public String toString();
81  	
82  }