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.locator;
21
22 import java.io.Serializable;
23
24 import org.peaseplate.internal.ResourceKey;
25
26
27 /**
28 * A locator is a reference to a resource. It usually can
29 * load the resource and check if it is outdated.
30 *
31 * There is no definition for the load method,
32 * since it returns different types of objects with each
33 * type of locator.
34 */
35 public interface Locator extends Serializable {
36
37 /**
38 * Returns the key
39 * @return the key
40 */
41 public ResourceKey getKey();
42
43 /**
44 * Returns the timestamp of the resource.
45 * Used for checking updates to the source of the resource.
46 * (usually this is the last modified date of the file).
47 * If there is no possibility to support such a timestamp, just return null.
48 * @return the timestamp, or null if not specified
49 */
50 public Long getTimestamp();
51
52 /**
53 * Sets the timestamp
54 * @param timestamp the timestamp, may be null
55 */
56 public void setTimestamp(Long timestamp);
57
58 /**
59 * Returns the raw size of the resource.
60 * Used for checking updates to the source of the resource.
61 * (usually this is the size of the file).
62 * If there is not possibility to support such a size, just return null.
63 * @return the raw size, or null if not specified
64 */
65 public Long getRawSize();
66
67 /**
68 * Sets the raw size
69 * @param rawSize the raw size, may be null
70 */
71 public void setRawSize(Long rawSize);
72
73 /**
74 * Returns true if the resource described by the locator
75 * got updated and needs to be reloaded
76 * @return true if the resource should get reloaded
77 */
78 public boolean isOutdated();
79
80 /**
81 * A meaningful representation of the locator, mainly used for textual output
82 * e.g. in error messages
83 * @return a meaningful representation of the locator
84 * @see org.peaseplate.internal.ResourceKey#toString()
85 */
86 public String toString();
87
88 }