Class StaticUnicodeSets


  • public class StaticUnicodeSets
    extends java.lang.Object
    This class statically initializes UnicodeSets, originally built for number parsing. Microbenchmarks show this to bring a very sizeable performance boost. IMPORTANT ASSUMPTION FOR NUMBER PARSING: All of the sets contain code points (no strings) and they are all case-folded. If this assumption were ever broken, logic in classes such as SymbolMatcher would need to be updated in order to return well-formed sets upon calls to getLeadCodePoints().
    • Constructor Detail

      • StaticUnicodeSets

        public StaticUnicodeSets()
    • Method Detail

      • get

        public static UnicodeSet get​(StaticUnicodeSets.Key key)
        Gets the static-allocated UnicodeSet according to the provided key.
        Parameters:
        key - The desired UnicodeSet according to the enum in this file.
        Returns:
        The requested UnicodeSet. Guaranteed to be frozen and non-null, but may be empty if an error occurred during data loading.
      • chooseFrom

        public static StaticUnicodeSets.Key chooseFrom​(java.lang.String str,
                                                       StaticUnicodeSets.Key key1)
        Checks if the UnicodeSet given by key1 contains the given string.
        Parameters:
        str - The string to check.
        key1 - The set to check.
        Returns:
        key1 if the set contains str, or COUNT if not.
      • chooseFrom

        public static StaticUnicodeSets.Key chooseFrom​(java.lang.String str,
                                                       StaticUnicodeSets.Key key1,
                                                       StaticUnicodeSets.Key key2)
        Checks if the UnicodeSet given by either key1 or key2 contains the string. Exported as U_COMMON_API for numparse_decimal.cpp
        Parameters:
        str - The string to check.
        key1 - The first set to check.
        key2 - The second set to check.
        Returns:
        key1 if that set contains str; key2 if that set contains str; or COUNT if neither set contains str.
      • chooseCurrency

        public static StaticUnicodeSets.Key chooseCurrency​(java.lang.String str)
        Looks through all Currency-related sets for the given string, returning the first match or null if no match was round.
      • saveSet

        private static void saveSet​(StaticUnicodeSets.Key key,
                                    java.lang.String unicodeSetPattern)