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


Java Node.nodeName方法代码示例

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


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

示例1: head

import org.jsoup.nodes.Node; //导入方法依赖的package包/类
@Override
public void head(Node node, int depth) {
	String name = node.nodeName();
	if (node instanceof TextNode) {
		append(((TextNode) node).text()); // TextNodes carry all user-readable text in the DOM.
	} else if (name.equals("ul")) {
		listNesting++;
	} else if (name.equals("li")) {
		append("\n ");
		for (int i = 1; i < listNesting; i++) {
			append("  ");
		}
		if (listNesting == 1) {
			append("* ");
		} else {
			append("- ");
		}
	} else if (name.equals("dt")) {
		append("  ");
	} else if (StringUtil.in(name, "p", "h1", "h2", "h3", "h4", "h5", "tr")) {
		append("\n");
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:24,代码来源:HtmlToPlainText.java

示例2: getPath

import org.jsoup.nodes.Node; //导入方法依赖的package包/类
public String getPath(Node n)
{
    String nodePath = "";
    while (n != null) {
        if (n instanceof TextNode) {
            n = n.parent();
        }
        if (NodeHelper.isInnerText(n)) {
            n = n.parent();
        }
        String parentNodeName = n.nodeName();
        nodePath = parentNodeName + "." + nodePath;

        if (!parentNodeName.equalsIgnoreCase("html")) {
            n = n.parent();
        }
        else {
            break;
        }
    }

    return nodePath;
}
 
开发者ID:UKPLab,项目名称:sigir2016-collection-for-focused-retrieval,代码行数:24,代码来源:Paragraph.java

示例3: head

import org.jsoup.nodes.Node; //导入方法依赖的package包/类
public void head(Node node, int depth) {
    String name = node.nodeName();
    if (node instanceof TextNode)
        append(((TextNode) node).text()); // TextNodes carry all user-readable text in the DOM.
    else if (name.equals("li"))
        append("\n * ");
    else if (name.equals("dt"))
        append("  ");
    else if (StringUtil.in(name, "p", "h1", "h2", "h3", "h4", "h5", "tr"))
        append("\n");
}
 
开发者ID:cpusoft,项目名称:common,代码行数:12,代码来源:HtmlToPlainText.java

示例4: tail

import org.jsoup.nodes.Node; //导入方法依赖的package包/类
public void tail(Node node, int depth) {
    String name = node.nodeName();
    if (StringUtil.in(name, "br", "dd", "dt", "p", "h1", "h2", "h3", "h4", "h5"))
        append("\n");
    else if (name.equals("a"))
        append(String.format(" <%s>", node.absUrl("href")));
}
 
开发者ID:3wks,项目名称:generator-thundr-gae-react,代码行数:8,代码来源:HtmlFormattingUtil.java

示例5: head

import org.jsoup.nodes.Node; //导入方法依赖的package包/类
public void head(Node node, int i)
{
    String name = node.nodeName();
    if (node instanceof TextNode)
        accum.append(((TextNode) node).text()); // TextNodes carry all user-readable text in the DOM.
    else if (name.equals("li"))
        accum.append("\n * ");
    else if (name.equals("dt"))
        accum.append("  ");
    else if (StringUtil.in(name, "p", "h1", "h2", "h3", "h4", "h5", "tr"))
        accum.append("\n");
}
 
开发者ID:notem,项目名称:Saber-Bot,代码行数:13,代码来源:HTMLStripper.java

示例6: tail

import org.jsoup.nodes.Node; //导入方法依赖的package包/类
public void tail(Node node, int depth)
{
    String name = node.nodeName();
    if (StringUtil.in(name, "br", "dd", "dt", "p", "h1", "h2", "h3", "h4", "h5"))
        accum.append("\n");
}
 
开发者ID:notem,项目名称:Saber-Bot,代码行数:7,代码来源:HTMLStripper.java

示例7: tail

import org.jsoup.nodes.Node; //导入方法依赖的package包/类
@Override
public void tail(Node node, int depth) {
	String name = node.nodeName();
	if (StringUtil.in(name, "br", "dd", "dt", "p", "h1", "h2", "h3", "h4", "h5")) {
		append("\n");
	} else if (StringUtil.in(name, "th", "td")) {
		append(" ");
	} else if (name.equals("a")) {
		append(String.format(" <%s>", node.absUrl("href")));
	} else if (name.equals("ul")) {
		listNesting--;
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:14,代码来源:HtmlToPlainText.java

示例8: parseText

import org.jsoup.nodes.Node; //导入方法依赖的package包/类
private List<Alert> parseText(String html) {
    List<Alert> alerts = new ArrayList<Alert>(); 

    Document doc = Jsoup.parseBodyFragment(html);
    List<Node> nodes = doc.body().childNodes();
    
    String status = "", title = "", detail = "";
    boolean isFirst = true;
    boolean hasDetail = false;
    StringBuilder builder = new StringBuilder();
    for (int nodeIndex = 0; nodeIndex < nodes.size(); nodeIndex++) {
        Node node= nodes.get(nodeIndex);
        String nodeName = node.nodeName();
        if ("span".equals(nodeName)) {
            Element elem = (Element)node;
            String clazz = elem.attr("class");
            if (clazz.indexOf("Title") == 0) {
                // Previous alert is done. Collect
                if (isFirst) {
                    isFirst = false;
                } else {
                    alerts.add(buildTempAlert(status, title, detail, hasDetail, builder));
                    // Reset hasDetail;
                    hasDetail = false;
                    builder = new StringBuilder();
                }
                
                // Extract the new status
                status = elem.text().toUpperCase();
            }
            // Other spans will be disregarded, like "DateStyle" spans
        } else if ("br".equals(nodeName)) {
        	// Append <br> and they will be treated later.
        	builder.append("<br>");
        } else if ("a".equals(nodeName) && ((Element)node).hasAttr("onclick")) {
            // Title found! Has detail
            hasDetail = true;
            title = ((Element)node).text();
            builder = new StringBuilder(); // Now builder builds detail
        } else {
            builder.append(node.outerHtml());
        }
    }

    alerts.add(buildTempAlert(status, title, detail, hasDetail, builder));
    return alerts;
}
 
开发者ID:speedyllama,项目名称:nyctransit,代码行数:48,代码来源:StatusParser.java

示例9: getHtmlStartingFromText

import org.jsoup.nodes.Node; //导入方法依赖的package包/类
public void getHtmlStartingFromText(String text, StringBuilder builder, List<Node> nodesList, boolean append) {


        for (Node node : nodesList) {
            String nodeName = node.nodeName();

            if (append) {
                builder.append(node.outerHtml());
                continue;
            }


            if (nodeName.equalsIgnoreCase("#text")) {

                if (node.toString().trim().equalsIgnoreCase(text))
                    append = true;

            }
            getHtmlStartingFromText(text, builder, node.childNodes(), append);
        }
    }
 
开发者ID:symphonyoss,项目名称:symphony-java-client,代码行数:22,代码来源:MlMessageParser.java

示例10: getName

import org.jsoup.nodes.Node; //导入方法依赖的package包/类
@Override
public String getName(final Node n) {
	return n.nodeName();
}
 
开发者ID:Coffeeboys,项目名称:RenewPass,代码行数:5,代码来源:JsoupNodeHelper.java

示例11: getHtmlStartingFromNode

import org.jsoup.nodes.Node; //导入方法依赖的package包/类
private void getHtmlStartingFromNode(String nodeType, String attrib, String attribValue, StringBuilder builder, List<Node> nodesList, boolean append) {


        for (Node node : nodesList) {
            String nodeName = node.nodeName();

            if (append) {

                if (node.nodeName().equalsIgnoreCase("#text") && node.outerHtml().charAt(0) != ' ')
                    builder.append(" ");

                builder.append(node.outerHtml());

                if (!node.nodeName().equalsIgnoreCase("#text"))
                    builder.append(" ");

                continue;
            }


            if (nodeName.equalsIgnoreCase(nodeType)) {

                if (node.attributes().hasKey(attrib) && node.attr(attrib).equalsIgnoreCase(attribValue))
                    append = true;

            }
            getHtmlStartingFromNode(nodeType, attrib, attribValue, builder, node.childNodes(), append);
        }
    }
 
开发者ID:symphonyoss,项目名称:symphony-java-client,代码行数:30,代码来源:MlMessageParser.java

示例12: updateMentionUidToEmail

import org.jsoup.nodes.Node; //导入方法依赖的package包/类
private void updateMentionUidToEmail(SymphonyClient symClient, List<Node> nodesList) {


        for (Node node : nodesList) {
            String nodeName = node.nodeName();


            if (nodeName.equalsIgnoreCase(NodeTypes.MENTION.toString())) {

                if (node.attributes().hasKey(AttribTypes.UID.toString())) {

                    String uid = node.attr(AttribTypes.UID.toString());

                    SymUser user = null;
                    try {
                        user = symClient.getUsersClient().getUserFromId(Long.parseLong(uid));

                        logger.info("Translated mention uid {} to email {}", uid, user.getEmailAddress());
                    } catch (UsersClientException e) {
                        logger.error("Could not identify user email from id", e);
                    }

                    if (user != null && user.getEmailAddress() != null) {
                        uid = user.getEmailAddress();
                    }

                    Attribute emailAttribute = new Attribute(AttribTypes.EMAIL.toString(), uid);

                    node.attributes().put(emailAttribute);
                    node.removeAttr(AttribTypes.UID.toString());

                }

            }
            updateMentionUidToEmail(symClient, node.childNodes());
        }


    }
 
开发者ID:symphonyoss,项目名称:symphony-java-client,代码行数:40,代码来源:MlMessageParser.java

示例13: stripTags

import org.jsoup.nodes.Node; //导入方法依赖的package包/类
private void stripTags(StringBuilder builder, List<Node> nodesList) {


        for (Node node : nodesList) {
            String nodeName = node.nodeName();

            if (nodeName.equalsIgnoreCase("#text")) {

                builder.append(node.toString().trim()).append(" ");


            } else {

                if (nodeName.equalsIgnoreCase(NodeTypes.ANCHOR.toString())) {

                    if (node.attributes().hasKey(AttribTypes.HREF.toString()))
                        builder.append(node.attr(AttribTypes.HREF.toString()));


                } else if (nodeName.equalsIgnoreCase(NodeTypes.HASHTAG.toString())) {

                    if (node.attributes().hasKey(AttribTypes.TAG.toString()))
                        builder.append("#").append(node.attr(AttribTypes.TAG.toString())).append(" ");

                } else if (nodeName.equalsIgnoreCase(NodeTypes.MENTION.toString())) {
                    SymUser user = new SymUser();
                    user.setEmailAddress("UID:" + node.attr(AttribTypes.UID.toString()));
                    user.setId(Long.valueOf(node.attr(AttribTypes.UID.toString())));

                    if (node.attributes().hasKey(AttribTypes.UID.toString())) {

                        if (symClient != null)
                            try {
                                user = symClient.getUsersClient().getUserFromId(Long.valueOf(node.attr(AttribTypes.UID.toString())));
                            } catch (UsersClientException e) {
                                logger.error("Could not identify user from userID", e);
                            }


                    } else if (node.attributes().hasKey(AttribTypes.EMAIL.toString())) {

                        user.setEmailAddress(node.attr(AttribTypes.EMAIL.toString()));
                    }
                    builder.append(user.getEmailAddress());
                } else if (nodeName.equalsIgnoreCase(NodeTypes.CASHTAG.toString())) {

                    if (node.attributes().hasKey(AttribTypes.TAG.toString()))
                        builder.append("$").append(node.attr(AttribTypes.TAG.toString())).append(" ");


                } else {

                    // recurse
                    stripTags(builder, node.childNodes());
                }
            }
        }
    }
 
开发者ID:symphonyoss,项目名称:symphony-java-client,代码行数:59,代码来源:MlMessageParser.java


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