亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? htmlformatter.java

?? HTML解釋器JAVA源碼
?? JAVA
字號:
/* * HtmlFormatter.java -- HTML document pretty-printer * Copyright (C) 1999 Quiotix Corporation.   * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as  * published by the Free Software Foundation.   * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License (http://www.gnu.org/copyleft/gpl.txt) * for more details. */package com.quiotix.html.parser;import java.io.*;import java.util.*;/**  * HtmlFormatter is a Visitor which traverses an HtmlDocument, dumping the * contents of the document to a specified output stream.  It assumes that * the documents has been preprocessed by HtmlCollector (which matches up * beginning and end tags) and by HtmlScrubber (which formats tags in a * consistent way).  In particular, HtmlScrubber should be invoked with the * TRIM_SPACES option to remove trailing spaces, which can confuse the  * formatting algorithm.  *  * <P>The right margin and indent increment can be specified as properties.   *  * @author Brian Goetz, Quiotix * @see com.quiotix.html.HtmlVisitor * @see com.quiotix.html.HtmlCollector * @see com.quiotix.html.HtmlScrubber */public class HtmlFormatter extends HtmlVisitor {  protected MarginWriter out;  protected int rightMargin=80;   protected int indentSize=2;  protected static Hashtable tagsIndentBlock = new Hashtable();  protected static Hashtable tagsNewlineBefore = new Hashtable();  protected static Hashtable tagsPreformatted = new Hashtable();  protected static Hashtable tagsTryMatch = new Hashtable();  protected static final String[] tagsIndentStrings    = { "TABLE", "TR", "TD", "TH", "FORM", "HTML", "HEAD", "BODY", "SELECT" };  protected static final String[] tagsNewlineBeforeStrings    = { "P", "H1", "H2", "H3", "H4", "H5", "H6", "BR" };  protected static final String[] tagsPreformattedStrings     = { "PRE", "SCRIPT", "STYLE" };  protected static final String[] tagsTryMatchStrings     = { "A", "TD", "TH", "TR", "I", "B", "EM", "FONT", "TT", "UL" };  static {    Integer dummy = new Integer(0);    for (int i=0; i < tagsIndentStrings.length; i++)       tagsIndentBlock.put(tagsIndentStrings[i], dummy);    for (int i=0; i < tagsNewlineBeforeStrings.length; i++)       tagsNewlineBefore.put(tagsNewlineBeforeStrings[i], dummy);    for (int i=0; i < tagsPreformattedStrings.length; i++)       tagsPreformatted.put(tagsPreformattedStrings[i], dummy);    for (int i=0; i < tagsTryMatchStrings.length; i++)       tagsTryMatch.put(tagsTryMatchStrings[i], dummy);  };  protected TagBlockRenderer blockRenderer = new TagBlockRenderer();  protected HtmlDocument.HtmlElement previousElement;  protected boolean inPreBlock;  public HtmlFormatter(OutputStream os) throws Exception {    out = new MarginWriter(new PrintWriter(new BufferedOutputStream(os)));    out.setRightMargin(rightMargin);  };  public void setRightMargin(int margin) {    rightMargin = margin;    out.setRightMargin(rightMargin);  };  public void setIndent(int indent) {    indentSize = indent;  };  public void visit(HtmlDocument.TagBlock block) {    boolean indent;    boolean preformat;    boolean alreadyDone = false;    int wasMargin=0;    if (tagsTryMatch.containsKey(block.startTag.tagName.toUpperCase())) {      blockRenderer.start();      blockRenderer.setTargetWidth(out.getRightMargin() - out.getLeftMargin());      blockRenderer.visit(block);      blockRenderer.finish();      if (!blockRenderer.hasBlownTarget()) {        out.printAutoWrap(blockRenderer.getString());        previousElement = block.endTag;        return;      };    };    // Only will get here if we've failed the try-block test    indent = tagsIndentBlock.containsKey(block.startTag.tagName.toUpperCase());    preformat = tagsPreformatted.containsKey(block.startTag.tagName.toUpperCase());    if (preformat) {      inPreBlock = true;      visit(block.startTag);      wasMargin = out.getLeftMargin();      out.setLeftMargin(0);      visit(block.body);      out.setLeftMargin(wasMargin);      visit(block.endTag);    } else if (indent) {      out.printlnSoft();      visit(block.startTag);      out.printlnSoft();      out.setLeftMargin(out.getLeftMargin() + indentSize);      visit(block.body);      out.setLeftMargin(out.getLeftMargin() - indentSize);      out.printlnSoft();      visit(block.endTag);      out.printlnSoft();      inPreBlock = false;    }    else {      visit(block.startTag);      visit(block.body);      visit(block.endTag);    };  }  public void visit(HtmlDocument.Tag t) {    String s = t.toString();    int hanging;     if (tagsNewlineBefore.containsKey(t.tagName.toUpperCase())        || out.getCurPosition() + s.length() > out.getRightMargin())      out.printlnSoft();    out.print("<" + t.tagName);    hanging = t.tagName.length() + 1;    for (Enumeration ae=t.attributeList.attributes.elements();         ae.hasMoreElements(); ) {      HtmlDocument.Attribute a = (HtmlDocument.Attribute) ae.nextElement();       out.printAutoWrap(" "+a.toString(), hanging);    };    if (t.emptyTag) out.print("/");    out.print(">");    previousElement = t;  }  public void visit(HtmlDocument.EndTag t) {    out.printAutoWrap(t.toString());    if (tagsNewlineBefore.containsKey(t.tagName.toUpperCase())) {      out.printlnSoft();      out.println();    };    previousElement = t;  }  public void visit(HtmlDocument.Comment c) {    out.print(c.toString());    previousElement = c;  }  public void visit(HtmlDocument.Text t) {    if (inPreBlock)       out.print(t.text);    else {      int start=0;      while (start < t.text.length()) {         int index = t.text.indexOf(' ', start) + 1;        if (index == 0)           index = t.text.length();        out.printAutoWrap(t.text.substring(start, index));        start = index;      };    };    previousElement = t;  }  public void visit(HtmlDocument.Newline n) {    if (inPreBlock)      out.println();    else if (previousElement instanceof HtmlDocument.Tag             || previousElement instanceof HtmlDocument.EndTag             || previousElement instanceof HtmlDocument.Comment             || previousElement instanceof HtmlDocument.Newline)      out.printlnSoft();    else if (previousElement instanceof HtmlDocument.Text)       out.print(" ");    previousElement = n;  }  public void start() {    previousElement = null;    inPreBlock = false;  };  public void finish() {    out.flush();  };  public static void main (String[] args) throws Exception {    InputStream r = new FileInputStream(args[0]);    HtmlDocument document;        try {       document = new HtmlParser(r).HtmlDocument();      document.accept(new HtmlCollector());      document.accept(new HtmlScrubber(HtmlScrubber.DEFAULT_OPTIONS                                        | HtmlScrubber.TRIM_SPACES));      document.accept(new HtmlFormatter(System.out));    }    catch (Exception e) {      e.printStackTrace();    }    finally {      r.close();    };  };}    /**  * Utility class, used by HtmlFormatter, which adds some word-wrapping  * and hanging indent functionality to a PrintWriter.  */class MarginWriter {  protected int tabStop;  protected int curPosition;  protected int leftMargin;  protected int rightMargin;  protected java.io.PrintWriter out;  protected char[] spaces = new char[256];  {    for (int i=0; i<spaces.length; i++)       spaces[i] =  ' ';  };    public MarginWriter(java.io.PrintWriter out) {     this.out = out;   }  public void flush() {    out.flush();  };  public void close() {    out.close();  };  public void print(String s) {    if (curPosition == 0 && leftMargin > 0) {      out.write(spaces, 0, leftMargin);      curPosition = leftMargin;    };    out.print(s);    curPosition += s.length();  }  public void printAutoWrap(String s) {    if (curPosition > leftMargin        && curPosition + s.length() > rightMargin)       println();    print(s);  };  public void printAutoWrap(String s, int hanging) {    if (curPosition > leftMargin        && curPosition + s.length() > rightMargin) {      println();      out.write(spaces, 0, hanging+leftMargin);      curPosition = leftMargin + hanging;    };    print(s);  };  public void println() {    curPosition = 0;    out.println();  };  public void printlnSoft() {    if (curPosition > 0)       println();  };  public void setLeftMargin(int leftMargin) {     this.leftMargin = leftMargin;  };  public int getLeftMargin() {     return leftMargin;   };  public void setRightMargin(int rightMargin) {     this.rightMargin = rightMargin;   };  public int getRightMargin() {    return rightMargin;  };  public int getCurPosition() {    return (curPosition == 0 ? leftMargin : curPosition);  };}/**  * Utility class, used by HtmlFormatter, which tentatively tries to format * the contents of an HtmlDocument.TagBlock to see if the entire block can * fit on the rest of the line.  If it cannot, it gives up and indicates  * failure through the hasBlownTarget method; if it can, the contents can * be retrieved through the getString method. */class TagBlockRenderer extends HtmlVisitor {  protected String s;  protected boolean multiLine;  protected boolean blownTarget;  protected int targetWidth=80;   public void start() {     s = "";     multiLine = false;     blownTarget = false;  }  public void finish() { };  public void setTargetWidth(int w) { targetWidth = w; }  public String getString()         { return s; }  public boolean isMultiLine()      { return multiLine; }  public boolean hasBlownTarget()   { return blownTarget; }  public void visit(HtmlDocument.Tag t)     {     if (s.length() < targetWidth)         s += t.toString();     else       blownTarget = true;  }  public void visit(HtmlDocument.EndTag t) {    if (s.length() < targetWidth)         s += t.toString();     else       blownTarget = true;  }  public void visit(HtmlDocument.Comment c) {     if (s.length() < targetWidth)         s += c.toString();     else       blownTarget = true;  }  public void visit(HtmlDocument.Text t)    {     if (s.length() < targetWidth)         s += t.toString();     else       blownTarget = true;  }  public void visit(HtmlDocument.Newline n) {     multiLine = true;     s += " ";   }}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕一区二区三| 国产欧美日本一区视频| 成人app在线观看| 日韩国产欧美视频| 亚洲欧洲色图综合| 久久夜色精品一区| 欧美另类久久久品| 91黄色在线观看| 国产精品一二三| 奇米影视一区二区三区| 中文字幕日本乱码精品影院| 精品国产区一区| 91精品久久久久久蜜臀| 91久久免费观看| 不卡大黄网站免费看| 国产一区二三区| 麻豆91小视频| 香蕉成人伊视频在线观看| 一区视频在线播放| 欧美激情一区不卡| 26uuu欧美| 日韩欧美一二三四区| 欧美精品电影在线播放| 欧美亚洲动漫精品| 91视频在线观看免费| 成人美女在线视频| 国产精品1024| 国产精品99久久久久久久vr| 久久精品国产成人一区二区三区 | 亚洲激情中文1区| 久久久久久久久久美女| 欧美本精品男人aⅴ天堂| 欧美顶级少妇做爰| 欧美日韩国产综合一区二区| 欧美性色aⅴ视频一区日韩精品| 99re热这里只有精品免费视频| 成人sese在线| av一区二区不卡| 色婷婷综合五月| 在线免费观看日本一区| 在线视频欧美区| 欧美日韩一区二区三区视频 | 这里只有精品免费| 欧美精品一二三| 欧美一区二区私人影院日本| 91麻豆精品国产91久久久 | 日韩精品欧美精品| 日本欧美在线看| 美女性感视频久久| 国内欧美视频一区二区| 国内精品伊人久久久久影院对白| 国产在线精品免费av| 懂色av一区二区三区免费看| av亚洲精华国产精华精| 91成人免费在线| 91麻豆精品国产自产在线| 日韩欧美国产不卡| 日本一区二区在线不卡| 亚洲私人黄色宅男| 性久久久久久久| 激情av综合网| av一区二区三区在线| 在线观看日韩电影| 日韩一区二区免费视频| 国产亚洲欧美一级| 亚洲免费av高清| 日韩主播视频在线| 国产一区二区三区av电影| 99久久精品国产麻豆演员表| 欧美日韩一区二区三区视频| 精品国产乱码久久久久久闺蜜| 国产欧美一区二区精品性色| 自拍偷拍亚洲综合| 婷婷综合在线观看| 国产传媒欧美日韩成人| 91色九色蝌蚪| 精品免费视频一区二区| 国产精品高潮久久久久无| 天天综合网天天综合色| 国产成人aaa| 欧美三级电影在线观看| 国产亚洲成av人在线观看导航 | 三级欧美在线一区| 国产精品原创巨作av| 色噜噜夜夜夜综合网| 日韩欧美国产一区二区在线播放 | 欧美一卡2卡三卡4卡5免费| 欧美激情一区二区三区不卡 | 91在线小视频| 欧美电影免费观看高清完整版在线| 国产精品久久久久9999吃药| 日韩av电影一区| 不卡视频一二三| 欧美v日韩v国产v| 亚洲一级二级三级| 成人污视频在线观看| 日韩精品一区二区三区视频播放 | 日韩限制级电影在线观看| ㊣最新国产の精品bt伙计久久| 秋霞电影一区二区| 色综合久久综合| 中文字幕av在线一区二区三区| 视频一区免费在线观看| 91麻豆精东视频| 国产三区在线成人av| 蜜臀av亚洲一区中文字幕| av亚洲精华国产精华精华| 久久综合狠狠综合久久综合88| 亚洲bdsm女犯bdsm网站| 91美女视频网站| 久久久精品人体av艺术| 日韩国产欧美在线观看| 欧美在线观看禁18| 18成人在线观看| 成人免费的视频| 亚洲国产精品二十页| 国产美女在线精品| 欧美大片国产精品| 午夜精品123| 欧美在线观看一区| 亚洲精品国产精华液| av不卡免费电影| 国产精品视频线看| 99久久精品国产一区二区三区| 国产网红主播福利一区二区| 精品一区二区三区免费观看| 日韩视频永久免费| 日本亚洲三级在线| 91精品国产入口| 日韩精品一级二级 | 成人sese在线| 中文字幕在线观看一区二区| 国产成a人亚洲精品| 国产婷婷精品av在线| 成人午夜精品一区二区三区| 中文一区在线播放| 成人动漫av在线| 亚洲免费看黄网站| 色婷婷精品大在线视频| 亚洲精品大片www| 欧美亚洲一区二区在线| 亚洲成av人影院| 91精品国模一区二区三区| 日本欧美韩国一区三区| 日韩欧美一区在线观看| 久久精品国产澳门| 国产拍揄自揄精品视频麻豆| 成人小视频在线| 洋洋av久久久久久久一区| 欧美三级在线播放| 日本不卡中文字幕| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 91亚洲精品乱码久久久久久蜜桃| 日韩一区在线看| 欧美色男人天堂| 免费在线观看日韩欧美| 久久久久久久av麻豆果冻| 成人午夜电影小说| 一区二区欧美国产| 欧美一区二区三区视频| 国产乱理伦片在线观看夜一区| 国产精品视频免费看| 欧美性xxxxx极品少妇| 男女男精品网站| 久久久不卡网国产精品一区| aaa国产一区| 午夜精品国产更新| 国产日韩欧美高清在线| 日本韩国一区二区三区视频| 欧美aaaaa成人免费观看视频| 国产欧美日韩精品一区| 欧美日韩在线免费视频| 国产在线精品国自产拍免费| 一区二区三区日韩精品| 日韩一区二区三区视频在线| 丰满少妇在线播放bd日韩电影| 亚洲午夜日本在线观看| 久久女同精品一区二区| 91国偷自产一区二区开放时间| 蜜臀av一级做a爰片久久| 亚洲天堂精品视频| 欧美大度的电影原声| 色综合咪咪久久| 国产在线精品免费| 亚洲制服欧美中文字幕中文字幕| 久久综合色天天久久综合图片| 91啪亚洲精品| 精品伊人久久久久7777人| 又紧又大又爽精品一区二区| 日韩精品一区二区三区四区视频 | 国产亚洲欧美中文| 欧美日韩亚洲高清一区二区| 国产精品影视网| 婷婷成人激情在线网| 椎名由奈av一区二区三区| 欧美一卡在线观看| 欧洲国产伦久久久久久久| 成人免费高清视频在线观看| 久久99精品国产.久久久久久| 亚洲国产日韩综合久久精品|