View Javadoc

1   package org.apache.velocity.runtime.resource.util;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "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   * A StringResourceRepository functions as a central repository for Velocity templates
24   * stored in Strings.
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: StringResourceRepository.java 532546 2007-04-26 00:06:33Z nbubna $
29   */
30  public interface StringResourceRepository
31  {
32      /**
33       * get the string resource that is stored with given key
34       * @param name String name to retrieve from the repository.
35       * @return A StringResource containing the template.
36       */
37      StringResource getStringResource(String name);
38  
39      /**
40       * add a string resource with given key.
41       * @param name The String name to store the template under.
42       * @param body A String containing a template.
43       */
44      void putStringResource(String name, String body);
45  
46      /**
47       * add a string resource with given key.
48       * @param name The String name to store the template under.
49       * @param body A String containing a template.
50       * @param encoding The encoding of this string template
51       */
52      void putStringResource(String name, String body, String encoding);
53  
54      /**
55       * delete a string resource with given key.
56       * @param name The string name to remove from the repository.
57       */
58      void removeStringResource(String name);
59      
60      /**
61       * Sets the default encoding of the repository. Encodings can also be stored per
62       * template string. The default implementation does this correctly.
63       * 
64       * @param encoding The encoding to use.
65       */
66      void setEncoding(String encoding);
67      
68      /**
69       * Returns the current encoding of this repository.
70       * 
71       * @return The current encoding of this repository.
72       */
73      String getEncoding();
74  }