Class Configuration


  • public class Configuration
    extends java.lang.Object
    Provides access to configuration values.
    Since:
    2.4
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String JLINE_CONFIGURATION
      System property which can point to a file or URL containing configuration properties to load.
      static java.lang.String JLINE_RC
      Default configuration file name loaded from user's home directory.
      private static java.util.Properties properties  
    • Constructor Summary

      Constructors 
      Constructor Description
      Configuration()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.net.URL determineUrl()  
      (package private) static java.lang.String extractEncodingFromCtype​(java.lang.String ctype)
      Parses the LC_CTYPE value to extract the encoding according to the POSIX standard, which says that the LC_CTYPE environment variable may be of the format [language[_territory][.codeset][@modifier]]
      static boolean getBoolean​(java.lang.String name)  
      static boolean getBoolean​(java.lang.String name, boolean defaultValue)  
      static java.lang.String getEncoding()
      Get the default encoding.
      static java.lang.String getFileEncoding()  
      static int getInteger​(java.lang.String name, int defaultValue)  
      static java.lang.String getLineSeparator()  
      static long getLong​(java.lang.String name, long defaultValue)  
      static java.lang.String getOsName()  
      static java.util.Properties getProperties()  
      static java.lang.String getString​(java.lang.String name)  
      static java.lang.String getString​(java.lang.String name, java.lang.String defaultValue)  
      static java.io.File getUserHome()  
      private static java.util.Properties initProperties()  
      static boolean isHpux()  
      static boolean isWindows()  
      private static void loadProperties​(java.net.URL url, java.util.Properties props)  
      static void reset()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • JLINE_CONFIGURATION

        public static final java.lang.String JLINE_CONFIGURATION
        System property which can point to a file or URL containing configuration properties to load.
        Since:
        2.7
        See Also:
        Constant Field Values
      • JLINE_RC

        public static final java.lang.String JLINE_RC
        Default configuration file name loaded from user's home directory.
        See Also:
        Constant Field Values
      • properties

        private static volatile java.util.Properties properties
    • Constructor Detail

      • Configuration

        public Configuration()
    • Method Detail

      • initProperties

        private static java.util.Properties initProperties()
      • loadProperties

        private static void loadProperties​(java.net.URL url,
                                           java.util.Properties props)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • determineUrl

        private static java.net.URL determineUrl()
      • reset

        public static void reset()
        Since:
        2.7
      • getProperties

        public static java.util.Properties getProperties()
        Since:
        2.7
      • getString

        public static java.lang.String getString​(java.lang.String name,
                                                 java.lang.String defaultValue)
      • getString

        public static java.lang.String getString​(java.lang.String name)
      • getBoolean

        public static boolean getBoolean​(java.lang.String name)
      • getBoolean

        public static boolean getBoolean​(java.lang.String name,
                                         boolean defaultValue)
      • getInteger

        public static int getInteger​(java.lang.String name,
                                     int defaultValue)
        Since:
        2.6
      • getLong

        public static long getLong​(java.lang.String name,
                                   long defaultValue)
        Since:
        2.6
      • getLineSeparator

        public static java.lang.String getLineSeparator()
        Since:
        2.7
      • getUserHome

        public static java.io.File getUserHome()
      • getOsName

        public static java.lang.String getOsName()
      • isWindows

        public static boolean isWindows()
        Since:
        2.7
      • isHpux

        public static boolean isHpux()
      • getFileEncoding

        public static java.lang.String getFileEncoding()
      • getEncoding

        public static java.lang.String getEncoding()
        Get the default encoding. Will first look at the LC_ALL, LC_CTYPE, and LANG environment variables, then the input.encoding system property, then the default charset according to the JVM.
        Returns:
        The default encoding to use when none is specified.
      • extractEncodingFromCtype

        static java.lang.String extractEncodingFromCtype​(java.lang.String ctype)
        Parses the LC_CTYPE value to extract the encoding according to the POSIX standard, which says that the LC_CTYPE environment variable may be of the format [language[_territory][.codeset][@modifier]]
        Parameters:
        ctype - The ctype to parse, may be null
        Returns:
        The encoding, if one was present, otherwise null