java.lang.Object
org.codelibs.jcifs.smb.Config
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 Summary
Modifier and TypeMethodDescriptionstatic booleangetBoolean(Properties props, String key, boolean def) Retrieve a boolean value.static InetAddressgetInetAddress(Properties props, String key, InetAddress def) Retrieve anInetAddress.static InetAddress[]getInetAddressArray(Properties props, String key, String delim, InetAddress[] def) Retrieve an array ofInetAddresscreated from a property value containing adelimseparated list of host names and/or ip addresses.static intgetInt(Properties props, String key) Retrieve anint.static intgetInt(Properties props, String key, int def) Retrieve anint.static InetAddressgetLocalHost(Properties props) Get the local host address based on the provided properties.static longgetLong(Properties props, String key, long def) Retrieve along.static voidThis static method registers the SMB URL protocol handler which is required to use SMB URLs with thejava.net.URLclass.
-
Method Details
-
registerSmbURLHandler
public static void registerSmbURLHandler()This static method registers the SMB URL protocol handler which is required to use SMB URLs with thejava.net.URLclass. 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
Retrieve anint. If the key does not exist or cannot be converted to anint, the provided default argument will be returned.- Parameters:
props- the properties to search inkey- the property key to look updef- 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
Retrieve anint. If the property is not found,-1is returned.- Parameters:
props- the properties to search inkey- the property key to look up- Returns:
- the integer value of the property or -1 if not found
-
getLong
Retrieve along. If the key does not exist or cannot be converted to along, the provided default argument will be returned.- Parameters:
props- the properties to search inkey- the property key to look updef- 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
Retrieve anInetAddress. If the address is not an IP address and cannot be resolvednullwill be returned.- Parameters:
props- the properties to search inkey- the property key to look updef- 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
Get the local host address based on the provided properties.- Parameters:
props- the properties to use for configuration- Returns:
- the local host InetAddress
-
getBoolean
Retrieve a boolean value. If the property is not found, the value ofdefis returned.- Parameters:
props- the properties to search inkey- the property key to look updef- 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 ofInetAddresscreated from a property value containing adelimseparated list of host names and/or ip addresses.- Parameters:
props- the properties to search inkey- the property key to look updelim- the delimiter to use for splitting the property valuedef- the default value to return if key is not found- Returns:
- an array of InetAddress objects or the default value
-