freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject incubator-freemarker git commit: Removed some needless/confusing getTemplate and removeTemplateFromCache overloads
Date Mon, 20 Mar 2017 19:10:55 GMT
Repository: incubator-freemarker
Updated Branches:
  refs/heads/3 f6a693c57 -> 1870d0294


Removed some needless/confusing getTemplate and removeTemplateFromCache overloads


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/1870d029
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/1870d029
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/1870d029

Branch: refs/heads/3
Commit: 1870d0294699a408afbcc3a7a669902abe34b943
Parents: f6a693c
Author: ddekany <ddekany@apache.org>
Authored: Mon Mar 20 20:10:42 2017 +0100
Committer: ddekany <ddekany@apache.org>
Committed: Mon Mar 20 20:10:42 2017 +0100

----------------------------------------------------------------------
 .../apache/freemarker/core/Configuration.java   | 31 ++------------------
 .../freemarker/dom/JaxenXPathSupport.java       |  2 +-
 .../freemarker/core/ConfigurationTest.java      | 27 -----------------
 .../DefaultTemplateResolverTest.java            | 12 ++++----
 4 files changed, 9 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/1870d029/src/main/java/org/apache/freemarker/core/Configuration.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/Configuration.java b/src/main/java/org/apache/freemarker/core/Configuration.java
index c5d290f..256b4c1 100644
--- a/src/main/java/org/apache/freemarker/core/Configuration.java
+++ b/src/main/java/org/apache/freemarker/core/Configuration.java
@@ -1816,17 +1816,6 @@ public class Configuration extends Configurable implements Cloneable,
ParserConf
     }
 
     /**
-     * Shorthand for {@link #getTemplate(String, Locale, Serializable, boolean)
-     * getTemplate(name, locale, null, ignoreMissing)}.
-     * 
-     * @since 2.3.21
-     */
-    public Template getTemplate(String name, Locale locale, boolean ignoreMissing)
-            throws TemplateNotFoundException, MalformedTemplateNameException, ParseException,
IOException {
-        return getTemplate(name, locale, null, ignoreMissing);
-    }
-    
-    /**
      * Retrieves the template with the given name (and according the specified further parameters)
from the template
      * templateResolver, loading it into the templateResolver first if it's missing/staled.
      * 
@@ -1899,8 +1888,8 @@ public class Configuration extends Configurable implements Cloneable,
ParserConf
      * 
      * @since 2.3.22
      */
-    public Template getTemplate(String name, Locale locale, Serializable customLookupCondition,
boolean
-            ignoreMissing)
+    public Template getTemplate(String name, Locale locale, Serializable customLookupCondition,
+            boolean ignoreMissing)
             throws TemplateNotFoundException, MalformedTemplateNameException, ParseException,
IOException {
         if (locale == null) {
             locale = getLocale();
@@ -2198,22 +2187,6 @@ public class Configuration extends Configurable implements Cloneable,
ParserConf
     }
     
     /**
-     * Equivalent to <tt>removeTemplateFromCache(name, thisCfg.getLocale(), thisCfg.getEncoding(thisCfg.getLocale()),
true)</tt>.
-     * @since 2.3.19
-     */
-    public void removeTemplateFromCache(String name) throws IOException {
-        removeTemplateFromCache(name, getLocale());
-    }
-
-    /**
-     * Equivalent to <tt>removeTemplateFromCache(name, locale, thisCfg.getEncoding(locale),
true)</tt>.
-     * @since 2.3.19
-     */
-    public void removeTemplateFromCache(String name, Locale locale) throws IOException {
-        removeTemplateFromCache(name, locale, null);
-    }
-
-    /**
      * Removes a template from the template templateResolver, hence forcing the re-loading
      * of it when it's next time requested. This is to give the application
      * finer control over templateResolver updating than {@link #setTemplateUpdateDelayMilliseconds(long)}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/1870d029/src/main/java/org/apache/freemarker/dom/JaxenXPathSupport.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/dom/JaxenXPathSupport.java b/src/main/java/org/apache/freemarker/dom/JaxenXPathSupport.java
index 0bb3c65..36773f4 100644
--- a/src/main/java/org/apache/freemarker/dom/JaxenXPathSupport.java
+++ b/src/main/java/org/apache/freemarker/dom/JaxenXPathSupport.java
@@ -198,7 +198,7 @@ class JaxenXPathSupport implements XPathSupport {
         int lastSlash = templatePath.lastIndexOf('/');
         templatePath = lastSlash == -1 ? "" : templatePath.substring(0, lastSlash + 1);
         systemId = env.toFullTemplateName(templatePath, systemId);
-        return env.getConfiguration().getTemplate(systemId, env.getLocale(), false);
+        return env.getConfiguration().getTemplate(systemId, env.getLocale());
     }
 
     private static InputSource createInputSource(String publicId, Template raw) throws IOException,
SAXException {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/1870d029/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/ConfigurationTest.java b/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
index 6539753..ab10de1 100644
--- a/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
+++ b/src/test/java/org/apache/freemarker/core/ConfigurationTest.java
@@ -342,33 +342,6 @@ public class ConfigurationTest extends TestCase {
             assertEquals(utf8, t.getEncoding());
         }
 
-        // 3 args:
-        try {
-            cfg.getTemplate("missing.ftl", hu, false);
-            fail();
-        } catch (TemplateNotFoundException e) {
-            // Expected
-        }
-        assertNull(cfg.getTemplate("missing.ftl", hu, true));
-        {
-            Template t = cfg.getTemplate(tFtl, null, true);
-            assertEquals(tFtl, t.getName());
-            assertEquals(tFtl, t.getSourceName());
-            assertEquals(Locale.GERMAN, t.getLocale());
-            assertNull(t.getCustomLookupCondition());
-            assertEquals(latin1, t.getEncoding());
-            assertOutputEquals("1", t);
-        }
-        {
-            Template t = cfg.getTemplate(tFtl, hu, true);
-            assertEquals(tFtl, t.getName());
-            assertEquals(tHuFtl, t.getSourceName());
-            assertEquals(hu, t.getLocale());
-            assertNull(t.getCustomLookupCondition());
-            assertEquals(latin2, t.getEncoding());
-            assertOutputEquals("1", t);
-        }
-
         // 4 args:
         try {
             cfg.getTemplate("missing.ftl", hu, custLookupCond, false);

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/1870d029/src/test/java/org/apache/freemarker/core/templateresolver/DefaultTemplateResolverTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/templateresolver/DefaultTemplateResolverTest.java
b/src/test/java/org/apache/freemarker/core/templateresolver/DefaultTemplateResolverTest.java
index 996f4fd..a80305d 100644
--- a/src/test/java/org/apache/freemarker/core/templateresolver/DefaultTemplateResolverTest.java
+++ b/src/test/java/org/apache/freemarker/core/templateresolver/DefaultTemplateResolverTest.java
@@ -153,11 +153,11 @@ public class DefaultTemplateResolverTest {
         assertEquals("1 v1", cfg.getTemplate("1.ftl").toString()); // no change 
         assertEquals("2 v1", cfg.getTemplate("2.ftl").toString()); // no change
         
-        cfg.removeTemplateFromCache("1.ftl");
+        cfg.removeTemplateFromCache("1.ftl", cfg.getLocale(), null);
         assertEquals("1 v2", cfg.getTemplate("1.ftl").toString()); // changed 
         assertEquals("2 v1", cfg.getTemplate("2.ftl").toString());
         
-        cfg.removeTemplateFromCache("2.ftl");
+        cfg.removeTemplateFromCache("2.ftl", cfg.getLocale(), null);
         assertEquals("1 v2", cfg.getTemplate("1.ftl").toString()); 
         assertEquals("2 v2", cfg.getTemplate("2.ftl").toString()); // changed
     }
@@ -186,20 +186,20 @@ public class DefaultTemplateResolverTest {
         assertEquals("1_en v1", cfg.getTemplate("1.ftl", Locale.UK).toString());        
         assertEquals("1 v1", cfg.getTemplate("1.ftl", Locale.GERMANY).toString());
         
-        cfg.removeTemplateFromCache("1.ftl");
+        cfg.removeTemplateFromCache("1.ftl", cfg.getLocale(), null);
         assertEquals("1_en_US v2", cfg.getTemplate("1.ftl").toString());        
         assertEquals("1_en v1", cfg.getTemplate("1.ftl", Locale.UK).toString());        
         assertEquals("1 v1", cfg.getTemplate("1.ftl", Locale.GERMANY).toString());
         assertEquals("1 v2", cfg.getTemplate("1.ftl", Locale.ITALY).toString());
         
-        cfg.removeTemplateFromCache("1.ftl", Locale.GERMANY);
+        cfg.removeTemplateFromCache("1.ftl", Locale.GERMANY, null);
         assertEquals("1_en v1", cfg.getTemplate("1.ftl", Locale.UK).toString());        
         assertEquals("1 v2", cfg.getTemplate("1.ftl", Locale.GERMANY).toString());
 
-        cfg.removeTemplateFromCache("1.ftl", Locale.CANADA);
+        cfg.removeTemplateFromCache("1.ftl", Locale.CANADA, null);
         assertEquals("1_en v1", cfg.getTemplate("1.ftl", Locale.UK).toString());
         
-        cfg.removeTemplateFromCache("1.ftl", Locale.UK);
+        cfg.removeTemplateFromCache("1.ftl", Locale.UK, null);
         assertEquals("1_en v2", cfg.getTemplate("1.ftl", Locale.UK).toString());        
     }
 


Mime
View raw message