01: package org.geotools.util;
02:
03: import java.util.HashSet;
04: import java.util.Iterator;
05:
06: import org.geotools.feature.iso.Types;
07: import org.opengis.feature.type.Name;
08:
09: public class Namespace extends HashSet implements
10: org.opengis.feature.type.Namespace {
11:
12: /**
13: * Name of the namespace, usually maps to a uri.
14: */
15: Name name;
16:
17: /**
18: * Construct a namespace from a pre-existing name.
19: *
20: * @param name
21: * The name of this namespace.
22: */
23: public Namespace(Name name) {
24: this .name = name;
25: }
26:
27: /**
28: * Construct a namespace from a uri.
29: *
30: * @param uri
31: * The uri of the namespace.
32: */
33: public Namespace(String uri) {
34: this .name = Types.typeName(uri);
35: }
36:
37: public Name getName() {
38: return name;
39: }
40:
41: public String getURI() {
42: return getName().getURI();
43: }
44:
45: public Name lookup(String lookupName) {
46: if (lookupName == null)
47: return null;
48:
49: Name name = new org.geotools.feature.Name(getURI(), lookupName);
50:
51: for (Iterator itr = iterator(); itr.hasNext();) {
52: Name n = (Name) itr.next();
53: if (name.equals(n))
54: return n;
55: }
56:
57: return null;
58: }
59:
60: }
|