當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。