Author: norman
Date: Tue Jan 25 19:03:06 2011
New Revision: 1063404
URL: http://svn.apache.org/viewvc?rev=1063404&view=rev
Log:
Get rid of some constants in ImapConstants which were not safe to modification
from outside. This was found by findbugs :)
Modified:
james/imap/trunk/api/src/main/java/org/apache/james/imap/api/ImapConstants.java
james/imap/trunk/message/src/main/java/org/apache/james/imap/main/AbstractImapResponseWriter.java
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/HeaderBodyElement.java
Modified:
james/imap/trunk/api/src/main/java/org/apache/james/imap/api/ImapConstants.java
URL:
http://svn.apache.org/viewvc/james/imap/trunk/api/src/main/java/org/apache/james/imap/api/ImapConstants.java?rev=1063404&r1=1063403&r2=1063404&view=diff
==============================================================================
---
james/imap/trunk/api/src/main/java/org/apache/james/imap/api/ImapConstants.java
(original)
+++
james/imap/trunk/api/src/main/java/org/apache/james/imap/api/ImapConstants.java
Tue Jan 25 19:03:06 2011
@@ -49,41 +49,27 @@ public interface ImapConstants {
public static final byte BYTE_OPENING_PARENTHESIS = 0x28;
- public static final byte[] BYTES_OPENING_PARENTHESIS = {
BYTE_OPENING_PARENTHESIS };
-
public static final byte BYTE_CLOSING_PARENTHESIS = 0x29;
- public static final byte[] BYTES_CLOSING_PARENTHESIS = {
BYTE_CLOSING_PARENTHESIS };
-
public static final byte BYTE_SP = 0x20;
- public static final byte[] BYTES_SPACE = { BYTE_SP };
-
public static final byte BYTE_DQUOTE = 0x22;
public static final byte BYTE_BACK_SLASH = 0x5C;
public static final byte BYTE_QUESTION = 0x3F;
- public static final byte[] BYTES_DQUOTE = { BYTE_DQUOTE };
-
public static final byte BYTE_OPEN_SQUARE_BRACKET = 0x5B;
- public static final byte[] BYTES_OPEN_SQUARE_BRACKET = {
BYTE_OPEN_SQUARE_BRACKET };
public static final byte BYTE_CLOSE_SQUARE_BRACKET = 0x5D;
- public static final byte[] BYTES_CLOSE_SQUARE_BRACKET = {
BYTE_CLOSE_SQUARE_BRACKET };
public static final byte BYTE_OPEN_BRACE = 0x7B;
- public static final byte[] BYTES_OPEN_BRACE = { BYTE_OPEN_BRACE };
public static final byte BYTE_CLOSE_BRACE = 0x7D;
- public static final byte[] BYTES_CLOSE_BRACE = { BYTE_CLOSE_BRACE };
-
- public static final byte[] BYTES_LINE_END = { 0x0D, 0x0A };
public static final char OPENING_PARENTHESIS = '(';
@@ -246,6 +232,7 @@ public interface ImapConstants {
public static final String STARTTLS = "STARTTLS";
+ public static final String LINE_END = "\r\n";
public static final long MAX_NZ_NUMBER = 4294967295L;
public static final long MIN_NZ_NUMBER = 1L;
Modified:
james/imap/trunk/message/src/main/java/org/apache/james/imap/main/AbstractImapResponseWriter.java
URL:
http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/main/AbstractImapResponseWriter.java?rev=1063404&r1=1063403&r2=1063404&view=diff
==============================================================================
---
james/imap/trunk/message/src/main/java/org/apache/james/imap/main/AbstractImapResponseWriter.java
(original)
+++
james/imap/trunk/message/src/main/java/org/apache/james/imap/main/AbstractImapResponseWriter.java
Tue Jan 25 19:03:06 2011
@@ -79,6 +79,11 @@ public abstract class AbstractImapRespon
write(wrap);
}
+ private void write(byte b) throws IOException {
+ final ByteBuffer wrap = ByteBuffer.wrap(new byte[] {b});
+ write(wrap);
+ }
+
public void untagged() throws IOException {
writeASCII(UNTAGGED);
}
@@ -103,12 +108,12 @@ public abstract class AbstractImapRespon
if (responseCode != null) {
writeASCII(" [");
writeASCII(responseCode);
- write(BYTES_CLOSE_SQUARE_BRACKET);
+ write(BYTE_CLOSE_SQUARE_BRACKET);
}
}
public void end() throws IOException {
- write(BYTES_LINE_END);
+ write(LINE_END.getBytes());
}
public void commandName(String commandName) throws IOException {
@@ -150,19 +155,19 @@ public abstract class AbstractImapRespon
}
public void closeParen() throws IOException {
- closeBracket(BYTES_CLOSING_PARENTHESIS);
+ closeBracket(BYTE_CLOSING_PARENTHESIS);
}
- private void closeBracket(final byte[] bracket) throws IOException {
+ private void closeBracket(final byte bracket) throws IOException {
write(bracket);
clearSkipNextSpace();
}
public void openParen() throws IOException {
- openBracket(BYTES_OPENING_PARENTHESIS);
+ openBracket(BYTE_OPENING_PARENTHESIS);
}
- private void openBracket(final byte[] bracket) throws IOException {
+ private void openBracket(final byte bracket) throws IOException {
space();
write(bracket);
skipNextSpace();
@@ -180,17 +185,17 @@ public abstract class AbstractImapRespon
if (skipNextSpace) {
skipNextSpace = false;
} else {
- write(BYTES_SPACE);
+ write(SP.getBytes());
}
}
public void literal(Literal literal) throws IOException {
space();
- write(BYTES_OPEN_BRACE);
+ write(BYTE_OPEN_BRACE);
final long size = literal.size();
writeASCII(Long.toString(size));
- write(BYTES_CLOSE_BRACE);
- write(BYTES_LINE_END);
+ write(BYTE_CLOSE_BRACE);
+ write(LINE_END.getBytes());
if (size > 0) {
write(literal);
}
@@ -199,11 +204,11 @@ public abstract class AbstractImapRespon
protected abstract void write(Literal literal) throws IOException;
public void closeSquareBracket() throws IOException {
- closeBracket(BYTES_CLOSE_SQUARE_BRACKET);
+ closeBracket(BYTE_CLOSE_SQUARE_BRACKET);
}
public void openSquareBracket() throws IOException {
- openBracket(BYTES_OPEN_SQUARE_BRACKET);
+ openBracket(BYTE_OPEN_SQUARE_BRACKET);
}
public void upperCaseAscii(String message) throws IOException {
Modified:
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/HeaderBodyElement.java
URL:
http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/HeaderBodyElement.java?rev=1063404&r1=1063403&r2=1063404&view=diff
==============================================================================
---
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/HeaderBodyElement.java
(original)
+++
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/HeaderBodyElement.java
Tue Jan 25 19:03:06 2011
@@ -83,7 +83,7 @@ final class HeaderBodyElement implements
* @see
org.apache.james.imap.message.response.FetchResponse.BodyElement#writeTo(java.nio.channels.WritableByteChannel)
*/
public void writeTo(WritableByteChannel channel) throws IOException {
- ByteBuffer endLine = ByteBuffer.wrap(ImapConstants.BYTES_LINE_END);
+ ByteBuffer endLine =
ByteBuffer.wrap(ImapConstants.LINE_END.getBytes());
endLine.rewind();
for (final Iterator<MessageResult.Header> it = headers.iterator();
it.hasNext();) {
MessageResult.Header header = it.next();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]