@Test public void testElementWithTypeNoAttributes() { Element e = new Element(Tag.valueOf("p"), ""); MarkupUtils.additionallyAnnotateAsType( e, "uk.gov.dstl.baleen.types.metadata.ProtectiveMarking"); mapper.map(jCas, e, collector); assertEquals(1, collector.getAnnotations().size()); ProtectiveMarking annotation = (ProtectiveMarking) collector.getAnnotations().get(0); assertEquals(annotation.getClassification(), null); }
@Override public void map(JCas jCas, Element element, AnnotationCollector collector) { Set<String> types = MarkupUtils.getTypes(element); for (String type : types) { try { Object annotation = getClass() .getClassLoader() .loadClass(type) .getConstructor(JCas.class) .newInstance(jCas); if (!(annotation instanceof Annotation)) { LOGGER.error("Type is not an annotation {}, ignoring", type); continue; } Arrays.stream(annotation.getClass().getMethods()) .filter( m -> m.getName().startsWith("set") && m.getName().length() > 3 && m.getParameterCount() == 1) .forEach(m -> setMethodValue(type, element, annotation, m)); collector.add((Annotation) annotation); } catch (Exception e) { LOGGER.error("Unable to create annotation of type {}", type, e); } } }
DataAttributeMapper implements ContentMapper { @Override public void map(JCas jCas, Element element, AnnotationCollector collector) { Set<String> types = MarkupUtils.getTypes(element); for (String type : types) { try { Object annotation = getClass() .getClassLoader() .loadClass(type) .getConstructor(JCas.class) .newInstance(jCas); if (!(annotation instanceof Annotation)) { LOGGER.error("Type is not an annotation {}, ignoring", type); continue; } Arrays.stream(annotation.getClass().getMethods()) .filter( m -> m.getName().startsWith("set") && m.getName().length() > 3 && m.getParameterCount() == 1) .forEach(m -> setMethodValue(type, element, annotation, m)); collector.add((Annotation) annotation); } catch (Exception e) { LOGGER.error("Unable to create annotation of type {}", type, e); } } } }
DataAttributeMapper implements ContentMapper { @Override public void map(JCas jCas, Element element, AnnotationCollector collector) { Set<String> types = MarkupUtils.getTypes(element); for (String type : types) { try { Object annotation = getClass() .getClassLoader() .loadClass(type) .getConstructor(JCas.class) .newInstance(jCas); if (!(annotation instanceof Annotation)) { LOGGER.error("Type is not an annotation {}, ignoring", type); continue; } Arrays.stream(annotation.getClass().getMethods()) .filter( m -> m.getName().startsWith("set") && m.getName().length() > 3 && m.getParameterCount() == 1) .forEach(m -> setMethodValue(type, element, annotation, m)); collector.add((Annotation) annotation); } catch (Exception e) { LOGGER.error("Unable to create annotation of type {}", type, e); } } }  }
DataAttributeMapper implements ContentMapper { @Override public void map(JCas jCas, Element element, AnnotationCollector collector) { Set<String> types = MarkupUtils.getTypes(element); for (String type : types) { try { Object annotation = getClass() .getClassLoader() .loadClass(type) .getConstructor(JCas.class) .newInstance(jCas); if (!(annotation instanceof Annotation)) { LOGGER.error("Type is not an annotation {}, ignoring", type); continue; } Arrays.stream(annotation.getClass().getMethods()) .filter( m -> m.getName().startsWith("set") && m.getName().length() > 3 && m.getParameterCount() == 1) .forEach(m -> setMethodValue(type, element, annotation, m)); collector.add((Annotation) annotation); } catch (Exception e) { LOGGER.error("Unable to create annotation of type {}", type, e); } } }  @Override void map(JCas jCas, Element element, AnnotationCollector collector); }
DataAttributeMapper implements ContentMapper { @Override public void map(JCas jCas, Element element, AnnotationCollector collector) { Set<String> types = MarkupUtils.getTypes(element); for (String type : types) { try { Object annotation = getClass() .getClassLoader() .loadClass(type) .getConstructor(JCas.class) .newInstance(jCas); if (!(annotation instanceof Annotation)) { LOGGER.error("Type is not an annotation {}, ignoring", type); continue; } Arrays.stream(annotation.getClass().getMethods()) .filter( m -> m.getName().startsWith("set") && m.getName().length() > 3 && m.getParameterCount() == 1) .forEach(m -> setMethodValue(type, element, annotation, m)); collector.add((Annotation) annotation); } catch (Exception e) { LOGGER.error("Unable to create annotation of type {}", type, e); } } }  @Override void map(JCas jCas, Element element, AnnotationCollector collector);  }