Hello All,

I would like to work on this RFE.
This change is quite simple and gives greater value to the Character class.
The change can be done without breaking any existing code by adding
the following enums in the Character class.

   /**
    * An enum for all the GeneralCategory values. The ordinal values
for these enums are compatible with the
    * corresponding byte values as returned by the getType method.
    * @since  1.7
    */
    public enum GeneralCategory {
        /**
         * General category "Cn" in the Unicode specification.
         * @since   1.7
         */
             UNASSIGNED("Cn"),//                  = 0;

        /**
         * General category "Lu" in the Unicode specification.
         * @since   1.7
         */
             UPPERCASE_LETTER("Lu"),//            = 1;

        /**
         * General category "Ll" in the Unicode specification.
         * @since   1.7
         */
             LOWERCASE_LETTER("Ll"),//            = 2;

        /**
         * General category "Lt" in the Unicode specification.
         * @since   1.7
         */
             TITLECASE_LETTER("Lt"),//            = 3;

        /**
         * General category "Lm" in the Unicode specification.
         * @since   1.7
         */
             MODIFIER_LETTER("Lm"),//             = 4;

        /**
         * General category "Lo" in the Unicode specification.
         * @since   1.7
         */
             OTHER_LETTER("Lo"),//                = 5;

        /**
         * General category "Mn" in the Unicode specification.
         * @since   1.7
         */
             NON_SPACING_MARK("Mn"),//            = 6;

        /**
         * General category "Me" in the Unicode specification.
         * @since   1.7
         */
             ENCLOSING_MARK("Me"),//              = 7;

        /**
         * General category "Mc" in the Unicode specification.
         * @since   1.7
         */
             COMBINING_SPACING_MARK("Mc"),//      = 8;

        /**
         * General category "Nd" in the Unicode specification.
         * @since   1.7
         */
             DECIMAL_DIGIT_NUMBER("Nd"),//        = 9;

        /**
         * General category "Nl" in the Unicode specification.
         * @since   1.7
         */
             LETTER_NUMBER("Nl"),//               = 10;

        /**
         * General category "No" in the Unicode specification.
         * @since   1.7
         */
             OTHER_NUMBER("No"),//                = 11;

        /**
         * General category "Zs" in the Unicode specification.
         * @since   1.7
         */
             SPACE_SEPARATOR("Zs"),//             = 12;

        /**
         * General category "Zl" in the Unicode specification.
         * @since   1.7
         */
             LINE_SEPARATOR("Zl"),//              = 13;

        /**
         * General category "Zp" in the Unicode specification.
         * @since   1.7
         */
             PARAGRAPH_SEPARATOR("Zp"),//         = 14;

        /**
         * General category "Cc" in the Unicode specification.
         * @since   1.7
         */
             CONTROL("Cc"),//                     = 15;

        /**
         * General category "Cf" in the Unicode specification.
         * @since   1.7
         */
             FORMAT("Cf"),//                      = 16;

             /**
              * Filler
              * @since   1.7
              */
                  UNKNOWN(null),//                      = 17;

        /**
         * General category "Co" in the Unicode specification.
         * @since   1.7
         */
             PRIVATE_USE("Co"),//                 = 18;

        /**
         * General category "Cs" in the Unicode specification.
         * @since   1.7
         */
             SURROGATE("Cs"),//                   = 19;

        /**
         * General category "Pd" in the Unicode specification.
         * @since   1.7
         */
             DASH_PUNCTUATION("Pd"),//            = 20;

        /**
         * General category "Ps" in the Unicode specification.
         * @since   1.7
         */
             START_PUNCTUATION("Ps"),//           = 21;

        /**
         * General category "Pe" in the Unicode specification.
         * @since   1.7
         */
             END_PUNCTUATION("Pe"),//             = 22;

        /**
         * General category "Pc" in the Unicode specification.
         * @since   1.7
         */
             CONNECTOR_PUNCTUATION("Pc"),//       = 23;

        /**
         * General category "Po" in the Unicode specification.
         * @since   1.7
         */
             OTHER_PUNCTUATION("Po"),//           = 24;

        /**
         * General category "Sm" in the Unicode specification.
         * @since   1.7
         */
             MATH_SYMBOL("Sm"),//                 = 25;

        /**
         * General category "Sc" in the Unicode specification.
         * @since   1.7
         */
             CURRENCY_SYMBOL("Sc"),//             = 26;

        /**
         * General category "Sk" in the Unicode specification.
         * @since   1.7
         */
             MODIFIER_SYMBOL("Sk"),//             = 27;

        /**
         * General category "So" in the Unicode specification.
         * @since   1.7
         */
             OTHER_SYMBOL("So"),//                = 28;

        /**
         * General category "Pi" in the Unicode specification.
         * @since   1.7
         */
             INITIAL_QUOTE_PUNCTUATION("Pi"),//   = 29;

        /**
         * General category "Pf" in the Unicode specification.
         * @since   1.7
         */
             FINAL_QUOTE_PUNCTUATION("Pf"),//     = 30;
             ;
             /**
              * The abbreviated name of the general category as
available from the UCD.
              *
              */
             private String abbreviatedName;
             /**
              * The constructor requires the abbreviated name as parameter
              * @param abbrName - abreviated Name for the general category
              *
              */
             private GeneralCategory(String abbrName) {
                 this.abbreviatedName = abbrName;
             }
             /**
              * This method returns the abbreviated name for the
general category represented by this instance.
              * @return - abbreviated name for the general category.
              */
             public String getAbbreviatedName() {
                 return abbreviatedName;
             }
    }


   /**
    * An enum for all the Directionality values. The ordinal values
for these enums are compatible with the
    * corresponding byte values as returned by the getDirectionality method.
    */

    public enum Directionality {
        /**
         * Strong bidirectional character type "L" in the Unicode specification.
         * @since 1.4
         */
        DIRECTIONALITY_LEFT_TO_RIGHT("L"),// = 0;

        /**
         * Strong bidirectional character type "R" in the Unicode specification.
         * @since 1.4
         */
        DIRECTIONALITY_RIGHT_TO_LEFT("R"),// = 1;

        /**
        * Strong bidirectional character type "AL" in the Unicode specification.
         * @since 1.4
         */
        DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC("AL"),// = 2;

        /**
         * Weak bidirectional character type "EN" in the Unicode specification.
         * @since 1.4
         */
        DIRECTIONALITY_EUROPEAN_NUMBER("EN"),// = 3;

        /**
         * Weak bidirectional character type "ES" in the Unicode specification.
         * @since 1.4
         */
        DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR("ES"),// = 4;

        /**
         * Weak bidirectional character type "ET" in the Unicode specification.
         * @since 1.4
         */
        DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR("ET"),// = 5;

        /**
         * Weak bidirectional character type "AN" in the Unicode specification.
         * @since 1.4
         */
        DIRECTIONALITY_ARABIC_NUMBER("AN"),// = 6;

        /**
         * Weak bidirectional character type "CS" in the Unicode specification.
         * @since 1.4
         */
        DIRECTIONALITY_COMMON_NUMBER_SEPARATOR("CS"),// = 7;

        /**
         * Weak bidirectional character type "NSM" in the Unicode specification.
         * @since 1.4
         */
        DIRECTIONALITY_NONSPACING_MARK("NSM"),// = 8;

        /**
         * Weak bidirectional character type "BN" in the Unicode specification.
         * @since 1.4
         */
        DIRECTIONALITY_BOUNDARY_NEUTRAL("BN"),// = 9;

        /**
         * Neutral bidirectional character type "B" in the Unicode
specification.
         * @since 1.4
         */
        DIRECTIONALITY_PARAGRAPH_SEPARATOR("B"),// = 10;

        /**
         * Neutral bidirectional character type "S" in the Unicode
specification.
         * @since 1.4
         */
        DIRECTIONALITY_SEGMENT_SEPARATOR("S"),// = 11;

        /**
         * Neutral bidirectional character type "WS" in the Unicode
specification.
         * @since 1.4
         */
        DIRECTIONALITY_WHITESPACE("WS"),// = 12;

        /**
         * Neutral bidirectional character type "ON" in the Unicode
specification.
         * @since 1.4
         */
        DIRECTIONALITY_OTHER_NEUTRALS("ON"),// = 13;

        /**
         * Strong bidirectional character type "LRE" in the Unicode
specification.
         * @since 1.4
         */
        DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING("LRE"),// = 14;

        /**
         * Strong bidirectional character type "LRO" in the Unicode
specification.
         * @since 1.4
         */
        DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE("LRO"),// = 15;

        /**
         * Strong bidirectional character type "RLE" in the Unicode
specification.
         * @since 1.4
         */
        DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING("RLE"),// = 16;

        /**
         * Strong bidirectional character type "RLO" in the Unicode
specification.
         * @since 1.4
         */
        DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE("RLO"),// = 17;

        /**
         * Weak bidirectional character type "PDF" in the Unicode specification.
         * @since 1.4
         */
        DIRECTIONALITY_POP_DIRECTIONAL_FORMAT("PDF"),// = 18;
        ;
        /**
         * The abbreviated name of the general category as available
from the UCD.
         *
         */
        private String abbreviatedName;
        /**
         * The constructor requires the abbreviated name as parameter
         * @param abbrName - abreviated Name for the directionality
         *
         */
        private Directionality(String abbrName) {
            this.abbreviatedName = abbrName;
        }
        /**
         * This method returns the abbreviated name for the
directionality represented by this instance.
         * @return - abbreviated name for the directionality.
         */
        public String getAbbreviatedName() {
            return abbreviatedName;
        }
}

Also the following methods can be added

/**
  *
  * @ returns - The general category for the unicode code point
  */
    public static GeneralCategory getGeneralCategory(int codePoint) {
        return GeneralCategory.values()[getType(codePoint)];
    }

/**
  *
  * @ returns - The directionality for the unicode code point
  */
    public static Directionality getDirectionalityOf(int codePoint) {
        return Directionality.values()[getDirectionality(codePoint)];
    }

Reply via email to