1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-23 16:18:50 -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 {
// List of tags whose content should be ignored.
private static final Set<String> TAGS_WITH_IGNORED_CONTENT = Collections.unmodifiableSet(new HashSet<String>() {
{
add("style");
add("script");
add("title");
add("!"); // comments
}
});
private static final Set<String> TAGS_WITH_IGNORED_CONTENT;
static {
Set<String> set = new HashSet<String>();
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) {

View File

@ -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<String> HEADERS_TO_SAVE = new HashSet<String>();
private static final Set<String> 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<String> 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.