diff options
Diffstat (limited to 'java/com/android/voicemail/impl/mail/store/imap')
9 files changed, 110 insertions, 110 deletions
diff --git a/java/com/android/voicemail/impl/mail/store/imap/DigestMd5Utils.java b/java/com/android/voicemail/impl/mail/store/imap/DigestMd5Utils.java index f156f67c1..aa2886812 100644 --- a/java/com/android/voicemail/impl/mail/store/imap/DigestMd5Utils.java +++ b/java/com/android/voicemail/impl/mail/store/imap/DigestMd5Utils.java @@ -121,27 +121,27 @@ public class DigestMd5Utils { private static class ResponseBuilder { - private StringBuilder mBuilder = new StringBuilder(); + private StringBuilder builder = new StringBuilder(); public ResponseBuilder appendQuoted(String key, String value) { - if (mBuilder.length() != 0) { - mBuilder.append(","); + if (builder.length() != 0) { + builder.append(","); } - mBuilder.append(key).append("=\"").append(value).append("\""); + builder.append(key).append("=\"").append(value).append("\""); return this; } public ResponseBuilder append(String key, String value) { - if (mBuilder.length() != 0) { - mBuilder.append(","); + if (builder.length() != 0) { + builder.append(","); } - mBuilder.append(key).append("=").append(value); + builder.append(key).append("=").append(value); return this; } @Override public String toString() { - return mBuilder.toString(); + return builder.toString(); } } } @@ -229,20 +229,20 @@ public class DigestMd5Utils { /** Parse the key-value pair returned by the server. */ private static class DigestMessageParser { - private final String mMessage; - private int mPosition = 0; - private Map<String, String> mResult = new ArrayMap<>(); + private final String message; + private int position = 0; + private Map<String, String> result = new ArrayMap<>(); public DigestMessageParser(String message) { - mMessage = message; + this.message = message; } @Nullable public Map<String, String> parse() { try { - while (mPosition < mMessage.length()) { + while (position < message.length()) { parsePair(); - if (mPosition != mMessage.length()) { + if (position != message.length()) { expect(','); } } @@ -250,42 +250,42 @@ public class DigestMd5Utils { VvmLog.e(TAG, e.toString()); return null; } - return mResult; + return result; } private void parsePair() { String key = parseKey(); expect('='); String value = parseValue(); - mResult.put(key, value); + result.put(key, value); } private void expect(char c) { if (pop() != c) { - throw new IllegalStateException("unexpected character " + mMessage.charAt(mPosition)); + throw new IllegalStateException("unexpected character " + message.charAt(position)); } } private char pop() { char result = peek(); - mPosition++; + position++; return result; } private char peek() { - return mMessage.charAt(mPosition); + return message.charAt(position); } private void goToNext(char c) { while (peek() != c) { - mPosition++; + position++; } } private String parseKey() { - int start = mPosition; + int start = position; goToNext('='); - return mMessage.substring(start, mPosition); + return message.substring(start, position); } private String parseValue() { @@ -319,13 +319,13 @@ public class DigestMd5Utils { if (c == '\\') { result.append(pop()); } else if (c == ',') { - mPosition--; + position--; break; } else { result.append(c); } - if (mPosition == mMessage.length()) { + if (position == message.length()) { break; } } diff --git a/java/com/android/voicemail/impl/mail/store/imap/ImapElement.java b/java/com/android/voicemail/impl/mail/store/imap/ImapElement.java index ee255d1eb..c2571f3d9 100644 --- a/java/com/android/voicemail/impl/mail/store/imap/ImapElement.java +++ b/java/com/android/voicemail/impl/mail/store/imap/ImapElement.java @@ -77,14 +77,14 @@ public abstract class ImapElement { } }; - private boolean mDestroyed = false; + private boolean destroyed = false; public abstract boolean isList(); public abstract boolean isString(); protected boolean isDestroyed() { - return mDestroyed; + return destroyed; } /** @@ -92,12 +92,12 @@ public abstract class ImapElement { * ImapTempFileLiteral}. */ public void destroy() { - mDestroyed = true; + destroyed = true; } /** Throws {@link RuntimeException} if it's already destroyed. */ protected final void checkNotDestroyed() { - if (mDestroyed) { + if (destroyed) { throw new RuntimeException("Already destroyed"); } } diff --git a/java/com/android/voicemail/impl/mail/store/imap/ImapList.java b/java/com/android/voicemail/impl/mail/store/imap/ImapList.java index e4a6ec0ac..a72883fa6 100644 --- a/java/com/android/voicemail/impl/mail/store/imap/ImapList.java +++ b/java/com/android/voicemail/impl/mail/store/imap/ImapList.java @@ -35,13 +35,13 @@ public class ImapList extends ImapElement { } }; - private ArrayList<ImapElement> mList = new ArrayList<ImapElement>(); + private ArrayList<ImapElement> list = new ArrayList<ImapElement>(); /* package */ void add(ImapElement e) { if (e == null) { throw new RuntimeException("Can't add null"); } - mList.add(e); + list.add(e); } @Override @@ -55,7 +55,7 @@ public class ImapList extends ImapElement { } public final int size() { - return mList.size(); + return list.size(); } public final boolean isEmpty() { @@ -84,7 +84,7 @@ public class ImapList extends ImapElement { * ImapElement#NONE}. */ public final ImapElement getElementOrNone(int index) { - return (index >= mList.size()) ? ImapElement.NONE : mList.get(index); + return (index >= list.size()) ? ImapElement.NONE : list.get(index); } /** @@ -112,7 +112,7 @@ public class ImapList extends ImapElement { /* package */ final ImapElement getKeyedElementOrNull(String key, boolean prefixMatch) { for (int i = 1; i < size(); i += 2) { if (is(i - 1, key, prefixMatch)) { - return mList.get(i); + return list.get(i); } } return null; @@ -162,18 +162,18 @@ public class ImapList extends ImapElement { @Override public void destroy() { - if (mList != null) { - for (ImapElement e : mList) { + if (list != null) { + for (ImapElement e : list) { e.destroy(); } - mList = null; + list = null; } super.destroy(); } @Override public String toString() { - return mList.toString(); + return list.toString(); } /** Return the text representations of the contents concatenated with ",". */ @@ -192,7 +192,7 @@ public class ImapList extends ImapElement { */ private final StringBuilder flatten(StringBuilder sb) { sb.append('['); - for (int i = 0; i < mList.size(); i++) { + for (int i = 0; i < list.size(); i++) { if (i > 0) { sb.append(','); } @@ -217,7 +217,7 @@ public class ImapList extends ImapElement { return false; } for (int i = 0; i < size(); i++) { - if (!mList.get(i).equalsForTest(thatList.getElementOrNone(i))) { + if (!list.get(i).equalsForTest(thatList.getElementOrNone(i))) { return false; } } diff --git a/java/com/android/voicemail/impl/mail/store/imap/ImapMemoryLiteral.java b/java/com/android/voicemail/impl/mail/store/imap/ImapMemoryLiteral.java index 96a8c4ae5..46f3fc5ed 100644 --- a/java/com/android/voicemail/impl/mail/store/imap/ImapMemoryLiteral.java +++ b/java/com/android/voicemail/impl/mail/store/imap/ImapMemoryLiteral.java @@ -26,35 +26,35 @@ import java.io.UnsupportedEncodingException; /** Subclass of {@link ImapString} used for literals backed by an in-memory byte array. */ public class ImapMemoryLiteral extends ImapString { private final String TAG = "ImapMemoryLiteral"; - private byte[] mData; + private byte[] data; /* package */ ImapMemoryLiteral(FixedLengthInputStream in) throws IOException { // We could use ByteArrayOutputStream and IOUtils.copy, but it'd perform an unnecessary // copy.... - mData = new byte[in.getLength()]; + data = new byte[in.getLength()]; int pos = 0; - while (pos < mData.length) { - int read = in.read(mData, pos, mData.length - pos); + while (pos < data.length) { + int read = in.read(data, pos, data.length - pos); if (read < 0) { break; } pos += read; } - if (pos != mData.length) { + if (pos != data.length) { VvmLog.w(TAG, "length mismatch"); } } @Override public void destroy() { - mData = null; + data = null; super.destroy(); } @Override public String getString() { try { - return new String(mData, "US-ASCII"); + return new String(data, "US-ASCII"); } catch (UnsupportedEncodingException e) { VvmLog.e(TAG, "Unsupported encoding: ", e); } @@ -63,11 +63,11 @@ public class ImapMemoryLiteral extends ImapString { @Override public InputStream getAsStream() { - return new ByteArrayInputStream(mData); + return new ByteArrayInputStream(data); } @Override public String toString() { - return String.format("{%d byte literal(memory)}", mData.length); + return String.format("{%d byte literal(memory)}", data.length); } } diff --git a/java/com/android/voicemail/impl/mail/store/imap/ImapResponse.java b/java/com/android/voicemail/impl/mail/store/imap/ImapResponse.java index d53d458da..48eb39d2d 100644 --- a/java/com/android/voicemail/impl/mail/store/imap/ImapResponse.java +++ b/java/com/android/voicemail/impl/mail/store/imap/ImapResponse.java @@ -18,12 +18,12 @@ package com.android.voicemail.impl.mail.store.imap; /** Class represents an IMAP response. */ public class ImapResponse extends ImapList { - private final String mTag; - private final boolean mIsContinuationRequest; + private final String tag; + private final boolean isContinuationRequest; /* package */ ImapResponse(String tag, boolean isContinuationRequest) { - mTag = tag; - mIsContinuationRequest = isContinuationRequest; + this.tag = tag; + this.isContinuationRequest = isContinuationRequest; } /* package */ static boolean isStatusResponse(String symbol) { @@ -36,12 +36,12 @@ public class ImapResponse extends ImapList { /** @return whether it's a tagged response. */ public boolean isTagged() { - return mTag != null; + return tag != null; } /** @return whether it's a continuation request. */ public boolean isContinuationRequest() { - return mIsContinuationRequest; + return isContinuationRequest; } public boolean isStatusResponse() { @@ -112,7 +112,7 @@ public class ImapResponse extends ImapList { @Override public String toString() { - String tag = mTag; + String tag = this.tag; if (isContinuationRequest()) { tag = "+"; } @@ -125,16 +125,16 @@ public class ImapResponse extends ImapList { return false; } final ImapResponse thatResponse = (ImapResponse) that; - if (mTag == null) { - if (thatResponse.mTag != null) { + if (tag == null) { + if (thatResponse.tag != null) { return false; } } else { - if (!mTag.equals(thatResponse.mTag)) { + if (!tag.equals(thatResponse.tag)) { return false; } } - if (mIsContinuationRequest != thatResponse.mIsContinuationRequest) { + if (isContinuationRequest != thatResponse.isContinuationRequest) { return false; } return true; diff --git a/java/com/android/voicemail/impl/mail/store/imap/ImapResponseParser.java b/java/com/android/voicemail/impl/mail/store/imap/ImapResponseParser.java index e37106a69..68d6babbd 100644 --- a/java/com/android/voicemail/impl/mail/store/imap/ImapResponseParser.java +++ b/java/com/android/voicemail/impl/mail/store/imap/ImapResponseParser.java @@ -33,21 +33,21 @@ public class ImapResponseParser { public static final int LITERAL_KEEP_IN_MEMORY_THRESHOLD = 2 * 1024 * 1024; /** Input stream */ - private final PeekableInputStream mIn; + private final PeekableInputStream in; - private final int mLiteralKeepInMemoryThreshold; + private final int literalKeepInMemoryThreshold; /** StringBuilder used by readUntil() */ - private final StringBuilder mBufferReadUntil = new StringBuilder(); + private final StringBuilder bufferReadUntil = new StringBuilder(); /** StringBuilder used by parseBareString() */ - private final StringBuilder mParseBareString = new StringBuilder(); + private final StringBuilder parseBareString = new StringBuilder(); /** * We store all {@link ImapResponse} in it. {@link #destroyResponses()} must be called from time * to time to destroy them and clear it. */ - private final ArrayList<ImapResponse> mResponsesToDestroy = new ArrayList<ImapResponse>(); + private final ArrayList<ImapResponse> responsesToDestroy = new ArrayList<ImapResponse>(); /** * Exception thrown when we receive BYE. It derives from IOException, so it'll be treated in the @@ -68,8 +68,8 @@ public class ImapResponseParser { /** Constructor for testing to override the literal size threshold. */ /* package for test */ ImapResponseParser(InputStream in, int literalKeepInMemoryThreshold) { - mIn = new PeekableInputStream(in); - mLiteralKeepInMemoryThreshold = literalKeepInMemoryThreshold; + this.in = new PeekableInputStream(in); + this.literalKeepInMemoryThreshold = literalKeepInMemoryThreshold; } private static IOException newEOSException() { @@ -85,7 +85,7 @@ public class ImapResponseParser { * shouldn't see EOF during parsing. */ private int peek() throws IOException { - final int next = mIn.peek(); + final int next = in.peek(); if (next == -1) { throw newEOSException(); } @@ -93,13 +93,13 @@ public class ImapResponseParser { } /** - * Read and return one byte from {@link #mIn}, and put it in {@link #mDiscourseLogger}. + * Read and return one byte from {@link #in}, and put it in {@link #mDiscourseLogger}. * * <p>Throws IOException() if reaches EOF. As long as logical response lines end with \r\n, we * shouldn't see EOF during parsing. */ private int readByte() throws IOException { - int next = mIn.read(); + int next = in.read(); if (next == -1) { throw newEOSException(); } @@ -112,10 +112,10 @@ public class ImapResponseParser { * @see #readResponse() */ public void destroyResponses() { - for (ImapResponse r : mResponsesToDestroy) { + for (ImapResponse r : responsesToDestroy) { r.destroy(); } - mResponsesToDestroy.clear(); + responsesToDestroy.clear(); } /** @@ -151,7 +151,7 @@ public class ImapResponseParser { response.destroy(); throw new ByeException(); } - mResponsesToDestroy.add(response); + responsesToDestroy.add(response); return response; } @@ -192,13 +192,13 @@ public class ImapResponseParser { * (rather than peeked) and won't be included in the result. */ /* package for test */ String readUntil(char end) throws IOException { - mBufferReadUntil.setLength(0); + bufferReadUntil.setLength(0); for (; ; ) { final int ch = readByte(); if (ch != end) { - mBufferReadUntil.append((char) ch); + bufferReadUntil.append((char) ch); } else { - return mBufferReadUntil.toString(); + return bufferReadUntil.toString(); } } } @@ -326,7 +326,7 @@ public class ImapResponseParser { * <p>If the value is "NIL", returns an empty string. */ private ImapString parseBareString() throws IOException, MessagingException { - mParseBareString.setLength(0); + parseBareString.setLength(0); for (; ; ) { final int ch = peek(); @@ -351,10 +351,10 @@ public class ImapResponseParser { ch == '"' || (0x00 <= ch && ch <= 0x1f) || ch == 0x7f) { - if (mParseBareString.length() == 0) { + if (parseBareString.length() == 0) { throw new MessagingException("Expected string, none found."); } - String s = mParseBareString.toString(); + String s = parseBareString.toString(); // NIL will be always converted into the empty string. if (ImapConstants.NIL.equalsIgnoreCase(s)) { @@ -363,11 +363,11 @@ public class ImapResponseParser { return new ImapSimpleString(s); } else if (ch == '[') { // Eat all until next ']' - mParseBareString.append((char) readByte()); - mParseBareString.append(readUntil(']')); - mParseBareString.append(']'); // readUntil won't include the end char. + parseBareString.append((char) readByte()); + parseBareString.append(readUntil(']')); + parseBareString.append(']'); // readUntil won't include the end char. } else { - mParseBareString.append((char) readByte()); + parseBareString.append((char) readByte()); } } } @@ -414,8 +414,8 @@ public class ImapResponseParser { } expect('\r'); expect('\n'); - FixedLengthInputStream in = new FixedLengthInputStream(mIn, size); - if (size > mLiteralKeepInMemoryThreshold) { + FixedLengthInputStream in = new FixedLengthInputStream(this.in, size); + if (size > literalKeepInMemoryThreshold) { return new ImapTempFileLiteral(in); } else { return new ImapMemoryLiteral(in); diff --git a/java/com/android/voicemail/impl/mail/store/imap/ImapSimpleString.java b/java/com/android/voicemail/impl/mail/store/imap/ImapSimpleString.java index 7cc866b74..76d3c6e91 100644 --- a/java/com/android/voicemail/impl/mail/store/imap/ImapSimpleString.java +++ b/java/com/android/voicemail/impl/mail/store/imap/ImapSimpleString.java @@ -24,27 +24,27 @@ import java.io.UnsupportedEncodingException; /** Subclass of {@link ImapString} used for non literals. */ public class ImapSimpleString extends ImapString { private final String TAG = "ImapSimpleString"; - private String mString; + private String string; /* package */ ImapSimpleString(String string) { - mString = (string != null) ? string : ""; + this.string = (string != null) ? string : ""; } @Override public void destroy() { - mString = null; + string = null; super.destroy(); } @Override public String getString() { - return mString; + return string; } @Override public InputStream getAsStream() { try { - return new ByteArrayInputStream(mString.getBytes("US-ASCII")); + return new ByteArrayInputStream(string.getBytes("US-ASCII")); } catch (UnsupportedEncodingException e) { VvmLog.e(TAG, "Unsupported encoding: ", e); } @@ -54,6 +54,6 @@ public class ImapSimpleString extends ImapString { @Override public String toString() { // Purposefully not return just mString, in order to prevent using it instead of getString. - return "\"" + mString + "\""; + return "\"" + string + "\""; } } diff --git a/java/com/android/voicemail/impl/mail/store/imap/ImapString.java b/java/com/android/voicemail/impl/mail/store/imap/ImapString.java index d5c555126..099e569a8 100644 --- a/java/com/android/voicemail/impl/mail/store/imap/ImapString.java +++ b/java/com/android/voicemail/impl/mail/store/imap/ImapString.java @@ -64,9 +64,9 @@ public abstract class ImapString extends ImapElement { private static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss Z", Locale.US); - private boolean mIsInteger; - private int mParsedInteger; - private Date mParsedDate; + private boolean isInteger; + private int parsedInteger; + private Date parsedDate; @Override public final boolean isList() { @@ -94,12 +94,12 @@ public abstract class ImapString extends ImapElement { /** @return whether it can be parsed as a number. */ public final boolean isNumber() { - if (mIsInteger) { + if (isInteger) { return true; } try { - mParsedInteger = Integer.parseInt(getString()); - mIsInteger = true; + parsedInteger = Integer.parseInt(getString()); + isInteger = true; return true; } catch (NumberFormatException e) { return false; @@ -116,19 +116,19 @@ public abstract class ImapString extends ImapElement { if (!isNumber()) { return defaultValue; } - return mParsedInteger; + return parsedInteger; } /** @return whether it can be parsed as a date using {@link #DATE_TIME_FORMAT}. */ public final boolean isDate() { - if (mParsedDate != null) { + if (parsedDate != null) { return true; } if (isEmpty()) { return false; } try { - mParsedDate = DATE_TIME_FORMAT.parse(getString()); + parsedDate = DATE_TIME_FORMAT.parse(getString()); return true; } catch (ParseException e) { VvmLog.w("ImapString", getString() + " can't be parsed as a date."); @@ -141,7 +141,7 @@ public abstract class ImapString extends ImapElement { if (!isDate()) { return null; } - return mParsedDate; + return parsedDate; } /** @return whether the value case-insensitively equals to {@code s}. */ diff --git a/java/com/android/voicemail/impl/mail/store/imap/ImapTempFileLiteral.java b/java/com/android/voicemail/impl/mail/store/imap/ImapTempFileLiteral.java index ab64d8537..417adcc02 100644 --- a/java/com/android/voicemail/impl/mail/store/imap/ImapTempFileLiteral.java +++ b/java/com/android/voicemail/impl/mail/store/imap/ImapTempFileLiteral.java @@ -33,20 +33,20 @@ import org.apache.commons.io.IOUtils; public class ImapTempFileLiteral extends ImapString { private final String TAG = "ImapTempFileLiteral"; - /* package for test */ final File mFile; + /* package for test */ final File file; /** Size is purely for toString() */ - private final int mSize; + private final int size; /* package */ ImapTempFileLiteral(FixedLengthInputStream stream) throws IOException { - mSize = stream.getLength(); - mFile = File.createTempFile("imap", ".tmp", TempDirectory.getTempDirectory()); + size = stream.getLength(); + file = File.createTempFile("imap", ".tmp", TempDirectory.getTempDirectory()); // Unfortunately, we can't really use deleteOnExit(), because temp filenames are random // so it'd simply cause a memory leak. // deleteOnExit() simply adds filenames to a static list and the list will never shrink. // mFile.deleteOnExit(); - OutputStream out = new FileOutputStream(mFile); + OutputStream out = new FileOutputStream(file); IOUtils.copy(stream, out); out.close(); } @@ -69,7 +69,7 @@ public class ImapTempFileLiteral extends ImapString { public InputStream getAsStream() { checkNotDestroyed(); try { - return new FileInputStream(mFile); + return new FileInputStream(file); } catch (FileNotFoundException e) { // It's probably possible if we're low on storage and the system clears the cache dir. LogUtils.w(TAG, "ImapTempFileLiteral: Temp file not found"); @@ -98,8 +98,8 @@ public class ImapTempFileLiteral extends ImapString { @Override public void destroy() { try { - if (!isDestroyed() && mFile.exists()) { - mFile.delete(); + if (!isDestroyed() && file.exists()) { + file.delete(); } } catch (RuntimeException re) { // Just log and ignore. @@ -110,10 +110,10 @@ public class ImapTempFileLiteral extends ImapString { @Override public String toString() { - return String.format("{%d byte literal(file)}", mSize); + return String.format("{%d byte literal(file)}", size); } public boolean tempFileExistsForTest() { - return mFile.exists(); + return file.exists(); } } |