Author: gsim Date: Fri Oct 10 12:56:52 2014 New Revision: 1630852 URL: http://svn.apache.org/r1630852 Log: PROTON-576: updates to bring things into line with the patch on the JIRA, rather than a stale older version I actually applied (not having a good day :P)
Modified: qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/codec/EncoderImpl.java qpid/proton/branches/examples/proton-j/src/test/java/org/apache/qpid/proton/codec/StringTypeTest.java Modified: qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/codec/EncoderImpl.java URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/codec/EncoderImpl.java?rev=1630852&r1=1630851&r2=1630852&view=diff ============================================================================== --- qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/codec/EncoderImpl.java (original) +++ qpid/proton/branches/examples/proton-j/src/main/java/org/apache/qpid/proton/codec/EncoderImpl.java Fri Oct 10 12:56:52 2014 @@ -805,29 +805,14 @@ public final class EncoderImpl implement c = 0x010000 + ((c & 0x03FF) << 10) + (low & 0x03FF); - - if (c <= 0x3FFFF) /* U+10000..U+3FFFF */ - { - _buffer.put((byte) 0xF0); - _buffer.put((byte)(0x90 | ((c >> 12) & 0x2F))); - _buffer.put((byte)(0x80 | ((c >> 6) & 0x3F))); - _buffer.put((byte)(0x80 | (c & 0x3F))); - } - else if (c <= 0xFFFFF) /* U+40000..U+FFFFF */ - { - _buffer.put((byte)(0xF0 | ((c >> 18) & 0x03))); - _buffer.put((byte)(0x80 | ((c >> 12) & 0x3F))); - _buffer.put((byte)(0x80 | ((c >> 6) & 0x3F))); - _buffer.put((byte)(0x80 | (c & 0x3F))); - } - else /* U+100000..U+10FFFF */ - { - _buffer.put((byte)(0xF4)); - _buffer.put((byte)(0x80 | ((c >> 12) & 0x3F))); - _buffer.put((byte)(0x80 | ((c >> 6) & 0x3F))); - _buffer.put((byte)(0x80 | (c & 0x3F))); - } + _buffer.put((byte)(0xF0 | ((c >> 18) & 0x07))); + _buffer.put((byte)(0x80 | ((c >> 12) & 0x3F))); + _buffer.put((byte)(0x80 | ((c >> 6) & 0x3F))); + _buffer.put((byte)(0x80 | (c & 0x3F))); } } } + + + } Modified: qpid/proton/branches/examples/proton-j/src/test/java/org/apache/qpid/proton/codec/StringTypeTest.java URL: http://svn.apache.org/viewvc/qpid/proton/branches/examples/proton-j/src/test/java/org/apache/qpid/proton/codec/StringTypeTest.java?rev=1630852&r1=1630851&r2=1630852&view=diff ============================================================================== --- qpid/proton/branches/examples/proton-j/src/test/java/org/apache/qpid/proton/codec/StringTypeTest.java (original) +++ qpid/proton/branches/examples/proton-j/src/test/java/org/apache/qpid/proton/codec/StringTypeTest.java Fri Oct 10 12:56:52 2014 @@ -25,11 +25,11 @@ import static org.junit.Assert.assertEqu import java.lang.Character.UnicodeBlock; import java.nio.ByteBuffer; import java.nio.charset.Charset; +import java.util.Arrays; import java.util.HashSet; import java.util.Set; import org.junit.Test; - import org.apache.qpid.proton.amqp.messaging.AmqpValue; /** @@ -40,20 +40,21 @@ public class StringTypeTest private static final Charset CHARSET_UTF8 = Charset.forName("UTF-8"); /** - * Loop over all the chars in a given {@link UnicodeBlock} and return a + * Loop over all the chars in given {@link UnicodeBlock}s and return a * {@link Set <String>} containing all the possible values as their * {@link String} values. * - * @param block the {@link UnicodeBlock} to loop over + * @param blocks the {@link UnicodeBlock}s to loop over * @return a {@link Set <String>} containing all the possible values as * {@link String} values */ - private static Set<String> getAllStringsFromUnicodeBlock(final UnicodeBlock block) + private static Set<String> getAllStringsFromUnicodeBlocks(final UnicodeBlock... blocks) { + final Set<UnicodeBlock> blockSet = new HashSet<UnicodeBlock>(Arrays.asList(blocks)); final Set<String> strings = new HashSet<String>(); for (int codePoint = 0; codePoint <= Character.MAX_CODE_POINT; codePoint++) { - if (UnicodeBlock.of(codePoint) == block) + if (blockSet.contains(UnicodeBlock.of(codePoint))) { final int charCount = Character.charCount(codePoint); final StringBuilder sb = new StringBuilder( @@ -129,19 +130,18 @@ public class StringTypeTest { // non-surrogate pair blocks - addAll(getAllStringsFromUnicodeBlock(UnicodeBlock.BASIC_LATIN)); - addAll(getAllStringsFromUnicodeBlock(UnicodeBlock.LATIN_1_SUPPLEMENT)); - addAll(getAllStringsFromUnicodeBlock(UnicodeBlock.GREEK)); - addAll(getAllStringsFromUnicodeBlock(UnicodeBlock.LETTERLIKE_SYMBOLS)); + addAll(getAllStringsFromUnicodeBlocks(UnicodeBlock.BASIC_LATIN, + UnicodeBlock.LATIN_1_SUPPLEMENT, + UnicodeBlock.GREEK, + UnicodeBlock.LETTERLIKE_SYMBOLS)); // blocks with surrogate pairs - //TODO: restore when Java 7 is baseline - //addAll(getAllStringsFromUnicodeBlock(UnicodeBlock.MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS)); - addAll(getAllStringsFromUnicodeBlock(UnicodeBlock.MUSICAL_SYMBOLS)); - //TODO: restore when Java 7 is baseline - //addAll(getAllStringsFromUnicodeBlock(UnicodeBlock.EMOTICONS)); - //addAll(getAllStringsFromUnicodeBlock(UnicodeBlock.PLAYING_CARDS)); - addAll(getAllStringsFromUnicodeBlock(UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_A)); - addAll(getAllStringsFromUnicodeBlock(UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_B)); + //TODO: restore others when Java 7 is baseline + addAll(getAllStringsFromUnicodeBlocks(/*UnicodeBlock.MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS,*/ + UnicodeBlock.MUSICAL_SYMBOLS, + /*UnicodeBlock.EMOTICONS,*/ + /*UnicodeBlock.PLAYING_CARDS,*/ + UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_A, + UnicodeBlock.SUPPLEMENTARY_PRIVATE_USE_AREA_B)); } }; } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org