diff src/org/eclipse/jetty/http/HttpFields.java @ 1019:f126d30e04a4

start replacing BufferCache with StringCache
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 31 Oct 2016 03:33:42 -0600
parents fa6158f29c45
children 6be43ef1eb96
line wrap: on
line diff
--- a/src/org/eclipse/jetty/http/HttpFields.java	Mon Oct 24 05:37:24 2016 -0600
+++ b/src/org/eclipse/jetty/http/HttpFields.java	Mon Oct 31 03:33:42 2016 -0600
@@ -59,22 +59,19 @@
  * 
  * 
  */
-public class HttpFields
+public final class HttpFields
 {
 	private static final Logger LOG = LoggerFactory.getLogger(HttpFields.class);
 	
-	/* ------------------------------------------------------------ */
-	public static final String __COOKIE_DELIM="\"\\\n\r\t\f\b%+ ;=";
-	public static final TimeZone __GMT = TimeZone.getTimeZone("GMT");
+	private static final String __COOKIE_DELIM="\"\\\n\r\t\f\b%+ ;=";
+	private static final TimeZone __GMT = TimeZone.getTimeZone("GMT");
 	
-	/* ------------------------------------------------------------ */
 	private static final String[] DAYS =
 	{ "Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
 	private static final String[] MONTHS =
 	{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Jan"};
 
 	
-	/* ------------------------------------------------------------ */
 	private static class DateGenerator
 	{
 		private final StringBuilder buf = new StringBuilder(32);
@@ -161,8 +158,7 @@
 		}
 	}
 
-	/* ------------------------------------------------------------ */
-	private static final ThreadLocal<DateGenerator> __dateGenerator =new ThreadLocal<DateGenerator>()
+	private static final ThreadLocal<DateGenerator> __dateGenerator = new ThreadLocal<DateGenerator>()
 	{
 		@Override
 		protected DateGenerator initialValue()
@@ -175,7 +171,7 @@
 	/**
 	 * Format HTTP date "EEE, dd MMM yyyy HH:mm:ss 'GMT'" 
 	 */
-	public static String formatDate(long date)
+	private static String formatDate(long date)
 	{
 		return __dateGenerator.get().formatDate(date);
 	}
@@ -184,7 +180,7 @@
 	/**
 	 * Format "EEE, dd-MMM-yyyy HH:mm:ss 'GMT'" for cookies
 	 */
-	public static void formatCookieDate(StringBuilder buf, long date)
+	private static void formatCookieDate(StringBuilder buf, long date)
 	{
 		__dateGenerator.get().formatCookieDate(buf,date);
 	}
@@ -193,14 +189,13 @@
 	/**
 	 * Format "EEE, dd-MMM-yyyy HH:mm:ss 'GMT'" for cookies
 	 */
-	public static String formatCookieDate(long date)
+	private static String formatCookieDate(long date)
 	{
 		StringBuilder buf = new StringBuilder(28);
 		formatCookieDate(buf, date);
 		return buf.toString();
 	}
 
-	/* ------------------------------------------------------------ */
 	private final static String __dateReceiveFmt[] =
 	{   
 		"EEE, dd MMM yyyy HH:mm:ss zzz", 
@@ -216,10 +211,9 @@
 		"EEE dd-MMM-yy HH:mm:ss zzz", "EEE dd-MMM-yy HH:mm:ss",
 	};
 
-	/* ------------------------------------------------------------ */
 	private static class DateParser
 	{
-		final SimpleDateFormat _dateReceive[]= new SimpleDateFormat[__dateReceiveFmt.length];
+		final SimpleDateFormat _dateReceive[] = new SimpleDateFormat[__dateReceiveFmt.length];
  
 		long parse(final String dateVal)
 		{
@@ -263,13 +257,6 @@
 		}
 	}
 
-	/* ------------------------------------------------------------ */
-	public static long parseDate(String date)
-	{
-		return __dateParser.get().parse(date);
-	}
-
-	/* ------------------------------------------------------------ */
 	private static final ThreadLocal<DateParser> __dateParser =new ThreadLocal<DateParser>()
 	{
 		@Override
@@ -279,12 +266,15 @@
 		}
 	};
 
-	/* -------------------------------------------------------------- */
-	public final static String __01Jan1970=formatDate(0);
-	public final static Buffer __01Jan1970_BUFFER=new ByteArrayBuffer(__01Jan1970);
-	public final static String __01Jan1970_COOKIE = formatCookieDate(0).trim();
+	private final static String __01Jan1970 = formatDate(0);
+	private final static Buffer __01Jan1970_BUFFER = new ByteArrayBuffer(__01Jan1970);
+	private final static String __01Jan1970_COOKIE = formatCookieDate(0).trim();
+
 
-	/* -------------------------------------------------------------- */
+
+
+
+
 	private final ArrayList<Field> _fields = new ArrayList<Field>(20);
 	private final HashMap<Buffer,Field> _names = new HashMap<Buffer,Field>(32);
 	
@@ -336,12 +326,12 @@
 	{
 		final List<String> list = new ArrayList<String>(_fields.size());
 
-	for (Field f : _fields)
-	{
-		if (f!=null)
-			list.add(BufferUtil.to8859_1_String(f._name));
-	}
-	return list;
+		for (Field f : _fields)
+		{
+			if (f!=null)
+				list.add(BufferUtil.to8859_1_String(f._name));
+		}
+		return list;
 	}
 	
 	/* -------------------------------------------------------------- */