@Test public void testFigure() throws UIMAException { final JCas jCas = JCasSingleton.getJCasInstance(); final StructuralAnnotations sa = new StructuralAnnotations(); final Element anchor = new Element(Tag.valueOf("img"), ""); anchor.attr("src", "test"); final AnnotationCollector collector = new AnnotationCollector(); sa.map(jCas, anchor, collector); Annotation fig = collector.getAnnotations().get(0); assertTrue(fig instanceof Figure); assertEquals("test", ((Figure) fig).getTarget()); }
@Override @SuppressWarnings({"squid:S128", "squid:S1479"} ) public void map(final JCas jCas, final Element element, final AnnotationCollector collector) { Structure s = null; switch (element.tagName().toLowerCase()) { case "p": s = new Paragraph(jCas); break; case "h1": s = createHeading(jCas, 1); break; case "h2": s = createHeading(jCas, 2); break; case "h3": s = createHeading(jCas, 3); break; case "h4": s = createHeading(jCas, 4); break; case "h5": s = createHeading(jCas, 5); break; case "h6": s = createHeading(jCas, 6); break; case "ul": s = new Unordered(jCas); break; case "ol": s = new Ordered(jCas); break; case "li": s = new ListItem(jCas); break; case "dl": s = new DefinitionList(jCas); break; case "dt": s = new DefinitionItem(jCas); break; case "dd": s = new DefinitionDescription(jCas); break; case "table": s = new Table(jCas); break; case "thead": s = new TableHeader(jCas); break; case "tfoot": s = new TableFooter(jCas); break; case "tbody": s = new TableBody(jCas); break; case "tr": final TableRow tr = new TableRow(jCas); tr.setRow(findRowIndexOfRow(element)); s = tr; break; case "th": case "td": final TableCell td = new TableCell(jCas); td.setColumn(findColIndexOfCell(element)); td.setRow(findRowIndexOfCell(element)); td.setRowSpan(getIntegerAttribute(element, "rowspan", 1)); td.setColumnSpan(getIntegerAttribute(element, "colspan", 1)); s = td; break; case "a": s = createAnchor(jCas, element); break; case "audio": case "video": case "embed": case "object": case "img": case "map": case "area": case "canvas": case "figure": final Figure figure = new Figure(jCas); if (element.hasAttr("src")) { figure.setTarget(element.attr("src")); } s = figure; break; case "caption": case "figcaption": s = new Caption(jCas); break; case "ins": case "u": s = createStyle(jCas, "underline"); break; case "i": case "em": s = createStyle(jCas, "italics"); break; case "b": case "strong": s = createStyle(jCas, "bold"); break; case "strike": case "s": case "del": s = createStyle(jCas, "strike"); break; case "sup": s = createStyle(jCas, "superscript"); break; case "sub": s = createStyle(jCas, "subscript"); break; case "small": s = createStyle(jCas, "small"); break; case "big": s = createStyle(jCas, "big"); break; case "mark": s = createStyle(jCas, "highlighted"); break; case "aside": s = new Aside(jCas); break; case "details": s = new Details(jCas); break; case "summary": s = new Summary(jCas); break; case "section": case "div": s = new Section(jCas); break; case "span": break; case "main": s = createFromMain(jCas, element); break; case "article": s = createFromArticle(jCas, element); break; case "header": s = new Header(jCas); break; case "footer": s = new Footer(jCas); break; case "kbd": case "samp": case "code": case "pre": s = new Preformatted(jCas); break; case "blockquote": collector.add(new Section(jCas)); case "q": s = new Quotation(jCas); break; case "time": case "meter": case "dfn": case "address": case "abbr": case "cite": return; case "hr": if (element.hasClass("pagebreak") || element.hasClass("sectionbreak")) { s = new Break(jCas); } break; case "html": case "head": case "title": case "meta": case "base": case "style": case "script": case "noscript": case "link": case "dialog": case "nav": case "menu": case "menuitem": case "param": case "track": case "source": case "iframe": case "form": case "input": case "textarea": case "button": case "select": case "optgroup": case "option": case "label": case "fieldset": case "legend": case "datalist": case "keygen": case "output": case "ruby": case "rt": case "rp": case "progress": case "bdo": case "bdi": default: break; } if (s != null) { if (element.hasAttr(CLASS)) { s.setElementClass(element.className()); } if (element.hasAttr("id")) { s.setElementId(element.id()); } collector.add(s); } }
StructuralAnnotations implements ContentMapper { @Override @SuppressWarnings({"squid:S128", "squid:S1479"} ) public void map(final JCas jCas, final Element element, final AnnotationCollector collector) { Structure s = null; switch (element.tagName().toLowerCase()) { case "p": s = new Paragraph(jCas); break; case "h1": s = createHeading(jCas, 1); break; case "h2": s = createHeading(jCas, 2); break; case "h3": s = createHeading(jCas, 3); break; case "h4": s = createHeading(jCas, 4); break; case "h5": s = createHeading(jCas, 5); break; case "h6": s = createHeading(jCas, 6); break; case "ul": s = new Unordered(jCas); break; case "ol": s = new Ordered(jCas); break; case "li": s = new ListItem(jCas); break; case "dl": s = new DefinitionList(jCas); break; case "dt": s = new DefinitionItem(jCas); break; case "dd": s = new DefinitionDescription(jCas); break; case "table": s = new Table(jCas); break; case "thead": s = new TableHeader(jCas); break; case "tfoot": s = new TableFooter(jCas); break; case "tbody": s = new TableBody(jCas); break; case "tr": final TableRow tr = new TableRow(jCas); tr.setRow(findRowIndexOfRow(element)); s = tr; break; case "th": case "td": final TableCell td = new TableCell(jCas); td.setColumn(findColIndexOfCell(element)); td.setRow(findRowIndexOfCell(element)); td.setRowSpan(getIntegerAttribute(element, "rowspan", 1)); td.setColumnSpan(getIntegerAttribute(element, "colspan", 1)); s = td; break; case "a": s = createAnchor(jCas, element); break; case "audio": case "video": case "embed": case "object": case "img": case "map": case "area": case "canvas": case "figure": final Figure figure = new Figure(jCas); if (element.hasAttr("src")) { figure.setTarget(element.attr("src")); } s = figure; break; case "caption": case "figcaption": s = new Caption(jCas); break; case "ins": case "u": s = createStyle(jCas, "underline"); break; case "i": case "em": s = createStyle(jCas, "italics"); break; case "b": case "strong": s = createStyle(jCas, "bold"); break; case "strike": case "s": case "del": s = createStyle(jCas, "strike"); break; case "sup": s = createStyle(jCas, "superscript"); break; case "sub": s = createStyle(jCas, "subscript"); break; case "small": s = createStyle(jCas, "small"); break; case "big": s = createStyle(jCas, "big"); break; case "mark": s = createStyle(jCas, "highlighted"); break; case "aside": s = new Aside(jCas); break; case "details": s = new Details(jCas); break; case "summary": s = new Summary(jCas); break; case "section": case "div": s = new Section(jCas); break; case "span": break; case "main": s = createFromMain(jCas, element); break; case "article": s = createFromArticle(jCas, element); break; case "header": s = new Header(jCas); break; case "footer": s = new Footer(jCas); break; case "kbd": case "samp": case "code": case "pre": s = new Preformatted(jCas); break; case "blockquote": collector.add(new Section(jCas)); case "q": s = new Quotation(jCas); break; case "time": case "meter": case "dfn": case "address": case "abbr": case "cite": return; case "hr": if (element.hasClass("pagebreak") || element.hasClass("sectionbreak")) { s = new Break(jCas); } break; case "html": case "head": case "title": case "meta": case "base": case "style": case "script": case "noscript": case "link": case "dialog": case "nav": case "menu": case "menuitem": case "param": case "track": case "source": case "iframe": case "form": case "input": case "textarea": case "button": case "select": case "optgroup": case "option": case "label": case "fieldset": case "legend": case "datalist": case "keygen": case "output": case "ruby": case "rt": case "rp": case "progress": case "bdo": case "bdi": default: break; } if (s != null) { if (element.hasAttr(CLASS)) { s.setElementClass(element.className()); } if (element.hasAttr("id")) { s.setElementId(element.id()); } collector.add(s); } } }
StructuralAnnotations implements ContentMapper { @Override @SuppressWarnings({"squid:S128", "squid:S1479"} ) public void map(final JCas jCas, final Element element, final AnnotationCollector collector) { Structure s = null; switch (element.tagName().toLowerCase()) { case "p": s = new Paragraph(jCas); break; case "h1": s = createHeading(jCas, 1); break; case "h2": s = createHeading(jCas, 2); break; case "h3": s = createHeading(jCas, 3); break; case "h4": s = createHeading(jCas, 4); break; case "h5": s = createHeading(jCas, 5); break; case "h6": s = createHeading(jCas, 6); break; case "ul": s = new Unordered(jCas); break; case "ol": s = new Ordered(jCas); break; case "li": s = new ListItem(jCas); break; case "dl": s = new DefinitionList(jCas); break; case "dt": s = new DefinitionItem(jCas); break; case "dd": s = new DefinitionDescription(jCas); break; case "table": s = new Table(jCas); break; case "thead": s = new TableHeader(jCas); break; case "tfoot": s = new TableFooter(jCas); break; case "tbody": s = new TableBody(jCas); break; case "tr": final TableRow tr = new TableRow(jCas); tr.setRow(findRowIndexOfRow(element)); s = tr; break; case "th": case "td": final TableCell td = new TableCell(jCas); td.setColumn(findColIndexOfCell(element)); td.setRow(findRowIndexOfCell(element)); td.setRowSpan(getIntegerAttribute(element, "rowspan", 1)); td.setColumnSpan(getIntegerAttribute(element, "colspan", 1)); s = td; break; case "a": s = createAnchor(jCas, element); break; case "audio": case "video": case "embed": case "object": case "img": case "map": case "area": case "canvas": case "figure": final Figure figure = new Figure(jCas); if (element.hasAttr("src")) { figure.setTarget(element.attr("src")); } s = figure; break; case "caption": case "figcaption": s = new Caption(jCas); break; case "ins": case "u": s = createStyle(jCas, "underline"); break; case "i": case "em": s = createStyle(jCas, "italics"); break; case "b": case "strong": s = createStyle(jCas, "bold"); break; case "strike": case "s": case "del": s = createStyle(jCas, "strike"); break; case "sup": s = createStyle(jCas, "superscript"); break; case "sub": s = createStyle(jCas, "subscript"); break; case "small": s = createStyle(jCas, "small"); break; case "big": s = createStyle(jCas, "big"); break; case "mark": s = createStyle(jCas, "highlighted"); break; case "aside": s = new Aside(jCas); break; case "details": s = new Details(jCas); break; case "summary": s = new Summary(jCas); break; case "section": case "div": s = new Section(jCas); break; case "span": break; case "main": s = createFromMain(jCas, element); break; case "article": s = createFromArticle(jCas, element); break; case "header": s = new Header(jCas); break; case "footer": s = new Footer(jCas); break; case "kbd": case "samp": case "code": case "pre": s = new Preformatted(jCas); break; case "blockquote": collector.add(new Section(jCas)); case "q": s = new Quotation(jCas); break; case "time": case "meter": case "dfn": case "address": case "abbr": case "cite": return; case "hr": if (element.hasClass("pagebreak") || element.hasClass("sectionbreak")) { s = new Break(jCas); } break; case "html": case "head": case "title": case "meta": case "base": case "style": case "script": case "noscript": case "link": case "dialog": case "nav": case "menu": case "menuitem": case "param": case "track": case "source": case "iframe": case "form": case "input": case "textarea": case "button": case "select": case "optgroup": case "option": case "label": case "fieldset": case "legend": case "datalist": case "keygen": case "output": case "ruby": case "rt": case "rp": case "progress": case "bdo": case "bdi": default: break; } if (s != null) { if (element.hasAttr(CLASS)) { s.setElementClass(element.className()); } if (element.hasAttr("id")) { s.setElementId(element.id()); } collector.add(s); } }  }
StructuralAnnotations implements ContentMapper { @Override @SuppressWarnings({"squid:S128", "squid:S1479"} ) public void map(final JCas jCas, final Element element, final AnnotationCollector collector) { Structure s = null; switch (element.tagName().toLowerCase()) { case "p": s = new Paragraph(jCas); break; case "h1": s = createHeading(jCas, 1); break; case "h2": s = createHeading(jCas, 2); break; case "h3": s = createHeading(jCas, 3); break; case "h4": s = createHeading(jCas, 4); break; case "h5": s = createHeading(jCas, 5); break; case "h6": s = createHeading(jCas, 6); break; case "ul": s = new Unordered(jCas); break; case "ol": s = new Ordered(jCas); break; case "li": s = new ListItem(jCas); break; case "dl": s = new DefinitionList(jCas); break; case "dt": s = new DefinitionItem(jCas); break; case "dd": s = new DefinitionDescription(jCas); break; case "table": s = new Table(jCas); break; case "thead": s = new TableHeader(jCas); break; case "tfoot": s = new TableFooter(jCas); break; case "tbody": s = new TableBody(jCas); break; case "tr": final TableRow tr = new TableRow(jCas); tr.setRow(findRowIndexOfRow(element)); s = tr; break; case "th": case "td": final TableCell td = new TableCell(jCas); td.setColumn(findColIndexOfCell(element)); td.setRow(findRowIndexOfCell(element)); td.setRowSpan(getIntegerAttribute(element, "rowspan", 1)); td.setColumnSpan(getIntegerAttribute(element, "colspan", 1)); s = td; break; case "a": s = createAnchor(jCas, element); break; case "audio": case "video": case "embed": case "object": case "img": case "map": case "area": case "canvas": case "figure": final Figure figure = new Figure(jCas); if (element.hasAttr("src")) { figure.setTarget(element.attr("src")); } s = figure; break; case "caption": case "figcaption": s = new Caption(jCas); break; case "ins": case "u": s = createStyle(jCas, "underline"); break; case "i": case "em": s = createStyle(jCas, "italics"); break; case "b": case "strong": s = createStyle(jCas, "bold"); break; case "strike": case "s": case "del": s = createStyle(jCas, "strike"); break; case "sup": s = createStyle(jCas, "superscript"); break; case "sub": s = createStyle(jCas, "subscript"); break; case "small": s = createStyle(jCas, "small"); break; case "big": s = createStyle(jCas, "big"); break; case "mark": s = createStyle(jCas, "highlighted"); break; case "aside": s = new Aside(jCas); break; case "details": s = new Details(jCas); break; case "summary": s = new Summary(jCas); break; case "section": case "div": s = new Section(jCas); break; case "span": break; case "main": s = createFromMain(jCas, element); break; case "article": s = createFromArticle(jCas, element); break; case "header": s = new Header(jCas); break; case "footer": s = new Footer(jCas); break; case "kbd": case "samp": case "code": case "pre": s = new Preformatted(jCas); break; case "blockquote": collector.add(new Section(jCas)); case "q": s = new Quotation(jCas); break; case "time": case "meter": case "dfn": case "address": case "abbr": case "cite": return; case "hr": if (element.hasClass("pagebreak") || element.hasClass("sectionbreak")) { s = new Break(jCas); } break; case "html": case "head": case "title": case "meta": case "base": case "style": case "script": case "noscript": case "link": case "dialog": case "nav": case "menu": case "menuitem": case "param": case "track": case "source": case "iframe": case "form": case "input": case "textarea": case "button": case "select": case "optgroup": case "option": case "label": case "fieldset": case "legend": case "datalist": case "keygen": case "output": case "ruby": case "rt": case "rp": case "progress": case "bdo": case "bdi": default: break; } if (s != null) { if (element.hasAttr(CLASS)) { s.setElementClass(element.className()); } if (element.hasAttr("id")) { s.setElementId(element.id()); } collector.add(s); } }  @Override @SuppressWarnings({"squid:S128", "squid:S1479"} /* fall through intended */) void map(final JCas jCas, final Element element, final AnnotationCollector collector); }
StructuralAnnotations implements ContentMapper { @Override @SuppressWarnings({"squid:S128", "squid:S1479"} ) public void map(final JCas jCas, final Element element, final AnnotationCollector collector) { Structure s = null; switch (element.tagName().toLowerCase()) { case "p": s = new Paragraph(jCas); break; case "h1": s = createHeading(jCas, 1); break; case "h2": s = createHeading(jCas, 2); break; case "h3": s = createHeading(jCas, 3); break; case "h4": s = createHeading(jCas, 4); break; case "h5": s = createHeading(jCas, 5); break; case "h6": s = createHeading(jCas, 6); break; case "ul": s = new Unordered(jCas); break; case "ol": s = new Ordered(jCas); break; case "li": s = new ListItem(jCas); break; case "dl": s = new DefinitionList(jCas); break; case "dt": s = new DefinitionItem(jCas); break; case "dd": s = new DefinitionDescription(jCas); break; case "table": s = new Table(jCas); break; case "thead": s = new TableHeader(jCas); break; case "tfoot": s = new TableFooter(jCas); break; case "tbody": s = new TableBody(jCas); break; case "tr": final TableRow tr = new TableRow(jCas); tr.setRow(findRowIndexOfRow(element)); s = tr; break; case "th": case "td": final TableCell td = new TableCell(jCas); td.setColumn(findColIndexOfCell(element)); td.setRow(findRowIndexOfCell(element)); td.setRowSpan(getIntegerAttribute(element, "rowspan", 1)); td.setColumnSpan(getIntegerAttribute(element, "colspan", 1)); s = td; break; case "a": s = createAnchor(jCas, element); break; case "audio": case "video": case "embed": case "object": case "img": case "map": case "area": case "canvas": case "figure": final Figure figure = new Figure(jCas); if (element.hasAttr("src")) { figure.setTarget(element.attr("src")); } s = figure; break; case "caption": case "figcaption": s = new Caption(jCas); break; case "ins": case "u": s = createStyle(jCas, "underline"); break; case "i": case "em": s = createStyle(jCas, "italics"); break; case "b": case "strong": s = createStyle(jCas, "bold"); break; case "strike": case "s": case "del": s = createStyle(jCas, "strike"); break; case "sup": s = createStyle(jCas, "superscript"); break; case "sub": s = createStyle(jCas, "subscript"); break; case "small": s = createStyle(jCas, "small"); break; case "big": s = createStyle(jCas, "big"); break; case "mark": s = createStyle(jCas, "highlighted"); break; case "aside": s = new Aside(jCas); break; case "details": s = new Details(jCas); break; case "summary": s = new Summary(jCas); break; case "section": case "div": s = new Section(jCas); break; case "span": break; case "main": s = createFromMain(jCas, element); break; case "article": s = createFromArticle(jCas, element); break; case "header": s = new Header(jCas); break; case "footer": s = new Footer(jCas); break; case "kbd": case "samp": case "code": case "pre": s = new Preformatted(jCas); break; case "blockquote": collector.add(new Section(jCas)); case "q": s = new Quotation(jCas); break; case "time": case "meter": case "dfn": case "address": case "abbr": case "cite": return; case "hr": if (element.hasClass("pagebreak") || element.hasClass("sectionbreak")) { s = new Break(jCas); } break; case "html": case "head": case "title": case "meta": case "base": case "style": case "script": case "noscript": case "link": case "dialog": case "nav": case "menu": case "menuitem": case "param": case "track": case "source": case "iframe": case "form": case "input": case "textarea": case "button": case "select": case "optgroup": case "option": case "label": case "fieldset": case "legend": case "datalist": case "keygen": case "output": case "ruby": case "rt": case "rp": case "progress": case "bdo": case "bdi": default: break; } if (s != null) { if (element.hasAttr(CLASS)) { s.setElementClass(element.className()); } if (element.hasAttr("id")) { s.setElementId(element.id()); } collector.add(s); } }  @Override @SuppressWarnings({"squid:S128", "squid:S1479"} /* fall through intended */) void map(final JCas jCas, final Element element, final AnnotationCollector collector);  }