Imported GNU Classpath 0.92
2006-08-14 Mark Wielaard <mark@klomp.org> Imported GNU Classpath 0.92 * HACKING: Add more importing hints. Update automake version requirement. * configure.ac (gconf-peer): New enable AC argument. Add --disable-gconf-peer and --enable-default-preferences-peer to classpath configure when gconf is disabled. * scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and gnu/java/awt/dnd/peer/gtk to bc. Classify gnu/java/security/Configuration.java as generated source file. * gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java, gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java, gnu/java/lang/management/VMClassLoadingMXBeanImpl.java, gnu/java/lang/management/VMRuntimeMXBeanImpl.java, gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java, gnu/java/lang/management/VMThreadMXBeanImpl.java, gnu/java/lang/management/VMMemoryMXBeanImpl.java, gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub classes. * java/lang/management/VMManagementFactory.java: Likewise. * java/net/VMURLConnection.java: Likewise. * gnu/java/nio/VMChannel.java: Likewise. * java/lang/Thread.java (getState): Add stub implementation. * java/lang/Class.java (isEnum): Likewise. * java/lang/Class.h (isEnum): Likewise. * gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed. * javax/naming/spi/NamingManager.java: New override for StackWalker functionality. * configure, sources.am, Makefile.in, gcj/Makefile.in, include/Makefile.in, testsuite/Makefile.in: Regenerated. From-SVN: r116139
This commit is contained in:
parent
abab460491
commit
ac1ed908de
1294 changed files with 99479 additions and 35933 deletions
|
@ -74,7 +74,7 @@ public class EventDispatcher extends Thread
|
|||
{
|
||||
try
|
||||
{
|
||||
wait();
|
||||
queue.wait();
|
||||
}
|
||||
catch (InterruptedException _)
|
||||
{
|
||||
|
@ -107,6 +107,7 @@ public class EventDispatcher extends Thread
|
|||
synchronized (queue)
|
||||
{
|
||||
queue.add(runner);
|
||||
queue.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
78
libjava/classpath/gnu/java/util/prefs/GConfBasedFactory.java
Normal file
78
libjava/classpath/gnu/java/util/prefs/GConfBasedFactory.java
Normal file
|
@ -0,0 +1,78 @@
|
|||
/* GConfBasedFactory.java -- GConf based PreferencesFactory implementation
|
||||
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. */
|
||||
|
||||
package gnu.java.util.prefs;
|
||||
|
||||
import java.util.prefs.Preferences;
|
||||
import java.util.prefs.PreferencesFactory;
|
||||
|
||||
/**
|
||||
* Factory object that generates a Preferences nodes that are read from a GConf
|
||||
* daemon.
|
||||
*
|
||||
* @author Mario Torre <neugens@limasoftware.net>
|
||||
*/
|
||||
public class GConfBasedFactory implements PreferencesFactory
|
||||
{
|
||||
/** System preference root. */
|
||||
private static final Preferences systemPreferences
|
||||
= new GConfBasedPreferences(null, "", false);
|
||||
|
||||
/** User preference root. */
|
||||
private static final Preferences userPreferences
|
||||
= new GConfBasedPreferences(null, "", true);
|
||||
|
||||
/**
|
||||
* Returns the system root preference node.
|
||||
*
|
||||
* @see java.util.prefs.PreferencesFactory#systemRoot()
|
||||
*/
|
||||
public Preferences systemRoot()
|
||||
{
|
||||
return systemPreferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user root preference node corresponding to the calling user.
|
||||
*
|
||||
* @see java.util.prefs.PreferencesFactory#userRoot()
|
||||
*/
|
||||
public Preferences userRoot()
|
||||
{
|
||||
return userPreferences;
|
||||
}
|
||||
}
|
412
libjava/classpath/gnu/java/util/prefs/GConfBasedPreferences.java
Normal file
412
libjava/classpath/gnu/java/util/prefs/GConfBasedPreferences.java
Normal file
|
@ -0,0 +1,412 @@
|
|||
/* GConfBasedPreferences.java -- GConf based Preferences implementation
|
||||
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. */
|
||||
|
||||
package gnu.java.util.prefs;
|
||||
|
||||
import gnu.java.util.prefs.gconf.GConfNativePeer;
|
||||
|
||||
import java.security.Permission;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.prefs.AbstractPreferences;
|
||||
import java.util.prefs.BackingStoreException;
|
||||
|
||||
/**
|
||||
* This is a GConf based preference implementation which writes the preferences
|
||||
* as GConf key-value pairs. System Root is defined to be the
|
||||
* <code>"/system"</code> directory of GConf for the current user, while User
|
||||
* Root is <code>"/apps/java"</code>. These defaults can be modified by
|
||||
* defining two system properties:<br />
|
||||
* <br />
|
||||
* User Root:<br />
|
||||
* <br />
|
||||
*
|
||||
* <pre>
|
||||
* gnu.java.util.prefs.gconf.user_root
|
||||
* </pre>
|
||||
*
|
||||
* <br />
|
||||
* <br />
|
||||
* and System Root:<br />
|
||||
* <br />
|
||||
*
|
||||
* <pre>
|
||||
* gnu.java.util.prefs.gconf.system_root
|
||||
* </pre>
|
||||
*
|
||||
* <br />
|
||||
*
|
||||
* @author Mario Torre <neugens@limasoftware.net>
|
||||
* @version 1.0.1
|
||||
*/
|
||||
public class GConfBasedPreferences
|
||||
extends AbstractPreferences
|
||||
{
|
||||
/** Get access to Runtime permission */
|
||||
private static final Permission PERMISSION
|
||||
= new RuntimePermission("preferences");
|
||||
|
||||
/** CGonf client backend */
|
||||
private static GConfNativePeer backend = new GConfNativePeer();
|
||||
|
||||
/** Default user root path */
|
||||
private static final String DEFAULT_USER_ROOT = "/apps/classpath";
|
||||
|
||||
/** Default system root path */
|
||||
private static final String DEFAULT_SYSTEM_ROOT = "/system";
|
||||
|
||||
/** current node full path */
|
||||
private String node = "";
|
||||
|
||||
/** True if this is a preference node in the user tree, false otherwise. */
|
||||
private final boolean isUser;
|
||||
|
||||
/**
|
||||
* Creates a preference root user node.
|
||||
*/
|
||||
public GConfBasedPreferences()
|
||||
{
|
||||
this(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a preference root node. When <code>isUser</code> is true it will
|
||||
* be user node otherwise it will be a system node.
|
||||
*/
|
||||
public GConfBasedPreferences(boolean isUser)
|
||||
{
|
||||
this(null, "", isUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new preference node given a parent node and a name, which has to
|
||||
* be relative to its parent. When <code>isUser</code> is true it will be user
|
||||
* node otherwise it will be a system node.
|
||||
*
|
||||
* @param parent The parent node of this newly created node.
|
||||
* @param name A name relative to the parent node.
|
||||
* @param isUser Set to <code>true</code> initializes this node to be
|
||||
* a user node, <code>false</code> initialize it to be a system node.
|
||||
*/
|
||||
public GConfBasedPreferences(AbstractPreferences parent, String name,
|
||||
boolean isUser)
|
||||
{
|
||||
super(parent, name);
|
||||
this.isUser = isUser;
|
||||
|
||||
// stores the fully qualified name of this node
|
||||
String absolutePath = this.absolutePath();
|
||||
if (absolutePath != null && absolutePath.endsWith("/"))
|
||||
{
|
||||
absolutePath = absolutePath.substring(0, absolutePath.length() - 1);
|
||||
}
|
||||
|
||||
this.node = this.getRealRoot(isUser) + absolutePath;
|
||||
|
||||
boolean nodeExist = backend.nodeExist(this.node);
|
||||
|
||||
this.newNode = !nodeExist;
|
||||
backend.startWatchingNode(this.node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a child node with the given name.
|
||||
* If the child node does not exists, it will be created.
|
||||
*
|
||||
* @param name The name of the requested node.
|
||||
* @return A new reference to the node, creating the node if it is necessary.
|
||||
*/
|
||||
protected AbstractPreferences childSpi(String name)
|
||||
{
|
||||
// we don't check anything here, if the node is a new node this will be
|
||||
// detected in the constructor, so we simply return a new reference to
|
||||
// the requested node.
|
||||
return new GConfBasedPreferences(this, name, this.isUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of names of the children of this preference node.
|
||||
* If the current node does not have children, the returned array will be
|
||||
* of <code>size</code> 0 (that is, not <code>null</code>).
|
||||
*
|
||||
* @return A <code>String</code> array of names of children of the current
|
||||
* node.
|
||||
* @throws BackingStoreException if this operation cannot be completed.
|
||||
*/
|
||||
protected String[] childrenNamesSpi() throws BackingStoreException
|
||||
{
|
||||
List nodeList = backend.getChildrenNodes(this.node);
|
||||
String[] nodes = new String[nodeList.size()];
|
||||
nodeList.toArray(nodes);
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Suggest a flush to the backend. Actually, this is only a suggestion as
|
||||
* GConf handles this for us asynchronously. More over, both sync and flush
|
||||
* have the same meaning in this class, so calling sync has exactly the same
|
||||
* effect.
|
||||
*
|
||||
* @see #sync
|
||||
* @throws BackingStoreException if this operation cannot be completed.
|
||||
*/
|
||||
public void flush() throws BackingStoreException
|
||||
{
|
||||
backend.suggestSync();
|
||||
}
|
||||
|
||||
/**
|
||||
* Request a flush.
|
||||
*
|
||||
* @see #flush
|
||||
* @throws BackingStoreException if this operation cannot be completed.
|
||||
*/
|
||||
protected void flushSpi() throws BackingStoreException
|
||||
{
|
||||
this.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all of the key in this preference node.
|
||||
* If the current node does not have preferences, the returned array will be
|
||||
* of size zero.
|
||||
*
|
||||
* @return A <code>String</code> array of keys stored under the current
|
||||
* node.
|
||||
* @throws BackingStoreException if this operation cannot be completed.
|
||||
*/
|
||||
protected String[] keysSpi() throws BackingStoreException
|
||||
{
|
||||
List keyList = backend.getKeys(this.node);
|
||||
String[] keys = new String[keyList.size()];
|
||||
keyList.toArray(keys);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does a recursive postorder traversal of the preference tree, starting from
|
||||
* the given directory invalidating every preference found in the node.
|
||||
*
|
||||
* @param directory The name of the starting directory (node)
|
||||
*/
|
||||
private void postorderRemove(String directory)
|
||||
{
|
||||
try
|
||||
{
|
||||
// gets the listing of directories in this node
|
||||
List dirs = backend.getChildrenNodes(directory);
|
||||
|
||||
if (dirs.size() != 0)
|
||||
{
|
||||
String currentDir = null;
|
||||
|
||||
for (Iterator itr = dirs.iterator(); itr.hasNext();)
|
||||
{
|
||||
currentDir = (String) itr.next();
|
||||
|
||||
// recursive search inside this directory
|
||||
postorderRemove(currentDir);
|
||||
}
|
||||
}
|
||||
|
||||
// remove all the keys associated to this directory
|
||||
List entries = backend.getKeys(directory);
|
||||
|
||||
if (entries.size() != 0)
|
||||
{
|
||||
String key = null;
|
||||
|
||||
for (Iterator keys = entries.iterator(); keys.hasNext();)
|
||||
{
|
||||
key = (String) keys.next();
|
||||
this.removeSpi(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (BackingStoreException ex)
|
||||
{
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the given key-value pair into this preference node.
|
||||
*
|
||||
* @param key The key of this preference.
|
||||
* @param value The value of this preference.
|
||||
*/
|
||||
protected void putSpi(String key, String value)
|
||||
{
|
||||
backend.setString(this.getGConfKey(key), value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this preference node, including all its children.
|
||||
* Also removes the preferences associated.
|
||||
*/
|
||||
protected void removeNodeSpi() throws BackingStoreException
|
||||
{
|
||||
this.postorderRemove(this.node);
|
||||
this.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the given key from this preference node.
|
||||
* If the key does not exist, no operation is performed.
|
||||
*
|
||||
* @param key The key to remove.
|
||||
*/
|
||||
protected void removeSpi(String key)
|
||||
{
|
||||
backend.unset(this.getGConfKey(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Suggest a sync to the backend. Actually, this is only a suggestion as GConf
|
||||
* handles this for us asynchronously. More over, both sync and flush have the
|
||||
* same meaning in this class, so calling flush has exactly the same effect.
|
||||
*
|
||||
* @see #flush
|
||||
* @throws BackingStoreException if this operation cannot be completed due to
|
||||
* a failure in the backing store, or inability to communicate with
|
||||
* it.
|
||||
*/
|
||||
public void sync() throws BackingStoreException
|
||||
{
|
||||
this.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Request a sync.
|
||||
*
|
||||
* @see #sync
|
||||
* @throws BackingStoreException if this operation cannot be completed due to
|
||||
* a failure in the backing store, or inability to communicate with
|
||||
* it.
|
||||
*/
|
||||
protected void syncSpi() throws BackingStoreException
|
||||
{
|
||||
this.sync();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the given key.
|
||||
* If the keys does not have a value, or there is an error in the backing
|
||||
* store, <code>null</code> is returned instead.
|
||||
*
|
||||
* @param key The key to retrieve.
|
||||
* @return The value associated with the given key.
|
||||
*/
|
||||
protected String getSpi(String key)
|
||||
{
|
||||
return backend.getKey(this.getGConfKey(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this preference node is a user node,
|
||||
* <code>false</code> if is a system preference node.
|
||||
*
|
||||
* @return <code>true</code> if this preference node is a user node,
|
||||
* <code>false</code> if is a system preference node.
|
||||
*/
|
||||
public boolean isUserNode()
|
||||
{
|
||||
return this.isUser;
|
||||
}
|
||||
|
||||
/*
|
||||
* PRIVATE METHODS
|
||||
*/
|
||||
|
||||
/**
|
||||
* Builds a GConf key string suitable for operations on the backend.
|
||||
*
|
||||
* @param key The key to convert into a valid GConf key.
|
||||
* @return A valid Gconf key.
|
||||
*/
|
||||
private String getGConfKey(String key)
|
||||
{
|
||||
String nodeName = "";
|
||||
|
||||
if (this.node.endsWith("/"))
|
||||
{
|
||||
nodeName = this.node + key;
|
||||
}
|
||||
else
|
||||
{
|
||||
nodeName = this.node + "/" + key;
|
||||
}
|
||||
|
||||
return nodeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the root node to use for this preference.
|
||||
*
|
||||
* @param isUser Defines if this node is a user (<code>true</code>) or system
|
||||
* (<code>false</code>) node.
|
||||
* @return The real root of this preference tree.
|
||||
*/
|
||||
private String getRealRoot(boolean isUser)
|
||||
{
|
||||
// not sure about this, we should have already these permissions...
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
|
||||
if (security != null)
|
||||
{
|
||||
security.checkPermission(PERMISSION);
|
||||
}
|
||||
|
||||
String root = null;
|
||||
|
||||
if (isUser)
|
||||
{
|
||||
root = System.getProperty("gnu.java.util.prefs.gconf.user_root",
|
||||
DEFAULT_USER_ROOT);
|
||||
}
|
||||
else
|
||||
{
|
||||
root = System.getProperty("gnu.java.util.prefs.gconf.system_root",
|
||||
DEFAULT_SYSTEM_ROOT);
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
}
|
298
libjava/classpath/gnu/java/util/prefs/gconf/GConfNativePeer.java
Normal file
298
libjava/classpath/gnu/java/util/prefs/gconf/GConfNativePeer.java
Normal file
|
@ -0,0 +1,298 @@
|
|||
/* 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. */
|
||||
|
||||
|
||||
package gnu.java.util.prefs.gconf;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.prefs.BackingStoreException;
|
||||
|
||||
/**
|
||||
* Native peer for GConf based preference backend.
|
||||
*
|
||||
* @author Mario Torre <neugens@limasoftware.net>
|
||||
* @version 1.0.1
|
||||
*/
|
||||
public final class GConfNativePeer
|
||||
{
|
||||
/**
|
||||
* Object to achieve locks for methods that need to be synchronized.
|
||||
*/
|
||||
private static final Object[] semaphore = new Object[0];
|
||||
|
||||
/**
|
||||
* Creates a new instance of GConfNativePeer
|
||||
*/
|
||||
public GConfNativePeer()
|
||||
{
|
||||
synchronized (semaphore)
|
||||
{
|
||||
init_class();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries whether the node <code>node</code> exists in theGConf database.
|
||||
* Returns <code>true</code> or <code>false</code>.
|
||||
*
|
||||
* @param node the node to check.
|
||||
*/
|
||||
public boolean nodeExist(String node)
|
||||
{
|
||||
return gconf_client_dir_exists(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the node <code>node</code> to the list of nodes the GConf will watch.
|
||||
* An event is raised everytime this node is changed. You can add a node
|
||||
* multiple times.
|
||||
*
|
||||
* @param node the node to track.
|
||||
*/
|
||||
public void startWatchingNode(String node)
|
||||
{
|
||||
gconf_client_add_dir(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the node <code>node</code> to the list of nodes the GConf is
|
||||
* watching. Note that if a node has been added multiple times, you must
|
||||
* remove it the same number of times before the remove takes effect.
|
||||
*
|
||||
* @param node the node you don't want to track anymore.
|
||||
*/
|
||||
public void stopWatchingNode(String node)
|
||||
{
|
||||
gconf_client_remove_dir(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param key the key to alter (or add).
|
||||
* @param value the new value for this key.
|
||||
* @return true if the key was updated, false otherwise.
|
||||
*/
|
||||
public boolean setString(String key, String value)
|
||||
{
|
||||
return gconf_client_set_string(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param key the key to unset.
|
||||
* @return true on success, false if the key was not updated.
|
||||
*/
|
||||
public boolean unset(String key)
|
||||
{
|
||||
return gconf_client_unset(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of a configuration key.
|
||||
*
|
||||
* @param key the configuration key.
|
||||
* @return the values of this key, null if the key is not valid.
|
||||
*/
|
||||
public String getKey(String key)
|
||||
{
|
||||
return gconf_client_get_string(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param node the node where keys are stored.
|
||||
* @return a java.util.List of keys. If there are no keys in the given node, a
|
||||
* list of size 0 is returned.
|
||||
*/
|
||||
public List getKeys(String node) throws BackingStoreException
|
||||
{
|
||||
return gconf_client_gconf_client_all_keys(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists the subnodes in <code>node</code>. The returned list contains
|
||||
* allocated strings. Each string is the name relative tho the given node.
|
||||
*
|
||||
* @param node the node to get subnodes from. If there are no subnodes in the
|
||||
* given node, a list of size 0 is returned.
|
||||
*/
|
||||
public List getChildrenNodes(String node) throws BackingStoreException
|
||||
{
|
||||
return gconf_client_gconf_client_all_nodes(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Suggest to the backend GConf daemon to synch with the database.
|
||||
*/
|
||||
public void suggestSync() throws BackingStoreException
|
||||
{
|
||||
gconf_client_suggest_sync();
|
||||
}
|
||||
|
||||
protected void finalize() throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
synchronized (semaphore)
|
||||
{
|
||||
finalize_class();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
|
||||
/* ***** native methods ***** */
|
||||
|
||||
/*
|
||||
* Basicly, these are one to one mappings to GConfClient functions.
|
||||
* GConfClient instances are handled by the native layer, and are hidden from
|
||||
* the main java class.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize the GConf native peer and enable the object cache.
|
||||
* It is meant to be used by the static initializer.
|
||||
*/
|
||||
native static final private void init_id_cache();
|
||||
|
||||
/**
|
||||
* Initialize the GConf native peer. This is meant to be used by the
|
||||
* class constructor.
|
||||
*/
|
||||
native static final private void init_class();
|
||||
|
||||
/**
|
||||
* Class finalizer.
|
||||
*/
|
||||
native static final private void finalize_class();
|
||||
|
||||
/**
|
||||
* Queries the GConf database to see if the given node exists, returning
|
||||
* true if the node exist, false otherwise.
|
||||
*
|
||||
* @param node the node to query for existence.
|
||||
* @return true if the node exist, false otherwise.
|
||||
*/
|
||||
native static final protected boolean gconf_client_dir_exists(String node);
|
||||
|
||||
/**
|
||||
* Adds the given node to the list of nodes that GConf watches for
|
||||
* changes.
|
||||
*
|
||||
* @param node the node to watch for changes.
|
||||
*/
|
||||
native static final protected void gconf_client_add_dir(String node);
|
||||
|
||||
/**
|
||||
* Removes the given node from the list of nodes that GConf watches for
|
||||
* changes.
|
||||
*
|
||||
* @param node the node to remove from from the list of watched nodes.
|
||||
*/
|
||||
native static final protected void gconf_client_remove_dir(String node);
|
||||
|
||||
/**
|
||||
* Sets the given key/value pair into the GConf database.
|
||||
* The key must be a valid GConf key.
|
||||
*
|
||||
* @param key the key to store in the GConf database
|
||||
* @param value the value to associate to the given key.
|
||||
* @return true if the change has effect, false otherwise.
|
||||
*/
|
||||
native static final protected boolean gconf_client_set_string(String key,
|
||||
String value);
|
||||
|
||||
/**
|
||||
* Returns the key associated to the given key. Null is returned if the
|
||||
* key is not valid.
|
||||
*
|
||||
* @param key the key to return the value of.
|
||||
* @return The value associated to the given key, or null.
|
||||
*/
|
||||
native static final protected String gconf_client_get_string(String key);
|
||||
|
||||
/**
|
||||
* Usets the given key, removing the key from the database.
|
||||
*
|
||||
* @param key the key to remove.
|
||||
* @return true if the operation success, false otherwise.
|
||||
*/
|
||||
native static final protected boolean gconf_client_unset(String key);
|
||||
|
||||
/**
|
||||
* Suggest to the GConf native peer a sync with the database.
|
||||
*
|
||||
*/
|
||||
native static final protected void gconf_client_suggest_sync();
|
||||
|
||||
/**
|
||||
* Returns a list of all nodes under the given node.
|
||||
*
|
||||
* @param node the source node.
|
||||
* @return A list of nodes under the given source node.
|
||||
*/
|
||||
native
|
||||
static final protected List gconf_client_gconf_client_all_nodes(String node);
|
||||
|
||||
/**
|
||||
* Returns a list of all keys stored in the given node.
|
||||
*
|
||||
* @param node the source node.
|
||||
* @return A list of all keys stored in the given node.
|
||||
*/
|
||||
native
|
||||
static final protected List gconf_client_gconf_client_all_keys(String node);
|
||||
|
||||
static
|
||||
{
|
||||
System.loadLibrary("gconfpeer");
|
||||
init_id_cache();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue