1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

Make sets immutable

Use final and unmodifiable and avoid anonymous inner classes.
This commit is contained in:
Andrew Gaul 2011-10-02 18:16:18 -07:00 committed by Andrew Gaul
parent 2e2428b093
commit 57be9e3ee3
2 changed files with 23 additions and 18 deletions

View File

@ -52,14 +52,15 @@ public class HtmlConverter {
*/ */
private static class HtmlToTextTagHandler implements Html.TagHandler { private static class HtmlToTextTagHandler implements Html.TagHandler {
// List of tags whose content should be ignored. // List of tags whose content should be ignored.
private static final Set<String> TAGS_WITH_IGNORED_CONTENT = Collections.unmodifiableSet(new HashSet<String>() { private static final Set<String> TAGS_WITH_IGNORED_CONTENT;
{ static {
add("style"); Set<String> set = new HashSet<String>();
add("script"); set.add("style");
add("title"); set.add("script");
add("!"); // comments set.add("title");
} set.add("!"); // comments
}); TAGS_WITH_IGNORED_CONTENT = Collections.unmodifiableSet(set);
}
@Override @Override
public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) { public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) {

View File

@ -5,6 +5,7 @@ import java.io.*;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; 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 final Flag[] PERMANENT_FLAGS = { Flag.DELETED, Flag.X_DESTROYED, Flag.SEEN, Flag.FLAGGED };
private static Set<String> HEADERS_TO_SAVE = new HashSet<String>(); private static final Set<String> HEADERS_TO_SAVE;
static { static {
HEADERS_TO_SAVE.add(K9.IDENTITY_HEADER); Set<String> set = new HashSet();
HEADERS_TO_SAVE.add("To"); set.add(K9.IDENTITY_HEADER);
HEADERS_TO_SAVE.add("Cc"); set.add("To");
HEADERS_TO_SAVE.add("From"); set.add("Cc");
HEADERS_TO_SAVE.add("In-Reply-To"); set.add("From");
HEADERS_TO_SAVE.add("References"); set.add("In-Reply-To");
HEADERS_TO_SAVE.add("Content-ID"); set.add("References");
HEADERS_TO_SAVE.add("Content-Disposition"); set.add("Content-ID");
HEADERS_TO_SAVE.add("User-Agent"); set.add("Content-Disposition");
set.add("User-Agent");
HEADERS_TO_SAVE = Collections.unmodifiableSet(set);
} }
/* /*
* a String containing the columns getMessages expects to work with * a String containing the columns getMessages expects to work with
* in the correct order. * in the correct order.