1 /**
2 * Copyright (C) 2007 Joern Krueger surething@users.sourceforge.net
3 *
4 * This program is free software; you can redistribute
5 * it and/or modify it under the terms of the GNU General
6 * Public License version 2 as published by the Free Software
7 * Foundation.
8 *
9 * This program is distributed in the hope that it will be
10 * useful, but WITHOUT ANY WARRANTY; without even the implied
11 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place,
18 * Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21 package de.surething.lda.locations;
22
23 import java.util.Set;
24 import java.util.TreeSet;
25
26 import de.surethingies.properties.ParameterFactory;
27 import de.surethingies.properties.TypedParameter;
28
29 public class IpLocation implements Location {
30
31 private String identifier;
32
33 /**
34 * Initialize with a Hostname and load the registered properties for it (if
35 * any)
36 */
37 public IpLocation(String hostName) {
38 identifier = hostName;
39
40 if (ParameterFactory.instance().get(LocationSettings.GROUP, hostName).size() == 0) {
41 Set<TypedParameter> parameters = new TreeSet<TypedParameter>();
42
43 parameters.add(new TypedParameter(LocationSettings.DISPLAY_NAME.param(), hostName, hostName));
44 parameters.add(new TypedParameter(LocationSettings.TELEPHONE.param(), hostName, ""));
45
46 ParameterFactory.instance().addParameters(parameters);
47 }
48 }
49
50 public String getIdentifier() {
51 return identifier;
52 }
53
54
55 @Override
56 public String toString() {
57 return (String) ParameterFactory.instance()
58 .get(LocationSettings.DISPLAY_NAME.param(), identifier).getValue();
59 }
60 }