java.lang.Object
org.codelibs.jcifs.smb1.Config
This class uses a static
Properties to act
as a cental repository for all jCIFS configuration properties. It cannot be
instantiated. Similar to System properties the namespace
is global therefore property names should be unique. Before use,
the load method should be called with the name of a
Properties file (or null indicating no
file) to initialize the Config. The System
properties will then populate the Config as well potentially
overwriting properties from the file. Thus properties provided on the
commandline with the -Dproperty.name=value VM parameter
will override properties from the configuration file.
There are several ways to set jCIFS properties. See the overview page of the API documentation for details.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic StringDefault OEM encoding used for SMB communication.static intCounter for tracking socket connections. -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectRetrieve a property as anObject.static booleangetBoolean(String key, boolean def) Retrieve a boolean value.static InetAddressgetInetAddress(String key, InetAddress def) Retrieve anInetAddress.static InetAddress[]getInetAddressArray(String key, String delim, InetAddress[] def) Retrieve an array ofInetAddresscreated from a property value containting adelimseparated list of hostnames and/or ipaddresses.static intRetrieve anint.static intRetrieve anint.static InetAddressGet the local host address configured for the client.static longRetrieve along.static StringgetProperty(String key) Retrieve aString.static StringgetProperty(String key, String def) Retrieve aString.static voidlist(PrintStream out) List the properties in theConfig.static voidload(InputStream in) Load theConfigwith properties from the streaminfrom aPropertiesfile.static voidThis static method registers the SMB URL protocol handler which is required to use SMB URLs with thejava.net.URLclass.static voidsetProperties(Properties prp) Set the properties to be used for configuration.static ObjectsetProperty(String key, String value) Add a property.static voidstore(OutputStream out, String header) Save the configuration properties to an output stream.
-
Field Details
-
socketCount
public static int socketCountCounter for tracking socket connections. -
DEFAULT_OEM_ENCODING
Default OEM encoding used for SMB communication.
-
-
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.smb1.smb1.SmbFile.<init>(SmbFile.java:355) ... -
setProperties
Set the properties to be used for configuration.- Parameters:
prp- the properties to set
-
load
Load theConfigwith properties from the streaminfrom aPropertiesfile.- Parameters:
in- the input stream to load properties from- Throws:
IOException- if an I/O error occurs
-
store
Save the configuration properties to an output stream.- Parameters:
out- the output stream to write properties toheader- a descriptive header for the properties- Throws:
IOException- if an I/O error occurs
-
list
List the properties in theConfig.- Parameters:
out- the print stream to write the properties to- Throws:
IOException- if an I/O error occurs
-
setProperty
Add a property.- Parameters:
key- the property keyvalue- the property value- Returns:
- the previous value of the property, or null if it did not have one
-
get
Retrieve a property as anObject.- Parameters:
key- the property key to look up- Returns:
- the property value as an Object, or null if not found
-
getProperty
Retrieve aString. If the key cannot be found, the provideddefdefault parameter will be returned.- Parameters:
key- the property key to look updef- the default value to return if the property is not found- Returns:
- the property value, or the default value if not found
-
getProperty
Retrieve aString. If the property is not found,nullis returned.- Parameters:
key- the property key to look up- Returns:
- the property value, or null if not found
-
getInt
Retrieve anint. If the key does not exist or cannot be converted to anint, the provided default argument will be returned.- Parameters:
key- the property key to look updef- the default value to return if the property is not found or cannot be parsed- Returns:
- the property value as an int, or the default value
-
getInt
Retrieve anint. If the property is not found,-1is returned.- Parameters:
key- the property key to look up- Returns:
- the property value as an int, 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:
key- the property key to look updef- the default value to return if the property is not found or cannot be parsed- Returns:
- the property value as a long, or the default value
-
getInetAddress
Retrieve anInetAddress. If the address is not an IP address and cannot be resolvednullwill be returned.- Parameters:
key- the property key to look updef- the default InetAddress to return if the property is not found or cannot be resolved- Returns:
- the property value as an InetAddress, or the default value
-
getLocalHost
Get the local host address configured for the client.- Returns:
- the configured local InetAddress, or null if not configured
-
getBoolean
Retrieve a boolean value. If the property is not found, the value ofdefis returned.- Parameters:
key- the property key to look updef- the default value to return if the property is not found- Returns:
- the property value as a boolean, or the default value
-
getInetAddressArray
Retrieve an array ofInetAddresscreated from a property value containting adelimseparated list of hostnames and/or ipaddresses.- Parameters:
key- the property key to look updelim- the delimiter used to separate addresses in the property valuedef- the default array to return if the property is not found or cannot be parsed- Returns:
- an array of InetAddress objects, or the default array
-