You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2014/02/21 08:28:25 UTC

[01/11] WICKET-4795 Wicket unit tests rely on hashmap iteration order

Repository: wicket
Updated Branches:
  refs/heads/sandbox/component-queueing-2 1fd9d57c0 -> e3328f141


http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/main/java/org/apache/wicket/ajax/json/XML.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/XML.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/XML.java
index b8705d6..0767e34 100755
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/XML.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/XML.java
@@ -31,11 +31,11 @@ import java.util.Iterator;
  * This provides static methods to convert an XML text into a JSONObject,
  * and to covert a JSONObject into an XML text.
  * @author JSON.org
- * @version 2011-02-11
+ * @version 2013-11-12
  */
 public class XML {
 
-    /** The Character '&'. */
+    /** The Character '&'. */
     public static final Character AMP   = new Character('&');
 
     /** The Character '''. */
@@ -50,7 +50,7 @@ public class XML {
     /** The Character '>'. */
     public static final Character GT    = new Character('>');
 
-    /** The Character '<'. */
+    /** The Character '&lt;'. */
     public static final Character LT    = new Character('<');
 
     /** The Character '?'. */
@@ -99,21 +99,22 @@ public class XML {
         }
         return sb.toString();
     }
-    
+
     /**
-     * Throw an exception if the string contains whitespace. 
+     * Throw an exception if the string contains whitespace.
      * Whitespace is not allowed in tagNames and attributes.
      * @param string
      * @throws JSONException
      */
-    public static void noSpace(String string) throws JSONException {
+    public static void noSpace(String string) throws JSONException
+    {
         int i, length = string.length();
         if (length == 0) {
             throw new JSONException("Empty string.");
         }
         for (i = 0; i < length; i += 1) {
             if (Character.isWhitespace(string.charAt(i))) {
-                throw new JSONException("'" + string + 
+                throw new JSONException("'" + string +
                         "' contains a space character.");
             }
         }
@@ -196,7 +197,7 @@ public class XML {
             token = x.nextToken();
             if (name == null) {
                 throw x.syntaxError("Mismatched close tag " + token);
-            }            
+            }
             if (!token.equals(name)) {
                 throw x.syntaxError("Mismatched " + name + " and " + token);
             }
@@ -229,7 +230,7 @@ public class XML {
                         if (!(token instanceof String)) {
                             throw x.syntaxError("Missing value");
                         }
-                        jsonobject.accumulate(string, 
+                        jsonobject.accumulate(string,
                                 XML.stringToValue((String)token));
                         token = null;
                     } else {
@@ -262,7 +263,7 @@ public class XML {
                         } else if (token instanceof String) {
                             string = (String)token;
                             if (string.length() > 0) {
-                                jsonobject.accumulate("content", 
+                                jsonobject.accumulate("content",
                                         XML.stringToValue(string));
                             }
 
@@ -274,7 +275,7 @@ public class XML {
                                     context.accumulate(tagName, "");
                                 } else if (jsonobject.length() == 1 &&
                                        jsonobject.opt("content") != null) {
-                                    context.accumulate(tagName, 
+                                    context.accumulate(tagName,
                                             jsonobject.opt("content"));
                                 } else {
                                     context.accumulate(tagName, jsonobject);
@@ -295,15 +296,12 @@ public class XML {
      * Try to convert a string into a number, boolean, or null. If the string
      * can't be converted, return the string. This is much less ambitious than
      * JSONObject.stringToValue, especially because it does not attempt to
-     * convert plus forms, octal forms, hex forms, or E forms lacking decimal 
+     * convert plus forms, octal forms, hex forms, or E forms lacking decimal
      * points.
      * @param string A String.
      * @return A simple JSON value.
      */
     public static Object stringToValue(String string) {
-        if ("".equals(string)) {
-            return string;
-        }
         if ("true".equalsIgnoreCase(string)) {
             return Boolean.TRUE;
         }
@@ -313,41 +311,31 @@ public class XML {
         if ("null".equalsIgnoreCase(string)) {
             return JSONObject.NULL;
         }
-        if ("0".equals(string)) {
-            return new Integer(0);
-        }
 
-// If it might be a number, try converting it. If that doesn't work, 
-// return the string.
+// If it might be a number, try converting it, first as a Long, and then as a
+// Double. If that doesn't work, return the string.
 
         try {
             char initial = string.charAt(0);
-            boolean negative = false;
-            if (initial == '-') {
-                initial = string.charAt(1);
-                negative = true;
-            }
-            if (initial == '0' && string.charAt(negative ? 2 : 1) == '0') {
-                return string;
-            }
-            if ((initial >= '0' && initial <= '9')) {
-                if (string.indexOf('.') >= 0) {
-                    return Double.valueOf(string);
-                } else if (string.indexOf('e') < 0 && string.indexOf('E') < 0) {
-                    Long myLong = new Long(string);
-                    if (myLong.longValue() == myLong.intValue()) {
-                        return new Integer(myLong.intValue());
-                    } else {
-                        return myLong;
-                    }
+            if (initial == '-' || (initial >= '0' && initial <= '9')) {
+                Long value = new Long(string);
+                if (value.toString().equals(string)) {
+                    return value;
                 }
             }
         }  catch (Exception ignore) {
+            try {
+                Double value = new Double(string);
+                if (value.toString().equals(string)) {
+                    return value;
+                }
+            }  catch (Exception ignoreAlso) {
+            }
         }
         return string;
     }
 
-    
+
     /**
      * Convert a well-formed (but not necessarily valid) XML string into a
      * JSONObject. Some information may be lost in this transformation
@@ -394,7 +382,7 @@ public class XML {
             throws JSONException {
         StringBuffer sb = new StringBuffer();
         int          i;
-        JSONArray    ja;
+        JSONArray ja;
         JSONObject   jo;
         String       key;
         Iterator     keys;
@@ -505,4 +493,4 @@ public class XML {
             }
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/main/java/org/apache/wicket/ajax/json/XMLTokener.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/XMLTokener.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/XMLTokener.java
index 3b80154..c20500d 100755
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/XMLTokener.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/XMLTokener.java
@@ -1,365 +1,367 @@
-package org.apache.wicket.ajax.json;
-
-/*
-Copyright (c) 2002 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-/**
- * The XMLTokener extends the JSONTokener to provide additional methods
- * for the parsing of XML texts.
- * @author JSON.org
- * @version 2010-12-24
- */
-public class XMLTokener extends JSONTokener {
-
-
-   /** The table of entity values. It initially contains Character values for
-    * amp, apos, gt, lt, quot.
-    */
-   public static final java.util.HashMap entity;
-
-   static {
-       entity = new java.util.HashMap(8);
-       entity.put("amp",  XML.AMP);
-       entity.put("apos", XML.APOS);
-       entity.put("gt",   XML.GT);
-       entity.put("lt",   XML.LT);
-       entity.put("quot", XML.QUOT);
-   }
-
-    /**
-     * Construct an XMLTokener from a string.
-     * @param s A source string.
-     */
-    public XMLTokener(String s) {
-        super(s);
-    }
-
-    /**
-     * Get the text in the CDATA block.
-     * @return The string up to the <code>]]&gt;</code>.
-     * @throws JSONException If the <code>]]&gt;</code> is not found.
-     */
-    public String nextCDATA() throws JSONException {
-        char         c;
-        int          i;
-        StringBuffer sb = new StringBuffer();
-        for (;;) {
-            c = next();
-            if (end()) {
-                throw syntaxError("Unclosed CDATA");
-            }
-            sb.append(c);
-            i = sb.length() - 3;
-            if (i >= 0 && sb.charAt(i) == ']' &&
-                          sb.charAt(i + 1) == ']' && sb.charAt(i + 2) == '>') {
-                sb.setLength(i);
-                return sb.toString();
-            }
-        }
-    }
-
-
-    /**
-     * Get the next XML outer token, trimming whitespace. There are two kinds
-     * of tokens: the '<' character which begins a markup tag, and the content
-     * text between markup tags.
-     *
-     * @return  A string, or a '<' Character, or null if there is no more
-     * source text.
-     * @throws JSONException
-     */
-    public Object nextContent() throws JSONException {
-        char         c;
-        StringBuffer sb;
-        do {
-            c = next();
-        } while (Character.isWhitespace(c));
-        if (c == 0) {
-            return null;
-        }
-        if (c == '<') {
-            return XML.LT;
-        }
-        sb = new StringBuffer();
-        for (;;) {
-            if (c == '<' || c == 0) {
-                back();
-                return sb.toString().trim();
-            }
-            if (c == '&') {
-                sb.append(nextEntity(c));
-            } else {
-                sb.append(c);
-            }
-            c = next();
-        }
-    }
-
-
-    /**
-     * Return the next entity. These entities are translated to Characters:
-     *     <code>&amp;  &apos;  &gt;  &lt;  &quot;</code>.
-     * @param ampersand An ampersand character.
-     * @return  A Character or an entity String if the entity is not recognized.
-     * @throws JSONException If missing ';' in XML entity.
-     */
-    public Object nextEntity(char ampersand) throws JSONException {
-        StringBuffer sb = new StringBuffer();
-        for (;;) {
-            char c = next();
-            if (Character.isLetterOrDigit(c) || c == '#') {
-                sb.append(Character.toLowerCase(c));
-            } else if (c == ';') {
-                break;
-            } else {
-                throw syntaxError("Missing ';' in XML entity: &" + sb);
-            }
-        }
-        String string = sb.toString();
-        Object object = entity.get(string);
-        return object != null ? object : ampersand + string + ";";
-    }
-
-
-    /**
-     * Returns the next XML meta token. This is used for skipping over <!...>
-     * and <?...?> structures.
-     * @return Syntax characters (<code>< > / = ! ?</code>) are returned as
-     *  Character, and strings and names are returned as Boolean. We don't care
-     *  what the values actually are.
-     * @throws JSONException If a string is not properly closed or if the XML
-     *  is badly structured.
-     */
-    public Object nextMeta() throws JSONException {
-        char c;
-        char q;
-        do {
-            c = next();
-        } while (Character.isWhitespace(c));
-        switch (c) {
-        case 0:
-            throw syntaxError("Misshaped meta tag");
-        case '<':
-            return XML.LT;
-        case '>':
-            return XML.GT;
-        case '/':
-            return XML.SLASH;
-        case '=':
-            return XML.EQ;
-        case '!':
-            return XML.BANG;
-        case '?':
-            return XML.QUEST;
-        case '"':
-        case '\'':
-            q = c;
-            for (;;) {
-                c = next();
-                if (c == 0) {
-                    throw syntaxError("Unterminated string");
-                }
-                if (c == q) {
-                    return Boolean.TRUE;
-                }
-            }
-        default:
-            for (;;) {
-                c = next();
-                if (Character.isWhitespace(c)) {
-                    return Boolean.TRUE;
-                }
-                switch (c) {
-                case 0:
-                case '<':
-                case '>':
-                case '/':
-                case '=':
-                case '!':
-                case '?':
-                case '"':
-                case '\'':
-                    back();
-                    return Boolean.TRUE;
-                }
-            }
-        }
-    }
-
-
-    /**
-     * Get the next XML Token. These tokens are found inside of angle
-     * brackets. It may be one of these characters: <code>/ > = ! ?</code> or it
-     * may be a string wrapped in single quotes or double quotes, or it may be a
-     * name.
-     * @return a String or a Character.
-     * @throws JSONException If the XML is not well formed.
-     */
-    public Object nextToken() throws JSONException {
-        char c;
-        char q;
-        StringBuffer sb;
-        do {
-            c = next();
-        } while (Character.isWhitespace(c));
-        switch (c) {
-        case 0:
-            throw syntaxError("Misshaped element");
-        case '<':
-            throw syntaxError("Misplaced '<'");
-        case '>':
-            return XML.GT;
-        case '/':
-            return XML.SLASH;
-        case '=':
-            return XML.EQ;
-        case '!':
-            return XML.BANG;
-        case '?':
-            return XML.QUEST;
-
-// Quoted string
-
-        case '"':
-        case '\'':
-            q = c;
-            sb = new StringBuffer();
-            for (;;) {
-                c = next();
-                if (c == 0) {
-                    throw syntaxError("Unterminated string");
-                }
-                if (c == q) {
-                    return sb.toString();
-                }
-                if (c == '&') {
-                    sb.append(nextEntity(c));
-                } else {
-                    sb.append(c);
-                }
-            }
-        default:
-
-// Name
-
-            sb = new StringBuffer();
-            for (;;) {
-                sb.append(c);
-                c = next();
-                if (Character.isWhitespace(c)) {
-                    return sb.toString();
-                }
-                switch (c) {
-                case 0:
-                    return sb.toString();
-                case '>':
-                case '/':
-                case '=':
-                case '!':
-                case '?':
-                case '[':
-                case ']':
-                    back();
-                    return sb.toString();
-                case '<':
-                case '"':
-                case '\'':
-                    throw syntaxError("Bad character in a name");
-                }
-            }
-        }
-    }
-    
-    
-    /**
-     * Skip characters until past the requested string.
-     * If it is not found, we are left at the end of the source with a result of false.
-     * @param to A string to skip past.
-     * @throws JSONException
-     */
-    public boolean skipPast(String to) throws JSONException {
-        boolean b;
-        char c;
-        int i;
-        int j;
-        int offset = 0;
-        int length = to.length();
-        char[] circle = new char[length];
-        
-        /*
-         * First fill the circle buffer with as many characters as are in the
-         * to string. If we reach an early end, bail.
-         */
-        
-        for (i = 0; i < length; i += 1) {
-            c = next();
-            if (c == 0) {
-                return false;
-            }
-            circle[i] = c;
-        }
-        /*
-         * We will loop, possibly for all of the remaining characters.
-         */
-        for (;;) {
-            j = offset;
-            b = true;
-            /*
-             * Compare the circle buffer with the to string. 
-             */
-            for (i = 0; i < length; i += 1) {
-                if (circle[j] != to.charAt(i)) {
-                    b = false;
-                    break;
-                }
-                j += 1;
-                if (j >= length) {
-                    j -= length;
-                }
-            }
-            /*
-             * If we exit the loop with b intact, then victory is ours.
-             */
-            if (b) {
-                return true;
-            }
-            /*
-             * Get the next character. If there isn't one, then defeat is ours.
-             */
-            c = next();
-            if (c == 0) {
-                return false;
-            }
-            /*
-             * Shove the character in the circle buffer and advance the 
-             * circle offset. The offset is mod n.
-             */
-            circle[offset] = c;
-            offset += 1;
-            if (offset >= length) {
-                offset -= length;
-            }
-        }
-    }
-}
+package org.apache.wicket.ajax.json;
+
+/*
+Copyright (c) 2002 JSON.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+/**
+ * The XMLTokener extends the JSONTokener to provide additional methods
+ * for the parsing of XML texts.
+ * @author JSON.org
+ * @version 2012-11-13
+ */
+public class XMLTokener extends JSONTokener
+{
+
+
+   /** The table of entity values. It initially contains Character values for
+    * amp, apos, gt, lt, quot.
+    */
+   public static final java.util.HashMap entity;
+
+   static {
+       entity = new java.util.HashMap(8);
+       entity.put("amp",  XML.AMP);
+       entity.put("apos", XML.APOS);
+       entity.put("gt",   XML.GT);
+       entity.put("lt",   XML.LT);
+       entity.put("quot", XML.QUOT);
+   }
+
+    /**
+     * Construct an XMLTokener from a string.
+     * @param s A source string.
+     */
+    public XMLTokener(String s) {
+        super(s);
+    }
+
+    /**
+     * Get the text in the CDATA block.
+     * @return The string up to the <code>]]&gt;</code>.
+     * @throws JSONException If the <code>]]&gt;</code> is not found.
+     */
+    public String nextCDATA() throws JSONException
+    {
+        char         c;
+        int          i;
+        StringBuffer sb = new StringBuffer();
+        for (;;) {
+            c = next();
+            if (end()) {
+                throw syntaxError("Unclosed CDATA");
+            }
+            sb.append(c);
+            i = sb.length() - 3;
+            if (i >= 0 && sb.charAt(i) == ']' &&
+                          sb.charAt(i + 1) == ']' && sb.charAt(i + 2) == '>') {
+                sb.setLength(i);
+                return sb.toString();
+            }
+        }
+    }
+
+
+    /**
+     * Get the next XML outer token, trimming whitespace. There are two kinds
+     * of tokens: the '<' character which begins a markup tag, and the content
+     * text between markup tags.
+     *
+     * @return  A string, or a '<' Character, or null if there is no more
+     * source text.
+     * @throws JSONException
+     */
+    public Object nextContent() throws JSONException {
+        char         c;
+        StringBuffer sb;
+        do {
+            c = next();
+        } while (Character.isWhitespace(c));
+        if (c == 0) {
+            return null;
+        }
+        if (c == '<') {
+            return XML.LT;
+        }
+        sb = new StringBuffer();
+        for (;;) {
+            if (c == '<' || c == 0) {
+                back();
+                return sb.toString().trim();
+            }
+            if (c == '&') {
+                sb.append(nextEntity(c));
+            } else {
+                sb.append(c);
+            }
+            c = next();
+        }
+    }
+
+
+    /**
+     * Return the next entity. These entities are translated to Characters:
+     *     <code>&amp;  &apos;  &gt;  &lt;  &quot;</code>.
+     * @param ampersand An ampersand character.
+     * @return  A Character or an entity String if the entity is not recognized.
+     * @throws JSONException If missing ';' in XML entity.
+     */
+    public Object nextEntity(char ampersand) throws JSONException {
+        StringBuffer sb = new StringBuffer();
+        for (;;) {
+            char c = next();
+            if (Character.isLetterOrDigit(c) || c == '#') {
+                sb.append(Character.toLowerCase(c));
+            } else if (c == ';') {
+                break;
+            } else {
+                throw syntaxError("Missing ';' in XML entity: &" + sb);
+            }
+        }
+        String string = sb.toString();
+        Object object = entity.get(string);
+        return object != null ? object : ampersand + string + ";";
+    }
+
+
+    /**
+     * Returns the next XML meta token. This is used for skipping over <!...>
+     * and <?...?> structures.
+     * @return Syntax characters (<code>< > / = ! ?</code>) are returned as
+     *  Character, and strings and names are returned as Boolean. We don't care
+     *  what the values actually are.
+     * @throws JSONException If a string is not properly closed or if the XML
+     *  is badly structured.
+     */
+    public Object nextMeta() throws JSONException {
+        char c;
+        char q;
+        do {
+            c = next();
+        } while (Character.isWhitespace(c));
+        switch (c) {
+        case 0:
+            throw syntaxError("Misshaped meta tag");
+        case '<':
+            return XML.LT;
+        case '>':
+            return XML.GT;
+        case '/':
+            return XML.SLASH;
+        case '=':
+            return XML.EQ;
+        case '!':
+            return XML.BANG;
+        case '?':
+            return XML.QUEST;
+        case '"':
+        case '\'':
+            q = c;
+            for (;;) {
+                c = next();
+                if (c == 0) {
+                    throw syntaxError("Unterminated string");
+                }
+                if (c == q) {
+                    return Boolean.TRUE;
+                }
+            }
+        default:
+            for (;;) {
+                c = next();
+                if (Character.isWhitespace(c)) {
+                    return Boolean.TRUE;
+                }
+                switch (c) {
+                case 0:
+                case '<':
+                case '>':
+                case '/':
+                case '=':
+                case '!':
+                case '?':
+                case '"':
+                case '\'':
+                    back();
+                    return Boolean.TRUE;
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Get the next XML Token. These tokens are found inside of angle
+     * brackets. It may be one of these characters: <code>/ > = ! ?</code> or it
+     * may be a string wrapped in single quotes or double quotes, or it may be a
+     * name.
+     * @return a String or a Character.
+     * @throws JSONException If the XML is not well formed.
+     */
+    public Object nextToken() throws JSONException {
+        char c;
+        char q;
+        StringBuffer sb;
+        do {
+            c = next();
+        } while (Character.isWhitespace(c));
+        switch (c) {
+        case 0:
+            throw syntaxError("Misshaped element");
+        case '<':
+            throw syntaxError("Misplaced '<'");
+        case '>':
+            return XML.GT;
+        case '/':
+            return XML.SLASH;
+        case '=':
+            return XML.EQ;
+        case '!':
+            return XML.BANG;
+        case '?':
+            return XML.QUEST;
+
+// Quoted string
+
+        case '"':
+        case '\'':
+            q = c;
+            sb = new StringBuffer();
+            for (;;) {
+                c = next();
+                if (c == 0) {
+                    throw syntaxError("Unterminated string");
+                }
+                if (c == q) {
+                    return sb.toString();
+                }
+                if (c == '&') {
+                    sb.append(nextEntity(c));
+                } else {
+                    sb.append(c);
+                }
+            }
+        default:
+
+// Name
+
+            sb = new StringBuffer();
+            for (;;) {
+                sb.append(c);
+                c = next();
+                if (Character.isWhitespace(c)) {
+                    return sb.toString();
+                }
+                switch (c) {
+                case 0:
+                    return sb.toString();
+                case '>':
+                case '/':
+                case '=':
+                case '!':
+                case '?':
+                case '[':
+                case ']':
+                    back();
+                    return sb.toString();
+                case '<':
+                case '"':
+                case '\'':
+                    throw syntaxError("Bad character in a name");
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Skip characters until past the requested string.
+     * If it is not found, we are left at the end of the source with a result of false.
+     * @param to A string to skip past.
+     * @throws JSONException
+     */
+    public boolean skipPast(String to) throws JSONException {
+        boolean b;
+        char c;
+        int i;
+        int j;
+        int offset = 0;
+        int length = to.length();
+        char[] circle = new char[length];
+
+        /*
+         * First fill the circle buffer with as many characters as are in the
+         * to string. If we reach an early end, bail.
+         */
+
+        for (i = 0; i < length; i += 1) {
+            c = next();
+            if (c == 0) {
+                return false;
+            }
+            circle[i] = c;
+        }
+
+        /* We will loop, possibly for all of the remaining characters. */
+
+        for (;;) {
+            j = offset;
+            b = true;
+
+            /* Compare the circle buffer with the to string. */
+
+            for (i = 0; i < length; i += 1) {
+                if (circle[j] != to.charAt(i)) {
+                    b = false;
+                    break;
+                }
+                j += 1;
+                if (j >= length) {
+                    j -= length;
+                }
+            }
+
+            /* If we exit the loop with b intact, then victory is ours. */
+
+            if (b) {
+                return true;
+            }
+
+            /* Get the next character. If there isn't one, then defeat is ours. */
+
+            c = next();
+            if (c == 0) {
+                return false;
+            }
+            /*
+             * Shove the character in the circle buffer and advance the
+             * circle offset. The offset is mod n.
+             */
+            circle[offset] = c;
+            offset += 1;
+            if (offset >= length) {
+                offset -= length;
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
index 53b18f7..5baddfa 100755
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
@@ -270,7 +270,7 @@ public class MockHttpServletRequest implements HttpServletRequest
 
 		if (uploadedFiles == null)
 		{
-			uploadedFiles = new HashMap<String, List<UploadedFile>>();
+			uploadedFiles = new HashMap<>();
 		}
 
 		UploadedFile uf = new UploadedFile(fieldName, file, contentType);
@@ -278,7 +278,7 @@ public class MockHttpServletRequest implements HttpServletRequest
 		List<UploadedFile> filesPerField = uploadedFiles.get(fieldName);
 		if (filesPerField == null)
 		{
-			filesPerField = new ArrayList<UploadedFile>();
+			filesPerField = new ArrayList<>();
 			uploadedFiles.put(fieldName, filesPerField);
 		}
 
@@ -300,7 +300,7 @@ public class MockHttpServletRequest implements HttpServletRequest
 		List<String> list = (List<String>)headers.get(name);
 		if (list == null)
 		{
-			list = new ArrayList<String>(1);
+			list = new ArrayList<>(1);
 			headers.put(name, list);
 		}
 		list.add(value);
@@ -729,7 +729,7 @@ public class MockHttpServletRequest implements HttpServletRequest
 	@Override
 	public Map<String, String[]> getParameterMap()
 	{
-		Map<String, String[]> params = new HashMap<String, String[]>(parameters);
+		Map<String, String[]> params = new HashMap<>(parameters);
 
 		for (String name : post.getParameterNames())
 		{

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/test/java/org/apache/wicket/TestDetachPageAjaxResult.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/TestDetachPageAjaxResult.html b/wicket-core/src/test/java/org/apache/wicket/TestDetachPageAjaxResult.html
index 371dc0f..9109f77 100644
--- a/wicket-core/src/test/java/org/apache/wicket/TestDetachPageAjaxResult.html
+++ b/wicket-core/src/test/java/org/apache/wicket/TestDetachPageAjaxResult.html
@@ -12,4 +12,4 @@ Wicket.Ajax.DebugWindow.enabled=true;
 Wicket.Ajax.baseUrl="wicket/bookmarkable/org.apache.wicket.TestDetachPage?0-1.IBehaviorListener.0-comp";
 /*]^]^>*/
 </script>
-</head>]]></header-contribution><evaluate><![CDATA[(function(){Wicket.Ajax.ajax({"u":"./org.apache.wicket.TestDetachPage?0-1.IBehaviorListener.0-comp","e":"click","c":"comp1"});})();]]></evaluate></ajax-response>
\ No newline at end of file
+</head>]]></header-contribution><evaluate><![CDATA[(function(){Wicket.Ajax.ajax({"u":"./org.apache.wicket.TestDetachPage?0-1.IBehaviorListener.0-comp","c":"comp1","e":"click"});})();]]></evaluate></ajax-response>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/test/java/org/apache/wicket/TestDetachPageExpectedResult.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/TestDetachPageExpectedResult.html b/wicket-core/src/test/java/org/apache/wicket/TestDetachPageExpectedResult.html
index 3ebadda..28b8e18 100644
--- a/wicket-core/src/test/java/org/apache/wicket/TestDetachPageExpectedResult.html
+++ b/wicket-core/src/test/java/org/apache/wicket/TestDetachPageExpectedResult.html
@@ -16,7 +16,7 @@ Wicket.Ajax.baseUrl="wicket/bookmarkable/org.apache.wicket.TestDetachPage?0";
 <script type="text/javascript" >
 /*<![CDATA[*/
 Wicket.Event.add(window, "domready", function(event) { 
-Wicket.Ajax.ajax({"u":"./org.apache.wicket.TestDetachPage?0-1.IBehaviorListener.0-comp","e":"click","c":"comp1"});;
+Wicket.Ajax.ajax({"u":"./org.apache.wicket.TestDetachPage?0-1.IBehaviorListener.0-comp","c":"comp1","e":"click"});;
 ;});
 /*]]>*/
 </script>

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/test/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehaviorTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehaviorTest.java b/wicket-core/src/test/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehaviorTest.java
index 3f848b5..8da123e 100644
--- a/wicket-core/src/test/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehaviorTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehaviorTest.java
@@ -66,18 +66,17 @@ public class AbstractDefaultAjaxBehaviorTest extends Assert
 
 		CharSequence json = behavior.renderAjaxAttributes(component, attributes);
 
-		String expected = "{\"" + AjaxAttributeName.COMPLETE_HANDLER +
-			"\":[function(attrs, jqXHR, textStatus){alert('Complete!');}],\"" +
-			AjaxAttributeName.URL + "\":\"some/url\",\"" +
-			AjaxAttributeName.PRECONDITION +
-			"\":[function(attrs){return somePrecondition();}],\"" +
-			AjaxAttributeName.FAILURE_HANDLER +
-			"\":[function(attrs, jqXHR, errorMessage, textStatus){alert('Failure!');}],\"" +
-			AjaxAttributeName.BEFORE_HANDLER +
-			"\":[function(attrs){alert('Before!');}],\"" +
-			AjaxAttributeName.SUCCESS_HANDLER +
-			"\":[function(attrs, jqXHR, data, textStatus){alert('Success!');}],\"" +
-			AjaxAttributeName.AFTER_HANDLER + "\":[function(attrs){alert('After!');}]}";
+		String expected =
+		"{" +
+			"\""+AjaxAttributeName.URL+"\":\"some/url\"," +
+			"\""+AjaxAttributeName.BEFORE_HANDLER+"\":[function(attrs){alert('Before!');}]," +
+			"\""+AjaxAttributeName.AFTER_HANDLER+"\":[function(attrs){alert('After!');}]," +
+			"\""+AjaxAttributeName.SUCCESS_HANDLER+"\":[function(attrs, jqXHR, data, textStatus){alert('Success!');}]," +
+			"\""+AjaxAttributeName.FAILURE_HANDLER+"\":[function(attrs, jqXHR, errorMessage, textStatus){alert('Failure!');}]," +
+			"\""+AjaxAttributeName.COMPLETE_HANDLER+"\":[function(attrs, jqXHR, textStatus){alert('Complete!');}]," +
+			"\""+AjaxAttributeName.PRECONDITION+"\":[function(attrs){return somePrecondition();}]" +
+		"}";
+
 		assertEquals(expected, json);
 	}
 }

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxBehaviorEnabled_expected.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxBehaviorEnabled_expected.html b/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxBehaviorEnabled_expected.html
index 7a2b706..bbf9673 100644
--- a/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxBehaviorEnabled_expected.html
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxBehaviorEnabled_expected.html
@@ -20,7 +20,7 @@ Wicket.Ajax.baseUrl="wicket/bookmarkable/org.apache.wicket.ajax.AjaxBehaviorEnab
 <script type="text/javascript" >
 /*<![CDATA[*/
 Wicket.Event.add(window, "domready", function(event) { 
-Wicket.Ajax.ajax({"u":"./org.apache.wicket.ajax.AjaxBehaviorEnabledPage?0-1.IBehaviorListener.0-enabled","e":"click","c":"enabled1"});;
+Wicket.Ajax.ajax({"u":"./org.apache.wicket.ajax.AjaxBehaviorEnabledPage?0-1.IBehaviorListener.0-enabled","c":"enabled1","e":"click"});;
 ;});
 /*]]>*/
 </script>

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxHeaderContributionPage2_expected.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxHeaderContributionPage2_expected.html b/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxHeaderContributionPage2_expected.html
index a318fda..31a4c9c 100644
--- a/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxHeaderContributionPage2_expected.html
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxHeaderContributionPage2_expected.html
@@ -24,7 +24,7 @@ Wicket.Ajax.baseUrl="wicket/bookmarkable/org.apache.wicket.ajax.AjaxHeaderContri
 Wicket.Event.add(window, "domready", function(event) { 
 domReady();;
 domReadyB();;
-Wicket.Ajax.ajax({"pd":true,"u":"./org.apache.wicket.ajax.AjaxHeaderContributionPage2?0-1.IBehaviorListener.0-link","e":"click","c":"link1"});;
+Wicket.Ajax.ajax({"u":"./org.apache.wicket.ajax.AjaxHeaderContributionPage2?0-1.IBehaviorListener.0-link","c":"link1","e":"click","pd":true});;
 ;});
 /*]]>*/
 </script>

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxHeaderContributionPage_expected.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxHeaderContributionPage_expected.html b/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxHeaderContributionPage_expected.html
index 7630cb2..1a2e61d 100644
--- a/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxHeaderContributionPage_expected.html
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/AjaxHeaderContributionPage_expected.html
@@ -20,7 +20,7 @@ Wicket.Ajax.baseUrl="wicket/bookmarkable/org.apache.wicket.ajax.AjaxHeaderContri
 /*<![CDATA[*/
 Wicket.Event.add(window, "domready", function(event) { 
 domReady();;
-Wicket.Ajax.ajax({"pd":true,"u":"./org.apache.wicket.ajax.AjaxHeaderContributionPage?0-1.IBehaviorListener.0-link","e":"click","c":"link1"});;
+Wicket.Ajax.ajax({"u":"./org.apache.wicket.ajax.AjaxHeaderContributionPage?0-1.IBehaviorListener.0-link","c":"link1","e":"click","pd":true});;
 ;});
 /*]]>*/
 </script>

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/test/java/org/apache/wicket/ajax/DomReadyOrderPage_ajax_expected.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/DomReadyOrderPage_ajax_expected.html b/wicket-core/src/test/java/org/apache/wicket/ajax/DomReadyOrderPage_ajax_expected.html
index e933201..2f7b0c6 100644
--- a/wicket-core/src/test/java/org/apache/wicket/ajax/DomReadyOrderPage_ajax_expected.html
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/DomReadyOrderPage_ajax_expected.html
@@ -12,4 +12,4 @@ Wicket.Ajax.DebugWindow.enabled=true;
 Wicket.Ajax.baseUrl="wicket/bookmarkable/org.apache.wicket.ajax.DomReadyOrderPage?0-1.IBehaviorListener.0-test";
 /*]^]^>*/
 </script>
-</head>]]></header-contribution><evaluate><![CDATA[(function(){Wicket.Ajax.ajax({"pd":true,"u":"./org.apache.wicket.ajax.DomReadyOrderPage?0-1.IBehaviorListener.0-test","e":"click","c":"test1"});})();(function(){test1();})();(function(){test2();})();]]></evaluate></ajax-response>
\ No newline at end of file
+</head>]]></header-contribution><evaluate><![CDATA[(function(){Wicket.Ajax.ajax({"u":"./org.apache.wicket.ajax.DomReadyOrderPage?0-1.IBehaviorListener.0-test","c":"test1","e":"click","pd":true});})();(function(){test1();})();(function(){test2();})();]]></evaluate></ajax-response>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/test/java/org/apache/wicket/ajax/DomReadyOrderPage_expected.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/DomReadyOrderPage_expected.html b/wicket-core/src/test/java/org/apache/wicket/ajax/DomReadyOrderPage_expected.html
index 955eff4..e99b6db 100644
--- a/wicket-core/src/test/java/org/apache/wicket/ajax/DomReadyOrderPage_expected.html
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/DomReadyOrderPage_expected.html
@@ -16,7 +16,7 @@ Wicket.Ajax.baseUrl="wicket/bookmarkable/org.apache.wicket.ajax.DomReadyOrderPag
 <script type="text/javascript" >
 /*<![CDATA[*/
 Wicket.Event.add(window, "domready", function(event) { 
-Wicket.Ajax.ajax({"pd":true,"u":"./org.apache.wicket.ajax.DomReadyOrderPage?0-1.IBehaviorListener.0-test","e":"click","c":"test1"});;
+Wicket.Ajax.ajax({"u":"./org.apache.wicket.ajax.DomReadyOrderPage?0-1.IBehaviorListener.0-test","c":"test1","e":"click","pd":true});;
 test1();;
 test2();;
 ;});

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage_expected.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage_expected.html b/wicket-core/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage_expected.html
index 0bad853..f0f9c40 100644
--- a/wicket-core/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage_expected.html
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage_expected.html
@@ -16,7 +16,7 @@ Wicket.Ajax.baseUrl="wicket/bookmarkable/org.apache.wicket.ajax.form.AjaxFormSub
 <script type="text/javascript" >
 /*<![CDATA[*/
 Wicket.Event.add(window, "domready", function(event) { 
-Wicket.Ajax.ajax({"pd":true,"f":"form1","u":"./org.apache.wicket.ajax.form.AjaxFormSubmitTestPage?0-1.IBehaviorListener.0-form-submit","e":"click","c":"submit2","sc":":submit","m":"POST"});;
+Wicket.Ajax.ajax({"u":"./org.apache.wicket.ajax.form.AjaxFormSubmitTestPage?0-1.IBehaviorListener.0-form-submit","m":"POST","c":"submit2","f":"form1","sc":":submit","e":"click","pd":true});;
 ;});
 /*]]>*/
 </script>

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/test/java/org/apache/wicket/ajax/form/OnChangeAjaxBehaviorTestPage_expected.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/form/OnChangeAjaxBehaviorTestPage_expected.html b/wicket-core/src/test/java/org/apache/wicket/ajax/form/OnChangeAjaxBehaviorTestPage_expected.html
index db1c0fa..593f226 100644
--- a/wicket-core/src/test/java/org/apache/wicket/ajax/form/OnChangeAjaxBehaviorTestPage_expected.html
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/form/OnChangeAjaxBehaviorTestPage_expected.html
@@ -16,8 +16,8 @@ Wicket.Ajax.baseUrl="wicket/bookmarkable/org.apache.wicket.ajax.form.OnChangeAja
 <script type="text/javascript" >
 /*<![CDATA[*/
 Wicket.Event.add(window, "domready", function(event) { 
-Wicket.Ajax.ajax({"u":"./org.apache.wicket.ajax.form.OnChangeAjaxBehaviorTestPage?0-1.IBehaviorListener.0-form-field","e":"inputchange change","c":"field1","m":"POST"});;
-Wicket.Ajax.ajax({"u":"./org.apache.wicket.ajax.form.OnChangeAjaxBehaviorTestPage?0-1.IBehaviorListener.0-form-dropDown","e":"inputchange change","c":"dropDown2","m":"POST"});;
+Wicket.Ajax.ajax({"u":"./org.apache.wicket.ajax.form.OnChangeAjaxBehaviorTestPage?0-1.IBehaviorListener.0-form-field","m":"POST","c":"field1","e":"inputchange change"});;
+Wicket.Ajax.ajax({"u":"./org.apache.wicket.ajax.form.OnChangeAjaxBehaviorTestPage?0-1.IBehaviorListener.0-form-dropDown","m":"POST","c":"dropDown2","e":"inputchange change"});;
 ;});
 /*]]>*/
 </script>

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkPageExpectedResult.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkPageExpectedResult.html b/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkPageExpectedResult.html
index 9e9a3cd..dfe7104 100644
--- a/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkPageExpectedResult.html
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkPageExpectedResult.html
@@ -16,7 +16,7 @@ Wicket.Ajax.baseUrl="wicket/bookmarkable/org.apache.wicket.ajax.markup.html.ajax
 <script type="text/javascript" >
 /*<![CDATA[*/
 Wicket.Event.add(window, "domready", function(event) { 
-Wicket.Ajax.ajax({"u":"./org.apache.wicket.ajax.markup.html.ajaxLink.AjaxLinkPage?0-1.IBehaviorListener.0-ajaxLink","e":"click","c":"ajaxLink1"});;
+Wicket.Ajax.ajax({"u":"./org.apache.wicket.ajax.markup.html.ajaxLink.AjaxLinkPage?0-1.IBehaviorListener.0-ajaxLink","c":"ajaxLink1","e":"click"});;
 ;});
 /*]]>*/
 </script>

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkWithBorderPageExpectedResult.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkWithBorderPageExpectedResult.html b/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkWithBorderPageExpectedResult.html
index 61c810e..d9c4297 100644
--- a/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkWithBorderPageExpectedResult.html
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxLinkWithBorderPageExpectedResult.html
@@ -16,7 +16,7 @@ Wicket.Ajax.baseUrl="wicket/bookmarkable/org.apache.wicket.ajax.markup.html.ajax
 <script type="text/javascript" >
 /*<![CDATA[*/
 Wicket.Event.add(window, "domready", function(event) { 
-Wicket.Ajax.ajax({"u":"./org.apache.wicket.ajax.markup.html.ajaxLink.AjaxLinkWithBorderPage?0-1.IBehaviorListener.0-border-border_body-ajaxLink","e":"click","c":"ajaxLink1"});;
+Wicket.Ajax.ajax({"u":"./org.apache.wicket.ajax.markup.html.ajaxLink.AjaxLinkWithBorderPage?0-1.IBehaviorListener.0-border-border_body-ajaxLink","c":"ajaxLink1","e":"click"});;
 ;});
 /*]]>*/
 </script>

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxPage2_ExpectedResult.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxPage2_ExpectedResult.html b/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxPage2_ExpectedResult.html
index 804f428..647d088 100644
--- a/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxPage2_ExpectedResult.html
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/markup/html/ajaxLink/AjaxPage2_ExpectedResult.html
@@ -16,7 +16,7 @@ Wicket.Ajax.baseUrl="wicket/bookmarkable/org.apache.wicket.ajax.markup.html.ajax
 <script type="text/javascript" >
 /*<![CDATA[*/
 Wicket.Event.add(window, "domready", function(event) { 
-Wicket.Ajax.ajax({"u":"./org.apache.wicket.ajax.markup.html.ajaxLink.AjaxPage2?0-1.IBehaviorListener.0-pageLayout-pageLayout_body-ajaxLink","e":"click","c":"ajaxLink1"});;
+Wicket.Ajax.ajax({"u":"./org.apache.wicket.ajax.markup.html.ajaxLink.AjaxPage2?0-1.IBehaviorListener.0-pageLayout-pageLayout_body-ajaxLink","c":"ajaxLink1","e":"click"});;
 ;});
 /*]]>*/
 </script>

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/test/java/org/apache/wicket/markup/html/basic/SimplePageExpectedResult_13.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/basic/SimplePageExpectedResult_13.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/basic/SimplePageExpectedResult_13.html
index 8df841c..d772e42 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/basic/SimplePageExpectedResult_13.html
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/basic/SimplePageExpectedResult_13.html
@@ -20,7 +20,7 @@ Wicket.Ajax.baseUrl="wicket/bookmarkable/org.apache.wicket.markup.html.basic.Sim
 <script type="text/javascript" >
 /*<![CDATA[*/
 Wicket.Event.add(window, "domready", function(event) { 
-Wicket.Ajax.ajax({"u":"./org.apache.wicket.markup.html.basic.SimplePage_13?0-1.IBehaviorListener.0-html","e":"click","c":"html1"});;
+Wicket.Ajax.ajax({"u":"./org.apache.wicket.markup.html.basic.SimplePage_13?0-1.IBehaviorListener.0-html","c":"html1","e":"click"});;
 ;});
 /*]]>*/
 </script>

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/test/java/org/apache/wicket/markup/html/border/HideableBorderPage_ExpectedResult.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/border/HideableBorderPage_ExpectedResult.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/border/HideableBorderPage_ExpectedResult.html
index ee28e23..18d5172 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/border/HideableBorderPage_ExpectedResult.html
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/border/HideableBorderPage_ExpectedResult.html
@@ -16,7 +16,7 @@ Wicket.Ajax.baseUrl="wicket/bookmarkable/org.apache.wicket.markup.html.border.Hi
 <script type="text/javascript" >
 /*<![CDATA[*/
 Wicket.Event.add(window, "domready", function(event) { 
-Wicket.Ajax.ajax({"u":"./org.apache.wicket.markup.html.border.HideableBorderPage?0-1.IBehaviorListener.0-hideable-hideLink","e":"click","c":"hideLink1"});;
+Wicket.Ajax.ajax({"u":"./org.apache.wicket.markup.html.border.HideableBorderPage?0-1.IBehaviorListener.0-hideable-hideLink","c":"hideLink1","e":"click"});;
 ;});
 /*]]>*/
 </script>

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/test/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadFieldTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadFieldTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadFieldTest.java
index 472c8e8..3d81ab8 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadFieldTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadFieldTest.java
@@ -20,6 +20,8 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.wicket.MarkupContainer;
 import org.apache.wicket.WicketTestCase;
@@ -48,7 +50,7 @@ public class MultiFileUploadFieldTest extends WicketTestCase
 	public void submitMultiFileUploadFields()
 	{
 		final AtomicBoolean submitted = new AtomicBoolean(false);
-		final ListModel<FileUpload> filesModel = new ListModel<FileUpload>(new ArrayList<FileUpload>());
+		final ListModel<FileUpload> filesModel = new ListModel<>(new ArrayList<FileUpload>());
 
 		TestPage page = new TestPage(filesModel)
 		{
@@ -63,13 +65,14 @@ public class MultiFileUploadFieldTest extends WicketTestCase
 				for (int i = 1; i < 2; i++)
 				{
 					FileUpload fileUpload = uploads.get(i);
-					assertEquals(MultiFileUploadFieldTest.class.getSimpleName()+i+".txt", fileUpload.getClientFileName());
+					String clientFileName = fileUpload.getClientFileName();
+					String id = clientFileName.replaceAll(MultiFileUploadFieldTest.class.getSimpleName() + "(\\d).txt", "$1");
 					try
 					{
-						assertEquals("Test"+i, IOUtils.toString(fileUpload.getInputStream()));
+						assertEquals("Test"+id, IOUtils.toString(fileUpload.getInputStream()));
 					} catch (IOException e)
 					{
-						fail("Reading file upload '"+i+"' failed: " + e.getMessage());
+						fail("Reading file upload '"+id+"' failed: " + e.getMessage());
 					}
 				}
 				submitted.set(true);

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPageExpectedResult_7.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPageExpectedResult_7.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPageExpectedResult_7.html
index 8a06d67..1eee2b0 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPageExpectedResult_7.html
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPageExpectedResult_7.html
@@ -16,7 +16,7 @@ Wicket.Ajax.baseUrl="wicket/bookmarkable/org.apache.wicket.markup.html.panel.Inl
 <script type="text/javascript" >
 /*<![CDATA[*/
 Wicket.Event.add(window, "domready", function(event) { 
-Wicket.Ajax.ajax({"u":"./org.apache.wicket.markup.html.panel.InlinePanelPage_7?0-1.IBehaviorListener.0-provider-ajaxRefresh","e":"click","c":"ajaxRefresh1"});;
+Wicket.Ajax.ajax({"u":"./org.apache.wicket.markup.html.panel.InlinePanelPage_7?0-1.IBehaviorListener.0-provider-ajaxRefresh","c":"ajaxRefresh1","e":"click"});;
 ;});
 /*]]>*/
 </script>

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPageExpectedResult_8.html
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPageExpectedResult_8.html b/wicket-core/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPageExpectedResult_8.html
index 7f2540f..69c755a 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPageExpectedResult_8.html
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPageExpectedResult_8.html
@@ -16,7 +16,7 @@ Wicket.Ajax.baseUrl="wicket/bookmarkable/org.apache.wicket.markup.html.panel.Inl
 <script type="text/javascript" >
 /*<![CDATA[*/
 Wicket.Event.add(window, "domready", function(event) { 
-Wicket.Ajax.ajax({"u":"./org.apache.wicket.markup.html.panel.InlinePanelPage_8?0-1.IBehaviorListener.0-add","e":"click","c":"add1"});;
+Wicket.Ajax.ajax({"u":"./org.apache.wicket.markup.html.panel.InlinePanelPage_8?0-1.IBehaviorListener.0-add","c":"add1","e":"click"});;
 ;});
 /*]]>*/
 </script>


[10/11] git commit: WICKET-831 Return response status 404 when a mapper cannot decode a request url

Posted by iv...@apache.org.
WICKET-831 Return response status 404 when a mapper cannot decode a request url


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/e3328f14
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/e3328f14
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/e3328f14

Branch: refs/heads/sandbox/component-queueing-2
Commit: e3328f1410d251e55e7a7a81dc181923a3a3a739
Parents: 3d26145
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Thu Feb 20 17:46:31 2014 +0200
Committer: Igor Vaynberg <ig...@gmail.com>
Committed: Thu Feb 20 23:24:05 2014 -0800

----------------------------------------------------------------------
 .../wicket/core/request/mapper/ResourceMapper.java   | 15 +++++++++++++--
 .../apache/wicket/request/mapper/AbstractMapper.java |  2 +-
 2 files changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/e3328f14/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/ResourceMapper.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/ResourceMapper.java b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/ResourceMapper.java
index 3455ec5..718ede2 100644
--- a/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/ResourceMapper.java
+++ b/wicket-core/src/main/java/org/apache/wicket/core/request/mapper/ResourceMapper.java
@@ -18,12 +18,15 @@ package org.apache.wicket.core.request.mapper;
 
 import java.util.List;
 
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.wicket.Application;
 import org.apache.wicket.request.IRequestHandler;
 import org.apache.wicket.request.IRequestMapper;
 import org.apache.wicket.request.Request;
 import org.apache.wicket.request.Url;
 import org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler;
+import org.apache.wicket.request.http.flow.AbortWithHttpErrorCodeException;
 import org.apache.wicket.request.mapper.AbstractMapper;
 import org.apache.wicket.request.mapper.parameter.IPageParametersEncoder;
 import org.apache.wicket.request.mapper.parameter.PageParameters;
@@ -229,8 +232,16 @@ public class ResourceMapper extends AbstractMapper implements IRequestMapper
 	
 					if (Strings.isEmpty(cacheUrl.getFileName()))
 					{
-						throw new IllegalStateException("caching strategy returned empty name for " +
-							resource);
+						if (Application.exists() && Application.get().usesDeploymentConfig())
+						{
+							throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_NOT_FOUND,
+								"caching strategy returned empty name for " + resource);
+						}
+						else
+						{
+							throw new IllegalStateException(
+									"caching strategy returned empty name for " + resource);
+						}
 					}
 					segments.set(lastSegmentAt, cacheUrl.getFileName());
 				}

http://git-wip-us.apache.org/repos/asf/wicket/blob/e3328f14/wicket-request/src/main/java/org/apache/wicket/request/mapper/AbstractMapper.java
----------------------------------------------------------------------
diff --git a/wicket-request/src/main/java/org/apache/wicket/request/mapper/AbstractMapper.java b/wicket-request/src/main/java/org/apache/wicket/request/mapper/AbstractMapper.java
index 5af0fb0..1857818 100644
--- a/wicket-request/src/main/java/org/apache/wicket/request/mapper/AbstractMapper.java
+++ b/wicket-request/src/main/java/org/apache/wicket/request/mapper/AbstractMapper.java
@@ -227,4 +227,4 @@ public abstract class AbstractMapper implements IRequestMapper
 		return res;
 	}
 
-}
\ No newline at end of file
+}


[04/11] git commit: Upgrade dependencies

Posted by iv...@apache.org.
Upgrade dependencies

Spring from 4.0.1 to 4.0.2
SLF4J from 1.7.5 to 1.7.6


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/7a4823cb
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/7a4823cb
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/7a4823cb

Branch: refs/heads/sandbox/component-queueing-2
Commit: 7a4823cb8d339f59e83fe902f1a461c8ba88e00a
Parents: a419626
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Thu Feb 20 12:07:43 2014 +0200
Committer: Igor Vaynberg <ig...@gmail.com>
Committed: Thu Feb 20 23:24:05 2014 -0800

----------------------------------------------------------------------
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/7a4823cb/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a2f6a77..1fa30dd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,12 +33,12 @@
 		<jacoco.version>0.6.4.201312101107</jacoco.version>
 		<jetty.version>8.1.14.v20131031</jetty.version>
 		<jetty9.version>9.0.7.v20131107</jetty9.version>
-		<spring.version>4.0.1.RELEASE</spring.version>
+		<spring.version>4.0.2.RELEASE</spring.version>
 		<servlet-api.version>3.0.1</servlet-api.version>
 		<maven.javadoc.version>2.9.1</maven.javadoc.version>
 		<maven.surefire.version>2.12.2</maven.surefire.version>
 		<mockito.version>1.9.5</mockito.version>
-		<slf4j.version>1.7.5</slf4j.version>
+		<slf4j.version>1.7.6</slf4j.version>
 		<hamcrest.version>1.3</hamcrest.version>
 	</properties>
 	<modules>


[08/11] git commit: Don't lookup twice the active request handler.

Posted by iv...@apache.org.
Don't lookup twice the active request handler.

Add '' around the logged data for easier reading


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/51e5b57b
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/51e5b57b
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/51e5b57b

Branch: refs/heads/sandbox/component-queueing-2
Commit: 51e5b57b5592f43d25fa38e53270bfe950680056
Parents: 79e4031
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Wed Feb 19 12:21:13 2014 +0200
Committer: Igor Vaynberg <ig...@gmail.com>
Committed: Thu Feb 20 23:24:05 2014 -0800

----------------------------------------------------------------------
 .../java/org/apache/wicket/cdi/AutoConversationManager.java | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/51e5b57b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/AutoConversationManager.java
----------------------------------------------------------------------
diff --git a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/AutoConversationManager.java b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/AutoConversationManager.java
index 5b88365..4aedb48 100644
--- a/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/AutoConversationManager.java
+++ b/wicket-cdi-1.1/src/main/java/org/apache/wicket/cdi/AutoConversationManager.java
@@ -60,8 +60,9 @@ public class AutoConversationManager implements IComponentOnBeforeRenderListener
 		if (component instanceof Page)
 		{
 			Page page = (Page)component;
-			autoEndIfNecessary(page, RequestCycle.get().getActiveRequestHandler());
-			autoBeginIfNecessary(page, RequestCycle.get().getActiveRequestHandler());
+			IRequestHandler activeRequestHandler = page.getRequestCycle().getActiveRequestHandler();
+			autoEndIfNecessary(page, activeRequestHandler);
+			autoBeginIfNecessary(page, activeRequestHandler);
 		}
 	}
 
@@ -78,7 +79,7 @@ public class AutoConversationManager implements IComponentOnBeforeRenderListener
 		conversation.begin();
 		autoConversation.setAutomatic(true);
 
-		logger.debug("Auto-began conversation {} for page {}", conversation.getId(), page);
+		logger.debug("Auto-began conversation '{}' for page '{}'", conversation.getId(), page);
 	}
 
 	protected void autoEndIfNecessary(Page page, IRequestHandler handler)
@@ -98,7 +99,7 @@ public class AutoConversationManager implements IComponentOnBeforeRenderListener
 		conversation.end();
 		ConversationPropagator.removeConversationIdFromPage(page);
 
-		logger.debug("Auto-ended conversation {} for page {}", cid, page);
+		logger.debug("Auto-ended conversation '{}' for page '{}'", cid, page);
 	}
 
 	protected boolean hasConversationalComponent(Page page)


[07/11] git commit: Upgrade ASM from 4.1 to 4.2

Posted by iv...@apache.org.
Upgrade ASM from 4.1 to 4.2


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/3f9265bb
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/3f9265bb
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/3f9265bb

Branch: refs/heads/sandbox/component-queueing-2
Commit: 3f9265bb41a7c31c15c9ef5b171caf61d0496ec6
Parents: 25474d5
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Wed Feb 19 14:48:47 2014 +0200
Committer: Igor Vaynberg <ig...@gmail.com>
Committed: Thu Feb 20 23:24:05 2014 -0800

----------------------------------------------------------------------
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/3f9265bb/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 178fd6b..80c0a39 100644
--- a/pom.xml
+++ b/pom.xml
@@ -500,7 +500,7 @@
 			<dependency>
 				<groupId>org.ow2.asm</groupId>
 				<artifactId>asm-util</artifactId>
-				<version>4.1</version>
+				<version>4.2</version>
 			</dependency>
 			<dependency>
 				<groupId>javax.inject</groupId>


[09/11] git commit: Upgrade org.apache.felix:maven-bundle-plugin to 2.4.0

Posted by iv...@apache.org.
Upgrade org.apache.felix:maven-bundle-plugin to 2.4.0


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/294f1eb5
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/294f1eb5
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/294f1eb5

Branch: refs/heads/sandbox/component-queueing-2
Commit: 294f1eb5719a6e2c0dd0a5aecb389dd6c8aa4fc3
Parents: 3f9265b
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Wed Feb 19 14:50:12 2014 +0200
Committer: Igor Vaynberg <ig...@gmail.com>
Committed: Thu Feb 20 23:24:05 2014 -0800

----------------------------------------------------------------------
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/294f1eb5/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 80c0a39..a2f6a77 100644
--- a/pom.xml
+++ b/pom.xml
@@ -851,7 +851,7 @@
 				<plugin>
 					<groupId>org.apache.felix</groupId>
 					<artifactId>maven-bundle-plugin</artifactId>
-					<version>2.3.7</version>
+					<version>2.4.0</version>
 					<executions>
 						<execution>
 							<id>bundle-manifest</id>


[03/11] git commit: WICKET-4795 Wicket unit tests rely on hashmap iteration order

Posted by iv...@apache.org.
WICKET-4795 Wicket unit tests rely on hashmap iteration order

Upgrade https://github.com/douglascrockford/JSON-java
Change JSONObject#map from HashMap to LinkedHashMap to maintain the order

Update the tests expectations to the new order of the Ajax request attributes.
Fix two more tests that were broken due to the different order of entries in HashMap

Fix Wicket's build with JDK 1.8.0 b129


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/79e40312
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/79e40312
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/79e40312

Branch: refs/heads/sandbox/component-queueing-2
Commit: 79e40312f17c045b661b0ecf9aa8296168817f63
Parents: 1fd9d57
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Tue Feb 18 17:58:46 2014 +0200
Committer: Igor Vaynberg <ig...@gmail.com>
Committed: Thu Feb 20 23:24:04 2014 -0800

----------------------------------------------------------------------
 .../java/org/apache/wicket/ajax/json/CDL.java   |  567 ++++-----
 .../org/apache/wicket/ajax/json/Cookie.java     |    8 +-
 .../org/apache/wicket/ajax/json/CookieList.java |    8 +-
 .../java/org/apache/wicket/ajax/json/HTTP.java  |   10 +-
 .../apache/wicket/ajax/json/HTTPTokener.java    |  156 +--
 .../org/apache/wicket/ajax/json/JSONArray.java  |  717 ++++++-----
 .../apache/wicket/ajax/json/JSONException.java  |   70 +-
 .../org/apache/wicket/ajax/json/JSONML.java     |   16 +-
 .../org/apache/wicket/ajax/json/JSONObject.java | 1131 +++++++++---------
 .../org/apache/wicket/ajax/json/JSONString.java |   37 +-
 .../apache/wicket/ajax/json/JSONStringer.java   |    1 -
 .../apache/wicket/ajax/json/JSONTokener.java    |    4 +-
 .../org/apache/wicket/ajax/json/JSONWriter.java |    5 +-
 .../wicket/ajax/json/JsonSequenceStringer.java  |    6 +-
 .../java/org/apache/wicket/ajax/json/README     |    9 +-
 .../java/org/apache/wicket/ajax/json/XML.java   |   70 +-
 .../org/apache/wicket/ajax/json/XMLTokener.java |  732 ++++++------
 .../http/mock/MockHttpServletRequest.java       |    8 +-
 .../apache/wicket/TestDetachPageAjaxResult.html |    2 +-
 .../wicket/TestDetachPageExpectedResult.html    |    2 +-
 .../ajax/AbstractDefaultAjaxBehaviorTest.java   |   23 +-
 .../ajax/AjaxBehaviorEnabled_expected.html      |    2 +-
 .../AjaxHeaderContributionPage2_expected.html   |    2 +-
 .../AjaxHeaderContributionPage_expected.html    |    2 +-
 .../ajax/DomReadyOrderPage_ajax_expected.html   |    2 +-
 .../wicket/ajax/DomReadyOrderPage_expected.html |    2 +-
 .../form/AjaxFormSubmitTestPage_expected.html   |    2 +-
 .../OnChangeAjaxBehaviorTestPage_expected.html  |    4 +-
 .../ajaxLink/AjaxLinkPageExpectedResult.html    |    2 +-
 .../AjaxLinkWithBorderPageExpectedResult.html   |    2 +-
 .../html/ajaxLink/AjaxPage2_ExpectedResult.html |    2 +-
 .../html/basic/SimplePageExpectedResult_13.html |    2 +-
 .../HideableBorderPage_ExpectedResult.html      |    2 +-
 .../form/upload/MultiFileUploadFieldTest.java   |   11 +-
 .../panel/InlinePanelPageExpectedResult_7.html  |    2 +-
 .../panel/InlinePanelPageExpectedResult_8.html  |    2 +-
 36 files changed, 1882 insertions(+), 1741 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/main/java/org/apache/wicket/ajax/json/CDL.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/CDL.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/CDL.java
index 3b0cbd3..b01fd10 100755
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/CDL.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/CDL.java
@@ -1,279 +1,288 @@
-package org.apache.wicket.ajax.json;
-
-/*
-Copyright (c) 2002 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-/**
- * This provides static methods to convert comma delimited text into a
- * JSONArray, and to covert a JSONArray into comma delimited text. Comma
- * delimited text is a very popular format for data interchange. It is
- * understood by most database, spreadsheet, and organizer programs.
- * <p>
- * Each row of text represents a row in a table or a data record. Each row
- * ends with a NEWLINE character. Each row contains one or more values.
- * Values are separated by commas. A value can contain any character except
- * for comma, unless is is wrapped in single quotes or double quotes.
- * <p>
- * The first row usually contains the names of the columns.
- * <p>
- * A comma delimited list can be converted into a JSONArray of JSONObjects.
- * The names for the elements in the JSONObjects can be taken from the names
- * in the first row.
- * @author JSON.org
- * @version 2010-12-24
- */
-public class CDL {
-
-    /**
-     * Get the next value. The value can be wrapped in quotes. The value can
-     * be empty.
-     * @param x A JSONTokener of the source text.
-     * @return The value string, or null if empty.
-     * @throws JSONException if the quoted string is badly formed.
-     */
-    private static String getValue(JSONTokener x) throws JSONException {
-        char c;
-        char q;
-        StringBuffer sb;
-        do {
-            c = x.next();
-        } while (c == ' ' || c == '\t');
-        switch (c) {
-        case 0:
-            return null;
-        case '"':
-        case '\'':
-            q = c;
-            sb = new StringBuffer();
-            for (;;) {
-                c = x.next();
-                if (c == q) {
-                    break;
-                }
-                if (c == 0 || c == '\n' || c == '\r') {
-                    throw x.syntaxError("Missing close quote '" + q + "'.");
-                }
-                sb.append(c);
-            }
-            return sb.toString();
-        case ',':
-            x.back();
-            return "";
-        default:
-            x.back();
-            return x.nextTo(',');
-        }
-    }
-
-    /**
-     * Produce a JSONArray of strings from a row of comma delimited values.
-     * @param x A JSONTokener of the source text.
-     * @return A JSONArray of strings.
-     * @throws JSONException
-     */
-    public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException {
-        JSONArray ja = new JSONArray();
-        for (;;) {
-            String value = getValue(x);
-            char c = x.next();
-            if (value == null || 
-                    (ja.length() == 0 && value.length() == 0 && c != ',')) {
-                return null;
-            }
-            ja.put(value);
-            for (;;) {                
-                if (c == ',') {
-                    break;
-                }
-                if (c != ' ') {
-                    if (c == '\n' || c == '\r' || c == 0) {
-                        return ja;
-                    }
-                    throw x.syntaxError("Bad character '" + c + "' (" +
-                            (int)c + ").");
-                }
-                c = x.next();
-            }
-        }
-    }
-
-    /**
-     * Produce a JSONObject from a row of comma delimited text, using a
-     * parallel JSONArray of strings to provides the names of the elements.
-     * @param names A JSONArray of names. This is commonly obtained from the
-     *  first row of a comma delimited text file using the rowToJSONArray
-     *  method.
-     * @param x A JSONTokener of the source text.
-     * @return A JSONObject combining the names and values.
-     * @throws JSONException
-     */
-    public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x)
-            throws JSONException {
-        JSONArray ja = rowToJSONArray(x);
-        return ja != null ? ja.toJSONObject(names) :  null;
-    }
-
-    /**
-     * Produce a comma delimited text row from a JSONArray. Values containing
-     * the comma character will be quoted. Troublesome characters may be 
-     * removed.
-     * @param ja A JSONArray of strings.
-     * @return A string ending in NEWLINE.
-     */
-    public static String rowToString(JSONArray ja) {
-        StringBuffer sb = new StringBuffer();
-        for (int i = 0; i < ja.length(); i += 1) {
-            if (i > 0) {
-                sb.append(',');
-            }
-            Object object = ja.opt(i);
-            if (object != null) {
-                String string = object.toString();
-                if (string.length() > 0 && (string.indexOf(',') >= 0 || 
-                        string.indexOf('\n') >= 0 || string.indexOf('\r') >= 0 || 
-                        string.indexOf(0) >= 0 || string.charAt(0) == '"')) {
-                    sb.append('"');
-                    int length = string.length();
-                    for (int j = 0; j < length; j += 1) {
-                        char c = string.charAt(j);
-                        if (c >= ' ' && c != '"') {
-                            sb.append(c);
-                        }
-                    }
-                    sb.append('"');
-                } else {
-                    sb.append(string);
-                }
-            }
-        }
-        sb.append('\n');
-        return sb.toString();
-    }
-
-    /**
-     * Produce a JSONArray of JSONObjects from a comma delimited text string,
-     * using the first row as a source of names.
-     * @param string The comma delimited text.
-     * @return A JSONArray of JSONObjects.
-     * @throws JSONException
-     */
-    public static JSONArray toJSONArray(String string) throws JSONException {
-        return toJSONArray(new JSONTokener(string));
-    }
-
-    /**
-     * Produce a JSONArray of JSONObjects from a comma delimited text string,
-     * using the first row as a source of names.
-     * @param x The JSONTokener containing the comma delimited text.
-     * @return A JSONArray of JSONObjects.
-     * @throws JSONException
-     */
-    public static JSONArray toJSONArray(JSONTokener x) throws JSONException {
-        return toJSONArray(rowToJSONArray(x), x);
-    }
-
-    /**
-     * Produce a JSONArray of JSONObjects from a comma delimited text string
-     * using a supplied JSONArray as the source of element names.
-     * @param names A JSONArray of strings.
-     * @param string The comma delimited text.
-     * @return A JSONArray of JSONObjects.
-     * @throws JSONException
-     */
-    public static JSONArray toJSONArray(JSONArray names, String string)
-            throws JSONException {
-        return toJSONArray(names, new JSONTokener(string));
-    }
-
-    /**
-     * Produce a JSONArray of JSONObjects from a comma delimited text string
-     * using a supplied JSONArray as the source of element names.
-     * @param names A JSONArray of strings.
-     * @param x A JSONTokener of the source text.
-     * @return A JSONArray of JSONObjects.
-     * @throws JSONException
-     */
-    public static JSONArray toJSONArray(JSONArray names, JSONTokener x)
-            throws JSONException {
-        if (names == null || names.length() == 0) {
-            return null;
-        }
-        JSONArray ja = new JSONArray();
-        for (;;) {
-            JSONObject jo = rowToJSONObject(names, x);
-            if (jo == null) {
-                break;
-            }
-            ja.put(jo);
-        }
-        if (ja.length() == 0) {
-            return null;
-        }
-        return ja;
-    }
-
-
-    /**
-     * Produce a comma delimited text from a JSONArray of JSONObjects. The
-     * first row will be a list of names obtained by inspecting the first
-     * JSONObject.
-     * @param ja A JSONArray of JSONObjects.
-     * @return A comma delimited text.
-     * @throws JSONException
-     */
-    public static String toString(JSONArray ja) throws JSONException {
-        JSONObject jo = ja.optJSONObject(0);
-        if (jo != null) {
-            JSONArray names = jo.names();
-            if (names != null) {
-                return rowToString(names) + toString(names, ja);
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Produce a comma delimited text from a JSONArray of JSONObjects using
-     * a provided list of names. The list of names is not included in the
-     * output.
-     * @param names A JSONArray of strings.
-     * @param ja A JSONArray of JSONObjects.
-     * @return A comma delimited text.
-     * @throws JSONException
-     */
-    public static String toString(JSONArray names, JSONArray ja)
-            throws JSONException {
-        if (names == null || names.length() == 0) {
-            return null;
-        }
-        StringBuffer sb = new StringBuffer();
-        for (int i = 0; i < ja.length(); i += 1) {
-            JSONObject jo = ja.optJSONObject(i);
-            if (jo != null) {
-                sb.append(rowToString(jo.toJSONArray(names)));
-            }
-        }
-        return sb.toString();
-    }
-}
+package org.apache.wicket.ajax.json;
+
+/*
+Copyright (c) 2002 JSON.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+/**
+ * This provides static methods to convert comma delimited text into a
+ * JSONArray, and to covert a JSONArray into comma delimited text. Comma
+ * delimited text is a very popular format for data interchange. It is
+ * understood by most database, spreadsheet, and organizer programs.
+ * <p>
+ * Each row of text represents a row in a table or a data record. Each row
+ * ends with a NEWLINE character. Each row contains one or more values.
+ * Values are separated by commas. A value can contain any character except
+ * for comma, unless is is wrapped in single quotes or double quotes.
+ * <p>
+ * The first row usually contains the names of the columns.
+ * <p>
+ * A comma delimited list can be converted into a JSONArray of JSONObjects.
+ * The names for the elements in the JSONObjects can be taken from the names
+ * in the first row.
+ * @author JSON.org
+ * @version 2012-11-13
+ */
+public class CDL {
+
+    /**
+     * Get the next value. The value can be wrapped in quotes. The value can
+     * be empty.
+     * @param x A JSONTokener of the source text.
+     * @return The value string, or null if empty.
+     * @throws JSONException if the quoted string is badly formed.
+     */
+    private static String getValue(JSONTokener x) throws JSONException
+    {
+        char c;
+        char q;
+        StringBuffer sb;
+        do {
+            c = x.next();
+        } while (c == ' ' || c == '\t');
+        switch (c) {
+        case 0:
+            return null;
+        case '"':
+        case '\'':
+            q = c;
+            sb = new StringBuffer();
+            for (;;) {
+                c = x.next();
+                if (c == q) {
+                    break;
+                }
+                if (c == 0 || c == '\n' || c == '\r') {
+                    throw x.syntaxError("Missing close quote '" + q + "'.");
+                }
+                sb.append(c);
+            }
+            return sb.toString();
+        case ',':
+            x.back();
+            return "";
+        default:
+            x.back();
+            return x.nextTo(',');
+        }
+    }
+
+    /**
+     * Produce a JSONArray of strings from a row of comma delimited values.
+     * @param x A JSONTokener of the source text.
+     * @return A JSONArray of strings.
+     * @throws JSONException
+     */
+    public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException
+    {
+        JSONArray ja = new JSONArray();
+        for (;;) {
+            String value = getValue(x);
+            char c = x.next();
+            if (value == null ||
+                    (ja.length() == 0 && value.length() == 0 && c != ',')) {
+                return null;
+            }
+            ja.put(value);
+            for (;;) {
+                if (c == ',') {
+                    break;
+                }
+                if (c != ' ') {
+                    if (c == '\n' || c == '\r' || c == 0) {
+                        return ja;
+                    }
+                    throw x.syntaxError("Bad character '" + c + "' (" +
+                            (int)c + ").");
+                }
+                c = x.next();
+            }
+        }
+    }
+
+    /**
+     * Produce a JSONObject from a row of comma delimited text, using a
+     * parallel JSONArray of strings to provides the names of the elements.
+     * @param names A JSONArray of names. This is commonly obtained from the
+     *  first row of a comma delimited text file using the rowToJSONArray
+     *  method.
+     * @param x A JSONTokener of the source text.
+     * @return A JSONObject combining the names and values.
+     * @throws JSONException
+     */
+    public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x)
+            throws JSONException
+    {
+        JSONArray ja = rowToJSONArray(x);
+        return ja != null ? ja.toJSONObject(names) :  null;
+    }
+
+    /**
+     * Produce a comma delimited text row from a JSONArray. Values containing
+     * the comma character will be quoted. Troublesome characters may be
+     * removed.
+     * @param ja A JSONArray of strings.
+     * @return A string ending in NEWLINE.
+     */
+    public static String rowToString(JSONArray ja) {
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < ja.length(); i += 1) {
+            if (i > 0) {
+                sb.append(',');
+            }
+            Object object = ja.opt(i);
+            if (object != null) {
+                String string = object.toString();
+                if (string.length() > 0 && (string.indexOf(',') >= 0 ||
+                        string.indexOf('\n') >= 0 || string.indexOf('\r') >= 0 ||
+                        string.indexOf(0) >= 0 || string.charAt(0) == '"')) {
+                    sb.append('"');
+                    int length = string.length();
+                    for (int j = 0; j < length; j += 1) {
+                        char c = string.charAt(j);
+                        if (c >= ' ' && c != '"') {
+                            sb.append(c);
+                        }
+                    }
+                    sb.append('"');
+                } else {
+                    sb.append(string);
+                }
+            }
+        }
+        sb.append('\n');
+        return sb.toString();
+    }
+
+    /**
+     * Produce a JSONArray of JSONObjects from a comma delimited text string,
+     * using the first row as a source of names.
+     * @param string The comma delimited text.
+     * @return A JSONArray of JSONObjects.
+     * @throws JSONException
+     */
+    public static JSONArray toJSONArray(String string) throws JSONException
+    {
+        return toJSONArray(new JSONTokener(string));
+    }
+
+    /**
+     * Produce a JSONArray of JSONObjects from a comma delimited text string,
+     * using the first row as a source of names.
+     * @param x The JSONTokener containing the comma delimited text.
+     * @return A JSONArray of JSONObjects.
+     * @throws JSONException
+     */
+    public static JSONArray toJSONArray(JSONTokener x) throws JSONException
+    {
+        return toJSONArray(rowToJSONArray(x), x);
+    }
+
+    /**
+     * Produce a JSONArray of JSONObjects from a comma delimited text string
+     * using a supplied JSONArray as the source of element names.
+     * @param names A JSONArray of strings.
+     * @param string The comma delimited text.
+     * @return A JSONArray of JSONObjects.
+     * @throws JSONException
+     */
+    public static JSONArray toJSONArray(JSONArray names, String string)
+            throws JSONException
+    {
+        return toJSONArray(names, new JSONTokener(string));
+    }
+
+    /**
+     * Produce a JSONArray of JSONObjects from a comma delimited text string
+     * using a supplied JSONArray as the source of element names.
+     * @param names A JSONArray of strings.
+     * @param x A JSONTokener of the source text.
+     * @return A JSONArray of JSONObjects.
+     * @throws JSONException
+     */
+    public static JSONArray toJSONArray(JSONArray names, JSONTokener x)
+            throws JSONException
+    {
+        if (names == null || names.length() == 0) {
+            return null;
+        }
+        JSONArray ja = new JSONArray();
+        for (;;) {
+            JSONObject jo = rowToJSONObject(names, x);
+            if (jo == null) {
+                break;
+            }
+            ja.put(jo);
+        }
+        if (ja.length() == 0) {
+            return null;
+        }
+        return ja;
+    }
+
+
+    /**
+     * Produce a comma delimited text from a JSONArray of JSONObjects. The
+     * first row will be a list of names obtained by inspecting the first
+     * JSONObject.
+     * @param ja A JSONArray of JSONObjects.
+     * @return A comma delimited text.
+     * @throws JSONException
+     */
+    public static String toString(JSONArray ja) throws JSONException
+    {
+        JSONObject jo = ja.optJSONObject(0);
+        if (jo != null) {
+            JSONArray names = jo.names();
+            if (names != null) {
+                return rowToString(names) + toString(names, ja);
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Produce a comma delimited text from a JSONArray of JSONObjects using
+     * a provided list of names. The list of names is not included in the
+     * output.
+     * @param names A JSONArray of strings.
+     * @param ja A JSONArray of JSONObjects.
+     * @return A comma delimited text.
+     * @throws JSONException
+     */
+    public static String toString(JSONArray names, JSONArray ja)
+            throws JSONException
+    {
+        if (names == null || names.length() == 0) {
+            return null;
+        }
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < ja.length(); i += 1) {
+            JSONObject jo = ja.optJSONObject(i);
+            if (jo != null) {
+                sb.append(rowToString(jo.toJSONArray(names)));
+            }
+        }
+        return sb.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/main/java/org/apache/wicket/ajax/json/Cookie.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/Cookie.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/Cookie.java
index 31a3e84..672d70a 100755
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/Cookie.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/Cookie.java
@@ -78,9 +78,10 @@ public class Cookie {
      *  members.
      * @throws JSONException
      */
-    public static JSONObject toJSONObject(String string) throws JSONException {
+    public static JSONObject toJSONObject(String string) throws JSONException
+    {
         String         name;
-        JSONObject     jo = new JSONObject();
+        JSONObject jo = new JSONObject();
         Object         value;
         JSONTokener x = new JSONTokener(string);
         jo.put("name", x.nextTo('='));
@@ -115,7 +116,8 @@ public class Cookie {
      * @return A cookie specification string
      * @throws JSONException
      */
-    public static String toString(JSONObject jo) throws JSONException {
+    public static String toString(JSONObject jo) throws JSONException
+    {
         StringBuffer sb = new StringBuffer();
 
         sb.append(escape(jo.getString("name")));

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/main/java/org/apache/wicket/ajax/json/CookieList.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/CookieList.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/CookieList.java
index 13c2eff..cf740dc 100755
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/CookieList.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/CookieList.java
@@ -26,6 +26,8 @@ SOFTWARE.
 
 import java.util.Iterator;
 
+import org.apache.wicket.ajax.json.Cookie;
+
 /**
  * Convert a web browser cookie list string to a JSONObject and back.
  * @author JSON.org
@@ -46,7 +48,8 @@ public class CookieList {
      * @return A JSONObject
      * @throws JSONException
      */
-    public static JSONObject toJSONObject(String string) throws JSONException {
+    public static JSONObject toJSONObject(String string) throws JSONException
+    {
         JSONObject jo = new JSONObject();
         JSONTokener x = new JSONTokener(string);
         while (x.more()) {
@@ -68,7 +71,8 @@ public class CookieList {
      * @return A cookie list string
      * @throws JSONException
      */
-    public static String toString(JSONObject jo) throws JSONException {
+    public static String toString(JSONObject jo) throws JSONException
+    {
         boolean      b = false;
         Iterator     keys = jo.keys();
         String       string;

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/main/java/org/apache/wicket/ajax/json/HTTP.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/HTTP.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/HTTP.java
index 4b265cb..e37434b 100755
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/HTTP.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/HTTP.java
@@ -68,9 +68,10 @@ public class HTTP {
      * of the XML string.
      * @throws JSONException
      */
-    public static JSONObject toJSONObject(String string) throws JSONException {
-        JSONObject     jo = new JSONObject();
-        HTTPTokener    x = new HTTPTokener(string);
+    public static JSONObject toJSONObject(String string) throws JSONException
+    {
+        JSONObject jo = new JSONObject();
+        HTTPTokener x = new HTTPTokener(string);
         String         token;
 
         token = x.nextToken();
@@ -124,7 +125,8 @@ public class HTTP {
      * @throws JSONException if the object does not contain enough
      *  information.
      */
-    public static String toString(JSONObject jo) throws JSONException {
+    public static String toString(JSONObject jo) throws JSONException
+    {
         Iterator     keys = jo.keys();
         String       string;
         StringBuffer sb = new StringBuffer();

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/main/java/org/apache/wicket/ajax/json/HTTPTokener.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/HTTPTokener.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/HTTPTokener.java
index 97b5b2b..a9962b9 100755
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/HTTPTokener.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/HTTPTokener.java
@@ -1,77 +1,79 @@
-package org.apache.wicket.ajax.json;
-
-/*
-Copyright (c) 2002 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-/**
- * The HTTPTokener extends the JSONTokener to provide additional methods
- * for the parsing of HTTP headers.
- * @author JSON.org
- * @version 2010-12-24
- */
-public class HTTPTokener extends JSONTokener {
-
-    /**
-     * Construct an HTTPTokener from a string.
-     * @param string A source string.
-     */
-    public HTTPTokener(String string) {
-        super(string);
-    }
-
-
-    /**
-     * Get the next token or string. This is used in parsing HTTP headers.
-     * @throws JSONException
-     * @return A String.
-     */
-    public String nextToken() throws JSONException {
-        char c;
-        char q;
-        StringBuffer sb = new StringBuffer();
-        do {
-            c = next();
-        } while (Character.isWhitespace(c));
-        if (c == '"' || c == '\'') {
-            q = c;
-            for (;;) {
-                c = next();
-                if (c < ' ') {
-                    throw syntaxError("Unterminated string.");
-                }
-                if (c == q) {
-                    return sb.toString();
-                }
-                sb.append(c);
-            }
-        } 
-        for (;;) {
-            if (c == 0 || Character.isWhitespace(c)) {
-                return sb.toString();
-            }
-            sb.append(c);
-            c = next();
-        }
-    }
-}
+package org.apache.wicket.ajax.json;
+
+/*
+Copyright (c) 2002 JSON.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+/**
+ * The HTTPTokener extends the JSONTokener to provide additional methods
+ * for the parsing of HTTP headers.
+ * @author JSON.org
+ * @version 2012-11-13
+ */
+public class HTTPTokener extends JSONTokener
+{
+
+    /**
+     * Construct an HTTPTokener from a string.
+     * @param string A source string.
+     */
+    public HTTPTokener(String string) {
+        super(string);
+    }
+
+
+    /**
+     * Get the next token or string. This is used in parsing HTTP headers.
+     * @throws JSONException
+     * @return A String.
+     */
+    public String nextToken() throws JSONException
+    {
+        char c;
+        char q;
+        StringBuffer sb = new StringBuffer();
+        do {
+            c = next();
+        } while (Character.isWhitespace(c));
+        if (c == '"' || c == '\'') {
+            q = c;
+            for (;;) {
+                c = next();
+                if (c < ' ') {
+                    throw syntaxError("Unterminated string.");
+                }
+                if (c == q) {
+                    return sb.toString();
+                }
+                sb.append(c);
+            }
+        }
+        for (;;) {
+            if (c == 0 || Character.isWhitespace(c)) {
+                return sb.toString();
+            }
+            sb.append(c);
+            c = next();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONArray.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONArray.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONArray.java
old mode 100755
new mode 100644
index d328d0c..65e9496
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONArray.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONArray.java
@@ -1,28 +1,28 @@
 package org.apache.wicket.ajax.json;
 
 /*
-Copyright (c) 2002 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
+ Copyright (c) 2002 JSON.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ The Software shall be used for Good, not Evil.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+ */
 
 import java.io.IOException;
 import java.io.StringWriter;
@@ -69,25 +69,21 @@ import java.util.Map;
  * <li>Strings do not need to be quoted at all if they do not begin with a quote
  * or single quote, and if they do not contain leading or trailing spaces, and
  * if they do not contain any of these characters:
- * <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers and
+ * <code>{ } [ ] / \ : , #</code> and if they do not look like numbers and
  * if they are not the reserved words <code>true</code>, <code>false</code>, or
  * <code>null</code>.</li>
- * <li>Values can be separated by <code>;</code> <small>(semicolon)</small> as
- * well as by <code>,</code> <small>(comma)</small>.</li>
  * </ul>
  *
  * @author JSON.org
- * @version 2012-04-20
+ * @version 2013-04-18
  */
 public class JSONArray {
 
-
     /**
      * The arrayList where the JSONArray's properties are kept.
      */
     private final ArrayList myArrayList;
 
-
     /**
      * Construct an empty JSONArray.
      */
@@ -97,10 +93,14 @@ public class JSONArray {
 
     /**
      * Construct a JSONArray from a JSONTokener.
-     * @param x A JSONTokener
-     * @throws JSONException If there is a syntax error.
+     *
+     * @param x
+     *            A JSONTokener
+     * @throws JSONException
+     *             If there is a syntax error.
      */
-    public JSONArray(JSONTokener x) throws JSONException {
+    public JSONArray(JSONTokener x) throws JSONException
+    {
         this();
         if (x.nextClean() != '[') {
             throw x.syntaxError("A JSONArray text must start with '['");
@@ -116,7 +116,6 @@ public class JSONArray {
                     this.myArrayList.add(x.nextValue());
                 }
                 switch (x.nextClean()) {
-                case ';':
                 case ',':
                     if (x.nextClean() == ']') {
                         return;
@@ -132,22 +131,26 @@ public class JSONArray {
         }
     }
 
-
     /**
      * Construct a JSONArray from a source JSON text.
-     * @param source     A string that begins with
-     * <code>[</code>&nbsp;<small>(left bracket)</small>
-     *  and ends with <code>]</code>&nbsp;<small>(right bracket)</small>.
-     *  @throws JSONException If there is a syntax error.
+     *
+     * @param source
+     *            A string that begins with <code>[</code>&nbsp;<small>(left
+     *            bracket)</small> and ends with <code>]</code>
+     *            &nbsp;<small>(right bracket)</small>.
+     * @throws JSONException
+     *             If there is a syntax error.
      */
-    public JSONArray(String source) throws JSONException {
+    public JSONArray(String source) throws JSONException
+    {
         this(new JSONTokener(source));
     }
 
-
     /**
      * Construct a JSONArray from a Collection.
-     * @param collection     A Collection.
+     *
+     * @param collection
+     *            A Collection.
      */
     public JSONArray(Collection collection) {
         this.myArrayList = new ArrayList();
@@ -159,12 +162,14 @@ public class JSONArray {
         }
     }
 
-
     /**
      * Construct a JSONArray from an array
-     * @throws JSONException If not an array.
+     *
+     * @throws JSONException
+     *             If not an array.
      */
-    public JSONArray(Object array) throws JSONException {
+    public JSONArray(Object array) throws JSONException
+    {
         this();
         if (array.getClass().isArray()) {
             int length = Array.getLength(array);
@@ -173,19 +178,21 @@ public class JSONArray {
             }
         } else {
             throw new JSONException(
-"JSONArray initial value should be a string or collection or array.");
+                    "JSONArray initial value should be a string or collection or array.");
         }
     }
 
-
     /**
      * Get the object value associated with an index.
+     *
      * @param index
-     *  The index must be between 0 and length() - 1.
+     *            The index must be between 0 and length() - 1.
      * @return An object value.
-     * @throws JSONException If there is no value for the index.
+     * @throws JSONException
+     *             If there is no value for the index.
      */
-    public Object get(int index) throws JSONException {
+    public Object get(int index) throws JSONException
+    {
         Object object = this.opt(index);
         if (object == null) {
             throw new JSONException("JSONArray[" + index + "] not found.");
@@ -193,161 +200,174 @@ public class JSONArray {
         return object;
     }
 
-
     /**
-     * Get the boolean value associated with an index.
-     * The string values "true" and "false" are converted to boolean.
+     * Get the boolean value associated with an index. The string values "true"
+     * and "false" are converted to boolean.
      *
-     * @param index The index must be between 0 and length() - 1.
-     * @return      The truth.
-     * @throws JSONException If there is no value for the index or if the
-     *  value is not convertible to boolean.
+     * @param index
+     *            The index must be between 0 and length() - 1.
+     * @return The truth.
+     * @throws JSONException
+     *             If there is no value for the index or if the value is not
+     *             convertible to boolean.
      */
-    public boolean getBoolean(int index) throws JSONException {
+    public boolean getBoolean(int index) throws JSONException
+    {
         Object object = this.get(index);
-        if (object.equals(Boolean.FALSE) ||
-                (object instanceof String &&
-                ((String)object).equalsIgnoreCase("false"))) {
+        if (object.equals(Boolean.FALSE)
+                || (object instanceof String && ((String) object)
+                        .equalsIgnoreCase("false"))) {
             return false;
-        } else if (object.equals(Boolean.TRUE) ||
-                (object instanceof String &&
-                ((String)object).equalsIgnoreCase("true"))) {
+        } else if (object.equals(Boolean.TRUE)
+                || (object instanceof String && ((String) object)
+                        .equalsIgnoreCase("true"))) {
             return true;
         }
         throw new JSONException("JSONArray[" + index + "] is not a boolean.");
     }
 
-
     /**
      * Get the double value associated with an index.
      *
-     * @param index The index must be between 0 and length() - 1.
-     * @return      The value.
-     * @throws   JSONException If the key is not found or if the value cannot
-     *  be converted to a number.
+     * @param index
+     *            The index must be between 0 and length() - 1.
+     * @return The value.
+     * @throws JSONException
+     *             If the key is not found or if the value cannot be converted
+     *             to a number.
      */
-    public double getDouble(int index) throws JSONException {
+    public double getDouble(int index) throws JSONException
+    {
         Object object = this.get(index);
         try {
-            return object instanceof Number
-                ? ((Number)object).doubleValue()
-                : Double.parseDouble((String)object);
+            return object instanceof Number ? ((Number) object).doubleValue()
+                    : Double.parseDouble((String) object);
         } catch (Exception e) {
-            throw new JSONException("JSONArray[" + index +
-                "] is not a number.");
+            throw new JSONException("JSONArray[" + index + "] is not a number.");
         }
     }
 
-
     /**
      * Get the int value associated with an index.
      *
-     * @param index The index must be between 0 and length() - 1.
-     * @return      The value.
-     * @throws   JSONException If the key is not found or if the value is not a number.
+     * @param index
+     *            The index must be between 0 and length() - 1.
+     * @return The value.
+     * @throws JSONException
+     *             If the key is not found or if the value is not a number.
      */
-    public int getInt(int index) throws JSONException {
+    public int getInt(int index) throws JSONException
+    {
         Object object = this.get(index);
         try {
-            return object instanceof Number
-                ? ((Number)object).intValue()
-                : Integer.parseInt((String)object);
+            return object instanceof Number ? ((Number) object).intValue()
+                    : Integer.parseInt((String) object);
         } catch (Exception e) {
-            throw new JSONException("JSONArray[" + index +
-                "] is not a number.");
+            throw new JSONException("JSONArray[" + index + "] is not a number.");
         }
     }
 
-
     /**
      * Get the JSONArray associated with an index.
-     * @param index The index must be between 0 and length() - 1.
-     * @return      A JSONArray value.
-     * @throws JSONException If there is no value for the index. or if the
-     * value is not a JSONArray
+     *
+     * @param index
+     *            The index must be between 0 and length() - 1.
+     * @return A JSONArray value.
+     * @throws JSONException
+     *             If there is no value for the index. or if the value is not a
+     *             JSONArray
      */
-    public JSONArray getJSONArray(int index) throws JSONException {
+    public JSONArray getJSONArray(int index) throws JSONException
+    {
         Object object = this.get(index);
         if (object instanceof JSONArray) {
-            return (JSONArray)object;
+            return (JSONArray) object;
         }
-        throw new JSONException("JSONArray[" + index +
-                "] is not a JSONArray.");
+        throw new JSONException("JSONArray[" + index + "] is not a JSONArray.");
     }
 
-
     /**
      * Get the JSONObject associated with an index.
-     * @param index subscript
-     * @return      A JSONObject value.
-     * @throws JSONException If there is no value for the index or if the
-     * value is not a JSONObject
+     *
+     * @param index
+     *            subscript
+     * @return A JSONObject value.
+     * @throws JSONException
+     *             If there is no value for the index or if the value is not a
+     *             JSONObject
      */
-    public JSONObject getJSONObject(int index) throws JSONException {
+    public JSONObject getJSONObject(int index) throws JSONException
+    {
         Object object = this.get(index);
         if (object instanceof JSONObject) {
-            return (JSONObject)object;
+            return (JSONObject) object;
         }
-        throw new JSONException("JSONArray[" + index +
-            "] is not a JSONObject.");
+        throw new JSONException("JSONArray[" + index + "] is not a JSONObject.");
     }
 
-
     /**
      * Get the long value associated with an index.
      *
-     * @param index The index must be between 0 and length() - 1.
-     * @return      The value.
-     * @throws   JSONException If the key is not found or if the value cannot
-     *  be converted to a number.
+     * @param index
+     *            The index must be between 0 and length() - 1.
+     * @return The value.
+     * @throws JSONException
+     *             If the key is not found or if the value cannot be converted
+     *             to a number.
      */
-    public long getLong(int index) throws JSONException {
+    public long getLong(int index) throws JSONException
+    {
         Object object = this.get(index);
         try {
-            return object instanceof Number
-                ? ((Number)object).longValue()
-                : Long.parseLong((String)object);
+            return object instanceof Number ? ((Number) object).longValue()
+                    : Long.parseLong((String) object);
         } catch (Exception e) {
-            throw new JSONException("JSONArray[" + index +
-                "] is not a number.");
+            throw new JSONException("JSONArray[" + index + "] is not a number.");
         }
     }
 
-
     /**
      * Get the string associated with an index.
-     * @param index The index must be between 0 and length() - 1.
-     * @return      A string value.
-     * @throws JSONException If there is no string value for the index.
+     *
+     * @param index
+     *            The index must be between 0 and length() - 1.
+     * @return A string value.
+     * @throws JSONException
+     *             If there is no string value for the index.
      */
-    public String getString(int index) throws JSONException {
+    public String getString(int index) throws JSONException
+    {
         Object object = this.get(index);
         if (object instanceof String) {
-            return (String)object;
+            return (String) object;
         }
         throw new JSONException("JSONArray[" + index + "] not a string.");
     }
 
-
     /**
      * Determine if the value is null.
-     * @param index The index must be between 0 and length() - 1.
+     *
+     * @param index
+     *            The index must be between 0 and length() - 1.
      * @return true if the value at the index is null, or if there is no value.
      */
     public boolean isNull(int index) {
         return JSONObject.NULL.equals(this.opt(index));
     }
 
-
     /**
      * Make a string from the contents of this JSONArray. The
-     * <code>separator</code> string is inserted between each element.
-     * Warning: This method assumes that the data structure is acyclical.
-     * @param separator A string that will be inserted between the elements.
+     * <code>separator</code> string is inserted between each element. Warning:
+     * This method assumes that the data structure is acyclical.
+     *
+     * @param separator
+     *            A string that will be inserted between the elements.
      * @return a string.
-     * @throws JSONException If the array contains an invalid number.
+     * @throws JSONException
+     *             If the array contains an invalid number.
      */
-    public String join(String separator) throws JSONException {
+    public String join(String separator) throws JSONException
+    {
         int len = this.length();
         StringBuffer sb = new StringBuffer();
 
@@ -360,7 +380,6 @@ public class JSONArray {
         return sb.toString();
     }
 
-
     /**
      * Get the number of elements in the JSONArray, included nulls.
      *
@@ -370,43 +389,43 @@ public class JSONArray {
         return this.myArrayList.size();
     }
 
-
     /**
      * Get the optional object value associated with an index.
-     * @param index The index must be between 0 and length() - 1.
-     * @return      An object value, or null if there is no
-     *              object at that index.
+     *
+     * @param index
+     *            The index must be between 0 and length() - 1.
+     * @return An object value, or null if there is no object at that index.
      */
     public Object opt(int index) {
-        return (index < 0 || index >= this.length())
-            ? null
-            : this.myArrayList.get(index);
+        return (index < 0 || index >= this.length()) ? null : this.myArrayList
+                .get(index);
     }
 
-
     /**
-     * Get the optional boolean value associated with an index.
-     * It returns false if there is no value at that index,
-     * or if the value is not Boolean.TRUE or the String "true".
+     * Get the optional boolean value associated with an index. It returns false
+     * if there is no value at that index, or if the value is not Boolean.TRUE
+     * or the String "true".
      *
-     * @param index The index must be between 0 and length() - 1.
-     * @return      The truth.
+     * @param index
+     *            The index must be between 0 and length() - 1.
+     * @return The truth.
      */
-    public boolean optBoolean(int index)  {
+    public boolean optBoolean(int index) {
         return this.optBoolean(index, false);
     }
 
-
     /**
-     * Get the optional boolean value associated with an index.
-     * It returns the defaultValue if there is no value at that index or if
-     * it is not a Boolean or the String "true" or "false" (case insensitive).
+     * Get the optional boolean value associated with an index. It returns the
+     * defaultValue if there is no value at that index or if it is not a Boolean
+     * or the String "true" or "false" (case insensitive).
      *
-     * @param index The index must be between 0 and length() - 1.
-     * @param defaultValue     A boolean default.
-     * @return      The truth.
+     * @param index
+     *            The index must be between 0 and length() - 1.
+     * @param defaultValue
+     *            A boolean default.
+     * @return The truth.
      */
-    public boolean optBoolean(int index, boolean defaultValue)  {
+    public boolean optBoolean(int index, boolean defaultValue) {
         try {
             return this.getBoolean(index);
         } catch (Exception e) {
@@ -414,28 +433,29 @@ public class JSONArray {
         }
     }
 
-
     /**
-     * Get the optional double value associated with an index.
-     * NaN is returned if there is no value for the index,
-     * or if the value is not a number and cannot be converted to a number.
+     * Get the optional double value associated with an index. NaN is returned
+     * if there is no value for the index, or if the value is not a number and
+     * cannot be converted to a number.
      *
-     * @param index The index must be between 0 and length() - 1.
-     * @return      The value.
+     * @param index
+     *            The index must be between 0 and length() - 1.
+     * @return The value.
      */
     public double optDouble(int index) {
         return this.optDouble(index, Double.NaN);
     }
 
-
     /**
-     * Get the optional double value associated with an index.
-     * The defaultValue is returned if there is no value for the index,
-     * or if the value is not a number and cannot be converted to a number.
+     * Get the optional double value associated with an index. The defaultValue
+     * is returned if there is no value for the index, or if the value is not a
+     * number and cannot be converted to a number.
      *
-     * @param index subscript
-     * @param defaultValue     The default value.
-     * @return      The value.
+     * @param index
+     *            subscript
+     * @param defaultValue
+     *            The default value.
+     * @return The value.
      */
     public double optDouble(int index, double defaultValue) {
         try {
@@ -445,27 +465,29 @@ public class JSONArray {
         }
     }
 
-
     /**
-     * Get the optional int value associated with an index.
-     * Zero is returned if there is no value for the index,
-     * or if the value is not a number and cannot be converted to a number.
+     * Get the optional int value associated with an index. Zero is returned if
+     * there is no value for the index, or if the value is not a number and
+     * cannot be converted to a number.
      *
-     * @param index The index must be between 0 and length() - 1.
-     * @return      The value.
+     * @param index
+     *            The index must be between 0 and length() - 1.
+     * @return The value.
      */
     public int optInt(int index) {
         return this.optInt(index, 0);
     }
 
-
     /**
-     * Get the optional int value associated with an index.
-     * The defaultValue is returned if there is no value for the index,
-     * or if the value is not a number and cannot be converted to a number.
-     * @param index The index must be between 0 and length() - 1.
-     * @param defaultValue     The default value.
-     * @return      The value.
+     * Get the optional int value associated with an index. The defaultValue is
+     * returned if there is no value for the index, or if the value is not a
+     * number and cannot be converted to a number.
+     *
+     * @param index
+     *            The index must be between 0 and length() - 1.
+     * @param defaultValue
+     *            The default value.
+     * @return The value.
      */
     public int optInt(int index, int defaultValue) {
         try {
@@ -475,53 +497,56 @@ public class JSONArray {
         }
     }
 
-
     /**
      * Get the optional JSONArray associated with an index.
-     * @param index subscript
-     * @return      A JSONArray value, or null if the index has no value,
-     * or if the value is not a JSONArray.
+     *
+     * @param index
+     *            subscript
+     * @return A JSONArray value, or null if the index has no value, or if the
+     *         value is not a JSONArray.
      */
     public JSONArray optJSONArray(int index) {
         Object o = this.opt(index);
-        return o instanceof JSONArray ? (JSONArray)o : null;
+        return o instanceof JSONArray ? (JSONArray) o : null;
     }
 
-
     /**
-     * Get the optional JSONObject associated with an index.
-     * Null is returned if the key is not found, or null if the index has
-     * no value, or if the value is not a JSONObject.
+     * Get the optional JSONObject associated with an index. Null is returned if
+     * the key is not found, or null if the index has no value, or if the value
+     * is not a JSONObject.
      *
-     * @param index The index must be between 0 and length() - 1.
-     * @return      A JSONObject value.
+     * @param index
+     *            The index must be between 0 and length() - 1.
+     * @return A JSONObject value.
      */
     public JSONObject optJSONObject(int index) {
         Object o = this.opt(index);
-        return o instanceof JSONObject ? (JSONObject)o : null;
+        return o instanceof JSONObject ? (JSONObject) o : null;
     }
 
-
     /**
-     * Get the optional long value associated with an index.
-     * Zero is returned if there is no value for the index,
-     * or if the value is not a number and cannot be converted to a number.
+     * Get the optional long value associated with an index. Zero is returned if
+     * there is no value for the index, or if the value is not a number and
+     * cannot be converted to a number.
      *
-     * @param index The index must be between 0 and length() - 1.
-     * @return      The value.
+     * @param index
+     *            The index must be between 0 and length() - 1.
+     * @return The value.
      */
     public long optLong(int index) {
         return this.optLong(index, 0);
     }
 
-
     /**
-     * Get the optional long value associated with an index.
-     * The defaultValue is returned if there is no value for the index,
-     * or if the value is not a number and cannot be converted to a number.
-     * @param index The index must be between 0 and length() - 1.
-     * @param defaultValue     The default value.
-     * @return      The value.
+     * Get the optional long value associated with an index. The defaultValue is
+     * returned if there is no value for the index, or if the value is not a
+     * number and cannot be converted to a number.
+     *
+     * @param index
+     *            The index must be between 0 and length() - 1.
+     * @param defaultValue
+     *            The default value.
+     * @return The value.
      */
     public long optLong(int index, long defaultValue) {
         try {
@@ -531,40 +556,40 @@ public class JSONArray {
         }
     }
 
-
     /**
      * Get the optional string value associated with an index. It returns an
-     * empty string if there is no value at that index. If the value
-     * is not a string and is not null, then it is coverted to a string.
+     * empty string if there is no value at that index. If the value is not a
+     * string and is not null, then it is coverted to a string.
      *
-     * @param index The index must be between 0 and length() - 1.
-     * @return      A String value.
+     * @param index
+     *            The index must be between 0 and length() - 1.
+     * @return A String value.
      */
     public String optString(int index) {
         return this.optString(index, "");
     }
 
-
     /**
-     * Get the optional string associated with an index.
-     * The defaultValue is returned if the key is not found.
+     * Get the optional string associated with an index. The defaultValue is
+     * returned if the key is not found.
      *
-     * @param index The index must be between 0 and length() - 1.
-     * @param defaultValue     The default value.
-     * @return      A String value.
+     * @param index
+     *            The index must be between 0 and length() - 1.
+     * @param defaultValue
+     *            The default value.
+     * @return A String value.
      */
     public String optString(int index, String defaultValue) {
         Object object = this.opt(index);
-        return JSONObject.NULL.equals(object)
- ? defaultValue : object
+        return JSONObject.NULL.equals(object) ? defaultValue : object
                 .toString();
     }
 
-
     /**
      * Append a boolean value. This increases the array's length by one.
      *
-     * @param value A boolean value.
+     * @param value
+     *            A boolean value.
      * @return this.
      */
     public JSONArray put(boolean value) {
@@ -572,38 +597,41 @@ public class JSONArray {
         return this;
     }
 
-
     /**
-     * Put a value in the JSONArray, where the value will be a
-     * JSONArray which is produced from a Collection.
-     * @param value A Collection value.
-     * @return      this.
+     * Put a value in the JSONArray, where the value will be a JSONArray which
+     * is produced from a Collection.
+     *
+     * @param value
+     *            A Collection value.
+     * @return this.
      */
     public JSONArray put(Collection value) {
         this.put(new JSONArray(value));
         return this;
     }
 
-
     /**
      * Append a double value. This increases the array's length by one.
      *
-     * @param value A double value.
-     * @throws JSONException if the value is not finite.
+     * @param value
+     *            A double value.
+     * @throws JSONException
+     *             if the value is not finite.
      * @return this.
      */
-    public JSONArray put(double value) throws JSONException {
+    public JSONArray put(double value) throws JSONException
+    {
         Double d = new Double(value);
         JSONObject.testValidity(d);
         this.put(d);
         return this;
     }
 
-
     /**
      * Append an int value. This increases the array's length by one.
      *
-     * @param value An int value.
+     * @param value
+     *            An int value.
      * @return this.
      */
     public JSONArray put(int value) {
@@ -611,11 +639,11 @@ public class JSONArray {
         return this;
     }
 
-
     /**
      * Append an long value. This increases the array's length by one.
      *
-     * @param value A long value.
+     * @param value
+     *            A long value.
      * @return this.
      */
     public JSONArray put(long value) {
@@ -623,24 +651,26 @@ public class JSONArray {
         return this;
     }
 
-
     /**
-     * Put a value in the JSONArray, where the value will be a
-     * JSONObject which is produced from a Map.
-     * @param value A Map value.
-     * @return      this.
+     * Put a value in the JSONArray, where the value will be a JSONObject which
+     * is produced from a Map.
+     *
+     * @param value
+     *            A Map value.
+     * @return this.
      */
     public JSONArray put(Map value) {
         this.put(new JSONObject(value));
         return this;
     }
 
-
     /**
      * Append an object value. This increases the array's length by one.
-     * @param value An object value.  The value should be a
-     *  Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
-     *  JSONObject.NULL object.
+     *
+     * @param value
+     *            An object value. The value should be a Boolean, Double,
+     *            Integer, JSONArray, JSONObject, Long, or String, or the
+     *            JSONObject.NULL object.
      * @return this.
      */
     public JSONArray put(Object value) {
@@ -648,111 +678,137 @@ public class JSONArray {
         return this;
     }
 
-
     /**
      * Put or replace a boolean value in the JSONArray. If the index is greater
      * than the length of the JSONArray, then null elements will be added as
      * necessary to pad it out.
-     * @param index The subscript.
-     * @param value A boolean value.
+     *
+     * @param index
+     *            The subscript.
+     * @param value
+     *            A boolean value.
      * @return this.
-     * @throws JSONException If the index is negative.
+     * @throws JSONException
+     *             If the index is negative.
      */
-    public JSONArray put(int index, boolean value) throws JSONException {
+    public JSONArray put(int index, boolean value) throws JSONException
+    {
         this.put(index, value ? Boolean.TRUE : Boolean.FALSE);
         return this;
     }
 
-
     /**
-     * Put a value in the JSONArray, where the value will be a
-     * JSONArray which is produced from a Collection.
-     * @param index The subscript.
-     * @param value A Collection value.
-     * @return      this.
-     * @throws JSONException If the index is negative or if the value is
-     * not finite.
+     * Put a value in the JSONArray, where the value will be a JSONArray which
+     * is produced from a Collection.
+     *
+     * @param index
+     *            The subscript.
+     * @param value
+     *            A Collection value.
+     * @return this.
+     * @throws JSONException
+     *             If the index is negative or if the value is not finite.
      */
-    public JSONArray put(int index, Collection value) throws JSONException {
+    public JSONArray put(int index, Collection value) throws JSONException
+    {
         this.put(index, new JSONArray(value));
         return this;
     }
 
-
     /**
      * Put or replace a double value. If the index is greater than the length of
-     *  the JSONArray, then null elements will be added as necessary to pad
-     *  it out.
-     * @param index The subscript.
-     * @param value A double value.
+     * the JSONArray, then null elements will be added as necessary to pad it
+     * out.
+     *
+     * @param index
+     *            The subscript.
+     * @param value
+     *            A double value.
      * @return this.
-     * @throws JSONException If the index is negative or if the value is
-     * not finite.
+     * @throws JSONException
+     *             If the index is negative or if the value is not finite.
      */
-    public JSONArray put(int index, double value) throws JSONException {
+    public JSONArray put(int index, double value) throws JSONException
+    {
         this.put(index, new Double(value));
         return this;
     }
 
-
     /**
      * Put or replace an int value. If the index is greater than the length of
-     *  the JSONArray, then null elements will be added as necessary to pad
-     *  it out.
-     * @param index The subscript.
-     * @param value An int value.
+     * the JSONArray, then null elements will be added as necessary to pad it
+     * out.
+     *
+     * @param index
+     *            The subscript.
+     * @param value
+     *            An int value.
      * @return this.
-     * @throws JSONException If the index is negative.
+     * @throws JSONException
+     *             If the index is negative.
      */
-    public JSONArray put(int index, int value) throws JSONException {
+    public JSONArray put(int index, int value) throws JSONException
+    {
         this.put(index, new Integer(value));
         return this;
     }
 
-
     /**
      * Put or replace a long value. If the index is greater than the length of
-     *  the JSONArray, then null elements will be added as necessary to pad
-     *  it out.
-     * @param index The subscript.
-     * @param value A long value.
+     * the JSONArray, then null elements will be added as necessary to pad it
+     * out.
+     *
+     * @param index
+     *            The subscript.
+     * @param value
+     *            A long value.
      * @return this.
-     * @throws JSONException If the index is negative.
+     * @throws JSONException
+     *             If the index is negative.
      */
-    public JSONArray put(int index, long value) throws JSONException {
+    public JSONArray put(int index, long value) throws JSONException
+    {
         this.put(index, new Long(value));
         return this;
     }
 
-
     /**
-     * Put a value in the JSONArray, where the value will be a
-     * JSONObject that is produced from a Map.
-     * @param index The subscript.
-     * @param value The Map value.
-     * @return      this.
-     * @throws JSONException If the index is negative or if the the value is
-     *  an invalid number.
+     * Put a value in the JSONArray, where the value will be a JSONObject that
+     * is produced from a Map.
+     *
+     * @param index
+     *            The subscript.
+     * @param value
+     *            The Map value.
+     * @return this.
+     * @throws JSONException
+     *             If the index is negative or if the the value is an invalid
+     *             number.
      */
-    public JSONArray put(int index, Map value) throws JSONException {
+    public JSONArray put(int index, Map value) throws JSONException
+    {
         this.put(index, new JSONObject(value));
         return this;
     }
 
-
     /**
      * Put or replace an object value in the JSONArray. If the index is greater
-     *  than the length of the JSONArray, then null elements will be added as
-     *  necessary to pad it out.
-     * @param index The subscript.
-     * @param value The value to put into the array. The value should be a
-     *  Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
-     *  JSONObject.NULL object.
+     * than the length of the JSONArray, then null elements will be added as
+     * necessary to pad it out.
+     *
+     * @param index
+     *            The subscript.
+     * @param value
+     *            The value to put into the array. The value should be a
+     *            Boolean, Double, Integer, JSONArray, JSONObject, Long, or
+     *            String, or the JSONObject.NULL object.
      * @return this.
-     * @throws JSONException If the index is negative or if the the value is
-     *  an invalid number.
+     * @throws JSONException
+     *             If the index is negative or if the the value is an invalid
+     *             number.
      */
-    public JSONArray put(int index, Object value) throws JSONException {
+    public JSONArray put(int index, Object value) throws JSONException
+    {
         JSONObject.testValidity(value);
         if (index < 0) {
             throw new JSONException("JSONArray[" + index + "] not found.");
@@ -768,12 +824,13 @@ public class JSONArray {
         return this;
     }
 
-
     /**
      * Remove an index and close the hole.
-     * @param index The index of the element to be removed.
-     * @return The value that was associated with the index,
-     * or null if there was no value.
+     *
+     * @param index
+     *            The index of the element to be removed.
+     * @return The value that was associated with the index, or null if there
+     *         was no value.
      */
     public Object remove(int index) {
         Object o = this.opt(index);
@@ -781,17 +838,20 @@ public class JSONArray {
         return o;
     }
 
-
     /**
-     * Produce a JSONObject by combining a JSONArray of names with the values
-     * of this JSONArray.
-     * @param names A JSONArray containing a list of key strings. These will be
-     * paired with the values.
+     * Produce a JSONObject by combining a JSONArray of names with the values of
+     * this JSONArray.
+     *
+     * @param names
+     *            A JSONArray containing a list of key strings. These will be
+     *            paired with the values.
      * @return A JSONObject, or null if there are no names or if this JSONArray
-     * has no values.
-     * @throws JSONException If any of the names are null.
+     *         has no values.
+     * @throws JSONException
+     *             If any of the names are null.
      */
-    public JSONObject toJSONObject(JSONArray names) throws JSONException {
+    public JSONObject toJSONObject(JSONArray names) throws JSONException
+    {
         if (names == null || names.length() == 0 || this.length() == 0) {
             return null;
         }
@@ -802,40 +862,39 @@ public class JSONArray {
         return jo;
     }
 
-
     /**
-     * Make a JSON text of this JSONArray. For compactness, no
-     * unnecessary whitespace is added. If it is not possible to produce a
-     * syntactically correct JSON text then null will be returned instead. This
-     * could occur if the array contains an invalid number.
+     * Make a JSON text of this JSONArray. For compactness, no unnecessary
+     * whitespace is added. If it is not possible to produce a syntactically
+     * correct JSON text then null will be returned instead. This could occur if
+     * the array contains an invalid number.
      * <p>
      * Warning: This method assumes that the data structure is acyclical.
      *
-     * @return a printable, displayable, transmittable
-     *  representation of the array.
+     * @return a printable, displayable, transmittable representation of the
+     *         array.
      */
-    @Override
     public String toString() {
         try {
-            return '[' + this.join(",") + ']';
+            return this.toString(0);
         } catch (Exception e) {
             return null;
         }
     }
 
-
     /**
-     * Make a prettyprinted JSON text of this JSONArray.
-     * Warning: This method assumes that the data structure is acyclical.
-     * @param indentFactor The number of spaces to add to each level of
-     *  indentation.
-     * @return a printable, displayable, transmittable
-     *  representation of the object, beginning
-     *  with <code>[</code>&nbsp;<small>(left bracket)</small> and ending
-     *  with <code>]</code>&nbsp;<small>(right bracket)</small>.
+     * Make a prettyprinted JSON text of this JSONArray. Warning: This method
+     * assumes that the data structure is acyclical.
+     *
+     * @param indentFactor
+     *            The number of spaces to add to each level of indentation.
+     * @return a printable, displayable, transmittable representation of the
+     *         object, beginning with <code>[</code>&nbsp;<small>(left
+     *         bracket)</small> and ending with <code>]</code>
+     *         &nbsp;<small>(right bracket)</small>.
      * @throws JSONException
      */
-    public String toString(int indentFactor) throws JSONException {
+    public String toString(int indentFactor) throws JSONException
+    {
         StringWriter sw = new StringWriter();
         synchronized (sw.getBuffer()) {
             return this.write(sw, indentFactor, 0).toString();
@@ -851,7 +910,8 @@ public class JSONArray {
      * @return The writer.
      * @throws JSONException
      */
-    public Writer write(Writer writer) throws JSONException {
+    public Writer write(Writer writer) throws JSONException
+    {
         return this.write(writer, 0, 0);
     }
 
@@ -869,7 +929,8 @@ public class JSONArray {
      * @throws JSONException
      */
     Writer write(Writer writer, int indentFactor, int indent)
-            throws JSONException {
+            throws JSONException
+    {
         try {
             boolean commanate = false;
             int length = this.length();
@@ -877,7 +938,7 @@ public class JSONArray {
 
             if (length == 1) {
                 JSONObject.writeValue(writer, this.myArrayList.get(0),
-                        indentFactor, indent);
+		                indentFactor, indent);
             } else if (length != 0) {
                 final int newindent = indent + indentFactor;
 
@@ -890,7 +951,7 @@ public class JSONArray {
                     }
                     JSONObject.indent(writer, newindent);
                     JSONObject.writeValue(writer, this.myArrayList.get(i),
-                            indentFactor, newindent);
+		                    indentFactor, newindent);
                     commanate = true;
                 }
                 if (indentFactor > 0) {
@@ -901,7 +962,7 @@ public class JSONArray {
             writer.write(']');
             return writer;
         } catch (IOException e) {
-           throw new JSONException(e);
+            throw new JSONException(e);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONException.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONException.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONException.java
index 10a52d7..76a7bf3 100755
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONException.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONException.java
@@ -1,29 +1,41 @@
-package org.apache.wicket.ajax.json;
-
-/**
- * The JSONException is thrown by the JSON.org classes when things are amiss.
- * @author JSON.org
- * @version 2010-12-24
- */
-public class JSONException extends Exception {
-    private static final long serialVersionUID = 0;
-    private Throwable cause;
-
-    /**
-     * Constructs a JSONException with an explanatory message.
-     * @param message Detail about the reason for the exception.
-     */
-    public JSONException(String message) {
-        super(message);
-    }
-
-    public JSONException(Throwable cause) {
-        super(cause.getMessage());
-        this.cause = cause;
-    }
-
-    @Override
-    public Throwable getCause() {
-        return this.cause;
-    }
-}
+package org.apache.wicket.ajax.json;
+
+/**
+ * The JSONException is thrown by the JSON.org classes when things are amiss.
+ *
+ * @author JSON.org
+ * @version 2013-02-10
+ */
+public class JSONException extends RuntimeException {
+    private static final long serialVersionUID = 0;
+    private Throwable cause;
+
+    /**
+     * Constructs a JSONException with an explanatory message.
+     *
+     * @param message
+     *            Detail about the reason for the exception.
+     */
+    public JSONException(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructs a new JSONException with the specified cause.
+     */
+    public JSONException(Throwable cause) {
+        super(cause.getMessage());
+        this.cause = cause;
+    }
+
+    /**
+     * Returns the cause of this exception or null if the cause is nonexistent
+     * or unknown.
+     *
+     * @returns the cause of this exception or null if the cause is nonexistent
+     *          or unknown.
+     */
+    public Throwable getCause() {
+        return this.cause;
+    }
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONML.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONML.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONML.java
index 4a2fe2e..ec4294f 100755
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONML.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONML.java
@@ -26,12 +26,15 @@ SOFTWARE.
 
 import java.util.Iterator;
 
+import org.apache.wicket.ajax.json.JSONArray;
+import org.apache.wicket.ajax.json.JSONException;
+
 
 /**
  * This provides static methods to convert an XML text into a JSONArray or
  * JSONObject, and to covert a JSONArray or JSONObject into an XML text using
  * the JsonML transform.
- * 
+ *
  * @author JSON.org
  * @version 2012-03-28
  */
@@ -49,8 +52,9 @@ public class JSONML {
     private static Object parse(
         XMLTokener x,
         boolean    arrayForm,
-        JSONArray  ja
-    ) throws JSONException {
+        JSONArray ja
+    ) throws JSONException
+    {
         String     attribute;
         char       c;
         String       closeTag = null;
@@ -174,7 +178,7 @@ public class JSONML {
                             if (!(token instanceof String)) {
                                 throw x.syntaxError("Missing value");
                             }
-                            newjo.accumulate(attribute, XML.stringToValue((String)token));
+                            newjo.accumulate(attribute, XML.stringToValue((String) token));
                             token = null;
                         } else {
                             newjo.accumulate(attribute, "");
@@ -227,7 +231,7 @@ public class JSONML {
             } else {
                 if (ja != null) {
                     ja.put(token instanceof String
-                        ? XML.stringToValue((String)token)
+                        ? XML.stringToValue((String) token)
                         : token);
                 }
             }
@@ -313,7 +317,7 @@ public class JSONML {
      */
     public static String toString(JSONArray ja) throws JSONException {
         int             i;
-        JSONObject   jo;
+        JSONObject jo;
         String       key;
         Iterator     keys;
         int             length;


[06/11] git commit: Change the initial capacity of the arraylist for stringResourceLoaders to 6.

Posted by iv...@apache.org.
Change the initial capacity of the arraylist for stringResourceLoaders to 6.

Wicket adds 5 in ResourceSettings' constructor. Leave 1 for the user application needs.


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/a4196262
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/a4196262
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/a4196262

Branch: refs/heads/sandbox/component-queueing-2
Commit: a419626216c8e4e3c3dbc17a7cb7515d48103934
Parents: 294f1eb
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Wed Feb 19 15:01:03 2014 +0200
Committer: Igor Vaynberg <ig...@gmail.com>
Committed: Thu Feb 20 23:24:05 2014 -0800

----------------------------------------------------------------------
 .../src/main/java/org/apache/wicket/settings/ResourceSettings.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/a4196262/wicket-core/src/main/java/org/apache/wicket/settings/ResourceSettings.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/settings/ResourceSettings.java b/wicket-core/src/main/java/org/apache/wicket/settings/ResourceSettings.java
index 3b6b440..be2b272 100644
--- a/wicket-core/src/main/java/org/apache/wicket/settings/ResourceSettings.java
+++ b/wicket-core/src/main/java/org/apache/wicket/settings/ResourceSettings.java
@@ -140,7 +140,7 @@ public class ResourceSettings implements IPropertiesFactoryContext
 	private IFileCleaner fileCleaner;
 
 	/** Chain of string resource loaders to use */
-	private final List<IStringResourceLoader> stringResourceLoaders = Generics.newArrayList(4);
+	private final List<IStringResourceLoader> stringResourceLoaders = Generics.newArrayList(6);
 
 	/** Flags used to determine how to behave if resources are not found */
 	private boolean throwExceptionOnMissingResource = true;


[02/11] WICKET-4795 Wicket unit tests rely on hashmap iteration order

Posted by iv...@apache.org.
http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONObject.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONObject.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONObject.java
index 4aabe0c..35246d8 100755
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONObject.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONObject.java
@@ -1,28 +1,28 @@
 package org.apache.wicket.ajax.json;
 
 /*
-Copyright (c) 2002 JSON.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
+ Copyright (c) 2002 JSON.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ The Software shall be used for Good, not Evil.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+ */
 
 import java.io.IOException;
 import java.io.StringWriter;
@@ -34,37 +34,42 @@ import java.util.Collection;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.Locale;
 import java.util.Map;
 import java.util.ResourceBundle;
+import java.util.Set;
 
 /**
  * A JSONObject is an unordered collection of name/value pairs. Its external
  * form is a string wrapped in curly braces with colons between the names and
  * values, and commas between the values and names. The internal form is an
- * object having <code>get</code> and <code>opt</code> methods for accessing the
- * values by name, and <code>put</code> methods for adding or replacing values
- * by name. The values can be any of these types: <code>Boolean</code>,
+ * object having <code>get</code> and <code>opt</code> methods for accessing
+ * the values by name, and <code>put</code> methods for adding or replacing
+ * values by name. The values can be any of these types: <code>Boolean</code>,
  * <code>JSONArray</code>, <code>JSONObject</code>, <code>Number</code>,
- * <code>String</code>, or the <code>JSONObject.NULL</code> object. A JSONObject
- * constructor can be used to convert an external form JSON text into an
- * internal form whose values can be retrieved with the <code>get</code> and
- * <code>opt</code> methods, or to convert values into a JSON text using the
- * <code>put</code> and <code>toString</code> methods. A <code>get</code> method
- * returns a value if one can be found, and throws an exception if one cannot be
- * found. An <code>opt</code> method returns a default value instead of throwing
- * an exception, and so is useful for obtaining optional values.
+ * <code>String</code>, or the <code>JSONObject.NULL</code> object. A
+ * JSONObject constructor can be used to convert an external form JSON text
+ * into an internal form whose values can be retrieved with the
+ * <code>get</code> and <code>opt</code> methods, or to convert values into a
+ * JSON text using the <code>put</code> and <code>toString</code> methods. A
+ * <code>get</code> method returns a value if one can be found, and throws an
+ * exception if one cannot be found. An <code>opt</code> method returns a
+ * default value instead of throwing an exception, and so is useful for
+ * obtaining optional values.
  * <p>
  * The generic <code>get()</code> and <code>opt()</code> methods return an
  * object, which you can cast or query for type. There are also typed
  * <code>get</code> and <code>opt</code> methods that do type checking and type
- * coercion for you. The opt methods differ from the get methods in that they do
- * not throw. Instead, they return a specified value, such as null.
+ * coercion for you. The opt methods differ from the get methods in that they
+ * do not throw. Instead, they return a specified value, such as null.
  * <p>
- * The <code>put</code> methods add or replace values in an object. For example,
+ * The <code>put</code> methods add or replace values in an object. For
+ * example,
  *
  * <pre>
- * myString = new JSONObject().put(&quot;JSON&quot;, &quot;Hello, World!&quot;).toString();
+ * myString = new JSONObject()
+ *         .put(&quot;JSON&quot;, &quot;Hello, World!&quot;).toString();
  * </pre>
  *
  * produces the string <code>{"JSON": "Hello, World"}</code>.
@@ -77,34 +82,30 @@ import java.util.ResourceBundle;
  * before the closing brace.</li>
  * <li>Strings may be quoted with <code>'</code>&nbsp;<small>(single
  * quote)</small>.</li>
- * <li>Strings do not need to be quoted at all if they do not begin with a quote
- * or single quote, and if they do not contain leading or trailing spaces, and
- * if they do not contain any of these characters:
- * <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers and
- * if they are not the reserved words <code>true</code>, <code>false</code>, or
- * <code>null</code>.</li>
- * <li>Keys can be followed by <code>=</code> or <code>=></code> as well as by
- * <code>:</code>.</li>
- * <li>Values can be followed by <code>;</code> <small>(semicolon)</small> as
- * well as by <code>,</code> <small>(comma)</small>.</li>
+ * <li>Strings do not need to be quoted at all if they do not begin with a
+ * quote or single quote, and if they do not contain leading or trailing
+ * spaces, and if they do not contain any of these characters:
+ * <code>{ } [ ] / \ : , #</code> and if they do not look like numbers and
+ * if they are not the reserved words <code>true</code>, <code>false</code>,
+ * or <code>null</code>.</li>
  * </ul>
  *
  * @author JSON.org
- * @version 2012-07-02
+ * @version 2013-06-17
  */
 public class JSONObject {
-
     /**
      * JSONObject.NULL is equivalent to the value that JavaScript calls null,
      * whilst Java's null is equivalent to the value that JavaScript calls
      * undefined.
      */
-     private static final class Null {
+    private static final class Null {
 
         /**
          * There is only intended to be a single instance of the NULL object,
          * so the clone method returns itself.
-         * @return     NULL.
+         *
+         * @return NULL.
          */
         protected final Object clone() {
             return this;
@@ -112,9 +113,11 @@ public class JSONObject {
 
         /**
          * A Null object is equal to the null value and to itself.
-         * @param object    An object to test for nullness.
-         * @return true if the object parameter is the JSONObject.NULL object
-         *  or null.
+         *
+         * @param object
+         *            An object to test for nullness.
+         * @return true if the object parameter is the JSONObject.NULL object or
+         *         null.
          */
         public boolean equals(Object object) {
             return object == null || object == this;
@@ -122,6 +125,7 @@ public class JSONObject {
 
         /**
          * Get the "null" string value.
+         *
          * @return The string "null".
          */
         public String toString() {
@@ -129,13 +133,11 @@ public class JSONObject {
         }
     }
 
-
     /**
      * The map where the JSONObject's properties are kept.
      */
     private final Map map;
 
-
     /**
      * It is sometimes more convenient and less ambiguous to have a
      * <code>NULL</code> object than to use Java's <code>null</code> value.
@@ -144,23 +146,26 @@ public class JSONObject {
      */
     public static final Object NULL = new Null();
 
-
     /**
      * Construct an empty JSONObject.
      */
     public JSONObject() {
-        this.map = new HashMap();
+        this.map = new LinkedHashMap();
     }
 
-
     /**
-     * Construct a JSONObject from a subset of another JSONObject.
-     * An array of strings is used to identify the keys that should be copied.
-     * Missing keys are ignored.
-     * @param jo A JSONObject.
-     * @param names An array of strings.
+     * Construct a JSONObject from a subset of another JSONObject. An array of
+     * strings is used to identify the keys that should be copied. Missing keys
+     * are ignored.
+     *
+     * @param jo
+     *            A JSONObject.
+     * @param names
+     *            An array of strings.
      * @throws JSONException
-     * @exception JSONException If a value is a non-finite number or if a name is duplicated.
+     * @exception JSONException
+     *                If a value is a non-finite number or if a name is
+     *                duplicated.
      */
     public JSONObject(JSONObject jo, String[] names) {
         this();
@@ -172,14 +177,17 @@ public class JSONObject {
         }
     }
 
-
     /**
      * Construct a JSONObject from a JSONTokener.
-     * @param x A JSONTokener object containing the source string.
-     * @throws JSONException If there is a syntax error in the source string
-     *  or a duplicated key.
+     *
+     * @param x
+     *            A JSONTokener object containing the source string.
+     * @throws JSONException
+     *             If there is a syntax error in the source string or a
+     *             duplicated key.
      */
-    public JSONObject(JSONTokener x) throws JSONException {
+    public JSONObject(JSONTokener x) throws JSONException
+    {
         this();
         char c;
         String key;
@@ -199,19 +207,15 @@ public class JSONObject {
                 key = x.nextValue().toString();
             }
 
-// The key is followed by ':'. We will also tolerate '=' or '=>'.
+// The key is followed by ':'.
 
             c = x.nextClean();
-            if (c == '=') {
-                if (x.next() != '>') {
-                    x.back();
-                }
-            } else if (c != ':') {
+            if (c != ':') {
                 throw x.syntaxError("Expected a ':' after a key");
             }
             this.putOnce(key, x.nextValue());
 
-// Pairs are separated by ','. We will also tolerate ';'.
+// Pairs are separated by ','.
 
             switch (x.nextClean()) {
             case ';':
@@ -229,12 +233,12 @@ public class JSONObject {
         }
     }
 
-
     /**
      * Construct a JSONObject from a Map.
      *
-     * @param map A map object that can be used to initialize the contents of
-     *  the JSONObject.
+     * @param map
+     *            A map object that can be used to initialize the contents of
+     *            the JSONObject.
      * @throws JSONException
      */
     public JSONObject(Map map) {
@@ -242,7 +246,7 @@ public class JSONObject {
         if (map != null) {
             Iterator i = map.entrySet().iterator();
             while (i.hasNext()) {
-                Map.Entry e = (Map.Entry)i.next();
+                Map.Entry e = (Map.Entry) i.next();
                 Object value = e.getValue();
                 if (value != null) {
                     this.map.put(e.getKey(), wrap(value));
@@ -251,42 +255,45 @@ public class JSONObject {
         }
     }
 
-
     /**
-     * Construct a JSONObject from an Object using bean getters.
-     * It reflects on all of the public methods of the object.
-     * For each of the methods with no parameters and a name starting
-     * with <code>"get"</code> or <code>"is"</code> followed by an uppercase letter,
-     * the method is invoked, and a key and the value returned from the getter method
-     * are put into the new JSONObject.
+     * Construct a JSONObject from an Object using bean getters. It reflects on
+     * all of the public methods of the object. For each of the methods with no
+     * parameters and a name starting with <code>"get"</code> or
+     * <code>"is"</code> followed by an uppercase letter, the method is invoked,
+     * and a key and the value returned from the getter method are put into the
+     * new JSONObject.
      *
-     * The key is formed by removing the <code>"get"</code> or <code>"is"</code> prefix.
-     * If the second remaining character is not upper case, then the first
-     * character is converted to lower case.
+     * The key is formed by removing the <code>"get"</code> or <code>"is"</code>
+     * prefix. If the second remaining character is not upper case, then the
+     * first character is converted to lower case.
      *
      * For example, if an object has a method named <code>"getName"</code>, and
-     * if the result of calling <code>object.getName()</code> is <code>"Larry Fine"</code>,
-     * then the JSONObject will contain <code>"name": "Larry Fine"</code>.
+     * if the result of calling <code>object.getName()</code> is
+     * <code>"Larry Fine"</code>, then the JSONObject will contain
+     * <code>"name": "Larry Fine"</code>.
      *
-     * @param bean An object that has getter methods that should be used
-     * to make a JSONObject.
+     * @param bean
+     *            An object that has getter methods that should be used to make
+     *            a JSONObject.
      */
     public JSONObject(Object bean) {
         this();
         this.populateMap(bean);
     }
 
-
     /**
      * Construct a JSONObject from an Object, using reflection to find the
-     * public members. The resulting JSONObject's keys will be the strings
-     * from the names array, and the values will be the field values associated
-     * with those keys in the object. If a key is not found or not visible,
-     * then it will not be copied into the new JSONObject.
-     * @param object An object that has fields that should be used to make a
-     * JSONObject.
-     * @param names An array of strings, the names of the fields to be obtained
-     * from the object.
+     * public members. The resulting JSONObject's keys will be the strings from
+     * the names array, and the values will be the field values associated with
+     * those keys in the object. If a key is not found or not visible, then it
+     * will not be copied into the new JSONObject.
+     *
+     * @param object
+     *            An object that has fields that should be used to make a
+     *            JSONObject.
+     * @param names
+     *            An array of strings, the names of the fields to be obtained
+     *            from the object.
      */
     public JSONObject(Object object, String names[]) {
         this();
@@ -300,26 +307,31 @@ public class JSONObject {
         }
     }
 
-
     /**
-     * Construct a JSONObject from a source JSON text string.
-     * This is the most commonly used JSONObject constructor.
-     * @param source    A string beginning
-     *  with <code>{</code>&nbsp;<small>(left brace)</small> and ending
-     *  with <code>}</code>&nbsp;<small>(right brace)</small>.
-     * @exception JSONException If there is a syntax error in the source
-     *  string or a duplicated key.
+     * Construct a JSONObject from a source JSON text string. This is the most
+     * commonly used JSONObject constructor.
+     *
+     * @param source
+     *            A string beginning with <code>{</code>&nbsp;<small>(left
+     *            brace)</small> and ending with <code>}</code>
+     *            &nbsp;<small>(right brace)</small>.
+     * @exception JSONException
+     *                If there is a syntax error in the source string or a
+     *                duplicated key.
      */
     public JSONObject(String source) throws JSONException {
         this(new JSONTokener(source));
     }
 
-
     /**
      * Construct a JSONObject from a ResourceBundle.
-     * @param baseName The ResourceBundle base name.
-     * @param locale The Locale to load the ResourceBundle for.
-     * @throws JSONException If any JSONExceptions are detected.
+     *
+     * @param baseName
+     *            The ResourceBundle base name.
+     * @param locale
+     *            The Locale to load the ResourceBundle for.
+     * @throws JSONException
+     *             If any JSONExceptions are detected.
      */
     public JSONObject(String baseName, Locale locale) throws JSONException {
         this();
@@ -337,7 +349,7 @@ public class JSONObject {
 // segment except the last. Add the value using the last segment's name into
 // the deepest nested JSONObject.
 
-                String[] path = ((String)key).split("\\.");
+                String[] path = ((String) key).split("\\.");
                 int last = path.length - 1;
                 JSONObject target = this;
                 for (int i = 0; i < last; i += 1) {
@@ -349,58 +361,59 @@ public class JSONObject {
                     }
                     target = nextTarget;
                 }
-                target.put(path[last], bundle.getString((String)key));
+                target.put(path[last], bundle.getString((String) key));
             }
         }
     }
 
-
     /**
      * Accumulate values under a key. It is similar to the put method except
-     * that if there is already an object stored under the key then a
-     * JSONArray is stored under the key to hold all of the accumulated values.
-     * If there is already a JSONArray, then the new value is appended to it.
-     * In contrast, the put method replaces the previous value.
-     *
-     * If only one value is accumulated that is not a JSONArray, then the
-     * result will be the same as using put. But if multiple values are
-     * accumulated, then the result will be like append.
-     * @param key   A key string.
-     * @param value An object to be accumulated under the key.
+     * that if there is already an object stored under the key then a JSONArray
+     * is stored under the key to hold all of the accumulated values. If there
+     * is already a JSONArray, then the new value is appended to it. In
+     * contrast, the put method replaces the previous value.
+     *
+     * If only one value is accumulated that is not a JSONArray, then the result
+     * will be the same as using put. But if multiple values are accumulated,
+     * then the result will be like append.
+     *
+     * @param key
+     *            A key string.
+     * @param value
+     *            An object to be accumulated under the key.
      * @return this.
-     * @throws JSONException If the value is an invalid number
-     *  or if the key is null.
+     * @throws JSONException
+     *             If the value is an invalid number or if the key is null.
      */
-    public JSONObject accumulate(
-        String key,
-        Object value
-    ) throws JSONException
-    {
+    public JSONObject accumulate(String key, Object value) throws JSONException {
         testValidity(value);
         Object object = this.opt(key);
         if (object == null) {
-            this.put(key, value instanceof JSONArray
-                    ? new JSONArray().put(value)
-                    : value);
+            this.put(key,
+                    value instanceof JSONArray ? new JSONArray().put(value)
+                            : value);
         } else if (object instanceof JSONArray) {
-            ((JSONArray)object).put(value);
+            ((JSONArray) object).put(value);
         } else {
             this.put(key, new JSONArray().put(object).put(value));
         }
         return this;
     }
 
-
     /**
      * Append values to the array under a key. If the key does not exist in the
      * JSONObject, then the key is put in the JSONObject with its value being a
      * JSONArray containing the value parameter. If the key was already
      * associated with a JSONArray, then the value parameter is appended to it.
-     * @param key   A key string.
-     * @param value An object to be accumulated under the key.
+     *
+     * @param key
+     *            A key string.
+     * @param value
+     *            An object to be accumulated under the key.
      * @return this.
-     * @throws JSONException If the key is null or if the current value
-     *  associated with the key is not a JSONArray.
+     * @throws JSONException
+     *             If the key is null or if the current value associated with
+     *             the key is not a JSONArray.
      */
     public JSONObject append(String key, Object value) throws JSONException {
         testValidity(value);
@@ -408,19 +421,20 @@ public class JSONObject {
         if (object == null) {
             this.put(key, new JSONArray().put(value));
         } else if (object instanceof JSONArray) {
-            this.put(key, ((JSONArray)object).put(value));
+            this.put(key, ((JSONArray) object).put(value));
         } else {
-            throw new JSONException("JSONObject[" + key +
-                    "] is not a JSONArray.");
+            throw new JSONException("JSONObject[" + key
+                    + "] is not a JSONArray.");
         }
         return this;
     }
 
-
     /**
-     * Produce a string from a double. The string "null" will be returned if
-     * the number is not finite.
-     * @param  d A double.
+     * Produce a string from a double. The string "null" will be returned if the
+     * number is not finite.
+     *
+     * @param d
+     *            A double.
      * @return A String.
      */
     public static String doubleToString(double d) {
@@ -431,8 +445,8 @@ public class JSONObject {
 // Shave off trailing zeros and decimal point, if possible.
 
         String string = Double.toString(d);
-        if (string.indexOf('.') > 0 && string.indexOf('e') < 0 &&
-                string.indexOf('E') < 0) {
+        if (string.indexOf('.') > 0 && string.indexOf('e') < 0
+                && string.indexOf('E') < 0) {
             while (string.endsWith("0")) {
                 string = string.substring(0, string.length() - 1);
             }
@@ -443,13 +457,14 @@ public class JSONObject {
         return string;
     }
 
-
     /**
      * Get the value object associated with a key.
      *
-     * @param key   A key string.
-     * @return      The object associated with the key.
-     * @throws      JSONException if the key is not found.
+     * @param key
+     *            A key string.
+     * @return The object associated with the key.
+     * @throws JSONException
+     *             if the key is not found.
      */
     public Object get(String key) throws JSONException {
         if (key == null) {
@@ -457,135 +472,135 @@ public class JSONObject {
         }
         Object object = this.opt(key);
         if (object == null) {
-            throw new JSONException("JSONObject[" + quote(key) +
-                    "] not found.");
+            throw new JSONException("JSONObject[" + quote(key) + "] not found.");
         }
         return object;
     }
 
-
     /**
      * Get the boolean value associated with a key.
      *
-     * @param key   A key string.
-     * @return      The truth.
-     * @throws      JSONException
-     *  if the value is not a Boolean or the String "true" or "false".
+     * @param key
+     *            A key string.
+     * @return The truth.
+     * @throws JSONException
+     *             if the value is not a Boolean or the String "true" or
+     *             "false".
      */
     public boolean getBoolean(String key) throws JSONException {
         Object object = this.get(key);
-        if (object.equals(Boolean.FALSE) ||
-                (object instanceof String &&
-                ((String)object).equalsIgnoreCase("false"))) {
+        if (object.equals(Boolean.FALSE)
+                || (object instanceof String && ((String) object)
+                        .equalsIgnoreCase("false"))) {
             return false;
-        } else if (object.equals(Boolean.TRUE) ||
-                (object instanceof String &&
-                ((String)object).equalsIgnoreCase("true"))) {
+        } else if (object.equals(Boolean.TRUE)
+                || (object instanceof String && ((String) object)
+                        .equalsIgnoreCase("true"))) {
             return true;
         }
-        throw new JSONException("JSONObject[" + quote(key) +
-                "] is not a Boolean.");
+        throw new JSONException("JSONObject[" + quote(key)
+                + "] is not a Boolean.");
     }
 
-
     /**
      * Get the double value associated with a key.
-     * @param key   A key string.
-     * @return      The numeric value.
-     * @throws JSONException if the key is not found or
-     *  if the value is not a Number object and cannot be converted to a number.
+     *
+     * @param key
+     *            A key string.
+     * @return The numeric value.
+     * @throws JSONException
+     *             if the key is not found or if the value is not a Number
+     *             object and cannot be converted to a number.
      */
     public double getDouble(String key) throws JSONException {
         Object object = this.get(key);
         try {
-            return object instanceof Number
-                ? ((Number)object).doubleValue()
-                : Double.parseDouble((String)object);
+            return object instanceof Number ? ((Number) object).doubleValue()
+                    : Double.parseDouble((String) object);
         } catch (Exception e) {
-            throw new JSONException("JSONObject[" + quote(key) +
-                "] is not a number.");
+            throw new JSONException("JSONObject[" + quote(key)
+                    + "] is not a number.");
         }
     }
 
-
     /**
      * Get the int value associated with a key.
      *
-     * @param key   A key string.
-     * @return      The integer value.
-     * @throws   JSONException if the key is not found or if the value cannot
-     *  be converted to an integer.
+     * @param key
+     *            A key string.
+     * @return The integer value.
+     * @throws JSONException
+     *             if the key is not found or if the value cannot be converted
+     *             to an integer.
      */
     public int getInt(String key) throws JSONException {
         Object object = this.get(key);
         try {
-            return object instanceof Number
-                ? ((Number)object).intValue()
-                : Integer.parseInt((String)object);
+            return object instanceof Number ? ((Number) object).intValue()
+                    : Integer.parseInt((String) object);
         } catch (Exception e) {
-            throw new JSONException("JSONObject[" + quote(key) +
-                "] is not an int.");
+            throw new JSONException("JSONObject[" + quote(key)
+                    + "] is not an int.");
         }
     }
 
-
     /**
      * Get the JSONArray value associated with a key.
      *
-     * @param key   A key string.
-     * @return      A JSONArray which is the value.
-     * @throws      JSONException if the key is not found or
-     *  if the value is not a JSONArray.
+     * @param key
+     *            A key string.
+     * @return A JSONArray which is the value.
+     * @throws JSONException
+     *             if the key is not found or if the value is not a JSONArray.
      */
     public JSONArray getJSONArray(String key) throws JSONException {
         Object object = this.get(key);
         if (object instanceof JSONArray) {
-            return (JSONArray)object;
+            return (JSONArray) object;
         }
-        throw new JSONException("JSONObject[" + quote(key) +
-                "] is not a JSONArray.");
+        throw new JSONException("JSONObject[" + quote(key)
+                + "] is not a JSONArray.");
     }
 
-
     /**
      * Get the JSONObject value associated with a key.
      *
-     * @param key   A key string.
-     * @return      A JSONObject which is the value.
-     * @throws      JSONException if the key is not found or
-     *  if the value is not a JSONObject.
+     * @param key
+     *            A key string.
+     * @return A JSONObject which is the value.
+     * @throws JSONException
+     *             if the key is not found or if the value is not a JSONObject.
      */
     public JSONObject getJSONObject(String key) throws JSONException {
         Object object = this.get(key);
         if (object instanceof JSONObject) {
-            return (JSONObject)object;
+            return (JSONObject) object;
         }
-        throw new JSONException("JSONObject[" + quote(key) +
-                "] is not a JSONObject.");
+        throw new JSONException("JSONObject[" + quote(key)
+                + "] is not a JSONObject.");
     }
 
-
     /**
      * Get the long value associated with a key.
      *
-     * @param key   A key string.
-     * @return      The long value.
-     * @throws   JSONException if the key is not found or if the value cannot
-     *  be converted to a long.
+     * @param key
+     *            A key string.
+     * @return The long value.
+     * @throws JSONException
+     *             if the key is not found or if the value cannot be converted
+     *             to a long.
      */
     public long getLong(String key) throws JSONException {
         Object object = this.get(key);
         try {
-            return object instanceof Number
-                ? ((Number)object).longValue()
-                : Long.parseLong((String)object);
+            return object instanceof Number ? ((Number) object).longValue()
+                    : Long.parseLong((String) object);
         } catch (Exception e) {
-            throw new JSONException("JSONObject[" + quote(key) +
-                "] is not a long.");
+            throw new JSONException("JSONObject[" + quote(key)
+                    + "] is not a long.");
         }
     }
 
-
     /**
      * Get an array of field names from a JSONObject.
      *
@@ -600,13 +615,12 @@ public class JSONObject {
         String[] names = new String[length];
         int i = 0;
         while (iterator.hasNext()) {
-            names[i] = (String)iterator.next();
+            names[i] = (String) iterator.next();
             i += 1;
         }
         return names;
     }
 
-
     /**
      * Get an array of field names from an Object.
      *
@@ -629,83 +643,94 @@ public class JSONObject {
         return names;
     }
 
-
     /**
      * Get the string associated with a key.
      *
-     * @param key   A key string.
-     * @return      A string which is the value.
-     * @throws   JSONException if there is no string value for the key.
+     * @param key
+     *            A key string.
+     * @return A string which is the value.
+     * @throws JSONException
+     *             if there is no string value for the key.
      */
     public String getString(String key) throws JSONException {
         Object object = this.get(key);
         if (object instanceof String) {
-            return (String)object;
+            return (String) object;
         }
-        throw new JSONException("JSONObject[" + quote(key) +
-            "] not a string.");
+        throw new JSONException("JSONObject[" + quote(key) + "] not a string.");
     }
 
-
     /**
      * Determine if the JSONObject contains a specific key.
-     * @param key   A key string.
-     * @return      true if the key exists in the JSONObject.
+     *
+     * @param key
+     *            A key string.
+     * @return true if the key exists in the JSONObject.
      */
     public boolean has(String key) {
         return this.map.containsKey(key);
     }
 
-
     /**
      * Increment a property of a JSONObject. If there is no such property,
-     * create one with a value of 1. If there is such a property, and if
-     * it is an Integer, Long, Double, or Float, then add one to it.
-     * @param key  A key string.
+     * create one with a value of 1. If there is such a property, and if it is
+     * an Integer, Long, Double, or Float, then add one to it.
+     *
+     * @param key
+     *            A key string.
      * @return this.
-     * @throws JSONException If there is already a property with this name
-     * that is not an Integer, Long, Double, or Float.
+     * @throws JSONException
+     *             If there is already a property with this name that is not an
+     *             Integer, Long, Double, or Float.
      */
     public JSONObject increment(String key) throws JSONException {
         Object value = this.opt(key);
         if (value == null) {
             this.put(key, 1);
         } else if (value instanceof Integer) {
-            this.put(key, ((Integer)value).intValue() + 1);
+            this.put(key, ((Integer) value).intValue() + 1);
         } else if (value instanceof Long) {
-            this.put(key, ((Long)value).longValue() + 1);
+            this.put(key, ((Long) value).longValue() + 1);
         } else if (value instanceof Double) {
-            this.put(key, ((Double)value).doubleValue() + 1);
+            this.put(key, ((Double) value).doubleValue() + 1);
         } else if (value instanceof Float) {
-            this.put(key, ((Float)value).floatValue() + 1);
+            this.put(key, ((Float) value).floatValue() + 1);
         } else {
             throw new JSONException("Unable to increment [" + quote(key) + "].");
         }
         return this;
     }
 
-
     /**
-     * Determine if the value associated with the key is null or if there is
-     *  no value.
-     * @param key   A key string.
-     * @return      true if there is no value associated with the key or if
-     *  the value is the JSONObject.NULL object.
+     * Determine if the value associated with the key is null or if there is no
+     * value.
+     *
+     * @param key
+     *            A key string.
+     * @return true if there is no value associated with the key or if the value
+     *         is the JSONObject.NULL object.
      */
     public boolean isNull(String key) {
         return JSONObject.NULL.equals(this.opt(key));
     }
 
-
     /**
      * Get an enumeration of the keys of the JSONObject.
      *
      * @return An iterator of the keys.
      */
     public Iterator keys() {
-        return this.map.keySet().iterator();
+        return this.keySet().iterator();
     }
 
+    /**
+     * Get a set of keys of the JSONObject.
+     *
+     * @return A keySet.
+     */
+    public Set keySet() {
+        return this.map.keySet();
+    }
 
     /**
      * Get the number of keys stored in the JSONObject.
@@ -716,16 +741,16 @@ public class JSONObject {
         return this.map.size();
     }
 
-
     /**
      * Produce a JSONArray containing the names of the elements of this
      * JSONObject.
+     *
      * @return A JSONArray containing the key strings, or null if the JSONObject
-     * is empty.
+     *         is empty.
      */
     public JSONArray names() {
         JSONArray ja = new JSONArray();
-        Iterator  keys = this.keys();
+        Iterator keys = this.keys();
         while (keys.hasNext()) {
             ja.put(keys.next());
         }
@@ -734,12 +759,14 @@ public class JSONObject {
 
     /**
      * Produce a string from a Number.
-     * @param  number A Number
+     *
+     * @param number
+     *            A Number
      * @return A String.
-     * @throws JSONException If n is a non-finite number.
+     * @throws JSONException
+     *             If n is a non-finite number.
      */
-    public static String numberToString(Number number)
-            throws JSONException {
+    public static String numberToString(Number number) throws JSONException {
         if (number == null) {
             throw new JSONException("Null pointer");
         }
@@ -748,8 +775,8 @@ public class JSONObject {
 // Shave off trailing zeros and decimal point, if possible.
 
         String string = number.toString();
-        if (string.indexOf('.') > 0 && string.indexOf('e') < 0 &&
-                string.indexOf('E') < 0) {
+        if (string.indexOf('.') > 0 && string.indexOf('e') < 0
+                && string.indexOf('E') < 0) {
             while (string.endsWith("0")) {
                 string = string.substring(0, string.length() - 1);
             }
@@ -760,38 +787,39 @@ public class JSONObject {
         return string;
     }
 
-
     /**
      * Get an optional value associated with a key.
-     * @param key   A key string.
-     * @return      An object which is the value, or null if there is no value.
+     *
+     * @param key
+     *            A key string.
+     * @return An object which is the value, or null if there is no value.
      */
     public Object opt(String key) {
         return key == null ? null : this.map.get(key);
     }
 
-
     /**
-     * Get an optional boolean associated with a key.
-     * It returns false if there is no such key, or if the value is not
-     * Boolean.TRUE or the String "true".
+     * Get an optional boolean associated with a key. It returns false if there
+     * is no such key, or if the value is not Boolean.TRUE or the String "true".
      *
-     * @param key   A key string.
-     * @return      The truth.
+     * @param key
+     *            A key string.
+     * @return The truth.
      */
     public boolean optBoolean(String key) {
         return this.optBoolean(key, false);
     }
 
-
     /**
-     * Get an optional boolean associated with a key.
-     * It returns the defaultValue if there is no such key, or if it is not
-     * a Boolean or the String "true" or "false" (case insensitive).
+     * Get an optional boolean associated with a key. It returns the
+     * defaultValue if there is no such key, or if it is not a Boolean or the
+     * String "true" or "false" (case insensitive).
      *
-     * @param key              A key string.
-     * @param defaultValue     The default.
-     * @return      The truth.
+     * @param key
+     *            A key string.
+     * @param defaultValue
+     *            The default.
+     * @return The truth.
      */
     public boolean optBoolean(String key, boolean defaultValue) {
         try {
@@ -801,30 +829,29 @@ public class JSONObject {
         }
     }
 
-
     /**
-     * Get an optional double associated with a key,
-     * or NaN if there is no such key or if its value is not a number.
-     * If the value is a string, an attempt will be made to evaluate it as
-     * a number.
+     * Get an optional double associated with a key, or NaN if there is no such
+     * key or if its value is not a number. If the value is a string, an attempt
+     * will be made to evaluate it as a number.
      *
-     * @param key   A string which is the key.
-     * @return      An object which is the value.
+     * @param key
+     *            A string which is the key.
+     * @return An object which is the value.
      */
     public double optDouble(String key) {
         return this.optDouble(key, Double.NaN);
     }
 
-
     /**
-     * Get an optional double associated with a key, or the
-     * defaultValue if there is no such key or if its value is not a number.
-     * If the value is a string, an attempt will be made to evaluate it as
-     * a number.
+     * Get an optional double associated with a key, or the defaultValue if
+     * there is no such key or if its value is not a number. If the value is a
+     * string, an attempt will be made to evaluate it as a number.
      *
-     * @param key   A key string.
-     * @param defaultValue     The default.
-     * @return      An object which is the value.
+     * @param key
+     *            A key string.
+     * @param defaultValue
+     *            The default.
+     * @return An object which is the value.
      */
     public double optDouble(String key, double defaultValue) {
         try {
@@ -834,30 +861,29 @@ public class JSONObject {
         }
     }
 
-
     /**
-     * Get an optional int value associated with a key,
-     * or zero if there is no such key or if the value is not a number.
-     * If the value is a string, an attempt will be made to evaluate it as
-     * a number.
+     * Get an optional int value associated with a key, or zero if there is no
+     * such key or if the value is not a number. If the value is a string, an
+     * attempt will be made to evaluate it as a number.
      *
-     * @param key   A key string.
-     * @return      An object which is the value.
+     * @param key
+     *            A key string.
+     * @return An object which is the value.
      */
     public int optInt(String key) {
         return this.optInt(key, 0);
     }
 
-
     /**
-     * Get an optional int value associated with a key,
-     * or the default if there is no such key or if the value is not a number.
-     * If the value is a string, an attempt will be made to evaluate it as
-     * a number.
+     * Get an optional int value associated with a key, or the default if there
+     * is no such key or if the value is not a number. If the value is a string,
+     * an attempt will be made to evaluate it as a number.
      *
-     * @param key   A key string.
-     * @param defaultValue     The default.
-     * @return      An object which is the value.
+     * @param key
+     *            A key string.
+     * @param defaultValue
+     *            The default.
+     * @return An object which is the value.
      */
     public int optInt(String key, int defaultValue) {
         try {
@@ -867,58 +893,55 @@ public class JSONObject {
         }
     }
 
-
     /**
-     * Get an optional JSONArray associated with a key.
-     * It returns null if there is no such key, or if its value is not a
-     * JSONArray.
+     * Get an optional JSONArray associated with a key. It returns null if there
+     * is no such key, or if its value is not a JSONArray.
      *
-     * @param key   A key string.
-     * @return      A JSONArray which is the value.
+     * @param key
+     *            A key string.
+     * @return A JSONArray which is the value.
      */
     public JSONArray optJSONArray(String key) {
         Object o = this.opt(key);
-        return o instanceof JSONArray ? (JSONArray)o : null;
+        return o instanceof JSONArray ? (JSONArray) o : null;
     }
 
-
     /**
-     * Get an optional JSONObject associated with a key.
-     * It returns null if there is no such key, or if its value is not a
-     * JSONObject.
+     * Get an optional JSONObject associated with a key. It returns null if
+     * there is no such key, or if its value is not a JSONObject.
      *
-     * @param key   A key string.
-     * @return      A JSONObject which is the value.
+     * @param key
+     *            A key string.
+     * @return A JSONObject which is the value.
      */
     public JSONObject optJSONObject(String key) {
         Object object = this.opt(key);
-        return object instanceof JSONObject ? (JSONObject)object : null;
+        return object instanceof JSONObject ? (JSONObject) object : null;
     }
 
-
     /**
-     * Get an optional long value associated with a key,
-     * or zero if there is no such key or if the value is not a number.
-     * If the value is a string, an attempt will be made to evaluate it as
-     * a number.
+     * Get an optional long value associated with a key, or zero if there is no
+     * such key or if the value is not a number. If the value is a string, an
+     * attempt will be made to evaluate it as a number.
      *
-     * @param key   A key string.
-     * @return      An object which is the value.
+     * @param key
+     *            A key string.
+     * @return An object which is the value.
      */
     public long optLong(String key) {
         return this.optLong(key, 0);
     }
 
-
     /**
-     * Get an optional long value associated with a key,
-     * or the default if there is no such key or if the value is not a number.
-     * If the value is a string, an attempt will be made to evaluate it as
-     * a number.
+     * Get an optional long value associated with a key, or the default if there
+     * is no such key or if the value is not a number. If the value is a string,
+     * an attempt will be made to evaluate it as a number.
      *
-     * @param key          A key string.
-     * @param defaultValue The default.
-     * @return             An object which is the value.
+     * @param key
+     *            A key string.
+     * @param defaultValue
+     *            The default.
+     * @return An object which is the value.
      */
     public long optLong(String key, long defaultValue) {
         try {
@@ -928,34 +951,34 @@ public class JSONObject {
         }
     }
 
-
     /**
-     * Get an optional string associated with a key.
-     * It returns an empty string if there is no such key. If the value is not
-     * a string and is not null, then it is converted to a string.
+     * Get an optional string associated with a key. It returns an empty string
+     * if there is no such key. If the value is not a string and is not null,
+     * then it is converted to a string.
      *
-     * @param key   A key string.
-     * @return      A string which is the value.
+     * @param key
+     *            A key string.
+     * @return A string which is the value.
      */
     public String optString(String key) {
         return this.optString(key, "");
     }
 
-
     /**
-     * Get an optional string associated with a key.
-     * It returns the defaultValue if there is no such key.
+     * Get an optional string associated with a key. It returns the defaultValue
+     * if there is no such key.
      *
-     * @param key   A key string.
-     * @param defaultValue     The default.
-     * @return      A string which is the value.
+     * @param key
+     *            A key string.
+     * @param defaultValue
+     *            The default.
+     * @return A string which is the value.
      */
     public String optString(String key, String defaultValue) {
         Object object = this.opt(key);
         return NULL.equals(object) ? defaultValue : object.toString();
     }
 
-
     private void populateMap(Object bean) {
         Class klass = bean.getClass();
 
@@ -963,9 +986,8 @@ public class JSONObject {
 
         boolean includeSuperClass = klass.getClassLoader() != null;
 
-        Method[] methods = includeSuperClass
-                ? klass.getMethods()
-                : klass.getDeclaredMethods();
+        Method[] methods = includeSuperClass ? klass.getMethods() : klass
+                .getDeclaredMethods();
         for (int i = 0; i < methods.length; i += 1) {
             try {
                 Method method = methods[i];
@@ -973,8 +995,8 @@ public class JSONObject {
                     String name = method.getName();
                     String key = "";
                     if (name.startsWith("get")) {
-                        if ("getClass".equals(name) ||
-                                "getDeclaringClass".equals(name)) {
+                        if ("getClass".equals(name)
+                                || "getDeclaringClass".equals(name)) {
                             key = "";
                         } else {
                             key = name.substring(3);
@@ -982,17 +1004,17 @@ public class JSONObject {
                     } else if (name.startsWith("is")) {
                         key = name.substring(2);
                     }
-                    if (key.length() > 0 &&
-                            Character.isUpperCase(key.charAt(0)) &&
-                            method.getParameterTypes().length == 0) {
+                    if (key.length() > 0
+                            && Character.isUpperCase(key.charAt(0))
+                            && method.getParameterTypes().length == 0) {
                         if (key.length() == 1) {
                             key = key.toLowerCase();
                         } else if (!Character.isUpperCase(key.charAt(1))) {
-                            key = key.substring(0, 1).toLowerCase() +
-                                key.substring(1);
+                            key = key.substring(0, 1).toLowerCase()
+                                    + key.substring(1);
                         }
 
-                        Object result = method.invoke(bean, (Object[])null);
+                        Object result = method.invoke(bean, (Object[]) null);
                         if (result != null) {
                             this.map.put(key, wrap(result));
                         }
@@ -1003,27 +1025,31 @@ public class JSONObject {
         }
     }
 
-
     /**
      * Put a key/boolean pair in the JSONObject.
      *
-     * @param key   A key string.
-     * @param value A boolean which is the value.
+     * @param key
+     *            A key string.
+     * @param value
+     *            A boolean which is the value.
      * @return this.
-     * @throws JSONException If the key is null.
+     * @throws JSONException
+     *             If the key is null.
      */
     public JSONObject put(String key, boolean value) throws JSONException {
         this.put(key, value ? Boolean.TRUE : Boolean.FALSE);
         return this;
     }
 
-
     /**
      * Put a key/value pair in the JSONObject, where the value will be a
      * JSONArray which is produced from a Collection.
-     * @param key   A key string.
-     * @param value A Collection value.
-     * @return      this.
+     *
+     * @param key
+     *            A key string.
+     * @param value
+     *            A Collection value.
+     * @return this.
      * @throws JSONException
      */
     public JSONObject put(String key, Collection value) throws JSONException {
@@ -1031,55 +1057,63 @@ public class JSONObject {
         return this;
     }
 
-
     /**
      * Put a key/double pair in the JSONObject.
      *
-     * @param key   A key string.
-     * @param value A double which is the value.
+     * @param key
+     *            A key string.
+     * @param value
+     *            A double which is the value.
      * @return this.
-     * @throws JSONException If the key is null or if the number is invalid.
+     * @throws JSONException
+     *             If the key is null or if the number is invalid.
      */
     public JSONObject put(String key, double value) throws JSONException {
         this.put(key, new Double(value));
         return this;
     }
 
-
     /**
      * Put a key/int pair in the JSONObject.
      *
-     * @param key   A key string.
-     * @param value An int which is the value.
+     * @param key
+     *            A key string.
+     * @param value
+     *            An int which is the value.
      * @return this.
-     * @throws JSONException If the key is null.
+     * @throws JSONException
+     *             If the key is null.
      */
     public JSONObject put(String key, int value) throws JSONException {
         this.put(key, new Integer(value));
         return this;
     }
 
-
     /**
      * Put a key/long pair in the JSONObject.
      *
-     * @param key   A key string.
-     * @param value A long which is the value.
+     * @param key
+     *            A key string.
+     * @param value
+     *            A long which is the value.
      * @return this.
-     * @throws JSONException If the key is null.
+     * @throws JSONException
+     *             If the key is null.
      */
     public JSONObject put(String key, long value) throws JSONException {
         this.put(key, new Long(value));
         return this;
     }
 
-
     /**
      * Put a key/value pair in the JSONObject, where the value will be a
      * JSONObject which is produced from a Map.
-     * @param key   A key string.
-     * @param value A Map value.
-     * @return      this.
+     *
+     * @param key
+     *            A key string.
+     * @param value
+     *            A Map value.
+     * @return this.
      * @throws JSONException
      */
     public JSONObject put(String key, Map value) throws JSONException {
@@ -1087,21 +1121,23 @@ public class JSONObject {
         return this;
     }
 
-
     /**
-     * Put a key/value pair in the JSONObject. If the value is null,
-     * then the key will be removed from the JSONObject if it is present.
-     * @param key   A key string.
-     * @param value An object which is the value. It should be of one of these
-     *  types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String,
-     *  or the JSONObject.NULL object.
+     * Put a key/value pair in the JSONObject. If the value is null, then the
+     * key will be removed from the JSONObject if it is present.
+     *
+     * @param key
+     *            A key string.
+     * @param value
+     *            An object which is the value. It should be of one of these
+     *            types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
+     *            String, or the JSONObject.NULL object.
      * @return this.
-     * @throws JSONException If the value is non-finite number
-     *  or if the key is null.
+     * @throws JSONException
+     *             If the value is non-finite number or if the key is null.
      */
     public JSONObject put(String key, Object value) throws JSONException {
         if (key == null) {
-            throw new JSONException("Null key.");
+            throw new NullPointerException("Null key.");
         }
         if (value != null) {
             testValidity(value);
@@ -1112,15 +1148,16 @@ public class JSONObject {
         return this;
     }
 
-
     /**
-     * Put a key/value pair in the JSONObject, but only if the key and the
-     * value are both non-null, and only if there is not already a member
-     * with that name.
+     * Put a key/value pair in the JSONObject, but only if the key and the value
+     * are both non-null, and only if there is not already a member with that
+     * name.
+     *
      * @param key
      * @param value
      * @return his.
-     * @throws JSONException if the key is a duplicate
+     * @throws JSONException
+     *             if the key is a duplicate
      */
     public JSONObject putOnce(String key, Object value) throws JSONException {
         if (key != null && value != null) {
@@ -1132,16 +1169,19 @@ public class JSONObject {
         return this;
     }
 
-
     /**
-     * Put a key/value pair in the JSONObject, but only if the
-     * key and the value are both non-null.
-     * @param key   A key string.
-     * @param value An object which is the value. It should be of one of these
-     *  types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String,
-     *  or the JSONObject.NULL object.
+     * Put a key/value pair in the JSONObject, but only if the key and the value
+     * are both non-null.
+     *
+     * @param key
+     *            A key string.
+     * @param value
+     *            An object which is the value. It should be of one of these
+     *            types: Boolean, Double, Integer, JSONArray, JSONObject, Long,
+     *            String, or the JSONObject.NULL object.
      * @return this.
-     * @throws JSONException If the value is a non-finite number.
+     * @throws JSONException
+     *             If the value is a non-finite number.
      */
     public JSONObject putOpt(String key, Object value) throws JSONException {
         if (key != null && value != null) {
@@ -1150,14 +1190,15 @@ public class JSONObject {
         return this;
     }
 
-
     /**
      * Produce a string in double quotes with backslash sequences in all the
      * right places. A backslash will be inserted within </, producing <\/,
-     * allowing JSON text to be delivered in HTML. In JSON text, a string
-     * cannot contain a control character or an unescaped quote or backslash.
-     * @param string A String
-     * @return  A String correctly formatted for insertion in a JSON text.
+     * allowing JSON text to be delivered in HTML. In JSON text, a string cannot
+     * contain a control character or an unescaped quote or backslash.
+     *
+     * @param string
+     *            A String
+     * @return A String correctly formatted for insertion in a JSON text.
      */
     public static String quote(String string) {
         StringWriter sw = new StringWriter();
@@ -1217,8 +1258,10 @@ public class JSONObject {
             default:
                 if (c < ' ' || (c >= '\u0080' && c < '\u00a0')
                         || (c >= '\u2000' && c < '\u2100')) {
-                    hhhh = "000" + Integer.toHexString(c);
-                    w.write("\\u" + hhhh.substring(hhhh.length() - 4));
+                    w.write("\\u");
+                    hhhh = Integer.toHexString(c);
+                    w.write("0000", 0, 4 - hhhh.length());
+                    w.write(hhhh);
                 } else {
                     w.write(c);
                 }
@@ -1230,9 +1273,11 @@ public class JSONObject {
 
     /**
      * Remove a name and its value, if present.
-     * @param key The name to be removed.
-     * @return The value that was associated with the name,
-     * or null if there was no value.
+     *
+     * @param key
+     *            The name to be removed.
+     * @return The value that was associated with the name, or null if there was
+     *         no value.
      */
     public Object remove(String key) {
         return this.map.remove(key);
@@ -1241,7 +1286,9 @@ public class JSONObject {
     /**
      * Try to convert a string into a number, boolean, or null. If the string
      * can't be converted, return the string.
-     * @param string A String.
+     *
+     * @param string
+     *            A String.
      * @return A simple JSON value.
      */
     public static Object stringToValue(String string) {
@@ -1260,66 +1307,69 @@ public class JSONObject {
         }
 
         /*
-         * If it might be a number, try converting it.
-         * If a number cannot be produced, then the value will just
-         * be a string. Note that the plus and implied string
-         * conventions are non-standard. A JSON parser may accept
-         * non-JSON forms as long as it accepts all correct JSON forms.
+         * If it might be a number, try converting it. If a number cannot be
+         * produced, then the value will just be a string.
          */
 
         char b = string.charAt(0);
-        if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+') {
+        if ((b >= '0' && b <= '9') || b == '-') {
             try {
-                if (string.indexOf('.') > -1 ||
-                        string.indexOf('e') > -1 || string.indexOf('E') > -1) {
+                if (string.indexOf('.') > -1 || string.indexOf('e') > -1
+                        || string.indexOf('E') > -1) {
                     d = Double.valueOf(string);
                     if (!d.isInfinite() && !d.isNaN()) {
                         return d;
                     }
                 } else {
                     Long myLong = new Long(string);
-                    if (myLong.longValue() == myLong.intValue()) {
-                        return new Integer(myLong.intValue());
-                    } else {
-                        return myLong;
+                    if (string.equals(myLong.toString())) {
+                        if (myLong.longValue() == myLong.intValue()) {
+                            return new Integer(myLong.intValue());
+                        } else {
+                            return myLong;
+                        }
                     }
                 }
-            }  catch (Exception ignore) {
+            } catch (Exception ignore) {
             }
         }
         return string;
     }
 
-
     /**
      * Throw an exception if the object is a NaN or infinite number.
-     * @param o The object to test.
-     * @throws JSONException If o is a non-finite number.
+     *
+     * @param o
+     *            The object to test.
+     * @throws JSONException
+     *             If o is a non-finite number.
      */
     public static void testValidity(Object o) throws JSONException {
         if (o != null) {
             if (o instanceof Double) {
-                if (((Double)o).isInfinite() || ((Double)o).isNaN()) {
+                if (((Double) o).isInfinite() || ((Double) o).isNaN()) {
                     throw new JSONException(
-                        "JSON does not allow non-finite numbers.");
+                            "JSON does not allow non-finite numbers.");
                 }
             } else if (o instanceof Float) {
-                if (((Float)o).isInfinite() || ((Float)o).isNaN()) {
+                if (((Float) o).isInfinite() || ((Float) o).isNaN()) {
                     throw new JSONException(
-                        "JSON does not allow non-finite numbers.");
+                            "JSON does not allow non-finite numbers.");
                 }
             }
         }
     }
 
-
     /**
      * Produce a JSONArray containing the values of the members of this
      * JSONObject.
-     * @param names A JSONArray containing a list of key strings. This
-     * determines the sequence of the values in the result.
+     *
+     * @param names
+     *            A JSONArray containing a list of key strings. This determines
+     *            the sequence of the values in the result.
      * @return A JSONArray of values.
-     * @throws JSONException If any of the values are non-finite numbers.
+     * @throws JSONException
+     *             If any of the values are non-finite numbers.
      */
     public JSONArray toJSONArray(JSONArray names) throws JSONException {
         if (names == null || names.length() == 0) {
@@ -1333,16 +1383,16 @@ public class JSONObject {
     }
 
     /**
-     * Make a JSON text of this JSONObject. For compactness, no whitespace
-     * is added. If this would not result in a syntactically correct JSON text,
+     * Make a JSON text of this JSONObject. For compactness, no whitespace is
+     * added. If this would not result in a syntactically correct JSON text,
      * then null will be returned instead.
      * <p>
      * Warning: This method assumes that the data structure is acyclical.
      *
-     * @return a printable, displayable, portable, transmittable
-     *  representation of the object, beginning
-     *  with <code>{</code>&nbsp;<small>(left brace)</small> and ending
-     *  with <code>}</code>&nbsp;<small>(right brace)</small>.
+     * @return a printable, displayable, portable, transmittable representation
+     *         of the object, beginning with <code>{</code>&nbsp;<small>(left
+     *         brace)</small> and ending with <code>}</code>&nbsp;<small>(right
+     *         brace)</small>.
      */
     public String toString() {
         try {
@@ -1352,18 +1402,19 @@ public class JSONObject {
         }
     }
 
-
     /**
      * Make a prettyprinted JSON text of this JSONObject.
      * <p>
      * Warning: This method assumes that the data structure is acyclical.
-     * @param indentFactor The number of spaces to add to each level of
-     *  indentation.
-     * @return a printable, displayable, portable, transmittable
-     *  representation of the object, beginning
-     *  with <code>{</code>&nbsp;<small>(left brace)</small> and ending
-     *  with <code>}</code>&nbsp;<small>(right brace)</small>.
-     * @throws JSONException If the object contains an invalid number.
+     *
+     * @param indentFactor
+     *            The number of spaces to add to each level of indentation.
+     * @return a printable, displayable, portable, transmittable representation
+     *         of the object, beginning with <code>{</code>&nbsp;<small>(left
+     *         brace)</small> and ending with <code>}</code>&nbsp;<small>(right
+     *         brace)</small>.
+     * @throws JSONException
+     *             If the object contains an invalid number.
      */
     public String toString(int indentFactor) throws JSONException {
         StringWriter w = new StringWriter();
@@ -1374,24 +1425,27 @@ public class JSONObject {
 
     /**
      * Make a JSON text of an Object value. If the object has an
-     * value.toJSONString() method, then that method will be used to produce
-     * the JSON text. The method is required to produce a strictly
-     * conforming text. If the object does not contain a toJSONString
-     * method (which is the most common case), then a text will be
-     * produced by other means. If the value is an array or Collection,
-     * then a JSONArray will be made from it and its toJSONString method
-     * will be called. If the value is a MAP, then a JSONObject will be made
-     * from it and its toJSONString method will be called. Otherwise, the
-     * value's toString method will be called, and the result will be quoted.
+     * value.toJSONString() method, then that method will be used to produce the
+     * JSON text. The method is required to produce a strictly conforming text.
+     * If the object does not contain a toJSONString method (which is the most
+     * common case), then a text will be produced by other means. If the value
+     * is an array or Collection, then a JSONArray will be made from it and its
+     * toJSONString method will be called. If the value is a MAP, then a
+     * JSONObject will be made from it and its toJSONString method will be
+     * called. Otherwise, the value's toString method will be called, and the
+     * result will be quoted.
      *
      * <p>
      * Warning: This method assumes that the data structure is acyclical.
-     * @param value The value to be serialized.
-     * @return a printable, displayable, transmittable
-     *  representation of the object, beginning
-     *  with <code>{</code>&nbsp;<small>(left brace)</small> and ending
-     *  with <code>}</code>&nbsp;<small>(right brace)</small>.
-     * @throws JSONException If the value is or contains an invalid number.
+     *
+     * @param value
+     *            The value to be serialized.
+     * @return a printable, displayable, transmittable representation of the
+     *         object, beginning with <code>{</code>&nbsp;<small>(left
+     *         brace)</small> and ending with <code>}</code>&nbsp;<small>(right
+     *         brace)</small>.
+     * @throws JSONException
+     *             If the value is or contains an invalid number.
      */
     public static String valueToString(Object value) throws JSONException {
         if (value == null || value.equals(null)) {
@@ -1400,27 +1454,27 @@ public class JSONObject {
         if (value instanceof JSONString) {
             Object object;
             try {
-                object = ((JSONString)value).toJSONString();
+                object = ((JSONString) value).toJSONString();
             } catch (Exception e) {
                 throw new JSONException(e);
             }
             if (object instanceof String) {
-                return (String)object;
+                return (String) object;
             }
             throw new JSONException("Bad value from toJSONString: " + object);
         }
         if (value instanceof Number) {
             return numberToString((Number) value);
         }
-        if (value instanceof Boolean || value instanceof JSONObject ||
-                value instanceof JSONArray) {
+        if (value instanceof Boolean || value instanceof JSONObject
+                || value instanceof JSONArray) {
             return value.toString();
         }
         if (value instanceof Map) {
-            return new JSONObject((Map)value).toString();
+            return new JSONObject((Map) value).toString();
         }
         if (value instanceof Collection) {
-            return new JSONArray((Collection)value).toString();
+            return new JSONArray((Collection) value).toString();
         }
         if (value.getClass().isArray()) {
             return new JSONArray(value).toString();
@@ -1428,73 +1482,68 @@ public class JSONObject {
         return quote(value.toString());
     }
 
-     /**
-      * Wrap an object, if necessary. If the object is null, return the NULL
-      * object. If it is an array or collection, wrap it in a JSONArray. If
-      * it is a map, wrap it in a JSONObject. If it is a standard property
-      * (Double, String, et al) then it is already wrapped. Otherwise, if it
-      * comes from one of the java packages, turn it into a string. And if
-      * it doesn't, try to wrap it in a JSONObject. If the wrapping fails,
-      * then null is returned.
-      *
-      * @param object The object to wrap
-      * @return The wrapped value
-      */
-     public static Object wrap(Object object) {
-         try {
-             if (object == null) {
-                 return NULL;
-             }
-             if (object instanceof JSONObject || object instanceof JSONArray  ||
-                     NULL.equals(object)      || object instanceof JSONString ||
-                     object instanceof Byte   || object instanceof Character  ||
-                     object instanceof Short  || object instanceof Integer    ||
-                     object instanceof Long   || object instanceof Boolean    ||
-                     object instanceof Float  || object instanceof Double     ||
-                     object instanceof String || object instanceof Enum) {
-                 return object;
-             }
-
-             if (object instanceof Collection) {
-                 return new JSONArray((Collection)object);
-             }
-             if (object.getClass().isArray()) {
-                 return new JSONArray(object);
-             }
-             if (object instanceof Map) {
-                 return new JSONObject((Map)object);
-             }
-             Package objectPackage = object.getClass().getPackage();
-             String objectPackageName = objectPackage != null
-                 ? objectPackage.getName()
-                 : "";
-             if (
-                 objectPackageName.startsWith("java.") ||
-                 objectPackageName.startsWith("javax.") ||
-                 object.getClass().getClassLoader() == null
-             ) {
-                 return object.toString();
-             }
-             return new JSONObject(object);
-         } catch(Exception exception) {
-             return null;
-         }
-     }
-
-
-     /**
-      * Write the contents of the JSONObject as JSON text to a writer.
-      * For compactness, no whitespace is added.
-      * <p>
-      * Warning: This method assumes that the data structure is acyclical.
-      *
-      * @return The writer.
-      * @throws JSONException
-      */
-     public Writer write(Writer writer) throws JSONException {
-        return this.write(writer, 0, 0);
+    /**
+     * Wrap an object, if necessary. If the object is null, return the NULL
+     * object. If it is an array or collection, wrap it in a JSONArray. If it is
+     * a map, wrap it in a JSONObject. If it is a standard property (Double,
+     * String, et al) then it is already wrapped. Otherwise, if it comes from
+     * one of the java packages, turn it into a string. And if it doesn't, try
+     * to wrap it in a JSONObject. If the wrapping fails, then null is returned.
+     *
+     * @param object
+     *            The object to wrap
+     * @return The wrapped value
+     */
+    public static Object wrap(Object object) {
+        try {
+            if (object == null) {
+                return NULL;
+            }
+            if (object instanceof JSONObject || object instanceof JSONArray
+                    || NULL.equals(object) || object instanceof JSONString
+                    || object instanceof Byte || object instanceof Character
+                    || object instanceof Short || object instanceof Integer
+                    || object instanceof Long || object instanceof Boolean
+                    || object instanceof Float || object instanceof Double
+                    || object instanceof String) {
+                return object;
+            }
+
+            if (object instanceof Collection) {
+                return new JSONArray((Collection) object);
+            }
+            if (object.getClass().isArray()) {
+                return new JSONArray(object);
+            }
+            if (object instanceof Map) {
+                return new JSONObject((Map) object);
+            }
+            Package objectPackage = object.getClass().getPackage();
+            String objectPackageName = objectPackage != null ? objectPackage
+                    .getName() : "";
+            if (objectPackageName.startsWith("java.")
+                    || objectPackageName.startsWith("javax.")
+                    || object.getClass().getClassLoader() == null) {
+                return object.toString();
+            }
+            return new JSONObject(object);
+        } catch (Exception exception) {
+            return null;
+        }
     }
 
+    /**
+     * Write the contents of the JSONObject as JSON text to a writer. For
+     * compactness, no whitespace is added.
+     * <p>
+     * Warning: This method assumes that the data structure is acyclical.
+     *
+     * @return The writer.
+     * @throws JSONException
+     */
+    public Writer write(Writer writer) throws JSONException {
+        return this.write(writer, 0, 0);
+    }
 
     static final Writer writeValue(Writer writer, Object value,
             int indentFactor, int indent) throws JSONException, IOException {
@@ -1590,5 +1639,5 @@ public class JSONObject {
         } catch (IOException exception) {
             throw new JSONException(exception);
         }
-     }
+    }
 }

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONString.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONString.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONString.java
index 00f24d6..55e5fee 100755
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONString.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONString.java
@@ -1,19 +1,18 @@
-package org.apache.wicket.ajax.json;
-
-/**
- * The <code>JSONString</code> interface allows a <code>toJSONString()</code> 
- * method so that a class can change the behavior of 
- * <code>JSONObject.toString()</code>, <code>JSONArray.toString()</code>,
- * and <code>JSONWriter.value(</code>Object<code>)</code>. The 
- * <code>toJSONString</code> method will be used instead of the default behavior 
- * of using the Object's <code>toString()</code> method and quoting the result.
- */
-public interface JSONString {
-    /**
-     * The <code>toJSONString</code> method allows a class to produce its own JSON 
-     * serialization. 
-     * 
-     * @return A strictly syntactically correct JSON text.
-     */
-    public String toJSONString();
-}
+package org.apache.wicket.ajax.json;
+/**
+ * The <code>JSONString</code> interface allows a <code>toJSONString()</code>
+ * method so that a class can change the behavior of
+ * <code>JSONObject.toString()</code>, <code>JSONArray.toString()</code>,
+ * and <code>JSONWriter.value(</code>Object<code>)</code>. The
+ * <code>toJSONString</code> method will be used instead of the default behavior
+ * of using the Object's <code>toString()</code> method and quoting the result.
+ */
+public interface JSONString {
+    /**
+     * The <code>toJSONString</code> method allows a class to produce its own JSON
+     * serialization.
+     *
+     * @return A strictly syntactically correct JSON text.
+     */
+    public String toJSONString();
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONStringer.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONStringer.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONStringer.java
index 76b2b4e..15eb62b 100755
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONStringer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONStringer.java
@@ -72,7 +72,6 @@ public class JSONStringer extends JSONWriter {
      * <code>endArray</code>).
      * @return The JSON text.
      */
-    @Override
     public String toString() {
         return this.mode == 'd' ? this.writer.toString() : null;
     }

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONTokener.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONTokener.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONTokener.java
old mode 100755
new mode 100644
index 3369c6d..a1aa0b1
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONTokener.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONTokener.java
@@ -70,7 +70,8 @@ public class JSONTokener {
     /**
      * Construct a JSONTokener from an InputStream.
      */
-    public JSONTokener(InputStream inputStream) throws JSONException {
+    public JSONTokener(InputStream inputStream) throws JSONException
+    {
         this(new InputStreamReader(inputStream));
     }
 
@@ -439,7 +440,6 @@ public class JSONTokener {
      *
      * @return " at {index} [character {character} line {line}]"
      */
-    @Override
     public String toString() {
         return " at " + this.index + " [character " + this.character + " line " +
             this.line + "]";

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONWriter.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONWriter.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONWriter.java
index 7762383..72310dd 100755
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONWriter.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JSONWriter.java
@@ -107,7 +107,8 @@ public class JSONWriter {
      * @return this
      * @throws JSONException If the value is out of sequence.
      */
-    private JSONWriter append(String string) throws JSONException {
+    private JSONWriter append(String string) throws JSONException
+    {
         if (string == null) {
             throw new JSONException("Null pointer");
         }
@@ -269,7 +270,7 @@ public class JSONWriter {
 
     /**
      * Push an array or object scope.
-     * @param c The scope to open.
+     * @param jo The scope to open.
      * @throws JSONException If nesting is too deep.
      */
     private void push(JSONObject jo) throws JSONException {

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/main/java/org/apache/wicket/ajax/json/JsonSequenceStringer.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JsonSequenceStringer.java b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JsonSequenceStringer.java
index be56a57..f21578d 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/JsonSequenceStringer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/JsonSequenceStringer.java
@@ -21,10 +21,10 @@ import java.io.IOException;
 import org.apache.wicket.util.io.StringBufferWriter;
 
 /**
- * An efficient implementation of a JSON stringer. The efficiency comes from the fact that istead of
+ * An efficient implementation of a JSON stringer. The efficiency comes from the fact that instead of
  * a {@link String} this class can return a {@link CharSequence}. This is better for downstream
- * method that can accept a {@link CharSequence} becuase it requires one less memory copy of the
- * internal {@link AppendingStringBufferWriter} to a {@link String} to get the JSON.
+ * method that can accept a {@link CharSequence} because it requires one less memory copy of the
+ * internal {@link StringBufferWriter} to a {@link String} to get the JSON.
  * 
  * @author igor
  */

http://git-wip-us.apache.org/repos/asf/wicket/blob/79e40312/wicket-core/src/main/java/org/apache/wicket/ajax/json/README
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/json/README b/wicket-core/src/main/java/org/apache/wicket/ajax/json/README
index d820f64..97f9503 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/json/README
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/json/README
@@ -1,5 +1,10 @@
 All JSON** classes are copied from https://github.com/douglascrockford/JSON-java.
-Last update: May 18 2012
+Last update: February 18 2014
+
+IMPORTANT: JSONObject#map field is manually changed to LinkedHashMap (from HashMap) to keep
+the order of the ajax attributes consistent for WicketTester based unit tests
+
+
 
 Json** are our custom.
-JsonFunction is borrowed from https://github.com/ivaynberg/wicket-select2.
\ No newline at end of file
+JsonFunction is borrowed from https://github.com/ivaynberg/wicket-select2.


[05/11] git commit: WICKET-5512 Allow using child selector for JS event bindings

Posted by iv...@apache.org.
WICKET-5512 Allow using child selector for JS event bindings


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/25474d52
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/25474d52
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/25474d52

Branch: refs/heads/sandbox/component-queueing-2
Commit: 25474d5226dfa057999bb566dfcd61318d468232
Parents: 51e5b57
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Wed Feb 19 14:33:56 2014 +0200
Committer: Igor Vaynberg <ig...@gmail.com>
Committed: Thu Feb 20 23:24:05 2014 -0800

----------------------------------------------------------------------
 .../ajax/AbstractDefaultAjaxBehavior.java       |  7 +++++
 .../ajax/attributes/AjaxAttributeName.java      |  7 ++++-
 .../ajax/attributes/AjaxRequestAttributes.java  | 28 ++++++++++++++++++++
 .../wicket/ajax/res/js/wicket-ajax-jquery.js    |  2 +-
 .../wicket/ajax/res/js/wicket-event-jquery.js   |  7 +++--
 .../ajax/attributes/AjaxAttributeNameTest.java  |  2 +-
 6 files changed, 48 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/25474d52/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
index 1da7366..1d0caf3 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
@@ -227,6 +227,13 @@ public abstract class AbstractDefaultAjaxBehavior extends AbstractAjaxBehavior
 					submittingComponentId);
 			}
 
+			CharSequence childSelector = attributes.getChildSelector();
+			if (Strings.isEmpty(childSelector) == false)
+			{
+				attributesJson.put(AjaxAttributeName.CHILD_SELECTOR.jsonName(),
+						childSelector);
+			}
+
 			String indicatorId = findIndicatorId();
 			if (Strings.isEmpty(indicatorId) == false)
 			{

http://git-wip-us.apache.org/repos/asf/wicket/blob/25474d52/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxAttributeName.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxAttributeName.java b/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxAttributeName.java
index e0ce088..0429ec3 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxAttributeName.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxAttributeName.java
@@ -218,7 +218,12 @@ public enum AjaxAttributeName {
 	/**
 	 * @see AbstractDefaultAjaxBehavior#getCallbackUrl();
 	 */
-	URL("u");
+	URL("u"),
+
+	/**
+	 * @see org.apache.wicket.ajax.attributes.AjaxRequestAttributes#childSelector
+	 */
+	CHILD_SELECTOR("sel");
 
 	private final String jsonName;
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/25474d52/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxRequestAttributes.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxRequestAttributes.java b/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxRequestAttributes.java
index 9eff742..fea733d 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxRequestAttributes.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/attributes/AjaxRequestAttributes.java
@@ -133,6 +133,34 @@ public final class AjaxRequestAttributes
 	private ThrottlingSettings throttlingSettings;
 
 	/**
+	 * A selector string to filter the descendants of the selected
+	 * elements that trigger the event. If the selector is null or empty,
+	 * the event is always triggered when it reaches the selected HTML element.
+	 *
+	 * @see <a href="http://api.jquery.com/on/">jQuery#on's selector</a>
+	 */
+	private CharSequence childSelector;
+
+	/**
+	 * @see #childSelector
+	 * @return The selector string that filters the descendants
+	 */
+	public CharSequence getChildSelector()
+	{
+		return childSelector;
+	}
+
+	/**
+	 * @see #childSelector
+	 * @param childSelector
+	 *            The selector string that filters the descendants
+	 */
+	public void setChildSelector(CharSequence childSelector)
+	{
+		this.childSelector = childSelector;
+	}
+
+	/**
 	 * Returns whether the form submit is multipart.
 	 * <p>
 	 * Note that for multipart AJAX requests a hidden IFRAME will be used and that can have negative

http://git-wip-us.apache.org/repos/asf/wicket/blob/25474d52/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
index 43ff3a4..a8c6102 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
@@ -1864,7 +1864,7 @@
 							call.ajax(attributes);
 						}
 						Wicket.Ajax._handleEventCancelation(attributes);
-					});
+					}, null, attrs.sel);
 				});
 			},
 			

http://git-wip-us.apache.org/repos/asf/wicket/blob/25474d52/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-event-jquery.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-event-jquery.js b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-event-jquery.js
index f814897..8ac06f2 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-event-jquery.js
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-event-jquery.js
@@ -148,8 +148,11 @@
 			 * @param type {String} The type of the DOM event
 			 * @param fn {Function} The event handler to unbind
 			 * @param data {Object} Extra data for the event
+			 * @param selector {String} A selector string to filter the descendants of the selected
+			 *      elements that trigger the event. If the selector is null or omitted,
+			 *      the event is always triggered when it reaches the selected element.
 			 */
-			add: function (element, type, fn, data) {
+			add: function (element, type, fn, data, selector) {
 				if (type === 'domready') {
 					jQuery(fn);
 				} else {
@@ -166,7 +169,7 @@
 								'" on element "' + element + '" because the element is not in the DOM');
 						}
 
-						jQuery(el).on(type, data, fn);
+						jQuery(el).on(type, selector, data, fn);
 					});
 				}
 				return element;

http://git-wip-us.apache.org/repos/asf/wicket/blob/25474d52/wicket-core/src/test/java/org/apache/wicket/ajax/attributes/AjaxAttributeNameTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/ajax/attributes/AjaxAttributeNameTest.java b/wicket-core/src/test/java/org/apache/wicket/ajax/attributes/AjaxAttributeNameTest.java
index 51027eb..c689423 100644
--- a/wicket-core/src/test/java/org/apache/wicket/ajax/attributes/AjaxAttributeNameTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/ajax/attributes/AjaxAttributeNameTest.java
@@ -57,7 +57,7 @@ public class AjaxAttributeNameTest extends Assert
 		}
 
 		assertEquals("all known json parameter names",
-			"tr|p|d|id|dt|wr|rt|pd|sp|ch|e|async|dep|ep|pre|coh|fh|sh|ah|bsh|bh|i|sc|mp|f|c|m|u|",
+			"tr|p|d|id|dt|wr|rt|pd|sp|ch|e|async|dep|ep|pre|coh|fh|sh|ah|bsh|bh|i|sc|mp|f|c|m|u|sel|",
 			sb.toString());
 	}
 }


[11/11] git commit: WICKET-1069 RFE: DataTable && colgroup

Posted by iv...@apache.org.
WICKET-1069 RFE: DataTable && colgroup


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/3d261456
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/3d261456
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/3d261456

Branch: refs/heads/sandbox/component-queueing-2
Commit: 3d261456f31d8064c75525a9981c52e68d76a22c
Parents: 7a4823c
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Thu Feb 20 15:20:35 2014 +0200
Committer: Igor Vaynberg <ig...@gmail.com>
Committed: Thu Feb 20 23:24:05 2014 -0800

----------------------------------------------------------------------
 .../wicket/examples/repeater/DataTablePage.html |  12 ++-
 .../wicket/examples/repeater/DataTablePage.java |  15 +++
 .../examples/repeater/RepeaterApplication.java  |   2 +
 .../html/repeater/data/table/ColGroup.html      |  23 +++++
 .../html/repeater/data/table/ColGroup.java      | 102 +++++++++++++++++++
 .../html/repeater/data/table/DataTable.html     |   1 +
 .../html/repeater/data/table/DataTable.java     |  11 +-
 7 files changed, 163 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/3d261456/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/DataTablePage.html
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/DataTablePage.html b/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/DataTablePage.html
index 8eb4b70..842cecb 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/DataTablePage.html
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/DataTablePage.html
@@ -25,6 +25,14 @@ This is a demo of the DataTable (DataView wrapper). Provided features:<br/>
 </ul>
 <br/>
 
-<table class="dataview" cellspacing="0" wicket:id="table">[table]</table>
+    <table class="dataview" cellspacing="0" wicket:id="table">[table]</table>
+
+    <br/>
+    <hr/>
+    <br/>
+
+    <span style="font-size: 16px">This is a table that uses <em>org.apache.wicket.extensions.markup.html.repeater.data.table.ColGroup</em>
+    to style the columns</span>:
+    <table wicket:id="tableWithColGroup">[table]</table>
 </wicket:extend>
-</html>
\ No newline at end of file
+</html>

http://git-wip-us.apache.org/repos/asf/wicket/blob/3d261456/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/DataTablePage.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/DataTablePage.java b/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/DataTablePage.java
index 8640299..46b067d 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/DataTablePage.java
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/DataTablePage.java
@@ -19,8 +19,10 @@ package org.apache.wicket.examples.repeater;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.wicket.AttributeModifier;
 import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
 import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
+import org.apache.wicket.extensions.markup.html.repeater.data.table.ColGroup;
 import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
 import org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable;
 import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
@@ -86,5 +88,18 @@ public class DataTablePage extends BasePage
 		dataTable.addBottomToolbar(new ExportToolbar(dataTable).addDataExporter(new CSVDataExporter()));
 
 		add(dataTable);
+
+		DataTable tableWithColGroup = new DataTable<>("tableWithColGroup", columns,
+				new SortableContactDataProvider(), 8);
+		add(tableWithColGroup);
+
+		ColGroup colgroup = tableWithColGroup.getColGroup();
+		colgroup.add(AttributeModifier.append("style", "border: solid 1px green;"));
+		colgroup.addCol(colgroup.new Col(AttributeModifier.append("style", "background-color: lightblue;")));
+		colgroup.addCol(colgroup.new Col(AttributeModifier.append("style", "background-color: lightgreen")));
+		colgroup.addCol(colgroup.new Col(AttributeModifier.append("style", "background-color: pink")));
+		colgroup.addCol(colgroup.new Col(AttributeModifier.append("style", "background-color: yellow")));
+		colgroup.addCol(colgroup.new Col(AttributeModifier.append("span", "2"),
+				AttributeModifier.append("style", "background-color: #CC6633")));
 	}
 }

http://git-wip-us.apache.org/repos/asf/wicket/blob/3d261456/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/RepeaterApplication.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/RepeaterApplication.java b/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/RepeaterApplication.java
index 17e3831..cd9c0ea 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/RepeaterApplication.java
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/RepeaterApplication.java
@@ -47,6 +47,8 @@ public class RepeaterApplication extends WebApplication
 		getDebugSettings().setDevelopmentUtilitiesEnabled(true);
 
 		getRequestCycleSettings().addResponseFilter(new ServerAndClientTimeFilter());
+
+		getMarkupSettings().setStripWicketTags(true);
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/wicket/blob/3d261456/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/ColGroup.html
----------------------------------------------------------------------
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/ColGroup.html b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/ColGroup.html
new file mode 100644
index 0000000..73c0df4
--- /dev/null
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/ColGroup.html
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<!DOCTYPE html>
+<html xmlns:wicket="http://wicket.apache.org">
+<wicket:panel>
+    <col wicket:id="col"/>
+</wicket:panel>
+</html>

http://git-wip-us.apache.org/repos/asf/wicket/blob/3d261456/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/ColGroup.java
----------------------------------------------------------------------
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/ColGroup.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/ColGroup.java
new file mode 100644
index 0000000..d19be5f
--- /dev/null
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/ColGroup.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.extensions.markup.html.repeater.data.table;
+
+import org.apache.wicket.behavior.Behavior;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.markup.repeater.RepeatingView;
+
+/**
+ * A panel that renders &lt;colgroup&gt; with &lt;col&gt; elements
+ * inside it.
+ *
+ * The columns can be used to style the whole table column.
+ *
+ * <p>
+ * <strong>Important</strong>: this component requires
+ * {@link org.apache.wicket.settings.MarkupSettings#getStripWicketTags()}
+ * to return {@code true}, otherwise the browsers break the rendering of
+ * the HTML elements. For example Google Chrome renders two &lt;colgroup&gt;
+ * elements.
+ * </p>
+ *
+ * @see DataTable#getColGroup()
+ */
+public class ColGroup extends Panel
+{
+	private static final long serialVersionUID = 1L;
+
+	private final RepeatingView colgroupCols;
+
+	public ColGroup(String id)
+	{
+		super(id);
+
+		this.colgroupCols = new RepeatingView("col");
+		add(colgroupCols);
+	}
+
+	/**
+	 * Adds a column to the group.
+	 *
+	 * <p>Usage:
+	 * <pre>
+	 *     <code>
+	 *         colgroup.addCol(colgroup.new Col(AttributeModifier.append("span", "2"),
+	 *             AttributeModifier.append("style", "background-color: #CC6633")))
+	 *     </code>
+	 * </pre>
+	 *
+	 * </p>
+	 *
+	 * @param column
+	 *          The column with the styling behaviors
+	 * @return {@code this}, for method chaining
+	 */
+	public ColGroup addCol(Col column)
+	{
+		colgroupCols.add(column);
+		return this;
+	}
+
+	/**
+	 * Hides the ColGroup if there are no &lt;col&gt;s to render
+	 */
+	@Override
+	protected void onConfigure()
+	{
+		super.onConfigure();
+
+		setVisible(colgroupCols.size() > 0);
+	}
+
+	public class Col extends WebMarkupContainer
+	{
+		private static final long serialVersionUID = 1L;
+
+		public Col(Behavior... behaviors)
+		{
+			super(colgroupCols.newChildId());
+
+			if (behaviors != null)
+			{
+				add(behaviors);
+			}
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/3d261456/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.html
----------------------------------------------------------------------
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.html b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.html
index 0be6c56..bd98744 100644
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.html
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.html
@@ -17,6 +17,7 @@
 -->
 <wicket:panel xmlns:wicket="http://wicket.apache.org">
 <caption wicket:id="caption"></caption>
+<colgroup wicket:id="colGroup"></colgroup>
 <thead wicket:id="topToolbars">
 	<wicket:container wicket:id="toolbars"></wicket:container>
 </thead>

http://git-wip-us.apache.org/repos/asf/wicket/blob/3d261456/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.java
----------------------------------------------------------------------
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.java b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.java
index a37fd4b..34935d1 100644
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.java
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.java
@@ -113,6 +113,8 @@ public class DataTable<T, S> extends Panel implements IPageableItems
 
 	private final Caption caption;
 
+	private final ColGroup colGroup;
+
 	private long toolbarIdCounter;
 
 	/**
@@ -138,6 +140,8 @@ public class DataTable<T, S> extends Panel implements IPageableItems
 		this.columns = columns;
 		this.caption = new Caption("caption", getCaptionModel());
 		add(caption);
+		this.colGroup = new ColGroup("colGroup");
+		add(colGroup);
 		body = newBodyContainer("body");
 		datagrid = new DataGridView<T>("rows", columns, dataProvider)
 		{
@@ -191,6 +195,11 @@ public class DataTable<T, S> extends Panel implements IPageableItems
 		return null;
 	}
 
+	public final ColGroup getColGroup()
+	{
+		return colGroup;
+	}
+
 	/**
 	 * Create the MarkupContainer for the <tbody> tag. Users may subclass it to provide their own
 	 * (modified) implementation.
@@ -512,7 +521,7 @@ public class DataTable<T, S> extends Panel implements IPageableItems
 	 * A caption for the table. It renders itself only if {@link DataTable#getCaptionModel()} has
 	 * non-empty value.
 	 */
-	private static class Caption extends Label
+	public static class Caption extends Label
 	{
 		/**
 		 */