freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject [1/4] incubator-freemarker git commit: FREEMARKER-55: cleanups with new #of(StringToIndexMap, Entry...)
Date Fri, 05 Jan 2018 19:29:01 GMT
Repository: incubator-freemarker
Updated Branches:
  refs/heads/3 f6cd47ca9 -> def59eb43


FREEMARKER-55: cleanups with new #of(StringToIndexMap, Entry...)


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

Branch: refs/heads/3
Commit: 0f45c1da0b372b56d3c3808837a4060778c97834
Parents: f6cd47c
Author: Woonsan Ko <woonsan@apache.org>
Authored: Fri Jan 5 13:54:03 2018 -0500
Committer: Woonsan Ko <woonsan@apache.org>
Committed: Fri Jan 5 13:54:03 2018 -0500

----------------------------------------------------------------------
 .../core/util/StringToIndexMapTest.java         | 32 ++++++++++--
 .../freemarker/core/util/StringToIndexMap.java  | 55 +++++++++++++-------
 ...aBoundFormElementTemplateDirectiveModel.java |  6 +--
 ...stractHtmlElementTemplateDirectiveModel.java | 44 +++++++---------
 ...tHtmlInputElementTemplateDirectiveModel.java | 22 +++-----
 .../model/form/FormTemplateDirectiveModel.java  | 36 ++++++-------
 .../model/form/InputTemplateDirectiveModel.java | 20 +++----
 7 files changed, 115 insertions(+), 100 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/0f45c1da/freemarker-core-test/src/test/java/org/apache/freemarker/core/util/StringToIndexMapTest.java
----------------------------------------------------------------------
diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/util/StringToIndexMapTest.java
b/freemarker-core-test/src/test/java/org/apache/freemarker/core/util/StringToIndexMapTest.java
index 3be5783..5973c45 100644
--- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/util/StringToIndexMapTest.java
+++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/util/StringToIndexMapTest.java
@@ -19,14 +19,19 @@
 
 package org.apache.freemarker.core.util;
 
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
-
 import org.apache.freemarker.core.util.StringToIndexMap.Entry;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableList;
 
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 public class StringToIndexMapTest {
 
     @Test
@@ -166,4 +171,25 @@ public class StringToIndexMapTest {
         }
     }
 
+    @Test
+    public void testEntryInheritance() {
+        StringToIndexMap base = StringToIndexMap.of("i", 0, "j", 1);
+        StringToIndexMap derived =StringToIndexMap.of(base,
+                new StringToIndexMap.Entry("k", 2),
+                new StringToIndexMap.Entry("l", 3));
+
+        assertEquals(4, derived.size());
+        assertEquals(-1, derived.get("a"));
+        assertEquals(0, derived.get("i"));
+        assertEquals(1, derived.get("j"));
+        assertEquals(2, derived.get("k"));
+        assertEquals(3, derived.get("l"));
+        assertEquals(ImmutableList.of("i", "j", "k", "l"), derived.getKeys());
+        assertEquals("i", derived.getKeyOfValue(0));
+        assertEquals("j", derived.getKeyOfValue(1));
+        assertEquals("k", derived.getKeyOfValue(2));
+        assertEquals("l", derived.getKeyOfValue(3));
+        assertNull(derived.getKeyOfValue(4));
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/0f45c1da/freemarker-core/src/main/java/org/apache/freemarker/core/util/StringToIndexMap.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/util/StringToIndexMap.java
b/freemarker-core/src/main/java/org/apache/freemarker/core/util/StringToIndexMap.java
index 280bc1d..79dbabf 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/util/StringToIndexMap.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/util/StringToIndexMap.java
@@ -19,6 +19,8 @@
 
 package org.apache.freemarker.core.util;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -37,10 +39,6 @@ public final class StringToIndexMap {
 
     private static final int MAX_VARIATIONS_TRIED = 4;
 
-    /** Input Entries from caller. */
-    private final Entry[] inputEntries;
-
-    /** Internal entry buckets. */
     private final Entry[] buckets;
     private final int bucketIndexMask;
     private final int bucketIndexOverlap;
@@ -133,9 +131,26 @@ public final class StringToIndexMap {
         return EMPTY;
     }
 
+    /**
+     * Create a new {@link StringToIndexMap} by inheriting all the entries in {@code baseMap}
and appending all
+     * the entry items in {@code additionalEntries}.
+     * @param baseMap {@link StringToIndexMap} to inherit entries from
+     * @param additionalEntries additional entries
+     * @return a new {@link StringToIndexMap} by adding all the entries in {@code inherited}
and appending all
+     * the entry items in {@code additionalEntries}
+     */
+    public static StringToIndexMap of(StringToIndexMap baseMap, Entry... additionalEntries)
{
+        final int additionalEntriesLength = (additionalEntries != null) ? additionalEntries.length
: 0;
+        List<Entry> newEntries = new ArrayList<>(baseMap.size() + additionalEntriesLength);
+        baseMap.collectAllEntriesTo(newEntries);
+        for (int i = 0; i < additionalEntriesLength; i++) {
+            newEntries.add(additionalEntries[i]);
+        }
+        return of(newEntries.toArray(new Entry[newEntries.size()]));
+    }
+
     // This is a very frequent case, so we optimize for it a bit.
     private StringToIndexMap(Entry entry) {
-        inputEntries = new Entry[] { entry };
         buckets = new Entry[] { entry };
         bucketIndexMask = 0;
         bucketIndexOverlap = 0;
@@ -148,15 +163,11 @@ public final class StringToIndexMap {
 
     private StringToIndexMap(Entry[] entries, int entriesLength) {
         if (entriesLength == 0) {
-            inputEntries = null;
             buckets = null;
             bucketIndexMask = 0;
             bucketIndexOverlap = 0;
             keys = Collections.emptyList();
         } else {
-            inputEntries = new Entry[entriesLength];
-            System.arraycopy(entries, 0, inputEntries, 0, entriesLength);
-
             String[] keyArray = new String[entriesLength];
             for (int i = 0; i < entriesLength; i++) {
                 keyArray[i] = entries[i].key;
@@ -177,7 +188,7 @@ public final class StringToIndexMap {
                         filledBucketCnt++;
                     }
                 }
-                // Ideally, filledBucketCnt == entriesLength. If less, we have buckets with
more then 1 element.
+                // Ideally, filledBucketCnt == entriesLength. If less, we have buckets with
more than 1 element.
                 int setupGoodness = filledBucketCnt - entriesLength;
 
                 if (bestSetup == null || bestSetupGoodness < setupGoodness) {
@@ -282,15 +293,6 @@ public final class StringToIndexMap {
 
     }
 
-    /**
-     * Return a cloned array from the original {@link Entry} array which was given by the
caller through directly
-     * using {@link #of(Entry...)} or {@link #of(Entry[], int)} or indirectly using other
methods such as {@link #of(String, int)}.
-     * @return a cloned array from the original {@link Entry} array which was given by the
caller
-     */
-    public Entry[] getInputEntries() {
-        return inputEntries;
-    }
-
     private static int getPowerOf2GreaterThanOrEqualTo(int n) {
         if (n == 0) {
             return 0;
@@ -352,6 +354,21 @@ public final class StringToIndexMap {
         return null;
     }
 
+    /**
+     * Traverse all the entries and collect all into the given {@code targetEntryCollection}.
+     */
+    private void collectAllEntriesTo(Collection<Entry> targetEntryCollection) {
+        if (buckets == null) {
+            return;
+        }
+        for (Entry entry : buckets) {
+            while (entry != null) {
+                targetEntryCollection.add(entry);
+                entry = entry.nextInSameBucket;
+            }
+        }
+    }
+
     /*
     // Code used to see how well the elements are spread among the buckets:
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/0f45c1da/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/AbstractDataBoundFormElementTemplateDirectiveModel.java
----------------------------------------------------------------------
diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/AbstractDataBoundFormElementTemplateDirectiveModel.java
b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/AbstractDataBoundFormElementTemplateDirectiveModel.java
index 11b47c3..ce37d88 100644
--- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/AbstractDataBoundFormElementTemplateDirectiveModel.java
+++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/AbstractDataBoundFormElementTemplateDirectiveModel.java
@@ -53,10 +53,6 @@ abstract class AbstractDataBoundFormElementTemplateDirectiveModel extends
Abstra
 
     private static final String ID_PARAM_NAME = ID_ATTR_NAME;
 
-    private static final StringToIndexMap.Entry[] NAMED_ARGS_ENTRIES = {
-            new StringToIndexMap.Entry(ID_PARAM_NAME, ID_PARAM_IDX)
-    };
-
     /**
      * Returns the argument index of the last predefined named argument item in the {@code
argsLayout}.
      * <P>
@@ -75,7 +71,7 @@ abstract class AbstractDataBoundFormElementTemplateDirectiveModel extends
Abstra
             ArgumentArrayLayout.create(
                     1,
                     false,
-                    StringToIndexMap.of(NAMED_ARGS_ENTRIES),
+                    StringToIndexMap.of(ID_PARAM_NAME, ID_PARAM_IDX),
                     true
                     );
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/0f45c1da/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/AbstractHtmlElementTemplateDirectiveModel.java
----------------------------------------------------------------------
diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/AbstractHtmlElementTemplateDirectiveModel.java
b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/AbstractHtmlElementTemplateDirectiveModel.java
index 8e30dd2..28f8f07 100644
--- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/AbstractHtmlElementTemplateDirectiveModel.java
+++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/AbstractHtmlElementTemplateDirectiveModel.java
@@ -38,7 +38,6 @@ import org.apache.freemarker.core.model.TemplateModel;
 import org.apache.freemarker.core.model.TemplateStringModel;
 import org.apache.freemarker.core.util.CallableUtils;
 import org.apache.freemarker.core.util.StringToIndexMap;
-import org.apache.freemarker.core.util._ArrayUtils;
 import org.springframework.util.ObjectUtils;
 import org.springframework.util.StringUtils;
 import org.springframework.web.servlet.support.RequestContext;
@@ -105,34 +104,29 @@ abstract class AbstractHtmlElementTemplateDirectiveModel
     private static final int CSSERRORCLASS_PARAM_IDX = NAMED_ARGS_OFFSET + 16;
     private static final String CSSERRORCLASS_PARAM_NAME = "cssErrorClass";
 
-    private static final StringToIndexMap.Entry[] NAMED_ARGS_ENTRIES =
-            _ArrayUtils.addAll(
-                    AbstractDataBoundFormElementTemplateDirectiveModel.ARGS_LAYOUT.getPredefinedNamedArgumentsMap()
-                            .getInputEntries(),
-                    new StringToIndexMap.Entry(CSS_CLASS_PARAM_NAME, CSS_CLASS_PARAM_IDX),
-                    new StringToIndexMap.Entry(CSS_STYLE_PARAM_NAME, CSS_STYLE_PARAM_IDX),
-                    new StringToIndexMap.Entry(LANG_PARAM_NAME, LANG_PARAM_IDX),
-                    new StringToIndexMap.Entry(TITLE_PARAM_NAME, TITLE_PARAM_IDX),
-                    new StringToIndexMap.Entry(DIR_PARAM_NAME, DIR_PARAM_IDX),
-                    new StringToIndexMap.Entry(TABINDEX_PARAM_NAME, TABINDEX_PARAM_IDX),
-                    new StringToIndexMap.Entry(ONCLICK_PARAM_NAME, ONCLICK_PARAM_IDX),
-                    new StringToIndexMap.Entry(ONDBLCLICK_PARAM_NAME, ONDBLCLICK_PARAM_IDX),
-                    new StringToIndexMap.Entry(ONMOUSEDOWN_PARAM_NAME, ONMOUSEDOWN_PARAM_IDX),
-                    new StringToIndexMap.Entry(ONMOUSEUP_PARAM_NAME, ONMOUSEUP_PARAM_IDX),
-                    new StringToIndexMap.Entry(ONMOUSEOVER_PARAM_NAME, ONMOUSEOVER_PARAM_IDX),
-                    new StringToIndexMap.Entry(ONMOUSEMOVE_PARAM_NAME, ONMOUSEMOVE_PARAM_IDX),
-                    new StringToIndexMap.Entry(ONMOUSEOUT_PARAM_NAME, ONMOUSEOUT_PARAM_IDX),
-                    new StringToIndexMap.Entry(ONKEYPRESS_PARAM_NAME, ONKEYPRESS_PARAM_IDX),
-                    new StringToIndexMap.Entry(ONKEYUP_PARAM_NAME, ONKEYUP_PARAM_IDX),
-                    new StringToIndexMap.Entry(ONKEYDOWN_PARAM_NAME, ONKEYDOWN_PARAM_IDX),
-                    new StringToIndexMap.Entry(CSSERRORCLASS_PARAM_NAME, CSSERRORCLASS_PARAM_IDX)
-                    );
-
     protected static final ArgumentArrayLayout ARGS_LAYOUT =
             ArgumentArrayLayout.create(
                     1,
                     false,
-                    StringToIndexMap.of(NAMED_ARGS_ENTRIES),
+                    StringToIndexMap.of(AbstractDataBoundFormElementTemplateDirectiveModel.ARGS_LAYOUT.getPredefinedNamedArgumentsMap(),
+                            new StringToIndexMap.Entry(CSS_CLASS_PARAM_NAME, CSS_CLASS_PARAM_IDX),
+                            new StringToIndexMap.Entry(CSS_STYLE_PARAM_NAME, CSS_STYLE_PARAM_IDX),
+                            new StringToIndexMap.Entry(LANG_PARAM_NAME, LANG_PARAM_IDX),
+                            new StringToIndexMap.Entry(TITLE_PARAM_NAME, TITLE_PARAM_IDX),
+                            new StringToIndexMap.Entry(DIR_PARAM_NAME, DIR_PARAM_IDX),
+                            new StringToIndexMap.Entry(TABINDEX_PARAM_NAME, TABINDEX_PARAM_IDX),
+                            new StringToIndexMap.Entry(ONCLICK_PARAM_NAME, ONCLICK_PARAM_IDX),
+                            new StringToIndexMap.Entry(ONDBLCLICK_PARAM_NAME, ONDBLCLICK_PARAM_IDX),
+                            new StringToIndexMap.Entry(ONMOUSEDOWN_PARAM_NAME, ONMOUSEDOWN_PARAM_IDX),
+                            new StringToIndexMap.Entry(ONMOUSEUP_PARAM_NAME, ONMOUSEUP_PARAM_IDX),
+                            new StringToIndexMap.Entry(ONMOUSEOVER_PARAM_NAME, ONMOUSEOVER_PARAM_IDX),
+                            new StringToIndexMap.Entry(ONMOUSEMOVE_PARAM_NAME, ONMOUSEMOVE_PARAM_IDX),
+                            new StringToIndexMap.Entry(ONMOUSEOUT_PARAM_NAME, ONMOUSEOUT_PARAM_IDX),
+                            new StringToIndexMap.Entry(ONKEYPRESS_PARAM_NAME, ONKEYPRESS_PARAM_IDX),
+                            new StringToIndexMap.Entry(ONKEYUP_PARAM_NAME, ONKEYUP_PARAM_IDX),
+                            new StringToIndexMap.Entry(ONKEYDOWN_PARAM_NAME, ONKEYDOWN_PARAM_IDX),
+                            new StringToIndexMap.Entry(CSSERRORCLASS_PARAM_NAME, CSSERRORCLASS_PARAM_IDX)
+                            ),
                     true
                     );
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/0f45c1da/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/AbstractHtmlInputElementTemplateDirectiveModel.java
----------------------------------------------------------------------
diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/AbstractHtmlInputElementTemplateDirectiveModel.java
b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/AbstractHtmlInputElementTemplateDirectiveModel.java
index fd48eae..baee0d5 100644
--- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/AbstractHtmlInputElementTemplateDirectiveModel.java
+++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/AbstractHtmlInputElementTemplateDirectiveModel.java
@@ -33,7 +33,6 @@ import org.apache.freemarker.core.model.ObjectWrapperAndUnwrapper;
 import org.apache.freemarker.core.model.TemplateModel;
 import org.apache.freemarker.core.util.CallableUtils;
 import org.apache.freemarker.core.util.StringToIndexMap;
-import org.apache.freemarker.core.util._ArrayUtils;
 import org.springframework.web.servlet.support.RequestContext;
 
 abstract class AbstractHtmlInputElementTemplateDirectiveModel extends AbstractHtmlElementTemplateDirectiveModel
{
@@ -59,23 +58,18 @@ abstract class AbstractHtmlInputElementTemplateDirectiveModel extends
AbstractHt
     private static final int READONLY_PARAM_IDX = NAMED_ARGS_OFFSET + 5;
     private static final String READONLY_PARAM_NAME = "readonly";
 
-    private static final StringToIndexMap.Entry[] NAMED_ARGS_ENTRIES =
-            _ArrayUtils.addAll(
-                    AbstractHtmlElementTemplateDirectiveModel.ARGS_LAYOUT.getPredefinedNamedArgumentsMap()
-                            .getInputEntries(),
-                    new StringToIndexMap.Entry(ONFOCUS_PARAM_NAME, ONFOCUS_PARAM_IDX),
-                    new StringToIndexMap.Entry(ONBLUR_PARAM_NAME, ONBLUR_PARAM_IDX),
-                    new StringToIndexMap.Entry(ONCHANGE_PARAM_NAME, ONCHANGE_PARAM_IDX),
-                    new StringToIndexMap.Entry(ACCESSKEY_PARAM_NAME, ACCESSKEY_PARAM_IDX),
-                    new StringToIndexMap.Entry(DISABLED_PARAM_NAME, DISABLED_PARAM_IDX),
-                    new StringToIndexMap.Entry(READONLY_PARAM_NAME, READONLY_PARAM_IDX)
-                    );
-
     protected static final ArgumentArrayLayout ARGS_LAYOUT =
             ArgumentArrayLayout.create(
                     1,
                     false,
-                    StringToIndexMap.of(NAMED_ARGS_ENTRIES),
+                    StringToIndexMap.of(AbstractHtmlElementTemplateDirectiveModel.ARGS_LAYOUT.getPredefinedNamedArgumentsMap(),
+                            new StringToIndexMap.Entry(ONFOCUS_PARAM_NAME, ONFOCUS_PARAM_IDX),
+                            new StringToIndexMap.Entry(ONBLUR_PARAM_NAME, ONBLUR_PARAM_IDX),
+                            new StringToIndexMap.Entry(ONCHANGE_PARAM_NAME, ONCHANGE_PARAM_IDX),
+                            new StringToIndexMap.Entry(ACCESSKEY_PARAM_NAME, ACCESSKEY_PARAM_IDX),
+                            new StringToIndexMap.Entry(DISABLED_PARAM_NAME, DISABLED_PARAM_IDX),
+                            new StringToIndexMap.Entry(READONLY_PARAM_NAME, READONLY_PARAM_IDX)
+                            ),
                     true
                     );
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/0f45c1da/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/FormTemplateDirectiveModel.java
----------------------------------------------------------------------
diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/FormTemplateDirectiveModel.java
b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/FormTemplateDirectiveModel.java
index a453a76..985cb7d 100644
--- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/FormTemplateDirectiveModel.java
+++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/FormTemplateDirectiveModel.java
@@ -35,7 +35,6 @@ import org.apache.freemarker.core.model.TemplateModel;
 import org.apache.freemarker.core.model.TemplateStringModel;
 import org.apache.freemarker.core.util.CallableUtils;
 import org.apache.freemarker.core.util.StringToIndexMap;
-import org.apache.freemarker.core.util._ArrayUtils;
 import org.apache.freemarker.spring.model.SpringTemplateCallableHashModel;
 import org.springframework.beans.PropertyAccessor;
 import org.springframework.http.HttpMethod;
@@ -118,30 +117,25 @@ class FormTemplateDirectiveModel extends AbstractHtmlElementTemplateDirectiveMod
     private static final int METHOD_PARAM_PARAM_IDX = NAMED_ARGS_OFFSET + 12;
     private static final String METHOD_PARAM_PARAM_NAME = "methodParam";
 
-    private static final StringToIndexMap.Entry[] NAMED_ARGS_ENTRIES =
-            _ArrayUtils.addAll(
-                    AbstractHtmlElementTemplateDirectiveModel.ARGS_LAYOUT.getPredefinedNamedArgumentsMap()
-                            .getInputEntries(),
-                    new StringToIndexMap.Entry(ACTION_PARAM_NAME, ACTION_PARAM_IDX),
-                    new StringToIndexMap.Entry(METHOD_PARAM_NAME, METHOD_PARAM_IDX),
-                    new StringToIndexMap.Entry(TARGET_PARAM_NAME, TARGET_PARAM_IDX),
-                    new StringToIndexMap.Entry(ENCTYPE_PARAM_NAME, ENCTYPE_PARAM_IDX),
-                    new StringToIndexMap.Entry(ACCEPT_CHARSET_PARAM_NAME, ACCEPT_CHARSET_PARAM_IDX),
-                    new StringToIndexMap.Entry(ONSUBMIT_PARAM_NAME, ONSUBMIT_PARAM_IDX),
-                    new StringToIndexMap.Entry(ONRESET_PARAM_NAME, ONRESET_PARAM_IDX),
-                    new StringToIndexMap.Entry(AUTOCOMPLETE_PARAM_NAME, AUTOCOMPLETE_PARAM_IDX),
-                    new StringToIndexMap.Entry(NAME_PARAM_NAME, NAME_PARAM_IDX),
-                    new StringToIndexMap.Entry(VALUE_PARAM_NAME, VALUE_PARAM_IDX),
-                    new StringToIndexMap.Entry(TYPE_PARAM_NAME, TYPE_PARAM_IDX),
-                    new StringToIndexMap.Entry(SERVLET_RELATIVE_ACTION_PARAM_NAME, SERVLET_RELATIVE_ACTION_PARAM_IDX),
-                    new StringToIndexMap.Entry(METHOD_PARAM_PARAM_NAME, METHOD_PARAM_PARAM_IDX)
-                    );
-
     protected static final ArgumentArrayLayout ARGS_LAYOUT =
             ArgumentArrayLayout.create(
                     1,
                     false,
-                    StringToIndexMap.of(NAMED_ARGS_ENTRIES),
+                    StringToIndexMap.of(AbstractHtmlElementTemplateDirectiveModel.ARGS_LAYOUT.getPredefinedNamedArgumentsMap(),
+                            new StringToIndexMap.Entry(ACTION_PARAM_NAME, ACTION_PARAM_IDX),
+                            new StringToIndexMap.Entry(METHOD_PARAM_NAME, METHOD_PARAM_IDX),
+                            new StringToIndexMap.Entry(TARGET_PARAM_NAME, TARGET_PARAM_IDX),
+                            new StringToIndexMap.Entry(ENCTYPE_PARAM_NAME, ENCTYPE_PARAM_IDX),
+                            new StringToIndexMap.Entry(ACCEPT_CHARSET_PARAM_NAME, ACCEPT_CHARSET_PARAM_IDX),
+                            new StringToIndexMap.Entry(ONSUBMIT_PARAM_NAME, ONSUBMIT_PARAM_IDX),
+                            new StringToIndexMap.Entry(ONRESET_PARAM_NAME, ONRESET_PARAM_IDX),
+                            new StringToIndexMap.Entry(AUTOCOMPLETE_PARAM_NAME, AUTOCOMPLETE_PARAM_IDX),
+                            new StringToIndexMap.Entry(NAME_PARAM_NAME, NAME_PARAM_IDX),
+                            new StringToIndexMap.Entry(VALUE_PARAM_NAME, VALUE_PARAM_IDX),
+                            new StringToIndexMap.Entry(TYPE_PARAM_NAME, TYPE_PARAM_IDX),
+                            new StringToIndexMap.Entry(SERVLET_RELATIVE_ACTION_PARAM_NAME,
SERVLET_RELATIVE_ACTION_PARAM_IDX),
+                            new StringToIndexMap.Entry(METHOD_PARAM_PARAM_NAME, METHOD_PARAM_PARAM_IDX)
+                            ),
                     true
                     );
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/0f45c1da/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/InputTemplateDirectiveModel.java
----------------------------------------------------------------------
diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/InputTemplateDirectiveModel.java
b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/InputTemplateDirectiveModel.java
index a38e3c3..67f63be 100644
--- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/InputTemplateDirectiveModel.java
+++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/model/form/InputTemplateDirectiveModel.java
@@ -33,7 +33,6 @@ import org.apache.freemarker.core.model.ObjectWrapperAndUnwrapper;
 import org.apache.freemarker.core.model.TemplateModel;
 import org.apache.freemarker.core.util.CallableUtils;
 import org.apache.freemarker.core.util.StringToIndexMap;
-import org.apache.freemarker.core.util._ArrayUtils;
 import org.springframework.web.servlet.support.RequestContext;
 
 /**
@@ -88,22 +87,17 @@ class InputTemplateDirectiveModel extends AbstractHtmlInputElementTemplateDirect
     private static final int AUTOCOMPLETE_PARAM_IDX = NAMED_ARGS_OFFSET + 4;
     private static final String AUTOCOMPLETE_PARAM_NAME = "autocomplete";
 
-    private static final StringToIndexMap.Entry[] NAMED_ARGS_ENTRIES =
-            _ArrayUtils.addAll(
-                    AbstractHtmlInputElementTemplateDirectiveModel.ARGS_LAYOUT.getPredefinedNamedArgumentsMap()
-                            .getInputEntries(),
-                    new StringToIndexMap.Entry(SIZE_PARAM_NAME, SIZE_PARAM_IDX),
-                    new StringToIndexMap.Entry(MAXLENGTH_PARAM_NAME, MAXLENGTH_PARAM_IDX),
-                    new StringToIndexMap.Entry(ALT_PARAM_NAME, ALT_PARAM_IDX),
-                    new StringToIndexMap.Entry(ONSELECT_PARAM_NAME, ONSELECT_PARAM_IDX),
-                    new StringToIndexMap.Entry(AUTOCOMPLETE_PARAM_NAME, AUTOCOMPLETE_PARAM_IDX)
-                    );
-
     protected static final ArgumentArrayLayout ARGS_LAYOUT =
             ArgumentArrayLayout.create(
                     1,
                     false,
-                    StringToIndexMap.of(NAMED_ARGS_ENTRIES),
+                    StringToIndexMap.of(AbstractHtmlInputElementTemplateDirectiveModel.ARGS_LAYOUT.getPredefinedNamedArgumentsMap(),
+                            new StringToIndexMap.Entry(SIZE_PARAM_NAME, SIZE_PARAM_IDX),
+                            new StringToIndexMap.Entry(MAXLENGTH_PARAM_NAME, MAXLENGTH_PARAM_IDX),
+                            new StringToIndexMap.Entry(ALT_PARAM_NAME, ALT_PARAM_IDX),
+                            new StringToIndexMap.Entry(ONSELECT_PARAM_NAME, ONSELECT_PARAM_IDX),
+                            new StringToIndexMap.Entry(AUTOCOMPLETE_PARAM_NAME, AUTOCOMPLETE_PARAM_IDX)
+                            ),
                     true
                     );
 


Mime
View raw message