summaryrefslogtreecommitdiff
blob: 5657cac9feb40a54a788b2aee8a4b8372c953c28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.util.Map;
import java.util.HashMap;

public class Strings
{
   private static final Map<String, IDs> TO_ID;

   static
   {
      TO_ID = new HashMap<String, IDs>();
   }

   private Strings () {} /* Utility class. */

   public static IDs get_id_from_string (String string)
   {
      IDs result;

      string = string.toLowerCase();
      result = TO_ID.get(string);

      if (result == null)
      {
         result = IDs.generate_new_id("string");

         TO_ID.put(string, result);

         /* TODO: remove, it's for debug. */
         System.out.println
         (
            "[STR] (\""
            + string
            + "\"->"
            + result.get_value()
            + ")"
         );
      }

      return result;
   }
}