Last change
on this file was 298, checked in by imi, 18 years ago |
- added license description to head of each source file
|
File size:
946 bytes
|
Line | |
---|
1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.data.osm;
|
---|
3 |
|
---|
4 | import 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 primtive, 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 | */
|
---|
16 | public 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.