Resolve build warnings; part 4

Fix unchecked warnings

Change-Id: I872740fca4e5050e6ed2922eabc7e46e5e97ff3c
This commit is contained in:
Todd Kennedy 2011-02-02 13:23:06 -08:00
parent 8d8537cd2e
commit 5e39f90e9d
8 changed files with 66 additions and 69 deletions

View File

@ -217,7 +217,9 @@ public class Controller {
Mailbox.CONTENT_PROJECTION, WHERE_TYPE_ATTACHMENT, null, null);
try {
if (c.moveToFirst()) {
return new Mailbox().restore(c);
Mailbox m = new Mailbox();
m.restore(c);
return m;
}
} finally {
c.close();

View File

@ -391,7 +391,8 @@ public class LegacyConversions {
boolean attachmentFoundInDb = false;
try {
while (cursor.moveToNext()) {
Attachment dbAttachment = new Attachment().restore(cursor);
Attachment dbAttachment = new Attachment();
dbAttachment.restore(cursor);
// We test each of the fields here (instead of in SQL) because they may be
// null, or may be strings.
if (stringNotEqual(dbAttachment.mFileName, localAttachment.mFileName)) continue;

View File

@ -105,7 +105,8 @@ public class AccountShortcutPicker extends ListActivity
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Cursor cursor = (Cursor)parent.getItemAtPosition(position);
Account account = new Account().restore(cursor);
Account account = new Account();
account.restore(cursor);
setupShortcut(account);
finish();
}

View File

@ -601,7 +601,6 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
/**
* Set up address auto-completion adapters.
*/
@SuppressWarnings("all")
private void setupAddressAdapters() {
mAddressAdapterTo = new EmailAddressAdapter(this);
mAddressAdapterCc = new EmailAddressAdapter(this);

View File

@ -53,7 +53,7 @@ import java.util.regex.Pattern;
public class MimeMessage extends Message {
private MimeHeader mHeader;
private MimeHeader mExtendedHeader;
// NOTE: The fields here are transcribed out of headers, and values stored here will supercede
// the values found in the headers. Use caution to prevent any out-of-phase errors. In
// particular, any adds/changes/deletes here must be echoed by changes in the parse() function.
@ -69,7 +69,7 @@ public class MimeMessage extends Message {
// Shared random source for generating local message-id values
private static final java.util.Random sRandom = new java.util.Random();
// In MIME, en_US-like date format should be used. In other words "MMM" should be encoded to
// "Jan", not the other localized format like "Ene" (meaning January in locale es).
// This conversion is used when generating outgoing MIME messages. Incoming MIME date
@ -327,7 +327,7 @@ public class MimeMessage extends Message {
mReplyTo = replyTo;
}
}
/**
* Set the mime "Message-ID" header
* @param messageId the new Message-ID value
@ -337,7 +337,7 @@ public class MimeMessage extends Message {
public void setMessageId(String messageId) throws MessagingException {
setHeader("Message-ID", messageId);
}
/**
* Get the mime "Message-ID" header. This value will be preloaded with a locally-generated
* random ID, if the value has not previously been set. Local generation can be inhibited/
@ -409,7 +409,7 @@ public class MimeMessage extends Message {
/**
* Set extended header
*
*
* @param name Extended header name
* @param value header value - flattened by removing CR-NL if any
* remove header if value is null
@ -430,7 +430,7 @@ public class MimeMessage extends Message {
/**
* Get extended header
*
*
* @param name Extended header name
* @return header value - null if header does not exist
* @throws MessagingException
@ -444,7 +444,7 @@ public class MimeMessage extends Message {
/**
* Set entire extended headers from String
*
*
* @param headers Extended header and its value - "CR-NL-separated pairs
* if null or empty, remove entire extended headers
* @throws MessagingException
@ -466,7 +466,7 @@ public class MimeMessage extends Message {
/**
* Get entire extended headers as String
*
*
* @return "CR-NL-separated extended headers - null if extended header does not exist
*/
public String getExtendedHeaders() {
@ -478,7 +478,7 @@ public class MimeMessage extends Message {
/**
* Write message header and body to output stream
*
*
* @param out Output steam to write message header and body.
*/
public void writeTo(OutputStream out) throws IOException, MessagingException {
@ -500,7 +500,7 @@ public class MimeMessage extends Message {
}
class MimeMessageBuilder implements ContentHandler {
private Stack stack = new Stack();
private Stack<Object> stack = new Stack<Object>();
public MimeMessageBuilder() {
}

View File

@ -100,7 +100,7 @@ public abstract class EmailContent {
// Write the Content into a ContentValues container
public abstract ContentValues toContentValues();
// Read the Content from a ContentCursor
public abstract <T extends EmailContent> T restore (Cursor cursor);
public abstract void restore (Cursor cursor);
// The Uri is lazily initialized
public Uri getUri() {
@ -114,13 +114,13 @@ public abstract class EmailContent {
return mId != NOT_SAVED;
}
@SuppressWarnings("unchecked")
// The Content sub class must have a no-arg constructor
static public <T extends EmailContent> T getContent(Cursor cursor, Class<T> klass) {
try {
T content = klass.newInstance();
content.mId = cursor.getLong(0);
return (T)content.restore(cursor);
content.restore(cursor);
return content;
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InstantiationException e) {
@ -382,17 +382,15 @@ public abstract class EmailContent {
}
@Override
@SuppressWarnings("unchecked")
public EmailContent.Body restore(Cursor c) {
public void restore(Cursor cursor) {
mBaseUri = EmailContent.Body.CONTENT_URI;
mMessageKey = c.getLong(CONTENT_MESSAGE_KEY_COLUMN);
mHtmlContent = c.getString(CONTENT_HTML_CONTENT_COLUMN);
mTextContent = c.getString(CONTENT_TEXT_CONTENT_COLUMN);
mHtmlReply = c.getString(CONTENT_HTML_REPLY_COLUMN);
mTextReply = c.getString(CONTENT_TEXT_REPLY_COLUMN);
mSourceKey = c.getLong(CONTENT_SOURCE_KEY_COLUMN);
mIntroText = c.getString(CONTENT_INTRO_TEXT_COLUMN);
return this;
mMessageKey = cursor.getLong(CONTENT_MESSAGE_KEY_COLUMN);
mHtmlContent = cursor.getString(CONTENT_HTML_CONTENT_COLUMN);
mTextContent = cursor.getString(CONTENT_TEXT_CONTENT_COLUMN);
mHtmlReply = cursor.getString(CONTENT_HTML_REPLY_COLUMN);
mTextReply = cursor.getString(CONTENT_TEXT_REPLY_COLUMN);
mSourceKey = cursor.getLong(CONTENT_SOURCE_KEY_COLUMN);
mIntroText = cursor.getString(CONTENT_INTRO_TEXT_COLUMN);
}
public boolean update() {
@ -737,32 +735,30 @@ public abstract class EmailContent {
}
@Override
@SuppressWarnings("unchecked")
public EmailContent.Message restore(Cursor c) {
public void restore(Cursor cursor) {
mBaseUri = CONTENT_URI;
mId = c.getLong(CONTENT_ID_COLUMN);
mDisplayName = c.getString(CONTENT_DISPLAY_NAME_COLUMN);
mTimeStamp = c.getLong(CONTENT_TIMESTAMP_COLUMN);
mSubject = c.getString(CONTENT_SUBJECT_COLUMN);
mFlagRead = c.getInt(CONTENT_FLAG_READ_COLUMN) == 1;
mFlagLoaded = c.getInt(CONTENT_FLAG_LOADED_COLUMN);
mFlagFavorite = c.getInt(CONTENT_FLAG_FAVORITE_COLUMN) == 1;
mFlagAttachment = c.getInt(CONTENT_FLAG_ATTACHMENT_COLUMN) == 1;
mFlags = c.getInt(CONTENT_FLAGS_COLUMN);
mServerId = c.getString(CONTENT_SERVER_ID_COLUMN);
mServerTimeStamp = c.getLong(CONTENT_SERVER_TIMESTAMP_COLUMN);
mClientId = c.getString(CONTENT_CLIENT_ID_COLUMN);
mMessageId = c.getString(CONTENT_MESSAGE_ID_COLUMN);
mMailboxKey = c.getLong(CONTENT_MAILBOX_KEY_COLUMN);
mAccountKey = c.getLong(CONTENT_ACCOUNT_KEY_COLUMN);
mFrom = c.getString(CONTENT_FROM_LIST_COLUMN);
mTo = c.getString(CONTENT_TO_LIST_COLUMN);
mCc = c.getString(CONTENT_CC_LIST_COLUMN);
mBcc = c.getString(CONTENT_BCC_LIST_COLUMN);
mReplyTo = c.getString(CONTENT_REPLY_TO_COLUMN);
mMeetingInfo = c.getString(CONTENT_MEETING_INFO_COLUMN);
mSnippet = c.getString(CONTENT_SNIPPET_COLUMN);
return this;
mId = cursor.getLong(CONTENT_ID_COLUMN);
mDisplayName = cursor.getString(CONTENT_DISPLAY_NAME_COLUMN);
mTimeStamp = cursor.getLong(CONTENT_TIMESTAMP_COLUMN);
mSubject = cursor.getString(CONTENT_SUBJECT_COLUMN);
mFlagRead = cursor.getInt(CONTENT_FLAG_READ_COLUMN) == 1;
mFlagLoaded = cursor.getInt(CONTENT_FLAG_LOADED_COLUMN);
mFlagFavorite = cursor.getInt(CONTENT_FLAG_FAVORITE_COLUMN) == 1;
mFlagAttachment = cursor.getInt(CONTENT_FLAG_ATTACHMENT_COLUMN) == 1;
mFlags = cursor.getInt(CONTENT_FLAGS_COLUMN);
mServerId = cursor.getString(CONTENT_SERVER_ID_COLUMN);
mServerTimeStamp = cursor.getLong(CONTENT_SERVER_TIMESTAMP_COLUMN);
mClientId = cursor.getString(CONTENT_CLIENT_ID_COLUMN);
mMessageId = cursor.getString(CONTENT_MESSAGE_ID_COLUMN);
mMailboxKey = cursor.getLong(CONTENT_MAILBOX_KEY_COLUMN);
mAccountKey = cursor.getLong(CONTENT_ACCOUNT_KEY_COLUMN);
mFrom = cursor.getString(CONTENT_FROM_LIST_COLUMN);
mTo = cursor.getString(CONTENT_TO_LIST_COLUMN);
mCc = cursor.getString(CONTENT_CC_LIST_COLUMN);
mBcc = cursor.getString(CONTENT_BCC_LIST_COLUMN);
mReplyTo = cursor.getString(CONTENT_REPLY_TO_COLUMN);
mMeetingInfo = cursor.getString(CONTENT_MEETING_INFO_COLUMN);
mSnippet = cursor.getString(CONTENT_SNIPPET_COLUMN);
}
public boolean update() {
@ -1133,8 +1129,7 @@ public abstract class EmailContent {
}
@Override
@SuppressWarnings("unchecked")
public EmailContent.Account restore(Cursor cursor) {
public void restore(Cursor cursor) {
mId = cursor.getLong(CONTENT_ID_COLUMN);
mBaseUri = CONTENT_URI;
mDisplayName = cursor.getString(CONTENT_DISPLAY_NAME_COLUMN);
@ -1154,7 +1149,6 @@ public abstract class EmailContent {
mSecurityFlags = cursor.getLong(CONTENT_SECURITY_FLAGS_COLUMN);
mSecuritySyncKey = cursor.getString(CONTENT_SECURITY_SYNC_KEY_COLUMN);
mSignature = cursor.getString(CONTENT_SIGNATURE_COLUMN);
return this;
}
private long getId(Uri u) {
@ -2019,7 +2013,9 @@ public abstract class EmailContent {
Attachment[] attachments = new Attachment[count];
for (int i = 0; i < count; ++i) {
c.moveToNext();
attachments[i] = new Attachment().restore(c);
Attachment attach = new Attachment();
attach.restore(c);
attachments[i] = attach;
}
return attachments;
} finally {
@ -2061,8 +2057,7 @@ public abstract class EmailContent {
}
@Override
@SuppressWarnings("unchecked")
public EmailContent.Attachment restore(Cursor cursor) {
public void restore(Cursor cursor) {
mBaseUri = CONTENT_URI;
mId = cursor.getLong(CONTENT_ID_COLUMN);
mFileName= cursor.getString(CONTENT_FILENAME_COLUMN);
@ -2077,7 +2072,6 @@ public abstract class EmailContent {
mFlags = cursor.getInt(CONTENT_FLAGS_COLUMN);
mContentBytes = cursor.getBlob(CONTENT_CONTENT_BYTES_COLUMN);
mAccountKey = cursor.getLong(CONTENT_ACCOUNT_KEY_COLUMN);
return this;
}
@Override
@ -2361,7 +2355,7 @@ public abstract class EmailContent {
try {
if (c.moveToFirst()) {
return EmailContent.getContent(c, Mailbox.class);
return getContent(c, Mailbox.class);
} else {
return null;
}
@ -2371,8 +2365,7 @@ public abstract class EmailContent {
}
@Override
@SuppressWarnings("unchecked")
public EmailContent.Mailbox restore(Cursor cursor) {
public void restore(Cursor cursor) {
mBaseUri = CONTENT_URI;
mId = cursor.getLong(CONTENT_ID_COLUMN);
mDisplayName = cursor.getString(CONTENT_DISPLAY_NAME_COLUMN);
@ -2389,7 +2382,6 @@ public abstract class EmailContent {
mFlags = cursor.getInt(CONTENT_FLAGS_COLUMN);
mVisibleLimit = cursor.getInt(CONTENT_VISIBLE_LIMIT_COLUMN);
mSyncStatus = cursor.getString(CONTENT_SYNC_STATUS_COLUMN);
return this;
}
@Override
@ -2634,8 +2626,7 @@ public abstract class EmailContent {
}
@Override
@SuppressWarnings("unchecked")
public EmailContent.HostAuth restore(Cursor cursor) {
public void restore(Cursor cursor) {
mBaseUri = CONTENT_URI;
mId = cursor.getLong(CONTENT_ID_COLUMN);
mProtocol = cursor.getString(CONTENT_PROTOCOL_COLUMN);
@ -2646,7 +2637,6 @@ public abstract class EmailContent {
mPassword = cursor.getString(CONTENT_PASSWORD_COLUMN);
mDomain = cursor.getString(CONTENT_DOMAIN_COLUMN);
mAccountKey = cursor.getLong(CONTENT_ACCOUNT_KEY_COLUMN);
return this;
}
@Override

View File

@ -473,7 +473,8 @@ public class ExchangeService extends Service implements Runnable {
if (hostAuthId > 0) {
HostAuth ha = HostAuth.restoreHostAuthWithId(context, hostAuthId);
if (ha != null && ha.mProtocol.equals("eas")) {
Account account = new Account().restore(c);
Account account = new Account();
account.restore(c);
// Cache the HostAuth
account.mHostAuthRecv = ha;
accounts.add(account);
@ -1228,7 +1229,8 @@ public class ExchangeService extends Service implements Runnable {
try {
if (c.moveToFirst()) {
synchronized(sSyncLock) {
Mailbox m = new Mailbox().restore(c);
Mailbox m = new Mailbox();
m.restore(c);
Account acct = Account.restoreAccountWithId(context, accountId);
if (acct == null) {
reloadFolderListFailed(accountId);

View File

@ -70,7 +70,9 @@ public abstract class AccountTestCase extends ProviderTestCase2<EmailProvider> {
Account.CONTENT_PROJECTION, null, null, null);
try {
while (c.moveToNext()) {
accountList.add(new Account().restore(c));
Account account = new Account();
account.restore(c);
accountList.add(account);
}
} finally {
c.close();