com.couchbase.client
Class CouchbaseProperties

java.lang.Object
  extended by com.couchbase.client.CouchbaseProperties

public final class CouchbaseProperties
extends java.lang.Object

The CouchbaseProperties class abstracts system properties and those set via a file exposed through a unified class. The main purpose of this class is to centralize property management which can be called throughout the stack. If a filename is set and the properties file can be loaded, the information is used. All the time, properties set in the code override the file-given ones. The default namespace is "cbclient", which means that all properties need to adhere to the "cbclient." syntax. The getProperty method also allows you to pass a boolean param to control this behavior (ignore the namespace at all).


Method Summary
static java.lang.String getNamespace()
          Returns the namespace to be used for the properties.
static java.lang.String getProperty(java.lang.String name)
          Returns the property for the given name (or null if not set).
static java.lang.String getProperty(java.lang.String name, boolean ignore)
          Returns the property for the given name (or null if not set).
static java.lang.String getProperty(java.lang.String name, java.lang.String def)
          Returns the property for the given name (or given default if not set).
static java.lang.String getProperty(java.lang.String name, java.lang.String def, boolean ignore)
          Returns the property for the given name (or given default if not set).
static void setNamespace(java.lang.String ns)
          Replaces the default (or old) namespace with this new one.
static void setPropertyFile(java.lang.String filename)
          Set the filename of the properties file and load it (if possible).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setPropertyFile

public static void setPropertyFile(java.lang.String filename)
Set the filename of the properties file and load it (if possible).

Parameters:
filename - the filename of the properties file.

getProperty

public static java.lang.String getProperty(java.lang.String name,
                                           java.lang.String def,
                                           boolean ignore)
Returns the property for the given name (or given default if not set). If a System property is found, it is returned. Otherwise, if a file is set and it contains the property, it is returned. If no property is found, the default is returned.

Parameters:
name - the name of the property.
def - the default value to return.
ignore - ignore the property namespace.
Returns:
returns the property or default if not set.

getProperty

public static java.lang.String getProperty(java.lang.String name,
                                           boolean ignore)
Returns the property for the given name (or null if not set).

Parameters:
name - the name of the property.
ignore - ignore the property namespace.
Returns:
returns the property or null if not set.

getProperty

public static java.lang.String getProperty(java.lang.String name)
Returns the property for the given name (or null if not set).

Parameters:
name - the name of the property.
Returns:
returns the property or null if not set.

getProperty

public static java.lang.String getProperty(java.lang.String name,
                                           java.lang.String def)
Returns the property for the given name (or given default if not set).

Parameters:
name - the name of the property.
def - the default value to return.
Returns:
returns the property or the default if not set.

getNamespace

public static java.lang.String getNamespace()
Returns the namespace to be used for the properties.

Returns:
the namespace.

setNamespace

public static void setNamespace(java.lang.String ns)
Replaces the default (or old) namespace with this new one.

Parameters:
ns - the namespace to be used.


Copyright © 2006-2009 Dustin Sallings, 2009-2012 Couchbase, Inc.