You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ctakes.apache.org by tm...@apache.org on 2016/06/16 13:41:57 UTC
svn commit: r1748724 -
/ctakes/trunk/ctakes-utils/src/main/java/org/apache/ctakes/utils/struct/MapFactory.java
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;
+ }
+
+}