ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r1748724 - /ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/struct/MapFactory.java
Date Thu, 16 Jun 2016 13:41:57 GMT
Author: tmill
Date: Thu Jun 16 13:41:57 2016
New Revision: 1748724

URL: http://svn.apache.org/viewvc?rev=1748724&view=rev
Log:
Add map factory for indexing maps between uima structs with doc-based ids.

Added:
    ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/struct/MapFactory.java

Added: ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/struct/MapFactory.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/struct/MapFactory.java?rev=1748724&view=auto
==============================================================================
--- ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/struct/MapFactory.java
(added)
+++ ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/struct/MapFactory.java
Thu Jun 16 13:41:57 2016
@@ -0,0 +1,27 @@
+package org.apache.ctakes.utils.struct;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.uima.jcas.cas.TOP;
+
+public class MapFactory {
+  private static Map<String, Map<?,?>> mapIndex = new HashMap<>();
+
+  public static <K extends TOP,V extends TOP> V get(String mapId, K key){
+    Map<?,?> map = mapIndex.get(mapId);
+    return (V) map.get(key);
+  }
+  
+  public static <K extends TOP,V extends TOP> void put(String mapId, K key, V value){
+    Map<K,V> map = (Map<K,V>) mapIndex.get(mapId);
+    map.put(key, value);
+  }
+
+  public static <K extends TOP,V extends TOP> Map<K, V> createInstance(String
mapId){
+    Map<K,V> map = new HashMap<>();
+    mapIndex.put(mapId, map);
+    return map;
+  }
+
+}



Mime
View raw message