Methods Summary |
---|
public static java.lang.Object | get(java.lang.String key)Retrieve a property as an Object .
return prp.get( key );
|
public static boolean | getBoolean(java.lang.String key, boolean def)Retrieve a boolean value. If the property is not found, the value of def is returned.
String b = getProperty( key );
if( b != null ) {
def = b.toLowerCase().equals( "true" );
}
return def;
|
public static java.net.InetAddress | getInetAddress(java.lang.String key, java.net.InetAddress def)Retrieve an InetAddress . If the address is not
an IP address and cannot be resolved null will
be returned.
String addr = prp.getProperty( key );
if( addr != null ) {
try {
def = InetAddress.getByName( addr );
} catch( UnknownHostException uhe ) {
if( log.level > 0 ) {
log.println( addr );
uhe.printStackTrace( log );
}
}
}
return def;
|
public static java.net.InetAddress[] | getInetAddressArray(java.lang.String key, java.lang.String delim, java.net.InetAddress[] def)Retrieve an array of InetAddress created from a property
value containting a delim separated list of hostnames and/or
ipaddresses.
String p = getProperty( key );
if( p != null ) {
StringTokenizer tok = new StringTokenizer( p, delim );
int len = tok.countTokens();
InetAddress[] arr = new InetAddress[len];
for( int i = 0; i < len; i++ ) {
String addr = tok.nextToken();
try {
arr[i] = InetAddress.getByName( addr );
} catch( UnknownHostException uhe ) {
if( log.level > 0 ) {
log.println( addr );
uhe.printStackTrace( log );
}
return def;
}
}
return arr;
}
return def;
|
public static int | getInt(java.lang.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.
String s = prp.getProperty( key );
if( s != null ) {
try {
def = Integer.parseInt( s );
} catch( NumberFormatException nfe ) {
if( log.level > 0 )
nfe.printStackTrace( log );
}
}
return def;
|
public static int | getInt(java.lang.String key)Retrieve an int . If the property is not found, -1 is returned.
String s = prp.getProperty( key );
int result = -1;
if( s != null ) {
try {
result = Integer.parseInt( s );
} catch( NumberFormatException nfe ) {
if( log.level > 0 )
nfe.printStackTrace( log );
}
}
return result;
|
public static java.net.InetAddress | getLocalHost()
String addr = prp.getProperty( "jcifs.smb.client.laddr" );
if (addr != null) {
try {
return InetAddress.getByName( addr );
} catch( UnknownHostException uhe ) {
if( log.level > 0 ) {
log.println( "Ignoring jcifs.smb.client.laddr address: " + addr );
uhe.printStackTrace( log );
}
}
}
return null;
|
public static long | getLong(java.lang.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.
String s = prp.getProperty( key );
if( s != null ) {
try {
def = Long.parseLong( s );
} catch( NumberFormatException nfe ) {
if( log.level > 0 )
nfe.printStackTrace( log );
}
}
return def;
|
public static java.lang.String | getProperty(java.lang.String key)Retrieve a String . If the property is not found, null is returned.
return prp.getProperty( key );
|
public static java.lang.String | getProperty(java.lang.String key, java.lang.String def)Retrieve a String . If the key cannot be found,
the provided def default parameter will be returned.
return prp.getProperty( key, def );
|
public static void | list(java.io.PrintStream out)List the properties in the Code .
prp.list( out );
|
public static void | load(java.io.InputStream in)Load the Config with properties from the stream
in from a Properties file.
if( in != null ) {
prp.load( in );
}
try {
prp.putAll( System.getProperties() );
} catch( SecurityException se ) {
if( log.level > 1 )
log.println( "SecurityException: jcifs will ignore System properties" );
}
|
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.(URL.java:480)
at java.net.URL.(URL.java:376)
at java.net.URL.(URL.java:330)
at jcifs.smb.SmbFile.(SmbFile.java:355)
...
String filename;
int level;
FileInputStream in = null;
log = LogStream.getInstance();
try {
filename = System.getProperty( "jcifs.properties" );
if( filename != null && filename.length() > 1 ) {
in = new FileInputStream( filename );
}
Config.load( in );
if (in != null)
in.close();
} catch( IOException ioe ) {
if( log.level > 0 )
ioe.printStackTrace( log );
}
if(( level = Config.getInt( "jcifs.util.loglevel", -1 )) != -1 ) {
LogStream.setLevel( level );
}
try {
"".getBytes(DEFAULT_OEM_ENCODING);
} catch (UnsupportedEncodingException uee) {
if (log.level >= 2) {
log.println("WARNING: The default OEM encoding " + DEFAULT_OEM_ENCODING +
" does not appear to be supported by this JRE. The default encoding will be US-ASCII.");
}
DEFAULT_OEM_ENCODING = "US-ASCII";
}
if (log.level >= 4) {
try {
prp.store( log, "JCIFS PROPERTIES" );
} catch( IOException ioe ) {
}
}
String ver, pkgs;
ver = System.getProperty( "java.version" );
if( ver.startsWith( "1.1." ) || ver.startsWith( "1.2." )) {
throw new RuntimeException( "jcifs-0.7.0b4+ requires Java 1.3 or above. You are running " + ver );
}
pkgs = System.getProperty( "java.protocol.handler.pkgs" );
if( pkgs == null ) {
System.setProperty( "java.protocol.handler.pkgs", "jcifs" );
} else if( pkgs.indexOf( "jcifs" ) == -1 ) {
pkgs += "|jcifs";
System.setProperty( "java.protocol.handler.pkgs", pkgs );
}
|
public static void | setProperties(java.util.Properties prp)Set the default properties of the static Properties used by Config. This permits
a different Properties object/file to be used as the source of properties for
use by the jCIFS library. The Properties must be set before jCIFS
classes are accessed as most jCIFS classes load properties statically once.
Using this method will also override properties loaded
using the -Djcifs.properties= commandline parameter.
Config.prp = new Properties( prp );
try {
Config.prp.putAll( System.getProperties() );
} catch( SecurityException se ) {
if( log.level > 1 )
log.println( "SecurityException: jcifs will ignore System properties" );
}
|
public static java.lang.Object | setProperty(java.lang.String key, java.lang.String value)Add a property.
return prp.setProperty( key, value );
|
public static void | store(java.io.OutputStream out, java.lang.String header)
prp.store( out, header );
|