source: josm/trunk/src/org/openstreetmap/josm/data/osm/User.java@ 729

Last change on this file since 729 was 655, checked in by ramack, 16 years ago

patch by bruce89, closes #812; thanks bruce

  • Property svn:eol-style set to native
File size: 947 bytes
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.data.osm;
3
4import java.util.HashMap;
5
6/**
7 * A simple class to keep a list of user names.
8 *
9 * Instead of storing user names as strings with every OSM primitive, we store
10 * a reference to an user object, and make sure that for each username there
11 * is only one user object.
12 *
13 * @author fred
14 *
15 */
16public class User {
17
18 /** storage for existing User objects. */
19 private static HashMap<String,User> userMap = new HashMap<String,User>();
20
21 /** the username. */
22 public String name;
23
24 /** private constructor, only called from get method. */
25 private User(String name) {
26 this.name = name;
27 }
28
29 /** returns a new or existing User object that represents the given name. */
30 public static User get(String name) {
31 User user = userMap.get(name);
32 if (user == null) {
33 user = new User(name);
34 userMap.put(name, user);
35 }
36 return user;
37 }
38}
Note: See TracBrowser for help on using the repository browser.