|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ /* * PsSettings.java * * Created on January 13, 2004, 5:38 PM */ package org.netbeans.modules.openide.explorer; import java.util.HashMap; import java.util.Map; import org.openide.util.Lookup; /** Non-public settings storage for a few trivial settings the * property sheet needs to store. Should be migrated to use * registry and eliminate this class for post 3.6 - for now, * this will do. See * issuezilla issue 36157 for details. * * @author Tim Boudreau */ public abstract class PsSettings { protected PsSettings() {} private static PsSettings defaultInstance = null; /** Get the default instance of PropertySheetSettings */ public static PsSettings getDefault() { if (defaultInstance == null) { defaultInstance = (PsSettings) Lookup.getDefault().lookup(PsSettings.class); if (defaultInstance == null) { defaultInstance = new Trivial(); } } return defaultInstance; } public abstract int getInt (String key, int defaultValue); public abstract void putInt (String key, int value); public abstract void putBoolean (String key, boolean value); public abstract boolean getBoolean (String key, boolean defaultValue); public abstract void put (String key, String value); public abstract String get (String key, String defaultValue); private static class Trivial extends PsSettings { private Map map = new HashMap(); public String get(String key, String defaultValue) { String result = (String) map.get(key); if (result == null) { result = defaultValue; } return result; } public boolean getBoolean(String key, boolean defaultValue) { Boolean result = (Boolean) map.get(key); if (result == null) { return defaultValue; } else { return result.booleanValue(); } } public int getInt(String key, int defaultValue) { Integer i = (Integer) map.get(key); if (i == null) { return defaultValue; } return i.intValue(); } public void put(String key, String value) { map.put(key, value); } public void putBoolean(String key, boolean value) { map.put (key, value ? Boolean.TRUE : Boolean.FALSE); } public void putInt(String key, int value) { map.put (key, new Integer(value)); } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.