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

Merge branch 'legacy-collections' of https://github.com/andrewgaul/k-9 into andrewgaul

* 'legacy-collections' of https://github.com/andrewgaul/k-9:
  Prefer unsynchronized Collection types
This commit is contained in:
Andrew Chen 2011-11-01 13:26:54 -07:00
commit ea05f3b5d0
4 changed files with 30 additions and 27 deletions

View File

@ -1,9 +1,10 @@
package com.fsck.k9.activity.setup; package com.fsck.k9.activity.setup;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Vector; import java.util.List;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -134,8 +135,8 @@ public class Prefs extends K9PreferenceActivity {
addPreferencesFromResource(R.xml.global_preferences); addPreferencesFromResource(R.xml.global_preferences);
mLanguage = (ListPreference) findPreference(PREFERENCE_LANGUAGE); mLanguage = (ListPreference) findPreference(PREFERENCE_LANGUAGE);
Vector<CharSequence> entryVector = new Vector<CharSequence>(Arrays.asList(mLanguage.getEntries())); List<CharSequence> entryVector = new ArrayList<CharSequence>(Arrays.asList(mLanguage.getEntries()));
Vector<CharSequence> entryValueVector = new Vector<CharSequence>(Arrays.asList(mLanguage.getEntryValues())); List<CharSequence> entryValueVector = new ArrayList<CharSequence>(Arrays.asList(mLanguage.getEntryValues()));
String supportedLanguages[] = getResources().getStringArray(R.array.supported_languages); String supportedLanguages[] = getResources().getStringArray(R.array.supported_languages);
HashSet<String> supportedLanguageSet = new HashSet<String>(Arrays.asList(supportedLanguages)); HashSet<String> supportedLanguageSet = new HashSet<String>(Arrays.asList(supportedLanguages));
for (int i = entryVector.size() - 1; i > -1; --i) { for (int i = entryVector.size() - 1; i > -1; --i) {

View File

@ -1,6 +1,7 @@
package com.fsck.k9.crypto; package com.fsck.k9.crypto;
import java.util.Vector; import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -149,7 +150,7 @@ public class Apg extends CryptoProvider {
intent.putExtra(EXTRA_INTENT_VERSION, INTENT_VERSION); intent.putExtra(EXTRA_INTENT_VERSION, INTENT_VERSION);
long[] initialKeyIds = null; long[] initialKeyIds = null;
if (!pgpData.hasEncryptionKeys()) { if (!pgpData.hasEncryptionKeys()) {
Vector<Long> keyIds = new Vector<Long>(); List<Long> keyIds = new ArrayList<Long>();
if (pgpData.hasSignatureKey()) { if (pgpData.hasSignatureKey()) {
keyIds.add(pgpData.getSignatureKeyId()); keyIds.add(pgpData.getSignatureKeyId());
} }

View File

@ -422,13 +422,13 @@ public class MimeMessage extends Message {
} }
class MimeMessageBuilder implements ContentHandler { class MimeMessageBuilder implements ContentHandler {
private Stack<Object> stack = new Stack<Object>(); private final Deque<Object> stack = new ArrayDeque<Object>();
public MimeMessageBuilder() { public MimeMessageBuilder() {
} }
private void expect(Class<?> c) { private void expect(Class<?> c) {
if (!c.isInstance(stack.peek())) { if (!c.isInstance(stack.peekFirst())) {
throw new IllegalStateException("Internal stack error: " + "Expected '" throw new IllegalStateException("Internal stack error: " + "Expected '"
+ c.getName() + "' found '" + stack.peek().getClass().getName() + "'"); + c.getName() + "' found '" + stack.peek().getClass().getName() + "'");
} }
@ -436,13 +436,13 @@ public class MimeMessage extends Message {
public void startMessage() { public void startMessage() {
if (stack.isEmpty()) { if (stack.isEmpty()) {
stack.push(MimeMessage.this); stack.addFirst(MimeMessage.this);
} else { } else {
expect(Part.class); expect(Part.class);
try { try {
MimeMessage m = new MimeMessage(); MimeMessage m = new MimeMessage();
((Part)stack.peek()).setBody(m); ((Part)stack.peekFirst()).setBody(m);
stack.push(m); stack.addFirst(m);
} catch (MessagingException me) { } catch (MessagingException me) {
throw new Error(me); throw new Error(me);
} }
@ -451,7 +451,7 @@ public class MimeMessage extends Message {
public void endMessage() { public void endMessage() {
expect(MimeMessage.class); expect(MimeMessage.class);
stack.pop(); stack.removeFirst();
} }
public void startHeader() { public void startHeader() {
@ -462,7 +462,7 @@ public class MimeMessage extends Message {
expect(Part.class); expect(Part.class);
try { try {
Field parsedField = DefaultFieldParser.parse(field.getRaw(), null); Field parsedField = DefaultFieldParser.parse(field.getRaw(), null);
((Part)stack.peek()).addHeader(parsedField.getName(), parsedField.getBody().trim()); ((Part)stack.peekFirst()).addHeader(parsedField.getName(), parsedField.getBody().trim());
} catch (MessagingException me) { } catch (MessagingException me) {
throw new Error(me); throw new Error(me);
} catch (MimeException me) { } catch (MimeException me) {
@ -474,7 +474,7 @@ public class MimeMessage extends Message {
expect(Part.class); expect(Part.class);
try { try {
String[] tokens = fieldData.split(":", 2); String[] tokens = fieldData.split(":", 2);
((Part)stack.peek()).addHeader(tokens[0], tokens[1].trim()); ((Part)stack.peekFirst()).addHeader(tokens[0], tokens[1].trim());
} catch (MessagingException me) { } catch (MessagingException me) {
throw new Error(me); throw new Error(me);
} }
@ -487,11 +487,11 @@ public class MimeMessage extends Message {
public void startMultipart(BodyDescriptor bd) { public void startMultipart(BodyDescriptor bd) {
expect(Part.class); expect(Part.class);
Part e = (Part)stack.peek(); Part e = (Part)stack.peekFirst();
try { try {
MimeMultipart multiPart = new MimeMultipart(e.getContentType()); MimeMultipart multiPart = new MimeMultipart(e.getContentType());
e.setBody(multiPart); e.setBody(multiPart);
stack.push(multiPart); stack.addFirst(multiPart);
} catch (MessagingException me) { } catch (MessagingException me) {
throw new Error(me); throw new Error(me);
} }
@ -501,14 +501,14 @@ public class MimeMessage extends Message {
expect(Part.class); expect(Part.class);
Body body = MimeUtility.decodeBody(in, bd.getTransferEncoding()); Body body = MimeUtility.decodeBody(in, bd.getTransferEncoding());
try { try {
((Part)stack.peek()).setBody(body); ((Part)stack.peekFirst()).setBody(body);
} catch (MessagingException me) { } catch (MessagingException me) {
throw new Error(me); throw new Error(me);
} }
} }
public void endMultipart() { public void endMultipart() {
stack.pop(); stack.removeFirst();
} }
public void startBodyPart() { public void startBodyPart() {
@ -516,8 +516,8 @@ public class MimeMessage extends Message {
try { try {
MimeBodyPart bodyPart = new MimeBodyPart(); MimeBodyPart bodyPart = new MimeBodyPart();
((MimeMultipart)stack.peek()).addBodyPart(bodyPart); ((MimeMultipart)stack.peekFirst()).addBodyPart(bodyPart);
stack.push(bodyPart); stack.addFirst(bodyPart);
} catch (MessagingException me) { } catch (MessagingException me) {
throw new Error(me); throw new Error(me);
} }
@ -525,7 +525,7 @@ public class MimeMessage extends Message {
public void endBodyPart() { public void endBodyPart() {
expect(BodyPart.class); expect(BodyPart.class);
stack.pop(); stack.removeFirst();
} }
public void epilogue(InputStream is) throws IOException { public void epilogue(InputStream is) throws IOException {
@ -535,7 +535,7 @@ public class MimeMessage extends Message {
while ((b = is.read()) != -1) { while ((b = is.read()) != -1) {
sb.append((char)b); sb.append((char)b);
} }
// ((Multipart) stack.peek()).setEpilogue(sb.toString()); // ((Multipart) stack.peekFirst()).setEpilogue(sb.toString());
} }
public void preamble(InputStream is) throws IOException { public void preamble(InputStream is) throws IOException {
@ -545,7 +545,7 @@ public class MimeMessage extends Message {
while ((b = is.read()) != -1) { while ((b = is.read()) != -1) {
sb.append((char)b); sb.append((char)b);
} }
((MimeMultipart)stack.peek()).setPreamble(sb.toString()); ((MimeMultipart)stack.peekFirst()).setPreamble(sb.toString());
} }

View File

@ -45,14 +45,15 @@ import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.Deque;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Stack;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
/** /**
@ -1949,7 +1950,7 @@ public class WebDavStore extends Store {
*/ */
public class WebDavHandler extends DefaultHandler { public class WebDavHandler extends DefaultHandler {
private DataSet mDataSet = new DataSet(); private DataSet mDataSet = new DataSet();
private Stack<String> mOpenTags = new Stack<String>(); private final Deque<String> mOpenTags = new ArrayDeque<String>();
public DataSet getDataSet() { public DataSet getDataSet() {
return this.mDataSet; return this.mDataSet;
@ -1968,12 +1969,12 @@ public class WebDavStore extends Store {
@Override @Override
public void startElement(String namespaceURI, String localName, public void startElement(String namespaceURI, String localName,
String qName, Attributes atts) throws SAXException { String qName, Attributes atts) throws SAXException {
mOpenTags.push(localName); mOpenTags.addFirst(localName);
} }
@Override @Override
public void endElement(String namespaceURI, String localName, String qName) { public void endElement(String namespaceURI, String localName, String qName) {
mOpenTags.pop(); mOpenTags.removeFirst();
/** Reset the hash temp variables */ /** Reset the hash temp variables */
if (localName.equals("response")) { if (localName.equals("response")) {
@ -1984,7 +1985,7 @@ public class WebDavStore extends Store {
@Override @Override
public void characters(char ch[], int start, int length) { public void characters(char ch[], int start, int length) {
String value = new String(ch, start, length); String value = new String(ch, start, length);
mDataSet.addValue(value, mOpenTags.peek()); mDataSet.addValue(value, mOpenTags.peekFirst());
} }
} }