Module jcifs

Class Config

java.lang.Object
org.codelibs.jcifs.smb.Config

public class Config extends Object
This class now contains only utilities for config parsing. We strongly suggest that you create an explicit CIFSContextWrapper with your desired config. It's base implementation BaseContext should be sufficient for most needs. If you want to retain the classic singleton behavior you can use SingletonContext.getInstance() witch is initialized using system properties.
  • Method Details

    • registerSmbURLHandler

      public static void registerSmbURLHandler()
      This static method registers the SMB URL protocol handler which is required to use SMB URLs with the java.net.URL class. If this method is not called before attempting to create an SMB URL with the URL class the following exception will occur:
       Exception MalformedURLException: unknown protocol: smb
           at java.net.URL.<init>(URL.java:480)
           at java.net.URL.<init>(URL.java:376)
           at java.net.URL.<init>(URL.java:330)
           at org.codelibs.jcifs.smb.impl.SmbFile.<init>(SmbFile.java:355)
           ...
       
    • getInt

      public static int getInt(Properties props, String key, int def)
      Retrieve an int. If the key does not exist or cannot be converted to an int, the provided default argument will be returned.
      Parameters:
      props - the properties to search in
      key - the property key to look up
      def - the default value to return if key is not found or cannot be parsed
      Returns:
      the integer value of the property or the default value
    • getInt

      public static int getInt(Properties props, String key)
      Retrieve an int. If the property is not found, -1 is returned.
      Parameters:
      props - the properties to search in
      key - the property key to look up
      Returns:
      the integer value of the property or -1 if not found
    • getLong

      public static long getLong(Properties props, String key, long def)
      Retrieve a long. If the key does not exist or cannot be converted to a long, the provided default argument will be returned.
      Parameters:
      props - the properties to search in
      key - the property key to look up
      def - the default value to return if key is not found or cannot be parsed
      Returns:
      the long value of the property or the default value
    • getInetAddress

      public static InetAddress getInetAddress(Properties props, String key, InetAddress def)
      Retrieve an InetAddress. If the address is not an IP address and cannot be resolved null will be returned.
      Parameters:
      props - the properties to search in
      key - the property key to look up
      def - the default value to return if key is not found or cannot be resolved
      Returns:
      the InetAddress for the property or the default value
    • getLocalHost

      public static InetAddress getLocalHost(Properties props)
      Get the local host address based on the provided properties.
      Parameters:
      props - the properties to use for configuration
      Returns:
      the local host InetAddress
    • getBoolean

      public static boolean getBoolean(Properties props, String key, boolean def)
      Retrieve a boolean value. If the property is not found, the value of def is returned.
      Parameters:
      props - the properties to search in
      key - the property key to look up
      def - the default value to return if key is not found
      Returns:
      the boolean value of the property or the default value
    • getInetAddressArray

      public static InetAddress[] getInetAddressArray(Properties props, String key, String delim, InetAddress[] def)
      Retrieve an array of InetAddress created from a property value containing a delim separated list of host names and/or ip addresses.
      Parameters:
      props - the properties to search in
      key - the property key to look up
      delim - the delimiter to use for splitting the property value
      def - the default value to return if key is not found
      Returns:
      an array of InetAddress objects or the default value