Ignore:
Timestamp:
2005-10-03T04:18:02+02:00 (19 years ago)
Author:
imi
Message:
  • added Selection Dialog
  • added support for graphic engines with a better default engine
  • reorganized data classes with back references
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/data/osm/Key.java

    r7 r8  
    22
    33import java.util.Collection;
     4import java.util.HashMap;
    45import java.util.LinkedList;
     6import java.util.Map;
     7
     8import org.openstreetmap.josm.data.osm.visitor.Visitor;
    59
    610
     
    1519         * The key's name
    1620         */
    17         public String name;
     21        public final String name;
    1822
     23        /**
     24         * All keys are stored here.
     25         */
     26        private static Map<String, Key> allKeys = new HashMap<String, Key>();
     27       
     28        /**
     29         * Generate a key with the given name. You cannot call this directly but
     30         * have to use the static constructor. This makes sure, you get every key
     31         * only once.
     32         */
     33        private Key(String name) {
     34                this.name = name;
     35        }
     36
     37        /**
     38         * Get an instance of the key with the given name.
     39         * @param name  The name of the key to get.
     40         * @return An shared instance of the key with the given name.
     41         */
     42        public static Key get(String name) {
     43                Key key = allKeys.get(name);
     44                if (key == null) {
     45                        key = new Key(name);
     46                        allKeys.put(name, key);
     47                }
     48                return key;
     49        }
     50       
    1951        /**
    2052         * Return an empty list, since keys cannot have nodes.
     
    3971                return name.hashCode();
    4072        }
     73
     74        @Override
     75        public void visit(Visitor visitor) {
     76                visitor.visit(this);
     77        }
    4178}
Note: See TracChangeset for help on using the changeset viewer.