01: package org.apache.velocity.runtime.resource.util;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: /**
23: * Wrapper for Strings containing templates, allowing to add additional meta
24: * data like timestamps.
25: *
26: * @author <a href="mailto:eelco.hillenius@openedge.nl">Eelco Hillenius</a>
27: * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
28: * @version $Id: StringResource.java 479058 2006-11-25 00:26:32Z henning $
29: */
30: public final class StringResource {
31: /** template body */
32: private String body;
33:
34: /** encoding */
35: private String encoding;
36:
37: /** last modified ts */
38: private long lastModified;
39:
40: /**
41: * convenience constructor; sets body to 'body' and sets lastModified to now
42: * @param body
43: */
44: public StringResource(final String body, final String encoding) {
45: setBody(body);
46: setEncoding(encoding);
47: }
48:
49: /**
50: * Sets the template body.
51: * @return String containing the template body.
52: */
53: public String getBody() {
54: return body;
55: }
56:
57: /**
58: * Returns the modification date of the template.
59: * @return Modification date in milliseconds.
60: */
61: public long getLastModified() {
62: return lastModified;
63: }
64:
65: /**
66: * Sets a new value for the template body.
67: * @param body New body value
68: */
69: public void setBody(final String body) {
70: this .body = body;
71: this .lastModified = System.currentTimeMillis();
72: }
73:
74: /**
75: * Changes the last modified parameter.
76: * @param lastModified The modification time in millis.
77: */
78: public void setLastModified(final long lastModified) {
79: this .lastModified = lastModified;
80: }
81:
82: /**
83: * Returns the encoding of this String resource.
84: *
85: * @return The encoding of this String resource.
86: */
87: public String getEncoding() {
88: return this .encoding;
89: }
90:
91: /**
92: * Sets the encoding of this string resource.
93: *
94: * @param encoding The new encoding of this resource.
95: */
96: public void setEncoding(final String encoding) {
97: this.encoding = encoding;
98: }
99: }
|