@Override public HSDeck getDeckDetail(final HSDeck hsDeck, final float n) { try { final Document value = Jsoup.connect(HPDeckSource.BASE_URL + hsDeck.getUrl()).get(); final Elements select = value.select("section.class-listing table.listing td.col-name"); final HashMap<String, String> classHsItemMap = new HashMap<String, String>(); final ArrayList<String> list = new ArrayList<String>(); for (int i = 0; i < select.size(); ++i) { final String text = select.get(i).select("a").get(0).text(); classHsItemMap.put( text, select.get(i).text().trim().substring(select.get(i).text().trim().length() - 1)); list.add(text); } hsDeck.setClassHsItemMap(classHsItemMap); hsDeck.setClassHsItemList(DataBaseManager.getInstance().getAllCardsByNames(list)); final Elements select2 = value.select("section.neutral-listing table.listing td.col-name"); final HashMap<String, String> neutralHsItemMap = new HashMap<String, String>(); final ArrayList<String> list2 = new ArrayList<String>(); for (int j = 0; j < select2.size(); ++j) { final String text2 = select2.get(j).select("a").get(0).text(); neutralHsItemMap.put( text2, select2.get(j).text().trim().substring(select2.get(j).text().trim().length() - 1)); list2.add(text2); } hsDeck.setNeutralHsItemMap(neutralHsItemMap); hsDeck.setNeutralHsItemList(DataBaseManager.getInstance().getAllCardsByNames(list2)); hsDeck.setDescription( HtmlHelper.parseDescription(value.select("div.deck-description").html(), n, false)); return hsDeck; } catch (IOException ex) { ex.printStackTrace(); return hsDeck; } }
private void styleContents(CellStyle style) { if (style.getAlignment() != 2) { styleOut("text-align", style.getAlignment(), ALIGN); styleOut("vertical-align", style.getAlignment(), VERTICAL_ALIGN); } helper.colorStyles(style, out); }
public void testCleanTiming() throws Exception { long start = System.currentTimeMillis(); for (int i = 0; i < 100; i++) { String source = "<p>some html</p>"; String cleaned = HtmlHelper.clean(source); } long elapsed = System.currentTimeMillis() - start; System.out.println("100 cleanings in " + elapsed + " (ms)"); }
public void testTarget() throws Exception { String source = "<p>some text <a href=\"some.url\" target=\"_blank\">the link</a></p>"; String cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "<p>some text <a href=\"some.url\" target=\"help\">the link</a></p>"; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "<p>some text <a href=\"some.url\">the link</a></p>"; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "<p>some text <a href=\"some.url\">the link</a><a href=\"some.url\">the link</a></p>"; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "<a href=\"some.url\">the link</a>"; cleaned = HtmlHelper.clean(source); display(source, cleaned); }
private void fontStyle(Font font) { if (font.getBoldweight() >= Font.BOLDWEIGHT_BOLD) out.format(" font-weight: bold;%n"); if (font.getItalic()) out.format(" font-style: italic;%n"); out.format(" font-family: %s;%n", font.getFontName()); int fontheight = font.getFontHeightInPoints(); if (fontheight == 9) { fontheight = 10; } out.format(" font-size: %dpt;%n", fontheight); helper.styleColor(out, "color", getColor(font)); }
public void testClean() throws Exception { String source = "<p>some html</p>"; String cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "<p>some html"; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "some html"; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = null; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "<p>some html</p> "; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = " <p>some html</p> "; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "<P>some html</P>"; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "<P >some html</P >"; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "<P >some html< /P >"; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "<p>some html</p></p></p></p>"; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "<p>some html</p><p>more html</p>"; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "<P>some html</P>and then some"; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "leading text <P>some html</P> and then some"; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "leading text <P>some html</P> and then some"; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "<P>some html</P>and then some<div>some in a div"; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "<P>some html</P>and then some<div>some in a div</p>"; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "<P>some html</P>and then some<div>some in a div</div>and more"; cleaned = HtmlHelper.clean(source); display(source, cleaned); source = "<p>test <b></p>"; cleaned = HtmlHelper.clean(source); display(source, cleaned); }
public void testA() throws Exception { String source = "<p>test <b></p>"; String cleaned = HtmlHelper.clean(source); display(source, cleaned); }