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


Java TagNode.getAttributeByName方法代码示例

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


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

示例1: handleTagNode

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
@Override
public void handleTagNode(TagNode node, SpannableStringBuilder builder,
		int start, int end, SpanStack stack) {
	String src = node.getAttributeByName("src");

	builder.append("\uFFFC");

	Bitmap bitmap = loadBitmap(src);

	if (bitmap != null) {
		Drawable drawable = new BitmapDrawable(bitmap);
		drawable.setBounds(0, 0, bitmap.getWidth() - 1,
				bitmap.getHeight() - 1);

           stack.pushSpan( new ImageSpan(drawable), start, builder.length() );
	}
}
 
开发者ID:SysdataSpA,项目名称:SDHtmlTextView,代码行数:18,代码来源:ImageHandler.java

示例2: handleTagNode

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
@Override
public void handleTagNode(TagNode node, SpannableStringBuilder builder,
		int start, int end, Style style, SpanStack spanStack) {
	
	String align = node.getAttributeByName("align");

	if ( "right".equalsIgnoreCase(align) ) {
	    style = style.setTextAlignment(Style.TextAlignment.RIGHT);
	} else if ( "center".equalsIgnoreCase(align) ) {
           style =  style.setTextAlignment(Style.TextAlignment.CENTER);
	} else if ( "left".equalsIgnoreCase(align) ) {
           style =  style.setTextAlignment(Style.TextAlignment.LEFT);
	}
	
	super.handleTagNode(node, builder, start, end, style, spanStack);
}
 
开发者ID:SysdataSpA,项目名称:SDHtmlTextView,代码行数:17,代码来源:AlignmentAttributeHandler.java

示例3: handleTagNode

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
public void handleTagNode(TagNode node, SpannableStringBuilder builder, int start, int end, SpanStack spanStack) {

        if ( getSpanner().isAllowStyling() ) {
            String type = node.getAttributeByName("type");
            String href = node.getAttributeByName("href");

            LOG.debug("Found link tag: type=" + type + " and href=" + href );

            if ( type == null || ! type.equals("text/css") ) {
                LOG.debug("Ignoring link of type " + type );
            }

            List<CompiledRule> rules = this.textLoader.getCSSRules(href);

            for ( CompiledRule rule: rules ) {
                spanStack.registerCompiledRule(rule);
            }
        }
    }
 
开发者ID:benjamarle,项目名称:typhon,代码行数:20,代码来源:CSSLinkHandler.java

示例4: JoinedBefore

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
public static boolean JoinedBefore(ChatPlayer mp, int year, int month, int day) throws Exception {
	URL url = new URL("https://www.reddit.com/u/" + mp.UserName());
	URLConnection con = url.openConnection();
	con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
	InputStream in = con.getInputStream();
	HtmlCleaner cleaner = new HtmlCleaner();
	TagNode node = cleaner.clean(in);

	node = node.getElementsByAttValue("class", "age", true, true)[0];
	node = node.getElementsByName("time", false)[0];
	String joindate = node.getAttributeByName("datetime");
	SimpleDateFormat parserSDF = new SimpleDateFormat("yyyy-MM-dd");
	joindate = joindate.split("T")[0];
	Date date = parserSDF.parse(joindate);
	return date.before(new Calendar.Builder().setTimeZone(TimeZone.getTimeZone("UTC")).setDate(year, month, day)
			.build().getTime());
}
 
开发者ID:TBMCPlugins,项目名称:ButtonChat,代码行数:18,代码来源:PluginMain.java

示例5: checkStyleCSS

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
final private void checkStyleCSS(TagNode node)
		throws ClientProtocolException, IllegalStateException, IOException, SearchLibException, URISyntaxException {
	if (!("style".equalsIgnoreCase(node.getName())))
		return;
	String attr = node.getAttributeByName("type");
	if (!StringUtils.isEmpty(attr) && !"text/css".equalsIgnoreCase(attr))
		return;
	attr = node.getAttributeByName("media");
	if (!StringUtils.isEmpty(attr) && !"screen".equalsIgnoreCase(attr) && !"all".equalsIgnoreCase(attr))
		return;
	StringBuilder builder = (StringBuilder) node.getText();
	if (builder == null)
		return;
	String content = builder.toString();
	String newContent = StringEscapeUtils.unescapeXml(content);
	StringBuffer sb = checkCSSContent(baseUrl, newContent);
	if (sb != null)
		newContent = sb.toString();
	if (newContent.equals(content))
		return;
	node.removeAllChildren();
	node.addChild(new ContentNode(newContent));
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:24,代码来源:HtmlArchiver.java

示例6: downloadObjectLink

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
final private boolean downloadObjectLink(TagNode node)
		throws ClientProtocolException, IllegalStateException, IOException, SearchLibException, URISyntaxException,
		ParserConfigurationException, SAXException {
	String src = node.getAttributeByName("href");
	if (src == null)
		return false;
	String type = node.getAttributeByName("type");
	if (type == null && node.getName().equalsIgnoreCase("script"))
		type = "text/javascript";
	if (type == null && node.getName().equalsIgnoreCase("link") &&
			"stylesheet".equalsIgnoreCase(node.getAttributeByName("rel")))
		type = "text/css";
	if (type == null)
		return false;
	src = downloadObject(baseUrl, src, type);
	if (src != null)
		node.addAttribute("href", src);
	return true;
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:20,代码来源:HtmlArchiver.java

示例7: checkBaseHref

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
final private void checkBaseHref(TagNode node) {
	if (node == null)
		return;
	if (!"base".equalsIgnoreCase(node.getName()))
		return;
	String href = node.getAttributeByName("href");
	if (href != null) {
		try {
			baseUrl = new URL(href);
		} catch (MalformedURLException e) {
			Logging.warn(e);
			return;
		}
	}
	node.removeFromTree();
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:17,代码来源:HtmlArchiver.java

示例8: beforeChildren

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
@Override public void beforeChildren(TagNode node, SpannableStringBuilder builder) {
    TodoItems todoItem = null;
    if (node.getChildTags() != null && node.getChildTags().length > 0) {
        for (TagNode tagNode : node.getChildTags()) {
            Logger.e(tagNode.getName(), tagNode.getText());
            if (tagNode.getName() != null && tagNode.getName().equals("input")) {
                todoItem = new TodoItems();
                todoItem.isChecked = tagNode.getAttributeByName("checked") != null;
                break;
            }
        }
    }
    if ("ol".equals(getParentName(node))) {
        builder.append(String.valueOf(getMyIndex(node))).append(". ");
    } else if ("ul".equals(getParentName(node))) {
        if (todoItem != null) {
            if (checked == null || unchecked == null) {
                builder.append(todoItem.isChecked ? "☑" : "☐");
            } else {
                builder.append(SpannableBuilder.builder()
                        .append(todoItem.isChecked ? checked : unchecked))
                        .append(" ");
            }
        } else {
            builder.append("\u2022 ");
        }
    }
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:29,代码来源:ListsHandler.java

示例9: handleTagNode

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
@Override public void handleTagNode(TagNode node, SpannableStringBuilder builder, int start, int end) {
    String src = node.getAttributeByName("src");
    if (!InputHelper.isEmpty(src)) {
        builder.append("");
        if (isNull()) return;
        DrawableGetter imageGetter = new DrawableGetter(textView, width);
        builder.setSpan(new ImageSpan(imageGetter.getDrawable(src)), start, builder.length(), SPAN_EXCLUSIVE_EXCLUSIVE);
        builder.setSpan(new CenterSpan(), start, builder.length(), SPAN_EXCLUSIVE_EXCLUSIVE);
        appendNewLine(builder);
    }
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:12,代码来源:DrawableHandler.java

示例10: handleTagNode

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
@Override public void handleTagNode(TagNode node, SpannableStringBuilder spannableStringBuilder, int start, int end) {
    String href = node.getAttributeByName("href");
    if (href != null) {
        spannableStringBuilder.setSpan(new LinkSpan(href, linkColor), start, end, 33);
    } else if (node.getText() != null) {
        spannableStringBuilder.setSpan(new LinkSpan("https://github.com/" + node.getText().toString(), linkColor), start, end, 33);
    }
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:9,代码来源:LinkHandler.java

示例11: matches

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
@Override
public boolean matches(TagNode tagNode) {

    if ( tagNode == null ) {
        return false;
    }

    //If a tag name is given it should match
    if (tagName != null && tagName.length() > 0 && ! tagName.equals(tagNode.getName() ) ) {
        return  false;
    }

    String classAttribute = tagNode.getAttributeByName("class");
    return classAttribute != null && classAttribute.equals(className);
}
 
开发者ID:SysdataSpA,项目名称:SDHtmlTextView,代码行数:16,代码来源:CSSCompiler.java

示例12: handleTagNode

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
@Override
public void handleTagNode(TagNode node, SpannableStringBuilder builder, int start, int end,
                          Style useStyle, SpanStack spanStack) {

    if ( node.getAttributeByName("border") != null ) {
        Log.d("BorderAttributeHandler", "Adding BorderSpan from " + start + " to " + end);
        spanStack.pushSpan(new BorderSpan(useStyle, start, end, getSpanner().isUseColoursFromStyle() ), start, end);
    }

    super.handleTagNode(node, builder, start, end, useStyle, spanStack);

}
 
开发者ID:SysdataSpA,项目名称:SDHtmlTextView,代码行数:13,代码来源:BorderAttributeHandler.java

示例13: handleTagNode

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
@Override
public void handleTagNode(TagNode node, SpannableStringBuilder builder, int start, int end, Style useStyle,
                          SpanStack spanStack) {

    String styleAttr = node.getAttributeByName("style");

    if ( getSpanner().isAllowStyling() && styleAttr != null ) {
        super.handleTagNode(node, builder, start, end,
                parseStyleFromAttribute(useStyle, styleAttr),
                spanStack);
    } else {
        super.handleTagNode(node, builder, start, end, useStyle, spanStack);
    }

}
 
开发者ID:SysdataSpA,项目名称:SDHtmlTextView,代码行数:16,代码来源:StyleAttributeHandler.java

示例14: handleTagNode

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
@Override
public void handleTagNode(TagNode node, SpannableStringBuilder builder,
		int start, int end, SpanStack spanStack) {

	final String href = node.getAttributeByName("href");
	spanStack.pushSpan(new URLSpan(href), start, end);
}
 
开发者ID:SysdataSpA,项目名称:SDHtmlTextView,代码行数:8,代码来源:LinkHandler.java

示例15: removeMetaRefresh

import org.htmlcleaner.TagNode; //导入方法依赖的package包/类
private void removeMetaRefresh(TagNode rootNode) {
    for (TagNode element : rootNode.getElementListByName("meta", true)) {
        String httpEquiv = element.getAttributeByName("http-equiv");
        if (httpEquiv != null && httpEquiv.trim().equalsIgnoreCase("refresh")) {
            element.removeFromTree();
        }
    }
}
 
开发者ID:scoute-dich,项目名称:K9-MailClient,代码行数:9,代码来源:HtmlSanitizer.java


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