@Test public void testCreateMetadata() throws UIMAException { JCas jCas = JCasSingleton.getJCasInstance(); Metadata m1 = new Metadata(jCas); m1.setKey("en.hello"); m1.setValue("Hello World"); Metadata m2 = new Metadata(jCas); m2.setKey("fr.hello"); m2.setValue("Bonjour le monde"); Metadata m3 = new Metadata(jCas); m3.setKey("foo"); m3.setValue("bar"); Collection<Metadata> m = new ArrayList<>(); m.add(m1); m.add(m2); m.add(m3); Map<String, Object> metadata = SingleDocumentConsumerFormat.createMetadataMap(m); assertEquals(3, metadata.size()); assertTrue(metadata.containsKey("en_hello")); assertFalse(metadata.containsKey("en.hello")); assertEquals("Hello World", metadata.get("en_hello")); assertTrue(metadata.containsKey("fr_hello")); assertFalse(metadata.containsKey("fr.hello")); assertEquals("Bonjour le monde", metadata.get("fr_hello")); assertTrue(metadata.containsKey("foo")); assertEquals("bar", metadata.get("foo")); }
public static Map<String, Object> createMetadataMap(Collection<Metadata> md) { Map<String, Object> metadata = new HashMap<>(); for (Metadata m : md) { String key = m.getKey().replaceAll("\\.", "_"); if (metadata.containsKey(key)) { List<Object> list = new ArrayList<>(); Object o = metadata.get(key); if (o instanceof List) { list.addAll((List<?>) o); } list.add(m.getValue()); metadata.put(key, m.getValue()); } else { metadata.put(key, m.getValue()); } } return metadata; }
SingleDocumentConsumerFormat { public static Map<String, Object> createMetadataMap(Collection<Metadata> md) { Map<String, Object> metadata = new HashMap<>(); for (Metadata m : md) { String key = m.getKey().replaceAll("\\.", "_"); if (metadata.containsKey(key)) { List<Object> list = new ArrayList<>(); Object o = metadata.get(key); if (o instanceof List) { list.addAll((List<?>) o); } list.add(m.getValue()); metadata.put(key, m.getValue()); } else { metadata.put(key, m.getValue()); } } return metadata; } }
SingleDocumentConsumerFormat { public static Map<String, Object> createMetadataMap(Collection<Metadata> md) { Map<String, Object> metadata = new HashMap<>(); for (Metadata m : md) { String key = m.getKey().replaceAll("\\.", "_"); if (metadata.containsKey(key)) { List<Object> list = new ArrayList<>(); Object o = metadata.get(key); if (o instanceof List) { list.addAll((List<?>) o); } list.add(m.getValue()); metadata.put(key, m.getValue()); } else { metadata.put(key, m.getValue()); } } return metadata; } private  SingleDocumentConsumerFormat(); }
SingleDocumentConsumerFormat { public static Map<String, Object> createMetadataMap(Collection<Metadata> md) { Map<String, Object> metadata = new HashMap<>(); for (Metadata m : md) { String key = m.getKey().replaceAll("\\.", "_"); if (metadata.containsKey(key)) { List<Object> list = new ArrayList<>(); Object o = metadata.get(key); if (o instanceof List) { list.addAll((List<?>) o); } list.add(m.getValue()); metadata.put(key, m.getValue()); } else { metadata.put(key, m.getValue()); } } return metadata; } private  SingleDocumentConsumerFormat(); static Map<String, Object> formatCas(
      JCas jCas,
      IEntityConverterFields fields,
      boolean contentHashAsId,
      UimaMonitor monitor,
      UimaSupport support); static Map<String, Object> createDocumentAnnotationMap(DocumentAnnotation da); static Map<String, Object> createMetadataMap(Collection<Metadata> md); static List<String> createPublishedIdList(Collection<PublishedId> publishedIds); }
SingleDocumentConsumerFormat { public static Map<String, Object> createMetadataMap(Collection<Metadata> md) { Map<String, Object> metadata = new HashMap<>(); for (Metadata m : md) { String key = m.getKey().replaceAll("\\.", "_"); if (metadata.containsKey(key)) { List<Object> list = new ArrayList<>(); Object o = metadata.get(key); if (o instanceof List) { list.addAll((List<?>) o); } list.add(m.getValue()); metadata.put(key, m.getValue()); } else { metadata.put(key, m.getValue()); } } return metadata; } private  SingleDocumentConsumerFormat(); static Map<String, Object> formatCas(
      JCas jCas,
      IEntityConverterFields fields,
      boolean contentHashAsId,
      UimaMonitor monitor,
      UimaSupport support); static Map<String, Object> createDocumentAnnotationMap(DocumentAnnotation da); static Map<String, Object> createMetadataMap(Collection<Metadata> md); static List<String> createPublishedIdList(Collection<PublishedId> publishedIds);  }