org.openstreetmap.josm.data.osm
Class User

java.lang.Object
  extended by org.openstreetmap.josm.data.osm.User

public class User
extends java.lang.Object

A simple class to keep a list of user names. Instead of storing user names as strings with every OSM primitive, we store a reference to an user object, and make sure that for each username there is only one user object.


Field Summary
private static User anonymous
           
private  java.util.HashSet<java.lang.String> names
          the user name
private static java.util.HashSet<java.lang.Long> nonRelicensingUsers
           
private  int relicensingStatus
           
private static java.util.HashSet<java.lang.Long> relicensingUsers
           
static int STATUS_AGREED
           
static int STATUS_ANONYMOUS
           
static int STATUS_AUTO_AGREED
           
static int STATUS_NOT_AGREED
           
static int STATUS_UNDECIDED
           
static int STATUS_UNKNOWN
           
private  long uid
          the user id
private static java.util.concurrent.atomic.AtomicLong uidCounter
           
private static java.util.HashMap<java.lang.Long,User> userMap
          the map of known users
 
Constructor Summary
private User(long uid, java.lang.String name)
          private constructor, only called from get method.
 
Method Summary
 void addName(java.lang.String name)
          Adds a user name to the list if it is not there, yet.
static void clearUserMap()
          clears the static map of user ids to user objects
static User createLocalUser(java.lang.String name)
          Creates a local user with the given name
static User createOsmUser(long uid, java.lang.String name)
          Creates a user known to the OSM server
 boolean equals(java.lang.Object obj)
           
static User getAnonymous()
           
static User getById(long uid)
          Returns the user with user id uid or null if this user doesn't exist
static java.util.List<User> getByName(java.lang.String name)
          Returns the list of users with name name or the empty list if no such users exist
 long getId()
          Replies the user id.
 java.lang.String getName()
          Replies the user name
 java.util.ArrayList<java.lang.String> getNames()
          Returns the list of user names
private static long getNextLocalUid()
           
 int getRelicensingStatus()
          Finds out this user's relicensing status and saves it for quicker access.
 int hashCode()
           
 boolean hasName(java.lang.String name)
          Returns true if the name is in the names list
static void initRelicensingInformation()
           
 boolean isLocalUser()
           
 boolean isOsmUser()
           
static void loadRelicensingInformation(boolean clean)
           
 void setRelicensingStatus(int status)
          Sets this user's relicensing status.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

uidCounter

private static java.util.concurrent.atomic.AtomicLong uidCounter

userMap

private static java.util.HashMap<java.lang.Long,User> userMap
the map of known users


relicensingUsers

private static java.util.HashSet<java.lang.Long> relicensingUsers

nonRelicensingUsers

private static java.util.HashSet<java.lang.Long> nonRelicensingUsers

anonymous

private static final User anonymous

names

private final java.util.HashSet<java.lang.String> names
the user name


uid

private final long uid
the user id


relicensingStatus

private int relicensingStatus

STATUS_UNKNOWN

public static final int STATUS_UNKNOWN
See Also:
Constant Field Values

STATUS_UNDECIDED

public static final int STATUS_UNDECIDED
See Also:
Constant Field Values

STATUS_AGREED

public static final int STATUS_AGREED
See Also:
Constant Field Values

STATUS_NOT_AGREED

public static final int STATUS_NOT_AGREED
See Also:
Constant Field Values

STATUS_AUTO_AGREED

public static final int STATUS_AUTO_AGREED
See Also:
Constant Field Values

STATUS_ANONYMOUS

public static final int STATUS_ANONYMOUS
See Also:
Constant Field Values
Constructor Detail

User

private User(long uid,
             java.lang.String name)
private constructor, only called from get method.

Method Detail

getNextLocalUid

private static long getNextLocalUid()

createLocalUser

public static User createLocalUser(java.lang.String name)
Creates a local user with the given name

Parameters:
name - the name

createOsmUser

public static User createOsmUser(long uid,
                                 java.lang.String name)
Creates a user known to the OSM server

Parameters:
uid - the user id
name - the name

clearUserMap

public static void clearUserMap()
clears the static map of user ids to user objects


getById

public static User getById(long uid)
Returns the user with user id uid or null if this user doesn't exist

Parameters:
uid - the user id
Returns:
the user; null, if there is no user with this id

getByName

public static java.util.List<User> getByName(java.lang.String name)
Returns the list of users with name name or the empty list if no such users exist

Parameters:
name - the user name
Returns:
the list of users with name name or the empty list if no such users exist

getAnonymous

public static User getAnonymous()

initRelicensingInformation

public static void initRelicensingInformation()

loadRelicensingInformation

public static void loadRelicensingInformation(boolean clean)

getRelicensingStatus

public int getRelicensingStatus()
Finds out this user's relicensing status and saves it for quicker access.


setRelicensingStatus

public void setRelicensingStatus(int status)
Sets this user's relicensing status. This can be used if relicensing information is available from another source so that directly looking at the users_agreed/users_not_agreed files it not required.


getName

public java.lang.String getName()
Replies the user name

Returns:
the user name. Never null, but may be the empty string

getNames

public java.util.ArrayList<java.lang.String> getNames()
Returns the list of user names


addName

public void addName(java.lang.String name)
Adds a user name to the list if it is not there, yet.

Parameters:
name -

hasName

public boolean hasName(java.lang.String name)
Returns true if the name is in the names list

Parameters:
name -

getId

public long getId()
Replies the user id. If this user is known to the OSM server the positive user id from the server is replied. Otherwise, a negative local value is replied. A negative local is only unique during an editing session. It is lost when the application is closed and there is no guarantee that a negative local user id is always bound to a user with the same name.


isOsmUser

public boolean isOsmUser()

isLocalUser

public boolean isLocalUser()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


JOSM