You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2018/08/23 23:50:59 UTC

svn commit: r1838770 - in /pivot/trunk: core/src/org/apache/pivot/io/ core/src/org/apache/pivot/json/ core/src/org/apache/pivot/serialization/ core/src/org/apache/pivot/util/ core/src/org/apache/pivot/xml/ demos/src/org/apache/pivot/demos/suggest/ web-...

Author: rwhitcomb
Date: Thu Aug 23 23:50:59 2018
New Revision: 1838770

URL: http://svn.apache.org/viewvc?rev=1838770&view=rev
Log:
PIVOT-1041:  Add a "Constants" class and put a few common values into it.
I have looked for other things, but nothing else stands out as being a
"common" constant...
PIVOT-1032: Also fixed some style errors in these files along the way.

Added:
    pivot/trunk/core/src/org/apache/pivot/util/Constants.java
Modified:
    pivot/trunk/core/src/org/apache/pivot/io/FileSerializer.java
    pivot/trunk/core/src/org/apache/pivot/json/JSONSerializer.java
    pivot/trunk/core/src/org/apache/pivot/serialization/ByteArraySerializer.java
    pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializer.java
    pivot/trunk/core/src/org/apache/pivot/serialization/StringSerializer.java
    pivot/trunk/core/src/org/apache/pivot/util/Resources.java
    pivot/trunk/core/src/org/apache/pivot/util/Service.java
    pivot/trunk/core/src/org/apache/pivot/xml/XMLSerializer.java
    pivot/trunk/demos/src/org/apache/pivot/demos/suggest/SuggestionDemo.java
    pivot/trunk/web-server/src/org/apache/pivot/web/server/QueryServlet.java
    pivot/trunk/web/src/org/apache/pivot/web/Query.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/BrowserApplicationContext.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/text/PlainTextSerializer.java

Modified: pivot/trunk/core/src/org/apache/pivot/io/FileSerializer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/io/FileSerializer.java?rev=1838770&r1=1838769&r2=1838770&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/io/FileSerializer.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/io/FileSerializer.java Thu Aug 23 23:50:59 2018
@@ -29,6 +29,7 @@ import javax.activation.MimetypesFileTyp
 
 import org.apache.pivot.serialization.SerializationException;
 import org.apache.pivot.serialization.Serializer;
+import org.apache.pivot.util.Constants;
 
 /**
  * Implementation of the {@link Serializer} interface that reads and writes
@@ -37,8 +38,6 @@ import org.apache.pivot.serialization.Se
 public class FileSerializer implements Serializer<File> {
     private File tempFileDirectory;
 
-    public static final int BUFFER_SIZE = 1024;
-
     private static final MimetypesFileTypeMap MIME_TYPES_FILE_MAP = new MimetypesFileTypeMap();
 
     /**
@@ -56,7 +55,7 @@ public class FileSerializer implements S
      * @param tempFileDirectory The directory in which to store temporary
      * files (can be {@code null} to use the system default location).
      */
-    public FileSerializer(File tempFileDirectory) {
+    public FileSerializer(final File tempFileDirectory) {
         if (tempFileDirectory != null && !tempFileDirectory.isDirectory()) {
             throw new IllegalArgumentException("Temp file directory '" + tempFileDirectory + "' is not a directory.");
         }
@@ -69,12 +68,12 @@ public class FileSerializer implements S
      * and must be deleted by the caller.
      */
     @Override
-    public File readObject(InputStream inputStream) throws IOException, SerializationException {
+    public File readObject(final InputStream inputStream) throws IOException, SerializationException {
         File file = File.createTempFile(getClass().getName(), null, tempFileDirectory);
         OutputStream outputStream = null;
 
         try {
-            outputStream = new BufferedOutputStream(new FileOutputStream(file), BUFFER_SIZE);
+            outputStream = new BufferedOutputStream(new FileOutputStream(file), Constants.BUFFER_SIZE);
             for (int data = inputStream.read(); data != -1; data = inputStream.read()) {
                 outputStream.write((byte) data);
             }
@@ -91,12 +90,12 @@ public class FileSerializer implements S
      * Writes a file to an output stream.
      */
     @Override
-    public void writeObject(File file, OutputStream outputStream) throws IOException,
+    public void writeObject(final File file, final OutputStream outputStream) throws IOException,
         SerializationException {
         InputStream inputStream = null;
 
         try {
-            inputStream = new BufferedInputStream(new FileInputStream(file), BUFFER_SIZE);
+            inputStream = new BufferedInputStream(new FileInputStream(file), Constants.BUFFER_SIZE);
             for (int data = inputStream.read(); data != -1; data = inputStream.read()) {
                 outputStream.write((byte) data);
             }
@@ -108,7 +107,7 @@ public class FileSerializer implements S
     }
 
     @Override
-    public String getMIMEType(File file) {
+    public String getMIMEType(final File file) {
         return MIME_TYPES_FILE_MAP.getContentType(file);
     }
 }

Modified: pivot/trunk/core/src/org/apache/pivot/json/JSONSerializer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/json/JSONSerializer.java?rev=1838770&r1=1838769&r2=1838770&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/json/JSONSerializer.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/json/JSONSerializer.java Thu Aug 23 23:50:59 2018
@@ -32,6 +32,7 @@ import java.lang.reflect.ParameterizedTy
 import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.pivot.beans.BeanAdapter;
 import org.apache.pivot.collections.ArrayList;
@@ -46,6 +47,7 @@ import org.apache.pivot.io.EchoWriter;
 import org.apache.pivot.serialization.MacroReader;
 import org.apache.pivot.serialization.SerializationException;
 import org.apache.pivot.serialization.Serializer;
+import org.apache.pivot.util.Constants;
 import org.apache.pivot.util.ListenerList;
 import org.apache.pivot.util.Utils;
 
@@ -65,16 +67,14 @@ public class JSONSerializer implements S
 
     private JSONSerializerListener.Listeners jsonSerializerListeners = null;
 
-    public static final String DEFAULT_CHARSET_NAME = "UTF-8";
+    public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
     public static final Type DEFAULT_TYPE = Object.class;
 
     public static final String JSON_EXTENSION = "json";
     public static final String MIME_TYPE = "application/json";
-    public static final int BUFFER_SIZE = 2048;
-    public static final int BYTE_ORDER_MARK = 0xFEFF;
 
     public JSONSerializer() {
-        this(Charset.forName(DEFAULT_CHARSET_NAME), DEFAULT_TYPE);
+        this(DEFAULT_CHARSET, DEFAULT_TYPE);
     }
 
     public JSONSerializer(final Charset charset) {
@@ -82,7 +82,7 @@ public class JSONSerializer implements S
     }
 
     public JSONSerializer(final Type type) {
-        this(Charset.forName(DEFAULT_CHARSET_NAME), type);
+        this(DEFAULT_CHARSET, type);
     }
 
     public JSONSerializer(final Charset charset, final Type type) {
@@ -182,7 +182,7 @@ public class JSONSerializer implements S
     public Object readObject(final InputStream inputStream) throws IOException, SerializationException {
         Utils.checkNull(inputStream, "inputStream");
 
-        Reader reader = new BufferedReader(new InputStreamReader(inputStream, charset), BUFFER_SIZE);
+        Reader reader = new BufferedReader(new InputStreamReader(inputStream, charset), Constants.BUFFER_SIZE);
         if (verbose) {
             reader = new EchoReader(reader);
         }
@@ -221,7 +221,7 @@ public class JSONSerializer implements S
         c = realReader.read();
 
         // Ignore BOM (if present)
-        if (c == BYTE_ORDER_MARK) {
+        if (c == Constants.BYTE_ORDER_MARK) {
             c = realReader.read();
         }
 
@@ -792,7 +792,7 @@ public class JSONSerializer implements S
         Utils.checkNull(outputStream, "outputStream");
 
         Writer writer = new BufferedWriter(new OutputStreamWriter(outputStream, charset),
-            BUFFER_SIZE);
+            Constants.BUFFER_SIZE);
         if (verbose) {
             writer = new EchoWriter(writer);
         }

Modified: pivot/trunk/core/src/org/apache/pivot/serialization/ByteArraySerializer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/serialization/ByteArraySerializer.java?rev=1838770&r1=1838769&r2=1838770&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/serialization/ByteArraySerializer.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/serialization/ByteArraySerializer.java Thu Aug 23 23:50:59 2018
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 
+import org.apache.pivot.util.Constants;
 import org.apache.pivot.util.Utils;
 
 /**
@@ -34,8 +35,6 @@ import org.apache.pivot.util.Utils;
 public class ByteArraySerializer implements Serializer<byte[]> {
     public static final String MIME_TYPE = "application/octet-stream";
 
-    public static final int BUFFER_SIZE = 16384;
-
     /**
      * Reads a byte array from an input stream.
      */
@@ -46,10 +45,10 @@ public class ByteArraySerializer impleme
         byte[] result = null;
 
         try {
-            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
+            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, Constants.BUFFER_SIZE);
             ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
 
-            byte[] buffer = new byte[BUFFER_SIZE];
+            byte[] buffer = new byte[Constants.BUFFER_SIZE];
             int read;
             while ((read = bufferedInputStream.read(buffer)) != -1) {
                 byteOutputStream.write(buffer, 0, read);
@@ -76,7 +75,7 @@ public class ByteArraySerializer impleme
         Utils.checkNull(outputStream, "outputStream");
 
         try {
-            BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream);
+            BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream, Constants.BUFFER_SIZE);
             bufferedOutputStream.write(bytes);
             bufferedOutputStream.flush();
         } catch (IOException exception) {

Modified: pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializer.java?rev=1838770&r1=1838769&r2=1838770&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializer.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/serialization/CSVSerializer.java Thu Aug 23 23:50:59 2018
@@ -29,6 +29,7 @@ import java.io.Writer;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.pivot.beans.BeanAdapter;
 import org.apache.pivot.collections.ArrayAdapter;
@@ -39,6 +40,7 @@ import org.apache.pivot.collections.List
 import org.apache.pivot.collections.Sequence;
 import org.apache.pivot.io.EchoReader;
 import org.apache.pivot.io.EchoWriter;
+import org.apache.pivot.util.Constants;
 import org.apache.pivot.util.ListenerList;
 import org.apache.pivot.util.Utils;
 
@@ -56,19 +58,17 @@ public class CSVSerializer implements Se
     private boolean verbose = false;
 
     private int c = -1;
-    private static final int BOM = 0xFEFF;
 
     private CSVSerializerListener.Listeners csvSerializerListeners = null;
 
-    public static final String DEFAULT_CHARSET_NAME = "ISO-8859-1";
+    public static final Charset DEFAULT_CHARSET = StandardCharsets.ISO_8859_1;
     public static final Type DEFAULT_ITEM_TYPE = HashMap.class;
 
     public static final String CSV_EXTENSION = "csv";
     public static final String MIME_TYPE = "text/csv";
-    public static final int BUFFER_SIZE = 16384;
 
     public CSVSerializer() {
-        this(Charset.forName(DEFAULT_CHARSET_NAME), DEFAULT_ITEM_TYPE);
+        this(DEFAULT_CHARSET, DEFAULT_ITEM_TYPE);
     }
 
     public CSVSerializer(final Charset charset) {
@@ -76,7 +76,7 @@ public class CSVSerializer implements Se
     }
 
     public CSVSerializer(final Type itemType) {
-        this(Charset.forName(DEFAULT_CHARSET_NAME), itemType);
+        this(DEFAULT_CHARSET, itemType);
     }
 
     public CSVSerializer(final Charset charset, final Type itemType) {
@@ -190,7 +190,7 @@ public class CSVSerializer implements Se
     public List<?> readObject(final InputStream inputStream) throws IOException, SerializationException {
         Utils.checkNull(inputStream, "inputStream");
 
-        Reader reader = new BufferedReader(new InputStreamReader(inputStream, charset), BUFFER_SIZE);
+        Reader reader = new BufferedReader(new InputStreamReader(inputStream, charset), Constants.BUFFER_SIZE);
         if (verbose) {
             reader = new EchoReader(reader);
         }
@@ -243,7 +243,7 @@ public class CSVSerializer implements Se
         c = lineNumberReader.read();
 
         // Ignore Byte Order Mark (if present)
-        if (c == BOM) {
+        if (c == Constants.BYTE_ORDER_MARK) {
             c = lineNumberReader.read();
         }
 
@@ -416,7 +416,7 @@ public class CSVSerializer implements Se
         Utils.checkNull(outputStream, "outputStream");
 
         Writer writer = new BufferedWriter(new OutputStreamWriter(outputStream, charset),
-            BUFFER_SIZE);
+            Constants.BUFFER_SIZE);
         if (verbose) {
             writer = new EchoWriter(writer);
         }

Modified: pivot/trunk/core/src/org/apache/pivot/serialization/StringSerializer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/serialization/StringSerializer.java?rev=1838770&r1=1838769&r2=1838770&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/serialization/StringSerializer.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/serialization/StringSerializer.java Thu Aug 23 23:50:59 2018
@@ -25,6 +25,7 @@ import java.io.OutputStream;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 
+import org.apache.pivot.util.Constants;
 import org.apache.pivot.util.Utils;
 
 /**
@@ -41,7 +42,6 @@ public class StringSerializer implements
 
     public static final String TEXT_EXTENSION = "txt";
     public static final String MIME_TYPE = "text/plain";
-    public static final int BUFFER_SIZE = 16384;
 
     public StringSerializer() {
         this(StandardCharsets.UTF_8);
@@ -72,10 +72,10 @@ public class StringSerializer implements
         String result = null;
 
         try {
-            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
+            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream, Constants.BUFFER_SIZE);
             ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
 
-            byte[] buffer = new byte[BUFFER_SIZE];
+            byte[] buffer = new byte[Constants.BUFFER_SIZE];
             int read;
             while ((read = bufferedInputStream.read(buffer)) != -1) {
                 byteOutputStream.write(buffer, 0, read);
@@ -105,7 +105,7 @@ public class StringSerializer implements
         Utils.checkNull(outputStream, "outputStream");
 
         try {
-            BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream);
+            BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream, Constants.BUFFER_SIZE);
             bufferedOutputStream.write(text.getBytes(charset));
             bufferedOutputStream.flush();
         } catch (IOException exception) {

Added: pivot/trunk/core/src/org/apache/pivot/util/Constants.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/util/Constants.java?rev=1838770&view=auto
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/util/Constants.java (added)
+++ pivot/trunk/core/src/org/apache/pivot/util/Constants.java Thu Aug 23 23:50:59 2018
@@ -0,0 +1,60 @@
+/*
+ * 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.pivot.util;
+
+/**
+ * A static class that contains constant values used throughout the system.
+ */
+public final class Constants {
+
+    /** Private constructor for a utility class. */
+    private Constants() {
+    }
+
+    /**
+     * The non-default buffer size to use for <tt>BufferedReader</tt> and
+     * and <tt>BufferedWriter</tt>.
+     * <p> This should be larger than the default value (which seems to be
+     * 8192 as of Java 7), or there is no point in using it.
+     */
+    public static final int BUFFER_SIZE = 16_384;
+
+    /**
+     * Standard URL encoding scheme.
+     */
+    public static final String URL_ENCODING = "UTF-8";
+
+    /**
+     * The Byte-Order-Mark that can be used to distinguish the byte ordering
+     * of a UTF-16 stream.
+     * <p> Meant to be ignored if present in a UTF-8 stream (for instance).
+     */
+    public static final int BYTE_ORDER_MARK = 0xFEFF;
+
+    /** The plain-text HTTP protocol identifier. */
+    public static final String HTTP_PROTOCOL = "http";
+    /** The secure HTTP protocol identifier. */
+    public static final String HTTPS_PROTOCOL = "https";
+
+    /** Standard name of the HTTP header for the content type. */
+    public static final String CONTENT_TYPE_HEADER = "Content-Type";
+    /** Standard name of the HTTP header for the content length. */
+    public static final String CONTENT_LENGTH_HEADER = "Content-Length";
+    /** Standard name of the HTTP header for the location. */
+    public static final String LOCATION_HEADER = "Location";
+
+}

Modified: pivot/trunk/core/src/org/apache/pivot/util/Resources.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/util/Resources.java?rev=1838770&r1=1838769&r2=1838770&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/util/Resources.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/util/Resources.java Thu Aug 23 23:50:59 2018
@@ -19,6 +19,7 @@ package org.apache.pivot.util;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.MissingResourceException;
@@ -39,23 +40,23 @@ public class Resources implements Dictio
 
     private Map<String, Object> resourceMap = null;
 
-    public static final String DEFAULT_CHARSET_NAME = "UTF-8";
+    public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
 
     public Resources(final String baseName) throws IOException, SerializationException {
-        this(null, baseName, Locale.getDefault(), Charset.forName(DEFAULT_CHARSET_NAME));
+        this(null, baseName, Locale.getDefault(), DEFAULT_CHARSET);
     }
 
     public Resources(final Resources parent, final String baseName) throws IOException, SerializationException {
-        this(parent, baseName, Locale.getDefault(), Charset.forName(DEFAULT_CHARSET_NAME));
+        this(parent, baseName, Locale.getDefault(), DEFAULT_CHARSET);
     }
 
     public Resources(final String baseName, final Locale locale) throws IOException, SerializationException {
-        this(null, baseName, locale, Charset.forName(DEFAULT_CHARSET_NAME));
+        this(null, baseName, locale, DEFAULT_CHARSET);
     }
 
     public Resources(final Resources parent, final String baseName, final Locale locale) throws IOException,
         SerializationException {
-        this(parent, baseName, locale, Charset.forName(DEFAULT_CHARSET_NAME));
+        this(parent, baseName, locale, DEFAULT_CHARSET);
     }
 
     public Resources(final String baseName, final Charset charset) throws IOException, SerializationException {

Modified: pivot/trunk/core/src/org/apache/pivot/util/Service.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/util/Service.java?rev=1838770&r1=1838769&r2=1838770&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/util/Service.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/util/Service.java Thu Aug 23 23:50:59 2018
@@ -20,6 +20,7 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
 
 /**
  * Utility class for locating and instantiating service providers.
@@ -67,7 +68,7 @@ public final class Service {
                     BufferedReader reader = null;
                     try {
                         reader = new BufferedReader(new InputStreamReader(serviceInputStream,
-                            "UTF-8"));
+                            StandardCharsets.UTF_8));
                         String line = reader.readLine();
                         while (line != null && (line.length() == 0 || line.startsWith("#"))) {
                             line = reader.readLine();

Modified: pivot/trunk/core/src/org/apache/pivot/xml/XMLSerializer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/xml/XMLSerializer.java?rev=1838770&r1=1838769&r2=1838770&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/xml/XMLSerializer.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/xml/XMLSerializer.java Thu Aug 23 23:50:59 2018
@@ -26,6 +26,7 @@ import java.io.OutputStreamWriter;
 import java.io.Reader;
 import java.io.Writer;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLOutputFactory;
@@ -36,6 +37,7 @@ import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.pivot.serialization.SerializationException;
 import org.apache.pivot.serialization.Serializer;
+import org.apache.pivot.util.Constants;
 import org.apache.pivot.util.ListenerList;
 import org.apache.pivot.util.Utils;
 
@@ -49,17 +51,11 @@ public class XMLSerializer implements Se
 
     public static final String XMLNS_ATTRIBUTE_PREFIX = "xmlns";
 
-    public static final String DEFAULT_CHARSET_NAME = "UTF-8";
     public static final String XML_EXTENSION = "xml";
     public static final String MIME_TYPE = "text/xml";
-    /**
-     * Buffer size to use while reading and writing (should be bigger than the default for
-     * BufferedReader or BufferedWriter, which seems to be 8192 as of Java 7).
-     */
-    public static final int BUFFER_SIZE = 16384;
 
     public XMLSerializer() {
-        this(Charset.forName(DEFAULT_CHARSET_NAME));
+        this(StandardCharsets.UTF_8);
     }
 
     public XMLSerializer(final Charset charset) {
@@ -76,7 +72,7 @@ public class XMLSerializer implements Se
     public Element readObject(final InputStream inputStream) throws IOException, SerializationException {
         Utils.checkNull(inputStream, "inputStream");
 
-        Reader reader = new BufferedReader(new InputStreamReader(inputStream, charset), BUFFER_SIZE);
+        Reader reader = new BufferedReader(new InputStreamReader(inputStream, charset), Constants.BUFFER_SIZE);
         Element element = readObject(reader);
 
         return element;
@@ -199,7 +195,7 @@ public class XMLSerializer implements Se
         Utils.checkNull(outputStream, "outputStream");
 
         Writer writer = new BufferedWriter(new OutputStreamWriter(outputStream, charset),
-            BUFFER_SIZE);
+            Constants.BUFFER_SIZE);
         writeObject(element, writer);
         writer.flush();
     }

Modified: pivot/trunk/demos/src/org/apache/pivot/demos/suggest/SuggestionDemo.java
URL: http://svn.apache.org/viewvc/pivot/trunk/demos/src/org/apache/pivot/demos/suggest/SuggestionDemo.java?rev=1838770&r1=1838769&r2=1838770&view=diff
==============================================================================
--- pivot/trunk/demos/src/org/apache/pivot/demos/suggest/SuggestionDemo.java (original)
+++ pivot/trunk/demos/src/org/apache/pivot/demos/suggest/SuggestionDemo.java Thu Aug 23 23:50:59 2018
@@ -28,6 +28,7 @@ import org.apache.pivot.beans.Bindable;
 import org.apache.pivot.collections.List;
 import org.apache.pivot.collections.Map;
 import org.apache.pivot.json.JSON;
+import org.apache.pivot.util.Constants;
 import org.apache.pivot.util.Resources;
 import org.apache.pivot.util.concurrent.Task;
 import org.apache.pivot.util.concurrent.TaskListener;
@@ -84,7 +85,7 @@ public class SuggestionDemo extends Wind
         // Get the query text
         String text;
         try {
-            text = URLEncoder.encode(textInput.getText(), "UTF-8");
+            text = URLEncoder.encode(textInput.getText(), Constants.URL_ENCODING);
         } catch (UnsupportedEncodingException exception) {
             throw new RuntimeException(exception);
         }
@@ -118,7 +119,7 @@ public class SuggestionDemo extends Wind
                                 if (suggestionPopupArgument.getResult()) {
                                     String textLocal;
                                     try {
-                                        textLocal = URLEncoder.encode(textInput.getText(), "UTF-8");
+                                        textLocal = URLEncoder.encode(textInput.getText(), Constants.URL_ENCODING);
                                     } catch (UnsupportedEncodingException exception) {
                                         throw new RuntimeException(exception);
                                     }

Modified: pivot/trunk/web-server/src/org/apache/pivot/web/server/QueryServlet.java
URL: http://svn.apache.org/viewvc/pivot/trunk/web-server/src/org/apache/pivot/web/server/QueryServlet.java?rev=1838770&r1=1838769&r2=1838770&view=diff
==============================================================================
--- pivot/trunk/web-server/src/org/apache/pivot/web/server/QueryServlet.java (original)
+++ pivot/trunk/web-server/src/org/apache/pivot/web/server/QueryServlet.java Thu Aug 23 23:50:59 2018
@@ -36,6 +36,7 @@ import org.apache.pivot.collections.Arra
 import org.apache.pivot.collections.Sequence;
 import org.apache.pivot.serialization.SerializationException;
 import org.apache.pivot.serialization.Serializer;
+import org.apache.pivot.util.Constants;
 import org.apache.pivot.util.ImmutableIterator;
 import org.apache.pivot.web.Query;
 import org.apache.pivot.web.QueryDictionary;
@@ -57,12 +58,12 @@ public abstract class QueryServlet exten
             this(new String[] {});
         }
 
-        public Path(String[] elements) {
+        public Path(final String[] elements) {
             this.elements = new ArrayList<>(elements);
         }
 
         @Override
-        public int add(String element) {
+        public int add(final String element) {
             throw new UnsupportedOperationException();
         }
 
@@ -72,27 +73,27 @@ public abstract class QueryServlet exten
         }
 
         @Override
-        public String update(int index, String element) {
+        public String update(final int index, final String element) {
             throw new UnsupportedOperationException();
         }
 
         @Override
-        public int remove(String element) {
+        public int remove(final String element) {
             throw new UnsupportedOperationException();
         }
 
         @Override
-        public Sequence<String> remove(int index, int count) {
+        public Sequence<String> remove(final int index, final int count) {
             return elements.remove(index, count);
         }
 
         @Override
-        public String get(int index) {
+        public String get(final int index) {
             return elements.get(index);
         }
 
         @Override
-        public int indexOf(String element) {
+        public int indexOf(final String element) {
             return elements.indexOf(element);
         }
 
@@ -133,14 +134,6 @@ public abstract class QueryServlet exten
     private transient ThreadLocal<QueryDictionary> requestHeaders = new ThreadLocal<>();
     private transient ThreadLocal<QueryDictionary> responseHeaders = new ThreadLocal<>();
 
-    public static final String HTTP_PROTOCOL = "http";
-    public static final String HTTPS_PROTOCOL = "https";
-    public static final String URL_ENCODING = "UTF-8";
-
-    public static final String CONTENT_TYPE_HEADER = "Content-Type";
-    public static final String CONTENT_LENGTH_HEADER = "Content-Length";
-    public static final String LOCATION_HEADER = "Location";
-
     /**
      * Gets the host name that was requested.
      * @return The host name from the request.
@@ -189,7 +182,7 @@ public abstract class QueryServlet exten
      * on the {@link #isSecure} setting.
      */
     public String getProtocol() {
-        return isSecure() ? HTTPS_PROTOCOL : HTTP_PROTOCOL;
+        return isSecure() ? Constants.HTTPS_PROTOCOL : Constants.HTTP_PROTOCOL;
     }
 
     /**
@@ -199,7 +192,7 @@ public abstract class QueryServlet exten
     public URL getLocation() {
         URL location;
         try {
-            location = new URL(isSecure() ? HTTPS_PROTOCOL : HTTP_PROTOCOL, getHostname(),
+            location = new URL(isSecure() ? Constants.HTTPS_PROTOCOL : Constants.HTTP_PROTOCOL, getHostname(),
                 getPort(), getContextPath() + getServletPath() + "/");
         } catch (MalformedURLException exception) {
             throw new RuntimeException(exception);
@@ -266,7 +259,7 @@ public abstract class QueryServlet exten
      * @param path The path to the server resources.
      * @throws QueryException if there is a problem, Houston.
      */
-    protected void validate(Query.Method method, Path path) throws QueryException {
+    protected void validate(final Query.Method method, final Path path) throws QueryException {
         // No-op
     }
 
@@ -278,7 +271,7 @@ public abstract class QueryServlet exten
      * @return The result of the GET.
      * @throws QueryException on any error.
      */
-    protected Object doGet(Path path) throws QueryException {
+    protected Object doGet(final Path path) throws QueryException {
         throw new QueryException(Query.Status.METHOD_NOT_ALLOWED);
     }
 
@@ -292,7 +285,7 @@ public abstract class QueryServlet exten
      * <tt>null</tt> if operation did not result in the creation of a resource.
      * @throws QueryException on errors.
      */
-    protected URL doPost(Path path, Object value) throws QueryException {
+    protected URL doPost(final Path path, final Object value) throws QueryException {
         throw new QueryException(Query.Status.METHOD_NOT_ALLOWED);
     }
 
@@ -306,7 +299,7 @@ public abstract class QueryServlet exten
      * resource; <tt>false</tt>, otherwise.
      * @throws QueryException on any error.
      */
-    protected boolean doPut(Path path, Object value) throws QueryException {
+    protected boolean doPut(final Path path, final Object value) throws QueryException {
         throw new QueryException(Query.Status.METHOD_NOT_ALLOWED);
     }
 
@@ -317,7 +310,7 @@ public abstract class QueryServlet exten
      * @param path The server path for this request.
      * @throws QueryException if there was a problem.
      */
-    protected void doDelete(Path path) throws QueryException {
+    protected void doDelete(final Path path) throws QueryException {
         throw new QueryException(Query.Status.METHOD_NOT_ALLOWED);
     }
 
@@ -334,7 +327,7 @@ public abstract class QueryServlet exten
         throws QueryException;
 
     @Override
-    protected void service(HttpServletRequest request, HttpServletResponse response)
+    protected void service(final HttpServletRequest request, final HttpServletResponse response)
         throws IOException, ServletException {
         try {
             try {
@@ -343,7 +336,7 @@ public abstract class QueryServlet exten
                 port.set(Integer.valueOf(request.getLocalPort()));
                 contextPath.set(request.getContextPath());
                 servletPath.set(request.getServletPath());
-                secure.set(Boolean.valueOf(url.getProtocol().equalsIgnoreCase(HTTPS_PROTOCOL)));
+                secure.set(Boolean.valueOf(url.getProtocol().equalsIgnoreCase(Constants.HTTPS_PROTOCOL)));
             } catch (MalformedURLException exception) {
                 throw new ServletException(exception);
             }
@@ -361,8 +354,8 @@ public abstract class QueryServlet exten
                 for (int i = 0, n = pairs.length; i < n; i++) {
                     String[] pair = pairs[i].split("=");
 
-                    String key = URLDecoder.decode(pair[0], URL_ENCODING);
-                    String value = URLDecoder.decode((pair.length > 1) ? pair[1] : "", URL_ENCODING);
+                    String key = URLDecoder.decode(pair[0], Constants.URL_ENCODING);
+                    String value = URLDecoder.decode((pair.length > 1) ? pair[1] : "", Constants.URL_ENCODING);
 
                     parametersDictionary.add(key, value);
                 }
@@ -408,7 +401,7 @@ public abstract class QueryServlet exten
 
     @Override
     @SuppressWarnings("unchecked")
-    protected final void doGet(HttpServletRequest request, HttpServletResponse response)
+    protected final void doGet(final HttpServletRequest request, final HttpServletResponse response)
         throws IOException, ServletException {
         Path path = getPath(request);
 
@@ -443,7 +436,7 @@ public abstract class QueryServlet exten
                 }
 
                 // Set the content length header
-                response.setHeader(CONTENT_LENGTH_HEADER, String.valueOf(tempFile.length()));
+                response.setHeader(Constants.CONTENT_LENGTH_HEADER, String.valueOf(tempFile.length()));
 
                 // Write the contents of the file out to the response
                 try (FileInputStream fileInputStream = new FileInputStream(tempFile)) {
@@ -469,7 +462,7 @@ public abstract class QueryServlet exten
     }
 
     @Override
-    protected final void doPost(HttpServletRequest request, HttpServletResponse response)
+    protected final void doPost(final HttpServletRequest request, final HttpServletResponse response)
         throws IOException, ServletException {
         Path path = getPath(request);
 
@@ -496,7 +489,7 @@ public abstract class QueryServlet exten
                 response.setStatus(Query.Status.NO_CONTENT);
             } else {
                 response.setStatus(Query.Status.CREATED);
-                response.setHeader(LOCATION_HEADER, location.toString());
+                response.setHeader(Constants.LOCATION_HEADER, location.toString());
             }
 
             setResponseHeaders(response);
@@ -505,7 +498,7 @@ public abstract class QueryServlet exten
     }
 
     @Override
-    protected final void doPut(HttpServletRequest request, HttpServletResponse response)
+    protected final void doPut(final HttpServletRequest request, final HttpServletResponse response)
         throws IOException, ServletException {
         Path path = getPath(request);
 
@@ -536,7 +529,7 @@ public abstract class QueryServlet exten
     }
 
     @Override
-    protected final void doDelete(HttpServletRequest request, HttpServletResponse response)
+    protected final void doDelete(final HttpServletRequest request, final HttpServletResponse response)
         throws IOException, ServletException {
         try {
             Path path = getPath(request);
@@ -556,27 +549,27 @@ public abstract class QueryServlet exten
     }
 
     @Override
-    protected final void doHead(HttpServletRequest request, HttpServletResponse response)
+    protected final void doHead(final HttpServletRequest request, final HttpServletResponse response)
         throws IOException, ServletException {
         response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
         response.flushBuffer();
     }
 
     @Override
-    protected final void doOptions(HttpServletRequest request, HttpServletResponse response)
+    protected final void doOptions(final HttpServletRequest request, final HttpServletResponse response)
         throws IOException, ServletException {
         response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
         response.flushBuffer();
     }
 
     @Override
-    protected final void doTrace(HttpServletRequest request, HttpServletResponse response)
+    protected final void doTrace(final HttpServletRequest request, final HttpServletResponse response)
         throws IOException, ServletException {
         response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
         response.flushBuffer();
     }
 
-    private static Path getPath(HttpServletRequest request) {
+    private static Path getPath(final HttpServletRequest request) {
         String pathInfo = request.getPathInfo();
         Path path;
         if (pathInfo == null || pathInfo.length() == 0) {
@@ -588,7 +581,7 @@ public abstract class QueryServlet exten
         return path;
     }
 
-    private void setResponseHeaders(HttpServletResponse response) {
+    private void setResponseHeaders(final HttpServletResponse response) {
         QueryDictionary responseHeaderDictionary = responseHeaders.get();
 
         for (String key : responseHeaderDictionary) {

Modified: pivot/trunk/web/src/org/apache/pivot/web/Query.java
URL: http://svn.apache.org/viewvc/pivot/trunk/web/src/org/apache/pivot/web/Query.java?rev=1838770&r1=1838769&r2=1838770&view=diff
==============================================================================
--- pivot/trunk/web/src/org/apache/pivot/web/Query.java (original)
+++ pivot/trunk/web/src/org/apache/pivot/web/Query.java Thu Aug 23 23:50:59 2018
@@ -34,6 +34,7 @@ import org.apache.pivot.io.IOTask;
 import org.apache.pivot.json.JSONSerializer;
 import org.apache.pivot.serialization.SerializationException;
 import org.apache.pivot.serialization.Serializer;
+import org.apache.pivot.util.Constants;
 import org.apache.pivot.util.ListenerList;
 import org.apache.pivot.util.Utils;
 
@@ -98,10 +99,6 @@ public abstract class Query<V> extends I
 
     public static final int DEFAULT_PORT = -1;
 
-    private static final String HTTP_PROTOCOL = "http";
-    private static final String HTTPS_PROTOCOL = "https";
-    private static final String URL_ENCODING = "UTF-8";
-
     static {
         try {
             // See http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html
@@ -122,11 +119,13 @@ public abstract class Query<V> extends I
      * @param executorService The executor to use for running the query (in the background).
      * @throws IllegalArgumentException if the {@code URL} cannot be constructed.
      */
-    public Query(String hostname, int port, String path, boolean secure, ExecutorService executorService) {
+    public Query(final String hostname, final int port, final String path, final boolean secure,
+        final ExecutorService executorService) {
         super(executorService);
 
         try {
-            locationContext = new URL(secure ? HTTPS_PROTOCOL : HTTP_PROTOCOL, hostname, port, path);
+            locationContext =
+                new URL(secure ? Constants.HTTPS_PROTOCOL : Constants.HTTP_PROTOCOL, hostname, port, path);
         } catch (MalformedURLException exception) {
             throw new IllegalArgumentException("Unable to construct context URL.", exception);
         }
@@ -148,14 +147,14 @@ public abstract class Query<V> extends I
 
     public boolean isSecure() {
         String protocol = locationContext.getProtocol();
-        return protocol.equalsIgnoreCase(HTTPS_PROTOCOL);
+        return protocol.equalsIgnoreCase(Constants.HTTPS_PROTOCOL);
     }
 
     public HostnameVerifier getHostnameVerifier() {
         return hostnameVerifier;
     }
 
-    public void setHostnameVerifier(HostnameVerifier hostnameVerifier) {
+    public void setHostnameVerifier(final HostnameVerifier hostnameVerifier) {
         this.hostnameVerifier = hostnameVerifier;
     }
 
@@ -175,7 +174,7 @@ public abstract class Query<V> extends I
      * @param proxy This query's proxy, or <tt>null</tt> to use the default JVM
      * proxy settings
      */
-    public void setProxy(Proxy proxy) {
+    public void setProxy(final Proxy proxy) {
         this.proxy = proxy;
     }
 
@@ -189,8 +188,8 @@ public abstract class Query<V> extends I
                         queryStringBuilder.append("&");
                     }
 
-                    queryStringBuilder.append(URLEncoder.encode(key, URL_ENCODING) + "="
-                        + URLEncoder.encode(parameters.get(key, index), URL_ENCODING));
+                    queryStringBuilder.append(URLEncoder.encode(key, Constants.URL_ENCODING) + "="
+                        + URLEncoder.encode(parameters.get(key, index), Constants.URL_ENCODING));
                 } catch (UnsupportedEncodingException exception) {
                     throw new IllegalStateException("Unable to construct query string.", exception);
                 }
@@ -263,7 +262,7 @@ public abstract class Query<V> extends I
      * @param serializer The serializer (must be non-null).
      * @throws IllegalArgumentException if the input is {@code null}.
      */
-    public void setSerializer(Serializer<?> serializer) {
+    public void setSerializer(final Serializer<?> serializer) {
         Utils.checkNull(serializer, "serializer");
 
         this.serializer = serializer;
@@ -353,7 +352,7 @@ public abstract class Query<V> extends I
 
             // Set the request headers
             if (result != null) {
-                connection.setRequestProperty("Content-Type", serializerLocal.getMIMEType(result));
+                connection.setRequestProperty(Constants.CONTENT_TYPE_HEADER, serializerLocal.getMIMEType(result));
             }
 
             for (String key : requestHeaders) {

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/BrowserApplicationContext.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/BrowserApplicationContext.java?rev=1838770&r1=1838769&r2=1838770&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/BrowserApplicationContext.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/BrowserApplicationContext.java Thu Aug 23 23:50:59 2018
@@ -30,6 +30,7 @@ import netscape.javascript.JSObject;
 import org.apache.pivot.collections.ArrayList;
 import org.apache.pivot.collections.HashMap;
 import org.apache.pivot.collections.immutable.ImmutableMap;
+import org.apache.pivot.util.Constants;
 import org.apache.pivot.util.Utils;
 
 /**
@@ -104,7 +105,7 @@ public final class BrowserApplicationCon
                             String key = property[0].trim();
                             String value;
                             try {
-                                value = URLDecoder.decode(property[1].trim(), "UTF-8");
+                                value = URLDecoder.decode(property[1].trim(), Constants.URL_ENCODING);
                             } catch (UnsupportedEncodingException exception) {
                                 throw new RuntimeException(exception);
                             }
@@ -148,7 +149,7 @@ public final class BrowserApplicationCon
                                 } else {
                                     String value;
                                     try {
-                                        value = URLDecoder.decode(propertyValue, "UTF-8");
+                                        value = URLDecoder.decode(propertyValue, Constants.URL_ENCODING);
                                     } catch (UnsupportedEncodingException exception) {
                                         throw new RuntimeException(exception);
                                     }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/text/PlainTextSerializer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/PlainTextSerializer.java?rev=1838770&r1=1838769&r2=1838770&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/text/PlainTextSerializer.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/text/PlainTextSerializer.java Thu Aug 23 23:50:59 2018
@@ -28,6 +28,7 @@ import java.io.Writer;
 import java.nio.charset.Charset;
 
 import org.apache.pivot.serialization.Serializer;
+import org.apache.pivot.util.Constants;
 import org.apache.pivot.util.Utils;
 
 /**
@@ -38,12 +39,11 @@ public class PlainTextSerializer impleme
     private Charset charset = null;
 
     public static final String MIME_TYPE = "text/plain";
-    public static final int BUFFER_SIZE = 16_384;
 
     private boolean expandTabs = false;
     private int tabWidth = 4;
 
-    private int bufferSize = BUFFER_SIZE;
+    private int bufferSize = Constants.BUFFER_SIZE;
 
 
     public PlainTextSerializer() {
@@ -92,7 +92,7 @@ public class PlainTextSerializer impleme
 
     /**
      * Sets the buffer size used internally for reading and writing.  The
-     * default value is {@link #BUFFER_SIZE}.  A value of <tt>0</tt> will
+     * default value is {@link Constants#BUFFER_SIZE}.  A value of <tt>0</tt> will
      * use the default value in the {@link BufferedReader} and {@link BufferedWriter}
      * classes (probably 8192).
      *