BlackenCodePoints { public static String getName(int codepoint) { createShortMap(); if (shortMap.containsKey(codepoint)) { return shortMap.get(codepoint); } String name = Character.getName(codepoint); name = "CODEPOINT_" + name.replaceAll("[ ()-]+", "_"); try { BlackenCodePoints.class.getDeclaredField(name); } catch (NoSuchFieldException | SecurityException ex) { name = null; } return name; }  static String getCodepointName(int codepoint); static String getName(int codepoint); static String asString(int codepoint); @LongName("NULL")
    static final public int CODEPOINT_NUL; @LongName("START OF HEADING")
    static final public int CODEPOINT_SOH; @LongName("START OF TEXT")
    static final public int CODEPOINT_STX; @LongName("END OF TEXT")
    static final public int CODEPOINT_ETX; @LongName("END OF TRANSMISSION")
    static final public int CODEPOINT_EOT; @LongName("ENQUIRY")
    static final public int CODEPOINT_ENQ; @LongName("ACKNOWLEDGE")
    static final public int CODEPOINT_ACK; @LongName("BELL")
    static final public int CODEPOINT_BEL; @LongName("BACKSPACE")
    static final public int CODEPOINT_BS; @LongName("CHARACTER TABULATION")
    static final public int CODEPOINT_HT; @LongName("LINE FEED (LF)")
    static final public int CODEPOINT_LF; @LongName("LINE TABULATION")
    static final public int CODEPOINT_VT; @LongName("FORM FEED (FF)")
    static final public int CODEPOINT_FF; @LongName("CARRIAGE RETURN (CR)")
    static final public int CODEPOINT_CR; @LongName("SHIFT OUT")
    static final public int CODEPOINT_SO; @LongName("SHIFT IN")
    static final public int CODEPOINT_SI; @LongName("DATA LINK ESCAPE")
    static final public int CODEPOINT_DLE; @LongName("DEVICE CONTROL ONE")
    static final public int CODEPOINT_DC1; @LongName("DEVICE CONTROL TWO")
    static final public int CODEPOINT_DC2; @LongName("DEVICE CONTROL THREE")
    static final public int CODEPOINT_DC3; @LongName("DEVICE CONTROL FOUR")
    static final public int CODEPOINT_DC4; @LongName("NEGATIVE ACKNOWLEDGE")
    static final public int CODEPOINT_NAK; @LongName("SYNCHRONOUS IDLE")
    static final public int CODEPOINT_SYN; @LongName("END OF TRANSMISSION BLOCK")
    static final public int CODEPOINT_ETB; @LongName("CANCEL")
    static final public int CODEPOINT_CAN; @LongName("END OF MEDIUM")
    static final public int CODEPOINT_EM; @LongName("SUBSTITUTE")
    static final public int CODEPOINT_SUB; @LongName("ESCAPE")
    static final public int CODEPOINT_ESC; @LongName("INFORMATION SEPARATOR FOUR")
    static final public int CODEPOINT_FS; @LongName("INFORMATION SEPARATOR THREE")
    static final public int CODEPOINT_GS; @LongName("INFORMATION SEPARATOR TWO")
    static final public int CODEPOINT_RS; @LongName("INFORMATION SEPARATOR ONE")
    static final public int CODEPOINT_US; static final public int CODEPOINT_SPACE; @LongName("SPACE")
    static final public int CODEPOINT_SP; @LongName("DELETE")
    static final public int CODEPOINT_DEL; @LongName("LATIN 1 SUPPLEMENT 80")
    static final public int CODEPOINT_PAD; @LongName("LATIN 1 SUPPLEMENT 81")
    static final public int CODEPOINT_HOP; @LongName("BREAK PERMITTED HERE")
    static final public int CODEPOINT_SPH; @LongName("NO BREAK HERE")
    static final public int CODEPOINT_NBH; @LongName("LATIN 1 SUPPLEMENT 84")
    static final public int CODEPOINT_IND; @LongName("NEXT LINE (NEL)")
    static final public int CODEPOINT_NEL; @LongName("START OF SELECTED AREA")
    static final public int CODEPOINT_SSA; @LongName("END OF SELECTED AREA")
    static final public int CODEPOINT_ESA; @LongName("CHARACTER TABULATION SET")
    static final public int CODEPOINT_HTS; @LongName("CHARACTER TABULATION WITH JUSTIFICATION")
    static final public int CODEPOINT_HTJ; @LongName("LINE TABULATION SET")
    static final public int CODEPOINT_VTS; @LongName("PARTIAL LINE FORWARD")
    static final public int CODEPOINT_PLD; @LongName("PARTIAL LINE BACKWARD")
    static final public int CODEPOINT_PLU; @LongName("REVERSE LINE FEED")
    static final public int CODEPOINT_RI; @LongName("SINGLE SHIFT TWO")
    static final public int CODEPOINT_SS2; @LongName("SINGLE SHIFT THREE")
    static final public int CODEPOINT_SS3; @LongName("DEVICE CONTROL STRING")
    static final public int CODEPOINT_DCS; @LongName("PRIVATE USE ONE")
    static final public int CODEPOINT_PU1; @LongName("PRIVATE USE TWO")
    static final public int CODEPOINT_PU2; @LongName("SET TRANSMIT STATE")
    static final public int CODEPOINT_STS; @LongName("CANCEL CHARACTER")
    static final public int CODEPOINT_CCH; @LongName("MESSAGE WAITING")
    static final public int CODEPOINT_MW; @LongName("START OF GUARDED AREA")
    static final public int CODEPOINT_SPA; @LongName("END OF GUARDED AREA")
    static final public int CODEPOINT_EPA; @LongName("START OF STRING")
    static final public int CODEPOINT_SOS; @LongName("LATIN 1 SUPPLEMENT 99")
    static final public int CODEPOINT_SGCI; @LongName("SINGLE CHARACTER INTRODUCER")
    static final public int CODEPOINT_SCI; @LongName("CONTROL SEQUENCE INTRODUCER")
    static final public int CODEPOINT_CSI; @LongName("STRING TERMINATOR")
    static final public int CODEPOINT_ST; @LongName("OPERATING SYSTEM COMMAND")
    static final public int CODEPOINT_OSC; @LongName("PRIVACY MESSAGE")
    static final public int CODEPOINT_PM; @LongName("APPLICATION PROGRAM COMMAND")
    static final public int CODEPOINT_APC; @LongName("NO-BREAK SPACE")
    static final public int CODEPOINT_NBSP; static final public int CODEPOINT_COMBINING_GRAVE_ACCENT; static final public int CODEPOINT_COMBINING_ACUTE_ACCENT; static final public int CODEPOINT_COMBINING_CIRCUMFLEX_ACCENT; static final public int CODEPOINT_COMBINING_TILDE; static final public int CODEPOINT_COMBINING_MACRON; static final public int CODEPOINT_COMBINING_OVERLINE; static final public int CODEPOINT_COMBINING_BREVE; static final public int CODEPOINT_COMBINING_DOT_ABOVE; static final public int CODEPOINT_COMBINING_DIAERESIS; static final public int CODEPOINT_COMBINING_HOOK_ABOVE; static final public int CODEPOINT_COMBINING_RING_ABOVE; static final public int CODEPOINT_COMBINING_DOUBLE_ACUTE_ACCENT; static final public int CODEPOINT_COMBINING_CARON; static final public int CODEPOINT_COMBINING_VERTICAL_LINE_ABOVE; static final public int CODEPOINT_COMBINING_DOUBLE_VERTICAL_LINE_ABOVE; static final public int CODEPOINT_COMBINING_DOUBLE_GRAVE_ACCENT; static final public int CODEPOINT_COMBINING_CANDRABINDU; static final public int CODEPOINT_COMBINING_INVERTED_BREVE; static final public int CODEPOINT_COMBINING_TURNED_COMMA_ABOVE; static final public int CODEPOINT_COMBINING_COMMA_ABOVE; static final public int CODEPOINT_COMBINING_REVERSED_COMMA_ABOVE; static final public int CODEPOINT_COMBINING_COMMA_ABOVE_RIGHT; static final public int CODEPOINT_COMBINING_GRAVE_ACCENT_BELOW; static final public int CODEPOINT_COMBINING_ACUTE_ACCENT_BELOW; static final public int CODEPOINT_COMBINING_LEFT_TACK_BELOW; static final public int CODEPOINT_COMBINING_RIGHT_TACK_BELOW; static final public int CODEPOINT_COMBINING_LEFT_ANGLE_ABOVE; static final public int CODEPOINT_COMBINING_HORN; static final public int CODEPOINT_COMBINING_LEFT_HALF_RING_BELOW; static final public int CODEPOINT_COMBINING_UP_TACK_BELOW; static final public int CODEPOINT_COMBINING_DOWN_TACK_BELOW; static final public int CODEPOINT_COMBINING_PLUS_SIGN_BELOW; static final public int CODEPOINT_COMBINING_MINUS_SIGN_BELOW; static final public int CODEPOINT_COMBINING_PALATALIZED_HOOK_BELOW; static final public int CODEPOINT_COMBINING_RETROFLEX_HOOK_BELOW; static final public int CODEPOINT_COMBINING_DOT_BELOW; static final public int CODEPOINT_COMBINING_DIAERESIS_BELOW; static final public int CODEPOINT_COMBINING_RING_BELOW; static final public int CODEPOINT_COMBINING_COMMA_BELOW; static final public int CODEPOINT_COMBINING_CEDILLA; static final public int CODEPOINT_COMBINING_OGONEK; static final public int CODEPOINT_COMBINING_GREEK_YPOGEGRAMMENI; static final public int CODEPOINT_DAGGER; static final public int CODEPOINT_DOUBLE_DAGGER; static final public int CODEPOINT_BULLET; static final public int CODEPOINT_TRIANGULAR_BULLET; static final public int CODEPOINT_ONE_DOT_LEADER; static final public int CODEPOINT_TWO_DOT_LEADER; static final public int CODEPOINT_HORIZONTAL_ELLIPSIS; static final public int CODEPOINT_HYPHENATION_POINT; static final public int CODEPOINT_LIGHT_SHADE; static final public int CODEPOINT_MEDIUM_SHADE; static final public int CODEPOINT_DARK_SHADE; static final public int CODEPOINT_BLACK_SQUARE; static final public int CODEPOINT_WHITE_SQUARE; static final public int CODEPOINT_BLACK_SMALL_SQUARE; static final public int CODEPOINT_WHITE_SMALL_SQUARE; static final public int CODEPOINT_BOX_DRAWINGS_LIGHT_HORIZONTAL; static final public int CODEPOINT_BOX_DRAWINGS_HEAVY_HORIZONTAL; static final public int CODEPOINT_BOX_DRAWINGS_LIGHT_VERTICAL; static final public int CODEPOINT_BOX_DRAWINGS_HEAVY_VERTICAL; static final public int CODEPOINT_BOX_DRAWINGS_LIGHT_TRIPLE_DASH_HORIZONTAL; static final public int CODEPOINT_BOX_DRAWINGS_HEAVY_TRIPLE_DASH_HORIZONTAL; static final public int CODEPOINT_BOX_DRAWINGS_LIGHT_TRIPLE_DASH_VERTICAL; static final public int CODEPOINT_BOX_DRAWINGS_HEAVY_TRIPLE_DASH_VERTICAL; static final public int CODEPOINT_BOX_DRAWINGS_LIGHT_QUADRUPLE_DASH_HORIZONTAL; static final public int CODEPOINT_BOX_DRAWINGS_HEAVY_QUADRUPLE_DASH_HORIZONTAL; static final public int CODEPOINT_BOX_DRAWINGS_LIGHT_QUADRUPLE_DASH_VERTICAL; static final public int CODEPOINT_BOX_DRAWINGS_HEAVY_QUADRUPLE_DASH_VERTICAL; static final public int CODEPOINT_BOX_DRAWINGS_LIGHT_DOWN_AND_RIGHT; static final public int CODEPOINT_BOX_DRAWINGS_DOWN_LIGHT_AND_RIGHT_HEAVY; static final public int CODEPOINT_BOX_DRAWINGS_DOWN_HEAVY_AND_RIGHT_LIGHT; static final public int CODEPOINT_BOX_DRAWINGS_HEAVY_DOWN_AND_RIGHT; static final public int CODEPOINT_BOX_DRAWINGS_LIGHT_DOWN_AND_LEFT; static final public int CODEPOINT_BOX_DRAWINGS_DOWN_LIGHT_AND_LEFT_HEAVY; static final public int CODEPOINT_BOX_DRAWINGS_DOWN_HEAVY_AND_LEFT_LIGHT; static final public int CODEPOINT_BOX_DRAWINGS_HEAVY_DOWN_AND_LEFT; static final public int CODEPOINT_BOX_DRAWINGS_LIGHT_UP_AND_RIGHT; static final public int CODEPOINT_BOX_DRAWINGS_UP_LIGHT_AND_RIGHT_HEAVY; static final public int CODEPOINT_BOX_DRAWINGS_UP_HEAVY_AND_RIGHT_LIGHT; static final public int CODEPOINT_BOX_DRAWINGS_HEAVY_UP_AND_RIGHT; static final public int CODEPOINT_BOX_DRAWINGS_LIGHT_UP_AND_LEFT; static final public int CODEPOINT_BOX_DRAWINGS_UP_LIGHT_AND_LEFT_HEAVY; static final public int CODEPOINT_BOX_DRAWINGS_UP_HEAVY_AND_LEFT_LIGHT; static final public int CODEPOINT_BOX_DRAWINGS_HEAVY_UP_AND_LEFT; static final public int CODEPOINT_BOX_DRAWINGS_LIGHT_DOUBLE_DASH_HORIZONTAL; static final public int CODEPOINT_BOX_DRAWINGS_HEAVY_DOUBLE_DASH_HORIZONTAL; static final public int CODEPOINT_BOX_DRAWINGS_LIGHT_DOUBLE_DASH_VERTICAL; static final public int CODEPOINT_BOX_DRAWINGS_HEAVY_DOUBLE_DASH_VERTICAL; static final public int CODEPOINT_BOX_DRAWINGS_DOUBLE_HORIZONTAL; static final public int CODEPOINT_BOX_DRAWINGS_DOUBLE_VERTICAL; static final public int CODEPOINT_BOX_DRAWINGS_DOWN_SINGLE_AND_RIGHT_DOUBLE; static final public int CODEPOINT_BOX_DRAWINGS_DOWN_DOUBLE_AND_RIGHT_SINGLE; static final public int CODEPOINT_BOX_DRAWINGS_DOUBLE_DOWN_AND_RIGHT; static final public int CODEPOINT_BOX_DRAWINGS_DOWN_SINGLE_AND_LEFT_DOUBLE; static final public int CODEPOINT_BOX_DRAWINGS_DOWN_DOUBLE_AND_LEFT_SINGLE; static final public int CODEPOINT_BOX_DRAWINGS_DOUBLE_DOWN_AND_LEFT; static final public int CODEPOINT_BOX_DRAWINGS_UP_SINGLE_AND_RIGHT_DOUBLE; static final public int CODEPOINT_BOX_DRAWINGS_UP_DOUBLE_AND_RIGHT_SINGLE; static final public int CODEPOINT_BOX_DRAWINGS_DOUBLE_UP_AND_RIGHT; static final public int CODEPOINT_BOX_DRAWINGS_UP_SINGLE_AND_LEFT_DOUBLE; static final public int CODEPOINT_BOX_DRAWINGS_UP_DOUBLE_AND_LEFT_SINGLE; static final public int CODEPOINT_BOX_DRAWINGS_DOUBLE_UP_AND_LEFT; static final public int CODEPOINT_BOX_DRAWINGS_LIGHT_LEFT; static final public int CODEPOINT_BOX_DRAWINGS_LIGHT_UP; static final public int CODEPOINT_BOX_DRAWINGS_LIGHT_RIGHT; static final public int CODEPOINT_BOX_DRAWINGS_LIGHT_DOWN; static final public int CODEPOINT_BOX_DRAWINGS_HEAVY_LEFT; static final public int CODEPOINT_BOX_DRAWINGS_HEAVY_UP; static final public int CODEPOINT_BOX_DRAWINGS_HEAVY_RIGHT; static final public int CODEPOINT_BOX_DRAWINGS_HEAVY_DOWN; static final public int CODEPOINT_BOX_DRAWINGS_LIGHT_LEFT_AND_HEAVY_RIGHT; static final public int CODEPOINT_BOX_DRAWINGS_LIGHT_UP_AND_HEAVY_DOWN; static final public int CODEPOINT_BOX_DRAWINGS_HEAVY_LEFT_AND_LIGHT_RIGHT; static final public int CODEPOINT_BOX_DRAWINGS_HEAVY_UP_AND_LIGHT_DOWN; static final public int CODEPOINT_DOTTED_CIRCLE; }
@Test public void testGetName() { StringBuilder buf = new StringBuilder(); for (Field f : BlackenCodePoints.class.getFields()) { String fieldname = f.getName(); if (fieldname.startsWith("CODEPOINT_")) { int codepoint = BlackenKeys.NO_KEY; try { codepoint = f.getInt(null); } catch (IllegalArgumentException | IllegalAccessException ex) { throw new RuntimeException(ex); } BlackenCodePoints.LongName longname = f.getAnnotation(BlackenCodePoints.LongName.class); String codepointname = Character.getName(codepoint); if (codepointname == null) { buf.append(String.format("Field %s has codepoint %s " + "which is UNDEFINED\n", fieldname, codepoint)); continue; } String found = BlackenCodePoints.getName(codepoint); if (fieldname.equals("CODEPOINT_SP") && found.equals("CODEPOINT_SPACE")) { continue; } if (longname != null) { if (!codepointname.equals(longname.value())) { buf.append(String.format("Field %s has LongName %s " + "which is different than expected (%s)\n", fieldname, longname.value(), codepointname)); } if (found == null || !found.equals(fieldname)) { buf.append(String.format("Field %s didn't return field" + " name; returned %s (codepoint: %s)\n", fieldname, found, codepointname)); } continue; } String expected = "CODEPOINT_" + codepointname.replaceAll("[ ()-]+", "_"); if (found == null || !found.equals(expected) || !found.equals(fieldname)) { buf.append(String.format( "Field %s; Unicode name: %s; Expected Field Name: %s; Returned Name: %s\n", fieldname, codepointname, expected, found)); } } } String msg = buf.toString(); if (!msg.isEmpty()) { msg = "Constants differ from expected value:\n" + msg; LOGGER.equals(msg); fail(msg); } }