コード例 #1
1
 @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;
   }
 }
コード例 #2
0
ファイル: StylerHelper.java プロジェクト: goozi/winter
 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);
 }
コード例 #3
0
 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)");
 }
コード例 #4
0
  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);
  }
コード例 #5
0
ファイル: StylerHelper.java プロジェクト: goozi/winter
  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));
  }
コード例 #6
0
  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 &lt;b&gt;</p>";
    cleaned = HtmlHelper.clean(source);
    display(source, cleaned);
  }
コード例 #7
0
 public void testA() throws Exception {
   String source = "<p>test &lt;b&gt;</p>";
   String cleaned = HtmlHelper.clean(source);
   display(source, cleaned);
 }