This is an automated email from the ASF dual-hosted git repository. matthieu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 12e1c580bb47a2d7fdef33aef2b99671d4bd8f33 Author: Matthieu Baechler <matth...@apache.org> AuthorDate: Thu Nov 7 22:10:29 2019 +0100 [Refactoring] move available charset names into StatusResponse --- .../apache/james/imap/api/display/CharsetUtil.java | 19 ------------------- .../imap/api/message/response/StatusResponse.java | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/protocols/imap/src/main/java/org/apache/james/imap/api/display/CharsetUtil.java b/protocols/imap/src/main/java/org/apache/james/imap/api/display/CharsetUtil.java index 8f47d62..915716c 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/api/display/CharsetUtil.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/api/display/CharsetUtil.java @@ -20,11 +20,8 @@ package org.apache.james.imap.api.display; import java.nio.ByteBuffer; import java.nio.charset.Charset; -import java.util.Set; -import java.util.stream.Stream; import com.beetstra.jutf7.CharsetProvider; -import com.github.steveash.guavate.Guavate; /** * Utility class which can be used to get a list of supported {@link Charset}'s @@ -33,26 +30,10 @@ import com.github.steveash.guavate.Guavate; */ public class CharsetUtil { - private static final Set<String> CHARSET_NAMES = - Charset.availableCharsets() - .values() - .stream() - .flatMap(charset -> Stream.concat( - Stream.of(charset.name()), - charset.aliases().stream())) - .collect(Guavate.toImmutableSet()); - private static final String X_MODIFIED_UTF_7 = "X-MODIFIED-UTF-7"; private static final Charset X_MODIFIED_UTF_7_CHARSET = new CharsetProvider().charsetForName(X_MODIFIED_UTF_7); /** - * Return an unmodifiable {@link Set} which holds the names (and aliases) of all supported Charsets - */ - public static final Set<String> getAvailableCharsetNames() { - return CHARSET_NAMES; - } - - /** * Decode the given UTF7 encoded <code>String</code> * * @return decoded diff --git a/protocols/imap/src/main/java/org/apache/james/imap/api/message/response/StatusResponse.java b/protocols/imap/src/main/java/org/apache/james/imap/api/message/response/StatusResponse.java index 148ef69..15f9931 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/api/message/response/StatusResponse.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/api/message/response/StatusResponse.java @@ -19,20 +19,24 @@ package org.apache.james.imap.api.message.response; +import java.nio.charset.Charset; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Set; +import java.util.stream.Stream; import javax.mail.Flags; import org.apache.james.imap.api.ImapCommand; -import org.apache.james.imap.api.display.CharsetUtil; import org.apache.james.imap.api.display.HumanReadableText; import org.apache.james.imap.api.message.IdRange; import org.apache.james.imap.api.message.MessageFlags; import org.apache.james.imap.api.message.UidRange; import org.apache.james.mailbox.MessageUid; +import com.github.steveash.guavate.Guavate; + /** * <p> * Represents an <code>RFC2060</code> status response. The five specified status @@ -44,6 +48,15 @@ import org.apache.james.mailbox.MessageUid; */ public interface StatusResponse extends ImapResponseMessage { + Set<String> AVAILABLE_CHARSET_NAMES = + Charset.availableCharsets() + .values() + .stream() + .flatMap(charset -> Stream.concat( + Stream.of(charset.name()), + charset.aliases().stream())) + .collect(Guavate.toImmutableSet()); + /** * Gets the server response type of this status message. * @@ -215,7 +228,7 @@ public interface StatusResponse extends ImapResponseMessage { * @return <code>ResponseCode</code>, not null */ public static ResponseCode badCharset() { - return new ResponseCode("BADCHARSET", CharsetUtil.getAvailableCharsetNames()); + return new ResponseCode("BADCHARSET", AVAILABLE_CHARSET_NAMES); } /** --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org