Package org.jdesktop.swingx.auth
Class DefaultUserNameStore
- java.lang.Object
-
- org.jdesktop.beans.AbstractBean
-
- org.jdesktop.swingx.auth.UserNameStore
-
- org.jdesktop.swingx.auth.DefaultUserNameStore
-
@JavaBean public class DefaultUserNameStore extends UserNameStore
Saves the user names in Preferences. Because any string could be part of the user name, for every user name that must be saved a new Preferences key/value pair must be stored.
-
-
Constructor Summary
Constructors Constructor Description DefaultUserNameStore()Creates a new instance of DefaultUserNameStore
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddUserName(java.lang.String name)Add a username to the store.booleancontainsUserName(java.lang.String name)java.util.prefs.PreferencesgetPreferences()java.lang.String[]getUserNames()Gets the current list of users.private voidinitPrefs()Creates the default prefs nodevoidloadUserNames()Loads the user names from PreferencesvoidremoveUserName(java.lang.String name)Removes a username from the list.voidsaveUserNames()Saves the user names to PreferencesvoidsetPreferences(java.util.prefs.Preferences prefs)voidsetUserNames(java.lang.String[] userNames)-
Methods inherited from class org.jdesktop.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clone, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
-
-
-
-
Field Detail
-
USER_KEY
private static final java.lang.String USER_KEY
The key for one of the preferences- See Also:
- Constant Field Values
-
NUM_KEY
private static final java.lang.String NUM_KEY
- See Also:
- Constant Field Values
-
prefs
private java.util.prefs.Preferences prefs
The preferences node
-
userNames
private java.lang.String[] userNames
Contains the user names. Since the list of user names is not frequently updated, there is no penalty in storing the values in an array.
-
-
Method Detail
-
loadUserNames
public void loadUserNames()
Loads the user names from Preferences- Specified by:
loadUserNamesin classUserNameStore
-
saveUserNames
public void saveUserNames()
Saves the user names to Preferences- Specified by:
saveUserNamesin classUserNameStore
-
getUserNames
public java.lang.String[] getUserNames()
Gets the current list of users.- Specified by:
getUserNamesin classUserNameStore
-
setUserNames
public void setUserNames(java.lang.String[] userNames)
- Specified by:
setUserNamesin classUserNameStore
-
addUserName
public void addUserName(java.lang.String name)
Add a username to the store.- Specified by:
addUserNamein classUserNameStore- Parameters:
name-
-
removeUserName
public void removeUserName(java.lang.String name)
Removes a username from the list.- Specified by:
removeUserNamein classUserNameStore- Parameters:
name-
-
containsUserName
public boolean containsUserName(java.lang.String name)
- Specified by:
containsUserNamein classUserNameStore
-
getPreferences
public java.util.prefs.Preferences getPreferences()
- Returns:
- Returns Preferences node in which the user names will be stored
-
setPreferences
public void setPreferences(java.util.prefs.Preferences prefs)
- Parameters:
prefs- the Preferences node to store the user names in. If null, or undefined, then they are stored in /org/jdesktop/swingx/auth/DefaultUserNameStore.
-
initPrefs
private void initPrefs()
Creates the default prefs node
-
-