From 57be9e3ee38bce74612f142a718addecfc909949 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Sun, 2 Oct 2011 18:16:18 -0700 Subject: [PATCH] Make sets immutable Use final and unmodifiable and avoid anonymous inner classes. --- src/com/fsck/k9/helper/HtmlConverter.java | 17 +++++++-------- src/com/fsck/k9/mail/store/LocalStore.java | 24 +++++++++++++--------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/com/fsck/k9/helper/HtmlConverter.java b/src/com/fsck/k9/helper/HtmlConverter.java index fefa22d2c..80da74c04 100644 --- a/src/com/fsck/k9/helper/HtmlConverter.java +++ b/src/com/fsck/k9/helper/HtmlConverter.java @@ -52,14 +52,15 @@ public class HtmlConverter { */ private static class HtmlToTextTagHandler implements Html.TagHandler { // List of tags whose content should be ignored. - private static final Set TAGS_WITH_IGNORED_CONTENT = Collections.unmodifiableSet(new HashSet() { - { - add("style"); - add("script"); - add("title"); - add("!"); // comments - } - }); + private static final Set TAGS_WITH_IGNORED_CONTENT; + static { + Set set = new HashSet(); + set.add("style"); + set.add("script"); + set.add("title"); + set.add("!"); // comments + TAGS_WITH_IGNORED_CONTENT = Collections.unmodifiableSet(set); + } @Override public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) { diff --git a/src/com/fsck/k9/mail/store/LocalStore.java b/src/com/fsck/k9/mail/store/LocalStore.java index ffb2f8abf..38300b2ff 100644 --- a/src/com/fsck/k9/mail/store/LocalStore.java +++ b/src/com/fsck/k9/mail/store/LocalStore.java @@ -5,6 +5,7 @@ import java.io.*; import java.net.URLEncoder; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; @@ -78,18 +79,21 @@ public class LocalStore extends Store implements Serializable { private static final Flag[] PERMANENT_FLAGS = { Flag.DELETED, Flag.X_DESTROYED, Flag.SEEN, Flag.FLAGGED }; - private static Set HEADERS_TO_SAVE = new HashSet(); + private static final Set HEADERS_TO_SAVE; static { - HEADERS_TO_SAVE.add(K9.IDENTITY_HEADER); - HEADERS_TO_SAVE.add("To"); - HEADERS_TO_SAVE.add("Cc"); - HEADERS_TO_SAVE.add("From"); - HEADERS_TO_SAVE.add("In-Reply-To"); - HEADERS_TO_SAVE.add("References"); - HEADERS_TO_SAVE.add("Content-ID"); - HEADERS_TO_SAVE.add("Content-Disposition"); - HEADERS_TO_SAVE.add("User-Agent"); + Set set = new HashSet(); + set.add(K9.IDENTITY_HEADER); + set.add("To"); + set.add("Cc"); + set.add("From"); + set.add("In-Reply-To"); + set.add("References"); + set.add("Content-ID"); + set.add("Content-Disposition"); + set.add("User-Agent"); + HEADERS_TO_SAVE = Collections.unmodifiableSet(set); } + /* * a String containing the columns getMessages expects to work with * in the correct order.