3030 *
3131 * This class contains decoder for mapcodes.
3232 */
33- class Decoder {
33+ @ SuppressWarnings ({"MagicNumber" , "StringConcatenationMissingWhitespace" })
34+ final class Decoder {
3435 private static final Logger LOG = LoggerFactory .getLogger (Decoder .class );
3536
3637 // Get direct access to the data model singleton.
@@ -225,12 +226,12 @@ static MapcodeZone decodeToMapcodeZone(@Nonnull final String argMapcode,
225226
226227 private static class Unicode2Ascii {
227228
228- public final char min ;
229- public final char max ;
229+ final char min ;
230+ final char max ;
230231 @ Nonnull
231- public final String convert ;
232+ final String convert ;
232233
233- public Unicode2Ascii (final char min , final char max , @ Nonnull final String convert ) {
234+ Unicode2Ascii (final char min , final char max , @ Nonnull final String convert ) {
234235 this .min = min ;
235236 this .max = max ;
236237 this .convert = convert ;
@@ -243,7 +244,8 @@ public Unicode2Ascii(final char min, final char max, @Nonnull final String conve
243244 // Special character '?' indicating missing character in alphabet.
244245 private static final char MISSCODE = '?' ;
245246
246- private final static char [][] ASCII2LANGUAGE = {
247+ // @formatter:off
248+ @ SuppressWarnings ("LongLine" ) private final static char [][] ASCII2LANGUAGE = {
247249 // Character: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9
248250 /* Roman */ {'\u0041' , '\u0042' , '\u0043' , '\u0044' , '\u0045' , '\u0046' , '\u0047' , '\u0048' , '\u0049' , '\u004a' , '\u004b' , '\u004c' , '\u004d' , '\u004e' , '\u004f' , '\u0050' , '\u0051' , '\u0052' , '\u0053' , '\u0054' , '\u0055' , '\u0056' , '\u0057' , '\u0058' , '\u0059' , '\u005a' , '\u0030' , '\u0031' , '\u0032' , '\u0033' , '\u0034' , '\u0035' , '\u0036' , '\u0037' , '\u0038' , '\u0039' }, // Roman
249251 /* Greek */ {'\u0391' , '\u0392' , '\u039e' , '\u0394' , '\u0388' , '\u0395' , '\u0393' , '\u0397' , '\u0399' , '\u03a0' , '\u039a' , '\u039b' , '\u039c' , '\u039d' , '\u039f' , '\u03a1' , '\u0398' , '\u03a8' , '\u03a3' , '\u03a4' , '\u0389' , '\u03a6' , '\u03a9' , '\u03a7' , '\u03a5' , '\u0396' , '\u0030' , '\u0031' , '\u0032' , '\u0033' , '\u0034' , '\u0035' , '\u0036' , '\u0037' , '\u0038' , '\u0039' }, // Greek
@@ -274,8 +276,10 @@ public Unicode2Ascii(final char min, final char max, @Nonnull final String conve
274276 /* Kannada */ {'\u0C92' , '\u0C95' , '\u0C96' , '\u0C97' , '\u0C8E' , '\u0C99' , '\u0C9A' , '\u0C9B' , '\u0C85' , '\u0C9C' , '\u0CA0' , '\u0CA1' , '\u0CA3' , '\u0CA4' , '\u0C89' , '\u0CA6' , '\u0CA7' , '\u0CA8' , '\u0CAA' , '\u0CAB' , '\u0C87' , '\u0CAC' , '\u0CAD' , '\u0CB0' , '\u0CB2' , '\u0CB5' , '\u0030' , '\u0031' , '\u0032' , '\u0033' , '\u0034' , '\u0035' , '\u0036' , '\u0037' , '\u0038' , '\u0039' }, // Kannada
275277 /* Gujarati */ {'\u0AB3' , '\u0A97' , '\u0A9C' , '\u0AA1' , '\u0A87' , '\u0AA6' , '\u0AAC' , '\u0A95' , '\u0A8F' , '\u0A9A' , '\u0A9F' , '\u0AA4' , '\u0AAA' , '\u0AA0' , '\u0A8D' , '\u0AB0' , '\u0AB5' , '\u0A9E' , '\u0AAE' , '\u0AAB' , '\u0A89' , '\u0AB7' , '\u0AA8' , '\u0A9D' , '\u0AA2' , '\u0AAD' , '\u0030' , '\u0031' , '\u0032' , '\u0033' , '\u0034' , '\u0035' , '\u0036' , '\u0037' , '\u0038' , '\u0039' } // Gujarati
276278 };
279+ // @formatter:on
277280
278- private final static Unicode2Ascii [] UNICODE2ASCII = {
281+ // @formatter:off
282+ @ SuppressWarnings ("LongLine" ) private final static Unicode2Ascii [] UNICODE2ASCII = {
279283 /* Roman */ new Unicode2Ascii ('\u0041' , '\u005a' , "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ), // Roman
280284 /* Greek */ new Unicode2Ascii ('\u0388' , '\u03a9' , "EU???????ABGDFZHQIKLMNCOJP?STYVXRW" ), // Greek
281285 /* Cyrillic */ new Unicode2Ascii ('\u0410' , '\u042f' , "AZBGDEFNI?KLMHOJPCTYQXSVW????U?R" ), // Cyrillic
@@ -322,6 +326,7 @@ public Unicode2Ascii(final char min, final char max, @Nonnull final String conve
322326 /* Georgian */ new Unicode2Ascii ('\u10d0' , '\u10ef' , "AB?CE?D?UF?GHOJ?KLMINPQRSTVW?XYZ" ),
323327 /* Armenian */ new Unicode2Ascii ('\u0562' , '\u0586' , "BCDE??FGHI?J?KLM?N?U?PQ?R??STVWXYZ?OA" )
324328 };
329+ // @formatter:on
325330
326331 @ Nonnull
327332 private static MapcodeZone decodeGrid (
@@ -981,19 +986,25 @@ private static String convertFromAbjad(@Nonnull final String mapcode) {
981986 } else if (form == 35 ) {
982987 final int c = ((DECODE_CHARS [(int ) s .charAt (2 )] * 8 ) + (DECODE_CHARS [(int ) s .charAt (6 )] - 18 ));
983988 if ((c >= 32 ) && (c < 63 )) {
984- newstr = s .substring (0 , 2 ) + Data .ENCODE_CHARS [c - 32 ] + s .charAt (4 ) + '.' + s .charAt (5 ) + s .charAt (7 ) + s .charAt (8 );
989+ newstr = s .substring (0 , 2 ) + Data .ENCODE_CHARS [c - 32 ] + s .charAt (4 ) + '.' + s .charAt (5 ) + s .charAt (7 ) +
990+ s .charAt (8 );
985991 } else if ((c >= 0 ) && (c < 31 )) {
986- newstr = s .substring (0 , 2 ) + Data .ENCODE_CHARS [c ] + '.' + s .charAt (4 ) + s .charAt (5 ) + s .charAt (7 ) + s .charAt (8 );
992+ newstr = s .substring (0 , 2 ) + Data .ENCODE_CHARS [c ] + '.' + s .charAt (4 ) + s .charAt (5 ) + s .charAt (7 ) +
993+ s .charAt (8 );
987994 }
988995 } else if (form == 45 ) {
989- final int c = (DECODE_CHARS [(int ) s .charAt (2 )] * 100 ) + (DECODE_CHARS [(int ) s .charAt (5 )] * 10 ) + (DECODE_CHARS [(int ) s .charAt (8 )] - 39 );
996+ final int c = (DECODE_CHARS [(int ) s .charAt (2 )] * 100 ) + (DECODE_CHARS [(int ) s .charAt (5 )] * 10 ) +
997+ (DECODE_CHARS [(int ) s .charAt (8 )] - 39 );
990998 if ((c >= 0 ) && (c < 961 )) {
991- newstr = s .substring (0 , 2 ) + Data .ENCODE_CHARS [c / 31 ] + s .charAt (3 ) + '.' + s .charAt (6 ) + s .charAt (7 ) + s .charAt (9 ) + Data .ENCODE_CHARS [c % 31 ];
999+ newstr = s .substring (0 , 2 ) + Data .ENCODE_CHARS [c / 31 ] + s .charAt (3 ) + '.' + s .charAt (6 ) + s .charAt (7 ) +
1000+ s .charAt (9 ) + Data .ENCODE_CHARS [c % 31 ];
9921001 }
9931002 } else if (form == 55 ) {
994- final int c = (DECODE_CHARS [(int ) s .charAt (2 )] * 100 ) + (DECODE_CHARS [(int ) s .charAt (6 )] * 10 ) + (DECODE_CHARS [(int ) s .charAt (9 )] - 39 );
1003+ final int c = (DECODE_CHARS [(int ) s .charAt (2 )] * 100 ) + (DECODE_CHARS [(int ) s .charAt (6 )] * 10 ) +
1004+ (DECODE_CHARS [(int ) s .charAt (9 )] - 39 );
9951005 if ((c >= 0 ) && (c < 961 )) {
996- newstr = s .substring (0 , 2 ) + Data .ENCODE_CHARS [c / 31 ] + s .charAt (3 ) + s .charAt (4 ) + '.' + s .charAt (7 ) + s .charAt (8 ) + s .charAt (10 ) + Data .ENCODE_CHARS [c % 31 ];
1006+ newstr = s .substring (0 , 2 ) + Data .ENCODE_CHARS [c / 31 ] + s .charAt (3 ) + s .charAt (4 ) + '.' + s .charAt (7 ) +
1007+ s .charAt (8 ) + s .charAt (10 ) + Data .ENCODE_CHARS [c % 31 ];
9971008 }
9981009 }
9991010
0 commit comments