public class JosmUserIdentityManager
extends java.lang.Object
implements org.openstreetmap.josm.data.Preferences.PreferenceChangedListener
Preferences.PreferenceChangeEvent
s and keeps track
of what the current JOSM instance knows about the current user. Other subsystems can
let the global JosmUserStateManager know in case they fully identify the current user, see
#setFullyIdentified(String, long)
.
The information kept by the JosmUserStateManager can be used to
Modifier and Type | Method and Description |
---|---|
static JosmUserIdentityManager |
getInstance()
Replies the unique instance of the JOSM user identity manager
|
int |
getUserId()
Replies the user id of the current JOSM user.
|
org.openstreetmap.josm.data.osm.UserInfo |
getUserInfo()
Replies verified additional information about the current user if the user is
isFullyIdentified() . |
java.lang.String |
getUserName()
Replies the user name of the current JOSM user.
|
void |
initFromPreferences()
Initializes the user identity manager from values in the
Preferences |
boolean |
isAnonymous()
Replies true if the current JOSM user is anonymous.
|
boolean |
isCurrentUser(java.lang.String username)
Replies true if the user with name
username is the current
user |
boolean |
isFullyIdentified()
Replies true if the current JOSM user is fully identified.
|
boolean |
isPartiallyIdentified()
Replies true if the current JOSM user is partially identified.
|
void |
preferenceChanged(org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent evt) |
void |
setAnonymous()
Remembers the fact that the current JOSM user is anonymous.
|
void |
setFullyIdentified(java.lang.String username,
org.openstreetmap.josm.data.osm.UserInfo userinfo)
Remembers the fact that the current JOSM user is fully identified with a
verified pair of user name and user id.
|
void |
setPartiallyIdentified(java.lang.String userName)
Remebers the fact that the current JOSM user is partially identified
by the user name of its OSM account.
|
public static JosmUserIdentityManager getInstance()
public void setAnonymous()
public void setPartiallyIdentified(java.lang.String userName) throws java.lang.IllegalArgumentException
userName
- the user name. Must not be null. Must not be empty (whitespace only).java.lang.IllegalArgumentException
- thrown if userName is nulljava.lang.IllegalArgumentException
- thrown if userName is emptypublic void setFullyIdentified(java.lang.String username, org.openstreetmap.josm.data.osm.UserInfo userinfo) throws java.lang.IllegalArgumentException
userName
- the user name. Must not be null. Must not be empty.userinfo
- additional information about the user, retrieved from the OSM server and including the user idjava.lang.IllegalArgumentException
- thrown if userName is nulljava.lang.IllegalArgumentException
- thrown if userName is emptyjava.lang.IllegalArgumentException
- thrown if userinfo is nullpublic boolean isAnonymous()
public boolean isPartiallyIdentified()
public boolean isFullyIdentified()
public java.lang.String getUserName()
isAnonymous()
is true.public int getUserId()
isAnonymous()
or
isPartiallyIdentified()
is true.public org.openstreetmap.josm.data.osm.UserInfo getUserInfo()
isFullyIdentified()
.public void initFromPreferences()
Preferences
public boolean isCurrentUser(java.lang.String username)
username
is the current
userusername
- the user nameusername
is the current
userpublic void preferenceChanged(org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent evt)
preferenceChanged
in interface org.openstreetmap.josm.data.Preferences.PreferenceChangedListener