org.gnu.gconf

Class ConfClient


public class ConfClient
extends GObject

ConfClient provides a client-side cache for a specified list of directories your're interested in. You can preload entire directories into cache to enhance performance. It also provides events when a value changes.

Method Summary

void
addDirectory(String dir, ConfClientPreloadType type)
Add a directory to the list of directories the ConfClient will watch.
void
addListener(ConfClientListener listener, String nameSpace)
Register an object to handle notify events.
void
clearCache()
If you know you're done reading values for a while you can blow away the cache.
boolean
dirExists(String dir)
Check to see if a directory exists in the GConf database.
protected static void
gconf_client_add_dir(Handle client, String dir, int preloadType, int[] error)
protected static String[]
gconf_client_all_dirs(Handle client, String dir, int[] error)
protected static Handle[]
gconf_client_all_entries(Handle client, String dir, int[] error)
protected static void
gconf_client_clear_cache(Handle client)
protected static boolean
gconf_client_dir_exists(Handle client, String dir, int[] error)
protected static Handle
gconf_client_get(Handle client, String key, int[] error)
protected static boolean
gconf_client_get_bool(Handle client, String key, int[] error)
protected static Handle
gconf_client_get_default()
protected static Handle
gconf_client_get_default_from_schema(Handle client, String key, int[] error)
protected static Handle
gconf_client_get_entry(Handle client, String key, String locale, boolean useSchemaDefault, int[] error)
protected static double
gconf_client_get_float(Handle client, String key, int[] error)
protected static Handle
gconf_client_get_for_engine(Handle engine)
protected static int
gconf_client_get_int(Handle client, String key, int[] error)
protected static Object[]
gconf_client_get_list(Handle client, String key, int listType, int[] error)
protected static boolean
gconf_client_get_pair(Handle client, String key, int carType, int cdrType, int[] car, int[] cdr, int[] error)
protected static Handle
gconf_client_get_schema(Handle client, String key, int[] error)
protected static String
gconf_client_get_string(Handle client, String key, int[] error)
protected static Handle
gconf_client_get_without_default(Handle client, String key, int[] error)
protected int
gconf_client_notify_add(Handle client, String namespace, int[] error)
protected static void
gconf_client_notify_remove(Handle client, int cnxn)
protected static void
gconf_client_preload(Handle client, String dirname, int type, int[] error)
protected static void
gconf_client_remove_dir(Handle client, String dir, int[] error)
protected static void
gconf_client_set(Handle client, String key, Handle val, int[] error)
protected static boolean
gconf_client_set_bool(Handle client, String key, boolean val, int[] error)
protected static boolean
gconf_client_set_float(Handle client, String key, double val, int[] error)
protected static boolean
gconf_client_set_int(Handle client, String key, int val, int[] error)
protected static boolean
gconf_client_set_list(Handle client, String key, int listType, Object[] list, int[] error)
protected static boolean
gconf_client_set_pair(Handle client, String key, int carType, int cdrType, int car, int cdr, int[] error)
protected static boolean
gconf_client_set_schema(Handle client, String key, Handle val, int[] error)
protected static boolean
gconf_client_set_string(Handle client, String key, String val, int[] error)
protected static void
gconf_client_suggest_sync(Handle client, int[] error)
protected static boolean
gconf_client_unset(Handle client, String key, int[] error)
protected static void
gconf_client_value_changed(Handle client, String key, Handle value)
ConfValue
get(String key)
Get the value of a configuration key.
List
getAllDirs(String dir)
Get a list of the subdirectories in the provided directory.
List
getAllEntries(String dir)
Get a list of all ConfEntries in the provided direcotry.
boolean
getBoolean(String key)
Request the boolean value stored at the provided key.
ConfValue
getDefaultFromSchema(String key)
Return the default value stored in the key's schema, if the key has a schema associated and the schema exists and the schema contains a default value.
double
getDouble(String key)
Request the double value stored at the provided key.
ConfEntry
getEntry(String key, String locale, boolean useSchemaDefault)
Obtain the full ConfEntry for a value.
static ConfClient
getInstance()
Method to get the default ConfClient
int
getInt(String key)
Request the int value stored at the provided key.
Object[]
getList(String key, ConfValueType listType)
Request the object array stored at the key.
ConfSchema
getSchema(String key)
Request the ConfSchema value stored at the provided key.
String
getString(String key)
Request the String value stored at the provided key.
protected void
notifyCallback(Handle e, String nameSpace)
void
preload(String directory, ConfClientPreloadType type)
Preload a directory.
void
removeDirectory(String dir)
Remove a directory from the list created with addDirectory.
void
removeListener(ConfClientListener listener, String nameSpace)
Removes a listener.
void
set(String key, ConfValue value)
Set the value of a configuration key.
boolean
setBoolean(String key, boolean value)
Change the value stored at the provided key to the provided boolean value.
boolean
setDouble(String key, double value)
Change the value stored at the provided key to the provided double value.
boolean
setInt(String key, int value)
Change the value stored at the provided key to the provided int value.
boolean
setList(String key, ConfValueType listType, List value)
boolean
setSchema(String key, ConfSchema value)
Change the value stored at the provided key to the provided ConfSchema value.
boolean
setString(String key, String value)
Change the value stored at the provided key to the provided String value.
void
suggestSync()
Suggest to gconfd that you've just finished a block of changes and it would be an optimal time to sync to permanent storage.
boolean
unset(String key)
Unsets the value of the provided key.

Method Details

addDirectory

public void addDirectory(String dir,
                         ConfClientPreloadType type)
            throws ConfException
Add a directory to the list of directories the ConfClient will watch. Any changes to keys below this directory will cause the "value_changed" event to be fired.

Parameters:
dir -
type -

Throws:
ConfException -


addListener

public void addListener(ConfClientListener listener,
                        String nameSpace)
            throws ConfException
Register an object to handle notify events.

See Also:
ConfClientListener


clearCache

public void clearCache()
If you know you're done reading values for a while you can blow away the cache. Note that this nullifies the effect of any preloading you may have done. However it frees some memory.


dirExists

public boolean dirExists(String dir)
            throws ConfException
Check to see if a directory exists in the GConf database.

Parameters:
dir -

Throws:
ConfException -


gconf_client_add_dir

protected static final void gconf_client_add_dir(Handle client,
                                                 String dir,
                                                 int preloadType,
                                                 int[] error)


gconf_client_all_dirs

protected static final String[] gconf_client_all_dirs(Handle client,
                                                      String dir,
                                                      int[] error)


gconf_client_all_entries

protected static final Handle[] gconf_client_all_entries(Handle client,
                                                         String dir,
                                                         int[] error)


gconf_client_clear_cache

protected static final void gconf_client_clear_cache(Handle client)


gconf_client_dir_exists

protected static final boolean gconf_client_dir_exists(Handle client,
                                                       String dir,
                                                       int[] error)


gconf_client_get

protected static final Handle gconf_client_get(Handle client,
                                               String key,
                                               int[] error)


gconf_client_get_bool

protected static final boolean gconf_client_get_bool(Handle client,
                                                     String key,
                                                     int[] error)


gconf_client_get_default

protected static final Handle gconf_client_get_default()


gconf_client_get_default_from_schema

protected static final Handle gconf_client_get_default_from_schema(Handle client,
                                                                   String key,
                                                                   int[] error)


gconf_client_get_entry

protected static final Handle gconf_client_get_entry(Handle client,
                                                     String key,
                                                     String locale,
                                                     boolean useSchemaDefault,
                                                     int[] error)


gconf_client_get_float

protected static final double gconf_client_get_float(Handle client,
                                                     String key,
                                                     int[] error)


gconf_client_get_for_engine

protected static final Handle gconf_client_get_for_engine(Handle engine)


gconf_client_get_int

protected static final int gconf_client_get_int(Handle client,
                                                String key,
                                                int[] error)


gconf_client_get_list

protected static final Object[] gconf_client_get_list(Handle client,
                                                      String key,
                                                      int listType,
                                                      int[] error)


gconf_client_get_pair

protected static final boolean gconf_client_get_pair(Handle client,
                                                     String key,
                                                     int carType,
                                                     int cdrType,
                                                     int[] car,
                                                     int[] cdr,
                                                     int[] error)


gconf_client_get_schema

protected static final Handle gconf_client_get_schema(Handle client,
                                                      String key,
                                                      int[] error)


gconf_client_get_string

protected static final String gconf_client_get_string(Handle client,
                                                      String key,
                                                      int[] error)


gconf_client_get_without_default

protected static final Handle gconf_client_get_without_default(Handle client,
                                                               String key,
                                                               int[] error)


gconf_client_notify_add

protected final int gconf_client_notify_add(Handle client,
                                            String namespace,
                                            int[] error)


gconf_client_notify_remove

protected static void gconf_client_notify_remove(Handle client,
                                                 int cnxn)


gconf_client_preload

protected static final void gconf_client_preload(Handle client,
                                                 String dirname,
                                                 int type,
                                                 int[] error)


gconf_client_remove_dir

protected static final void gconf_client_remove_dir(Handle client,
                                                    String dir,
                                                    int[] error)


gconf_client_set

protected static final void gconf_client_set(Handle client,
                                             String key,
                                             Handle val,
                                             int[] error)


gconf_client_set_bool

protected static final boolean gconf_client_set_bool(Handle client,
                                                     String key,
                                                     boolean val,
                                                     int[] error)


gconf_client_set_float

protected static final boolean gconf_client_set_float(Handle client,
                                                      String key,
                                                      double val,
                                                      int[] error)


gconf_client_set_int

protected static final boolean gconf_client_set_int(Handle client,
                                                    String key,
                                                    int val,
                                                    int[] error)


gconf_client_set_list

protected static final boolean gconf_client_set_list(Handle client,
                                                     String key,
                                                     int listType,
                                                     Object[] list,
                                                     int[] error)


gconf_client_set_pair

protected static final boolean gconf_client_set_pair(Handle client,
                                                     String key,
                                                     int carType,
                                                     int cdrType,
                                                     int car,
                                                     int cdr,
                                                     int[] error)


gconf_client_set_schema

protected static final boolean gconf_client_set_schema(Handle client,
                                                       String key,
                                                       Handle val,
                                                       int[] error)


gconf_client_set_string

protected static final boolean gconf_client_set_string(Handle client,
                                                       String key,
                                                       String val,
                                                       int[] error)


gconf_client_suggest_sync

protected static final void gconf_client_suggest_sync(Handle client,
                                                      int[] error)


gconf_client_unset

protected static final boolean gconf_client_unset(Handle client,
                                                  String key,
                                                  int[] error)


gconf_client_value_changed

protected static final void gconf_client_value_changed(Handle client,
                                                       String key,
                                                       Handle value)


get

public ConfValue get(String key)
            throws ConfException
Get the value of a configuration key.

Parameters:
key -

Throws:
ConfException -


getAllDirs

public List getAllDirs(String dir)
            throws ConfException
Get a list of the subdirectories in the provided directory.

Parameters:
dir -

Throws:
ConfException -


getAllEntries

public List getAllEntries(String dir)
            throws ConfException
Get a list of all ConfEntries in the provided direcotry.

Parameters:
dir -

Throws:
ConfException -


getBoolean

public boolean getBoolean(String key)
            throws ConfException
Request the boolean value stored at the provided key.

Parameters:
key -

Throws:
ConfException -


getDefaultFromSchema

public ConfValue getDefaultFromSchema(String key)
            throws ConfException
Return the default value stored in the key's schema, if the key has a schema associated and the schema exists and the schema contains a default value.

Parameters:
key -

Throws:
ConfException -


getDouble

public double getDouble(String key)
            throws ConfException
Request the double value stored at the provided key.

Parameters:
key -

Throws:
ConfException -


getEntry

public ConfEntry getEntry(String key,
                          String locale,
                          boolean useSchemaDefault)
            throws ConfException
Obtain the full ConfEntry for a value.

Parameters:
key -
locale -
useSchemaDefault -

Throws:
ConfException -


getInstance

public static ConfClient getInstance()
Method to get the default ConfClient

Returns:
The default ConfClient.


getInt

public int getInt(String key)
            throws ConfException
Request the int value stored at the provided key.

Parameters:
key -

Throws:
ConfException -


getList

public Object[] getList(String key,
                        ConfValueType listType)
            throws ConfException
Request the object array stored at the key. The return object array is of the type provided.

Parameters:
key -
listType -

Throws:
ConfException -


getSchema

public ConfSchema getSchema(String key)
            throws ConfException
Request the ConfSchema value stored at the provided key.

Parameters:
key -

Throws:
ConfException -


getString

public String getString(String key)
            throws ConfException
Request the String value stored at the provided key.

Parameters:
key -

Throws:
ConfException -


notifyCallback

protected void notifyCallback(Handle e,
                              String nameSpace)


preload

public void preload(String directory,
                    ConfClientPreloadType type)
            throws ConfException
Preload a directory. The directory must have been added already. This is only useful as an optimization if you clear the cache, then later want to do a lot a reads again.

Parameters:
directory - The directory to load
type - How to preload the directory.

Throws:
ConfException -


removeDirectory

public void removeDirectory(String dir)
            throws ConfException
Remove a directory from the list created with addDirectory.

Parameters:
dir -

Throws:
ConfException -


removeListener

public void removeListener(ConfClientListener listener,
                           String nameSpace)
Removes a listener.

See Also:
addListener(ConfClientListener,String)


set

public void set(String key,
                ConfValue value)
            throws ConfException
Set the value of a configuration key.

Parameters:
key -
value -

Throws:
ConfException -


setBoolean

public boolean setBoolean(String key,
                          boolean value)
            throws ConfException
Change the value stored at the provided key to the provided boolean value.

Parameters:
key -
value -

Throws:
ConfException -


setDouble

public boolean setDouble(String key,
                         double value)
            throws ConfException
Change the value stored at the provided key to the provided double value.

Parameters:
key -
value -

Throws:
ConfException -


setInt

public boolean setInt(String key,
                      int value)
            throws ConfException
Change the value stored at the provided key to the provided int value.

Parameters:
key -
value -

Throws:
ConfException -


setList

public boolean setList(String key,
                       ConfValueType listType,
                       List value)
            throws ConfException


setSchema

public boolean setSchema(String key,
                         ConfSchema value)
            throws ConfException
Change the value stored at the provided key to the provided ConfSchema value.

Parameters:
key -
value -

Throws:
ConfException -


setString

public boolean setString(String key,
                         String value)
            throws ConfException
Change the value stored at the provided key to the provided String value.

Parameters:
key -
value -

Throws:
ConfException -


suggestSync

public void suggestSync()
            throws ConfException
Suggest to gconfd that you've just finished a block of changes and it would be an optimal time to sync to permanent storage.

Throws:
ConfException -


unset

public boolean unset(String key)
            throws ConfException
Unsets the value of the provided key.

Parameters:
key -

Throws:
ConfException -