/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// fixme need security checks?
// CF preferences file name for Java nodes with short names
// This value is also in MacOSXPreferencesFile.c
// true if this node is a child of userRoot or is userRoot
private final boolean isUser;
// true if this node is userRoot or systemRoot
private final boolean isRoot;
// CF's storage location for this node and its keys
// absolutePath() + "/"
// User root and system root nodes
// Returns user root node, creating it if necessary.
// Called by MacOSXPreferencesFactory
userRoot = new MacOSXPreferences(true);
}
return userRoot;
}
// Returns system root node, creating it if necessary.
// Called by MacOSXPreferencesFactory
if (systemRoot == null) {
systemRoot = new MacOSXPreferences(false);
}
return systemRoot;
}
// Create a new root node. Called by getUserRoot() and getSystemRoot()
// Synchronization is provided by the caller.
}
// Create a new non-root node with the given parent.
// Called by childSpi().
}
boolean isNew)
{
}
{
if (isRoot)
else
this.isUser = isUserNode();
if (isNew)
else
}
// Create and return the MacOSXPreferencesFile for this node.
// Does not write anything to the file.
{
// The fourth slash is the end of the first three components.
// If there is no fourth slash, the name has fewer than 3 components
int componentCount = 0;
int pos = -1;
for (int i = 0; i < 4; i++) {
if (pos == -1) break;
}
if (pos == -1) {
// fewer than three components - use default name
} else {
// truncate to three components, no leading or trailing '/'
// replace '/' with '.' to make filesystem happy
// convert to all lowercase to survive on HFS+
}
}
// AbstractPreferences implementation
{
}
// AbstractPreferences implementation
{
}
// AbstractPreferences implementation
{
}
// AbstractPreferences implementation
protected void removeNodeSpi()
throws BackingStoreException
{
// Disallow flush or sync between these two operations
// (they may be manipulating two different files)
synchronized(MacOSXPreferencesFile.class) {
}
}
// Erase knowledge about a child of this node. Called by removeNodeSpi.
{
}
// AbstractPreferences implementation
throws BackingStoreException
{
if (result == null) throw new BackingStoreException("Couldn't get list of children for node '" + path + "'");
return result;
}
// AbstractPreferences implementation
throws BackingStoreException
{
if (result == null) throw new BackingStoreException("Couldn't get list of keys for node '" + path + "'");
return result;
}
// AbstractPreferences implementation
{
// Add to parent's child list here and disallow sync
// because parent and child might be in different files.
synchronized(MacOSXPreferencesFile.class) {
}
}
// AbstractPreferences override
public void flush()
throws BackingStoreException
{
// Flush should *not* check for removal, unlike sync, but should
// prevent simultaneous removal.
synchronized(lock) {
if (isUser) {
if (!MacOSXPreferencesFile.flushUser()) {
}
} else {
if (!MacOSXPreferencesFile.flushWorld()) {
}
}
}
}
// AbstractPreferences implementation
protected void flushSpi()
throws BackingStoreException
{
// nothing here - overridden flush() doesn't call this
}
// AbstractPreferences override
public void sync()
throws BackingStoreException
{
synchronized(lock) {
if (isRemoved())
throw new IllegalStateException("Node has been removed");
// fixme! overkill
if (isUser) {
if (!MacOSXPreferencesFile.syncUser()) {
}
} else {
if (!MacOSXPreferencesFile.syncWorld()) {
}
}
}
}
// AbstractPreferences implementation
protected void syncSpi()
throws BackingStoreException
{
// nothing here - overridden sync() doesn't call this
}
}