@Test public void parseWithFontColor() { HTMLElement element = new HTMLElement( "<html><font color =#000099>Örtlicher Ausbildungsplan für den <br>Studiengang</font></html>"); assertEquals(153, element.getRGBColor()); assertEquals("Örtlicher Ausbildungsplan für den\nStudiengang", element.getText()); element = new HTMLElement( "<html><p style=\"color:navy\">Örtlicher Ausbildungsplan für den <br>Studiengang</html>"); assertEquals(128, element.getRGBColor()); element = new HTMLElement("<html>Örtlicher Ausbildungsplan für den <br>Studiengang</html>"); assertEquals(0, element.getRGBColor()); }
public int getRGBColor() { ElementIterator iterator = new ElementIterator(htmlDocument); Element elem = iterator.next(); while (elem != null) { if (elem.getAttributes().isDefined(CSS.Attribute.COLOR)) { String colorAttr = elem.getAttributes().getAttribute(CSS.Attribute.COLOR).toString(); Color color = new StyleSheet().stringToColor(colorAttr); return color.getRGB() & ~0xFF000000; } elem = iterator.next(); } return 0; }
HTMLElement { public int getRGBColor() { ElementIterator iterator = new ElementIterator(htmlDocument); Element elem = iterator.next(); while (elem != null) { if (elem.getAttributes().isDefined(CSS.Attribute.COLOR)) { String colorAttr = elem.getAttributes().getAttribute(CSS.Attribute.COLOR).toString(); Color color = new StyleSheet().stringToColor(colorAttr); return color.getRGB() & ~0xFF000000; } elem = iterator.next(); } return 0; } }
HTMLElement { public int getRGBColor() { ElementIterator iterator = new ElementIterator(htmlDocument); Element elem = iterator.next(); while (elem != null) { if (elem.getAttributes().isDefined(CSS.Attribute.COLOR)) { String colorAttr = elem.getAttributes().getAttribute(CSS.Attribute.COLOR).toString(); Color color = new StyleSheet().stringToColor(colorAttr); return color.getRGB() & ~0xFF000000; } elem = iterator.next(); } return 0; } HTMLElement(String html); }
HTMLElement { public int getRGBColor() { ElementIterator iterator = new ElementIterator(htmlDocument); Element elem = iterator.next(); while (elem != null) { if (elem.getAttributes().isDefined(CSS.Attribute.COLOR)) { String colorAttr = elem.getAttributes().getAttribute(CSS.Attribute.COLOR).toString(); Color color = new StyleSheet().stringToColor(colorAttr); return color.getRGB() & ~0xFF000000; } elem = iterator.next(); } return 0; } HTMLElement(String html); FontDescriptor getFontDescriptor(); int getRGBColor(); String getHref(); String getText(); }
HTMLElement { public int getRGBColor() { ElementIterator iterator = new ElementIterator(htmlDocument); Element elem = iterator.next(); while (elem != null) { if (elem.getAttributes().isDefined(CSS.Attribute.COLOR)) { String colorAttr = elem.getAttributes().getAttribute(CSS.Attribute.COLOR).toString(); Color color = new StyleSheet().stringToColor(colorAttr); return color.getRGB() & ~0xFF000000; } elem = iterator.next(); } return 0; } HTMLElement(String html); FontDescriptor getFontDescriptor(); int getRGBColor(); String getHref(); String getText();  }