Author: sback
Date: 2007-06-27 09:55:40 +0000 (Wed, 27 Jun 2007)
New Revision: 13774
Modified:
trunk/freenet/src/freenet/support/SimpleFieldSet.java
Log:
Some code duplication avoided and readability improved
Modified: trunk/freenet/src/freenet/support/SimpleFieldSet.java
===================================================================
--- trunk/freenet/src/freenet/support/SimpleFieldSet.java 2007-06-27
01:06:03 UTC (rev 13773)
+++ trunk/freenet/src/freenet/support/SimpleFieldSet.java 2007-06-27
09:55:40 UTC (rev 13774)
@@ -35,6 +35,18 @@
static public final char MULTI_LEVEL_CHAR = '.';
/**
+ * Create a SimpleFieldSet.
+ * @param shortLived If false, strings will be interned to ensure that
they use as
+ * little memory as possible. Only set to true if the SFS will be
short-lived or
+ * small.
+ */
+ public SimpleFieldSet(boolean shortLived) {
+ values = new HashMap();
+ subsets = null;
+ this.shortLived = shortLived;
+ }
+
+ /**
* Construct a SimpleFieldSet from reading a BufferedReader.
* @param br
* @param allowMultiple If true, multiple lines with the same field name
will be
@@ -46,9 +58,7 @@
* problem.
*/
public SimpleFieldSet(BufferedReader br, boolean allowMultiple, boolean
shortLived) throws IOException {
- values = new HashMap();
- subsets = null;
- this.shortLived = shortLived;
+ this(shortLived);
read(br, allowMultiple);
}
@@ -61,23 +71,9 @@
}
public SimpleFieldSet(LineReader lis, int maxLineLength, int
lineBufferSize, boolean tolerant, boolean utf8OrIso88591, boolean
allowMultiple, boolean shortLived) throws IOException {
- values = new HashMap();
- subsets = null;
- this.shortLived = shortLived;
+ this(shortLived);
read(lis, maxLineLength, lineBufferSize, tolerant, utf8OrIso88591,
allowMultiple);
}
-
- /**
- * Create a SimpleFieldSet.
- * @param shortLived If false, strings will be interned to ensure that
they use as
- * little memory as possible. Only set to true if the SFS will be
short-lived or
- * small.
- */
- public SimpleFieldSet(boolean shortLived) {
- values = new HashMap();
- subsets = null;
- this.shortLived = shortLived;
- }
/**
* Construct from a string.
@@ -87,9 +83,7 @@
* @throws IOException if the string is too short or invalid.
*/
public SimpleFieldSet(String content, boolean allowMultiple, boolean
shortLived) throws IOException {
- values = new HashMap();
- subsets = null;
- this.shortLived = shortLived;
+ this(shortLived);
StringReader sr = new StringReader(content);
BufferedReader br = new BufferedReader(sr);
read(br, allowMultiple);