当前位置: 首页>>代码示例>>Java>>正文


Java Parser.setProperty方法代码示例

本文整理汇总了Java中org.ccil.cowan.tagsoup.Parser.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Parser.setProperty方法的具体用法?Java Parser.setProperty怎么用?Java Parser.setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ccil.cowan.tagsoup.Parser的用法示例。


在下文中一共展示了Parser.setProperty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fromHtml

import org.ccil.cowan.tagsoup.Parser; //导入方法依赖的package包/类
/**
 * Returns displayable styled text from the provided HTML string. Any <img> tags in the
 * HTML will use the specified ImageGetter to request a representation of the image (use null
 * if you don't want this) and the specified TagHandler to handle unknown tags (specify null if
 * you don't want this).
 * <p>
 * <p>This uses TagSoup to handle real HTML, including all of the brokenness found in the wild.
 */
public static Spanned fromHtml(@NonNull Context context, @NonNull String source, int flags,
                               @Nullable ImageGetter imageGetter, @Nullable TagHandler tagHandler,
                               @Nullable SpanCallback spanCallback) {
    if (source == null) {
        return null;
    }
    Parser parser = new Parser();
    try {
        parser.setProperty(Parser.schemaProperty, HtmlParser.schema);
    } catch (org.xml.sax.SAXNotRecognizedException | org.xml.sax.SAXNotSupportedException e) {
        // Should not happen.
        throw new RuntimeException(e);
    }
    HtmlToSpannedConverter converter =
            new HtmlToSpannedConverter(context, source, imageGetter, tagHandler, spanCallback, parser, flags);
    return converter.convert();
}
 
开发者ID:Pixplicity,项目名称:HtmlCompat,代码行数:26,代码来源:HtmlCompat.java

示例2: parse

import org.ccil.cowan.tagsoup.Parser; //导入方法依赖的package包/类
public String parse(String html) {
	Parser p = new Parser();
	p.setContentHandler(this);
	p.setErrorHandler(this);
	try {
		p.setFeature(Parser.defaultAttributesFeature, false); //or else some default attributes get added to <br>
		p.setFeature(Parser.ignorableWhitespaceFeature, false);

		p.setProperty(Parser.lexicalHandlerProperty, this);

		InputSource inputSource = new InputSource(new StringReader(html));
		p.parse(inputSource);

	} catch (Exception e) {
		// TODO Auto-generated catch block
	}

	return rebuiltHtml.toString();
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:20,代码来源:EformParser.java

示例3: fromHtml

import org.ccil.cowan.tagsoup.Parser; //导入方法依赖的package包/类
/**
 * Returns displayable styled text from the provided HTML string.
 * Any &lt;img&gt; tags in the HTML will use the specified ImageGetter
 * to request a representation of the image (use null if you don't
 * want this) and the specified TagHandler to handle unknown tags
 * (specify null if you don't want this).
 *
 * <p>This uses TagSoup to handle real HTML, including all of the brokenness found in the wild.
 */
public static SpannableStringBuilder fromHtml(String source, ImageGetter imageGetter,
        TagHandler tagHandler) {
    Parser parser = new Parser();
    try {
        parser.setProperty(Parser.schemaProperty, HtmlParser.schema);
    } catch (org.xml.sax.SAXNotRecognizedException | org.xml.sax.SAXNotSupportedException e) {
        // Should not happen.
        throw new RuntimeException(e);
    }

    HtmlToSpannedConverter converter =
            new HtmlToSpannedConverter(source, imageGetter, tagHandler,
                    parser);
    return converter.convert();
}
 
开发者ID:seven332,项目名称:Nimingban,代码行数:25,代码来源:Html.java

示例4: parse

import org.ccil.cowan.tagsoup.Parser; //导入方法依赖的package包/类
/**
 * @see org.apache.sling.commons.html.HtmlParser#parse(java.lang.String, java.io.InputStream, java.lang.String)
 */
public Document parse(String systemId, InputStream stream, String encoding) throws IOException {
    final Parser parser = new Parser();
    final DOMBuilder builder = new DOMBuilder();
    final InputSource source = new InputSource(stream);
    source.setEncoding(encoding);
    source.setSystemId(systemId);
    try {
        parser.setProperty("http://xml.org/sax/properties/lexical-handler", builder);
        parser.setContentHandler(builder);
        parser.parse(source);
    } catch (SAXException se) {
        if ( se.getCause() instanceof IOException ) {
            throw (IOException) se.getCause();
        }
        throw (IOException) new IOException("Unable to parse xml.").initCause(se);
    }
    return builder.getDocument();
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:22,代码来源:SlingHtmlParser.java

示例5: fromHtml

import org.ccil.cowan.tagsoup.Parser; //导入方法依赖的package包/类
public static Spanned fromHtml(String text, Html.ImageGetter imageGetter, Html.TagHandler tagHandler)
{
    Parser parser = new Parser();
    try {
        parser.setProperty(Parser.schemaProperty, HtmlParser.schema);
    } catch (org.xml.sax.SAXNotRecognizedException | SAXNotSupportedException e) {
        throw new RuntimeException(e);
    }
    HtmlToSpannedConverter converter = new HtmlToSpannedConverter(text, imageGetter, tagHandler, parser);
    return converter.convert();
}
 
开发者ID:nebulae-pan,项目名称:RichEditText,代码行数:12,代码来源:RichHtml.java

示例6: fromHtml

import org.ccil.cowan.tagsoup.Parser; //导入方法依赖的package包/类
/**
 * Returns displayable styled text from the provided HTML string.
 * Any &lt;img&gt; tags in the HTML will use the specified ImageGetter
 * to request a representation of the image (use null if you don't
 * want this) and the specified TagHandler to handle unknown tags
 * (specify null if you don't want this).
 *
 * <p>This uses TagSoup to handle real HTML, including all of the brokenness found in the wild.
 */
public static Spanned fromHtml(String source, ImageGetter imageGetter) {
    Parser parser = new Parser();
    try {
        parser.setProperty(Parser.schemaProperty, HtmlParser.schema);
    } catch (org.xml.sax.SAXNotRecognizedException | org.xml.sax.SAXNotSupportedException e) {
        // Should not happen.
        throw new RuntimeException(e);
    }

    HtmlToSpannedConverter converter =
            new HtmlToSpannedConverter(source, imageGetter, parser);
    return converter.convert();
}
 
开发者ID:CzBiX,项目名称:v2ex-android,代码行数:23,代码来源:Html.java


注:本文中的org.ccil.cowan.tagsoup.Parser.setProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。