gnu.java.util.prefs.gconf

Class GConfNativePeer


public final class GConfNativePeer
extends Object

Native peer for GConf based preference backend.

Constructor Summary

GConfNativePeer()
Creates a new instance of GConfNativePeer

Method Summary

static String
escapeString(String plain)
Escape the given string so the it is a valid GConf name.
protected void
finalize()
Called on an object by the Virtual Machine at most once, at some point after the Object is determined unreachable but before it is destroyed.
protected static List
gconf_all_keys(String node)
Returns a list of all keys stored in the given node.
protected static List
gconf_all_nodes(String node)
Returns a list of all nodes under the given node.
protected static boolean
gconf_dir_exists(String node)
Queries the GConf database to see if the given node exists, returning true if the node exist, false otherwise.
protected static String
gconf_escape_key(String plain)
Escape the input String so that it's a valid element for GConf.
protected static String
gconf_get_string(String key)
Returns the key associated to the given key.
protected static boolean
gconf_set_string(String key, String value)
Sets the given key/value pair into the GConf database.
protected static void
gconf_suggest_sync()
Suggest to the GConf native peer a sync with the database.
protected static String
gconf_unescape_key(String escaped)
Converts a string escaped with gconf_escape_key back into its original form.
protected static boolean
gconf_unset(String key)
Usets the given key, removing the key from the database.
List
getChildrenNodes(String node)
Lists the subnodes in node.
String
getKey(String key)
Gets the value of a configuration key.
List
getKeys(String node)
Lists the key in the given node.
boolean
nodeExist(String node)
Queries whether the node node exists in theGConf database.
boolean
setString(String key, String value)
Change the value of key to val.
void
suggestSync()
Suggest to the backend GConf daemon to synch with the database.
static String
unescapeString(String escaped)
Unescape a string escaped with escapeString(String).
boolean
unset(String key)
Unsets the value of key; if key is already unset, has no effect.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

GConfNativePeer

public GConfNativePeer()
Creates a new instance of GConfNativePeer

Method Details

escapeString

public static String escapeString(String plain)
Escape the given string so the it is a valid GConf name.

finalize

protected void finalize()
            throws Throwable
Called on an object by the Virtual Machine at most once, at some point after the Object is determined unreachable but before it is destroyed. You would think that this means it eventually is called on every Object, but this is not necessarily the case. If execution terminates abnormally, garbage collection does not always happen. Thus you cannot rely on this method to always work. For finer control over garbage collection, use references from the java.lang.ref package.

Virtual Machines are free to not call this method if they can determine that it does nothing important; for example, if your class extends Object and overrides finalize to do simply super.finalize().

finalize() will be called by a Thread that has no locks on any Objects, and may be called concurrently. There are no guarantees on the order in which multiple objects are finalized. This means that finalize() is usually unsuited for performing actions that must be thread-safe, and that your implementation must be use defensive programming if it is to always work.

If an Exception is thrown from finalize() during garbage collection, it will be patently ignored and the Object will still be destroyed.

It is allowed, although not typical, for user code to call finalize() directly. User invocation does not affect whether automatic invocation will occur. It is also permitted, although not recommended, for a finalize() method to "revive" an object by making it reachable from normal code again.

Unlike constructors, finalize() does not get called for an object's superclass unless the implementation specifically calls super.finalize().

The default implementation does nothing.

Overrides:
finalize in interface Object
Throws:
Throwable - permits a subclass to throw anything in an overridden version; but the default throws nothing

gconf_all_keys

protected static final List gconf_all_keys(String node)
            throws BackingStoreException
Returns a list of all keys stored in the given node.
Parameters:
node - the source node.
Returns:
A list of all keys stored in the given node.

gconf_all_nodes

protected static final List gconf_all_nodes(String node)
            throws BackingStoreException
Returns a list of all nodes under the given node.
Parameters:
node - the source node.
Returns:
A list of nodes under the given source node.

gconf_dir_exists

protected static final boolean gconf_dir_exists(String node)
Queries the GConf database to see if the given node exists, returning true if the node exist, false otherwise.
Parameters:
node - the node to query for existence.
Returns:
true if the node exist, false otherwise.

gconf_escape_key

protected static final String gconf_escape_key(String plain)
Escape the input String so that it's a valid element for GConf.
Parameters:
plain - the String to escape.
Returns:
An escaped String for use with GConf.

gconf_get_string

protected static final String gconf_get_string(String key)
Returns the key associated to the given key. Null is returned if the key is not valid.
Parameters:
key - the key to return the value of.
Returns:
The value associated to the given key, or null.

gconf_set_string

protected static final boolean gconf_set_string(String key,
                                                String value)
Sets the given key/value pair into the GConf database. The key must be a valid GConf key.
Parameters:
key - the key to store in the GConf database
value - the value to associate to the given key.
Returns:
true if the change has effect, false otherwise.

gconf_suggest_sync

protected static final void gconf_suggest_sync()
            throws BackingStoreException
Suggest to the GConf native peer a sync with the database.

gconf_unescape_key

protected static final String gconf_unescape_key(String escaped)
Converts a string escaped with gconf_escape_key back into its original form.
Parameters:
escaped - key as returned by gconf_escape_key
Returns:
An unescaped key.

gconf_unset

protected static final boolean gconf_unset(String key)
Usets the given key, removing the key from the database.
Parameters:
key - the key to remove.
Returns:
true if the operation success, false otherwise.

getChildrenNodes

public List getChildrenNodes(String node)
            throws BackingStoreException
Lists the subnodes in node. The returned list contains allocated strings. Each string is the name relative tho the given node.
Parameters:
node - the node to get subnodes from. If there are no subnodes in the given node, a list of size 0 is returned.

getKey

public String getKey(String key)
Gets the value of a configuration key.
Parameters:
key - the configuration key.
Returns:
the values of this key, null if the key is not valid.

getKeys

public List getKeys(String node)
            throws BackingStoreException
Lists the key in the given node. Does not list subnodes. Keys names are the stripped names (name relative to the current node) of the keys stored in this node.
Parameters:
node - the node where keys are stored.
Returns:
a java.util.List of keys. If there are no keys in the given node, a list of size 0 is returned.

nodeExist

public boolean nodeExist(String node)
Queries whether the node node exists in theGConf database. Returns true or false.
Parameters:
node - the node to check.

setString

public boolean setString(String key,
                         String value)
Change the value of key to val. Automatically creates the key if it didn't exist before (ie it was unset or it only had a default value). Key names must be valid GConf key names, that is, there can be more restrictions than for normal Preference Backend.
Parameters:
key - the key to alter (or add).
value - the new value for this key.
Returns:
true if the key was updated, false otherwise.

suggestSync

public void suggestSync()
            throws BackingStoreException
Suggest to the backend GConf daemon to synch with the database.

unescapeString

public static String unescapeString(String escaped)
Unescape a string escaped with escapeString(String).

unset

public boolean unset(String key)
Unsets the value of key; if key is already unset, has no effect. Depending on the GConf daemon, unsetting a key may have the side effect to remove it completely form the database.
Parameters:
key - the key to unset.
Returns:
true on success, false if the key was not updated.

GConfNativePeer.java -- GConf based preference peer for native methods Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.