You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by nb...@apache.org on 2007/04/26 02:06:34 UTC
svn commit: r532546 - in
/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/util:
StringResourceRepository.java StringResourceRepositoryImpl.java
Author: nbubna
Date: Wed Apr 25 17:06:33 2007
New Revision: 532546
URL: http://svn.apache.org/viewvc?view=rev&rev=532546
Log:
add method to allow encoding to be set per resource, not just per repository
Modified:
velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/util/StringResourceRepository.java
velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/util/StringResourceRepositoryImpl.java
Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/util/StringResourceRepository.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/util/StringResourceRepository.java?view=diff&rev=532546&r1=532545&r2=532546
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/util/StringResourceRepository.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/util/StringResourceRepository.java Wed Apr 25 17:06:33 2007
@@ -44,15 +44,22 @@
void putStringResource(String name, String body);
/**
+ * add a string resource with given key.
+ * @param name The String name to store the template under.
+ * @param body A String containing a template.
+ * @param encoding The encoding of this string template
+ */
+ void putStringResource(String name, String body, String encoding);
+
+ /**
* delete a string resource with given key.
* @param name The string name to remove from the repository.
*/
void removeStringResource(String name);
/**
- * Sets the encoding of the repository. The encoding should be stored per
- * template string so that multiple encodings can be stored in a single repository.
- * The default implementation does this correctly.
+ * Sets the default encoding of the repository. Encodings can also be stored per
+ * template string. The default implementation does this correctly.
*
* @param encoding The encoding to use.
*/
Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/util/StringResourceRepositoryImpl.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/util/StringResourceRepositoryImpl.java?view=diff&rev=532546&r1=532545&r2=532546
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/util/StringResourceRepositoryImpl.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/resource/util/StringResourceRepositoryImpl.java Wed Apr 25 17:06:33 2007
@@ -22,7 +22,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-
import org.apache.velocity.runtime.resource.loader.StringResourceLoader;
/**
@@ -33,8 +32,7 @@
* @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
* @version $Id$
*/
-public class StringResourceRepositoryImpl
- implements StringResourceRepository
+public class StringResourceRepositoryImpl implements StringResourceRepository
{
/**
* mem store
@@ -63,6 +61,14 @@
}
/**
+ * @see StringResourceRepository#putStringResource(java.lang.String, java.lang.String, java.lang.String)
+ */
+ public void putStringResource(final String name, final String body, final String encoding)
+ {
+ resources.put(name, new StringResource(body, encoding));
+ }
+
+ /**
* @see StringResourceRepository#removeStringResource(java.lang.String)
*/
public void removeStringResource(final String name)
@@ -75,7 +81,7 @@
*/
public String getEncoding()
{
- return encoding;
+ return encoding;
}
/**
@@ -83,6 +89,6 @@
*/
public void setEncoding(final String encoding)
{
- this.encoding = encoding;
+ this.encoding = encoding;
}
}