Class LanguageProfileReader


  • public class LanguageProfileReader
    extends java.lang.Object
    • Constructor Detail

      • LanguageProfileReader

        public LanguageProfileReader()
    • Method Detail

      • read

        public LanguageProfile read​(java.io.File profileFile)
                             throws java.io.IOException
        Reads a LanguageProfile from a File in UTF-8.
        Throws:
        java.io.IOException
      • read

        public LanguageProfile read​(java.io.InputStream inputStream)
                             throws java.io.IOException
        Reads a LanguageProfile from an InputStream in UTF-8.
        Throws:
        java.io.IOException
      • read

        public java.util.List<LanguageProfile> read​(java.lang.ClassLoader classLoader,
                                                    java.lang.String profileDirectory,
                                                    java.util.Collection<java.lang.String> profileFileNames)
                                             throws java.io.IOException
        Load profiles from the classpath in a specific directory.

        This is usually used to load built-in profiles, shipped with the jar.

        Parameters:
        classLoader - the ClassLoader to load the profiles from. Use MyClass.class.getClassLoader()
        profileDirectory - profile directory path inside the classpath. The default profiles are in "languages".
        profileFileNames - for example ["en", "fr", "de"].
        Throws:
        java.io.IOException
      • makePathForClassLoader

        private java.lang.String makePathForClassLoader​(java.lang.String profileDirectory,
                                                        java.lang.String fileName)
      • read

        public java.util.List<LanguageProfile> read​(java.util.Collection<java.lang.String> profileFileNames)
                                             throws java.io.IOException
        Same as read(ClassLoader, String, java.util.Collection) using the class loader of this class, and the default profiles directory of this library.
        Throws:
        java.io.IOException
      • readBuiltIn

        @NotNull
        public @NotNull LanguageProfile readBuiltIn​(@NotNull
                                                    @NotNull LdLocale locale)
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • makeProfileFileName

        @NotNull
        private @NotNull java.lang.String makeProfileFileName​(@NotNull
                                                              @NotNull LdLocale locale)
      • readBuiltIn

        @NotNull
        public @NotNull java.util.List<LanguageProfile> readBuiltIn​(@NotNull
                                                                    @NotNull java.util.Collection<LdLocale> languages)
                                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • readAll

        public java.util.List<LanguageProfile> readAll()
                                                throws java.io.IOException
        Deprecated.
        renamed to readAllBuiltIn()
        Throws:
        java.io.IOException
      • readAllBuiltIn

        public java.util.List<LanguageProfile> readAllBuiltIn()
                                                       throws java.io.IOException
        Reads all built-in language profiles from the "languages" folder (shipped with the jar).
        Throws:
        java.io.IOException
      • readAll

        public java.util.List<LanguageProfile> readAll​(java.io.File path)
                                                throws java.io.IOException
        Loads all profiles from the specified directory. Do not use this method for files distributed within a jar.
        Parameters:
        path - profile directory path
        Returns:
        empty if there is no language file in it.
        Throws:
        java.io.IOException
      • looksLikeLanguageProfileFile

        private boolean looksLikeLanguageProfileFile​(java.io.File file)
      • looksLikeLanguageProfileName

        private boolean looksLikeLanguageProfileName​(java.lang.String fileName)