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


Java TagNode类代码示例

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


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

示例1: handleTagNode

import org.htmlcleaner.TagNode; //导入依赖的package包/类
@Override public void handleTagNode(TagNode node, SpannableStringBuilder builder, int start, int end) {
    if (isPre) {
        StringBuffer buffer = new StringBuffer();
        buffer.append("\n");//fake padding top + make sure, pre is always by itself
        getPlainText(buffer, node);
        buffer.append("\n");//fake padding bottom + make sure, pre is always by itself
        builder.append(replace(buffer.toString()));
        builder.append("\n");
        builder.setSpan(new CodeBackgroundRoundedSpan(color), start, builder.length(), SPAN_EXCLUSIVE_EXCLUSIVE);
        builder.append("\n");
        this.appendNewLine(builder);
        this.appendNewLine(builder);
    } else {
        StringBuffer text = node.getText();
        builder.append(" ");
        builder.append(replace(text.toString()));
        builder.append(" ");
        final int stringStart = start + 1;
        final int stringEnd = builder.length() - 1;
        builder.setSpan(new BackgroundColorSpan(color), stringStart, stringEnd, SPAN_EXCLUSIVE_EXCLUSIVE);
        if (theme == PrefGetter.LIGHT) {
            builder.setSpan(new ForegroundColorSpan(Color.RED), stringStart, stringEnd, SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        builder.setSpan(new TypefaceSpan("monospace"), stringStart, stringEnd, SPAN_EXCLUSIVE_EXCLUSIVE);
    }
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:27,代码来源:PreTagHandler.java

示例2: readNode

import org.htmlcleaner.TagNode; //导入依赖的package包/类
private void readNode(Object node, Table table) {
    if (node instanceof TagNode) {
        TagNode tagNode = (TagNode) node;
        if (tagNode.getName().equals("td") || tagNode.getName().equals("th")) {
            Spanned result = this.getSpanner().fromTagNode(tagNode);
            table.addCell(result);
            return;
        }
        if (tagNode.getName().equals("tr")) {
            table.addRow();
        }
        for (Object child : tagNode.getChildTags()) {
            readNode(child, table);
        }
    }

}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:18,代码来源:TableHandler.java

示例3: getMyIndex

import org.htmlcleaner.TagNode; //导入依赖的package包/类
private int getMyIndex(TagNode node) {
    if (node.getParent() == null) {
        return -1;
    } else {
        int i = 1;
        for (Object child : node.getParent().getChildren()) {
            if (child == node) {
                return i;
            }
            if (child instanceof TagNode) {
                TagNode childNode = (TagNode) child;
                if ("li".equals(childNode.getName())) {
                    ++i;
                }
            }
        }
        return -1;
    }
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:20,代码来源:ListsHandler.java

示例4: 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

示例5: 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

示例6: getPlainText

import org.htmlcleaner.TagNode; //导入依赖的package包/类
private void getPlainText(StringBuffer buffer, Object node) {
	if (node instanceof ContentNode) {

		ContentNode contentNode = (ContentNode) node;
		String text = TextUtil.replaceHtmlEntities(contentNode.getContent()
				.toString(), true);

		buffer.append(text);

	} else if (node instanceof TagNode) {
		TagNode tagNode = (TagNode) node;
		for (Object child : tagNode.getAllChildren()) {
			getPlainText(buffer, child);
		}
	}
}
 
开发者ID:SysdataSpA,项目名称:SDHtmlTextView,代码行数:17,代码来源:PreHandler.java

示例7: getMyIndex

import org.htmlcleaner.TagNode; //导入依赖的package包/类
private int getMyIndex(TagNode node) {
	if (node.getParent() == null) {
		return -1;
	}

	int i = 1;

	for (Object child : node.getParent().getAllChildren()) {
		if (child == node) {
			return i;
		}

		if (child instanceof TagNode) {
			TagNode childNode = (TagNode) child;
			if ("li".equals(childNode.getName())) {
				i++;
			}
		}
	}

	return -1;
}
 
开发者ID:SysdataSpA,项目名称:SDHtmlTextView,代码行数:23,代码来源:ListItemHandler.java

示例8: handleTagNode

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

    if ( getSpanner().isAllowStyling() ) {

        if ( node.getAllChildren().size() == 1 ) {
            Object childNode = node.getAllChildren().get(0);

            if ( childNode instanceof ContentNode ) {
                parseCSSFromText( ( (ContentNode) childNode ).getContent(),
                        spanStack );
            }
        }
    }

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

示例9: loginCredit

import org.htmlcleaner.TagNode; //导入依赖的package包/类
public static String loginCredit() throws Exception {
    try {
        String result = Connector.getDataByGet(POST_CREDIT_URI, "big5", "http://nportal.ntut.edu.tw/aptreeList.do?apDn=ou=aa,ou=aproot,o=ldaproot");
        TagNode tagNode;
        tagNode = new HtmlCleaner().clean(result);
        TagNode[] nodes = tagNode.getElementsByAttValue("name",
                "sessionId", true, false);
        String sessionId = nodes[0].getAttributeByName("value");
        nodes = tagNode
                .getElementsByAttValue("name", "userid", true, false);
        String userid = nodes[0].getAttributeByName("value");
        HashMap<String, String> params = new HashMap<>();
        params.put("sessionId", sessionId);
        params.put("userid", userid);
        result = Connector.getDataByPost(CREDITS_URI, params, "big5");
        return result;
    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("登入學生查詢系統時發生錯誤");
    }
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:22,代码来源:CreditConnector.java

示例10: getYearList

import org.htmlcleaner.TagNode; //导入依赖的package包/类
public static ArrayList<String> getYearList() throws Exception {
    try {
        ArrayList<String> year_list = new ArrayList<>();
        HashMap<String, String> params = new HashMap<>();
        params.put("format", "-1");
        String result = Connector
                .getDataByPost(getStandardUri(lang), params, "big5");
        TagNode tagNode;
        tagNode = new HtmlCleaner().clean(result);
        TagNode[] rows = tagNode.getElementsByName("a", true);
        for (TagNode row : rows) {
            String year = row.getText().toString();
            year_list.add(year);
        }
        return year_list;
    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("入學年度清單讀取時發生錯誤");
    }
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:21,代码来源:CreditConnector.java

示例11: getDivisionList

import org.htmlcleaner.TagNode; //导入依赖的package包/类
public static ArrayList<String> getDivisionList(String year)
        throws Exception {
    try {
        matrics.clear();
        ArrayList<String> division_list = new ArrayList<>();
        HashMap<String, String> params = new HashMap<>();
        params.put("format", "-2");
        params.put("year", year);
        String result = Connector
                .getDataByPost(getStandardUri(lang), params, "big5");
        TagNode tagNode;
        tagNode = new HtmlCleaner().clean(result);
        TagNode[] rows = tagNode.getElementsByName("a", true);
        for (TagNode row : rows) {
            String division = row.getText().toString();
            String[] temp = row.getAttributeByName("href").split("=");
            String matric = temp[temp.length - 1];
            matrics.add(matric);
            division_list.add(division);
        }
        return division_list;
    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("學制清單讀取時發生錯誤");
    }
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:27,代码来源:CreditConnector.java

示例12: login_2_2

import org.htmlcleaner.TagNode; //导入依赖的package包/类
public static String login_2_2(String redirectUri, String account,
                               String password) throws Exception {
    try {
        String result = Connector.getDataByGet(redirectUri, "big5");
        TagNode tagNode;
        tagNode = new HtmlCleaner().clean(result);
        TagNode[] nodes = tagNode.getElementsByName("input", true);
        String __VIEWSTATE = nodes[0].getAttributeByName("value");
        String __EVENTVALIDATION = nodes[1].getAttributeByName("value");

        HashMap<String, String> params = new HashMap<>();
        params.put("__VIEWSTATE", __VIEWSTATE);
        params.put("__EVENTVALIDATION",
                __EVENTVALIDATION);
        params.put("__EVENTTARGET", "");
        params.put("__EVENTARGUMENT", "");
        params.put("TxtBox_loginName", account);
        params.put("TxtBox_password", password);
        params.put("btnSubmit_AD", "登入");
        result = Connector.getDataByPost(redirectUri, params, "big5");
        return result;
    } catch (Exception e) {
        throw new Exception("Ntutcc登入時發生錯誤");
    }
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:26,代码来源:NtutccLoginConnector.java

示例13: getCourseType

import org.htmlcleaner.TagNode; //导入依赖的package包/类
static String getCourseType(String courseNo) throws Exception {
    try {
        if (!isLogin) {
            loginCourse();
        }
        HashMap<String, String> params = new HashMap<>();
        params.put("format", "-1");
        params.put("code", courseNo);
        String result = Connector.getDataByPost(getCourseUri("zh"), params, "big5");
        TagNode tagNode;
        tagNode = new HtmlCleaner().clean(result);
        TagNode[] tables = tagNode.getElementsByAttValue("border", "1",
                true, false);

        TagNode[] rows = tables[0].getElementsByName("tr", true);
        TagNode[] temp = rows[7].getElementsByName("td", true);
        return temp[0].getText().toString();
    } catch (Exception ex) {
        throw new Exception("課程類別讀取時發生錯誤");
    }
}
 
开发者ID:kamisakihideyoshi,项目名称:TaipeiTechRefined,代码行数:22,代码来源:CourseConnector.java

示例14: toXML

import org.htmlcleaner.TagNode; //导入依赖的package包/类
/**
 * htmlcleaner로 html string을 xml string으로 바꿔주는 메소드.
 * @param source
 * @return
 */
private String toXML(String source){
	try {
		CleanerProperties props = new CleanerProperties();
		props.setTranslateSpecialEntities(true);
		props.setOmitComments(true);
		props.setPruneTags("script,style");
		// namespace를 무시한다.
		props.setNamespacesAware(false);
		props.setAdvancedXmlEscape(true);
		props.setTranslateSpecialEntities(true);
		HtmlCleaner cl = new HtmlCleaner(props);
		TagNode tagNode = cl.clean(source);
		source = new PrettyXmlSerializer(props).getXmlAsString(tagNode);
	} catch (IOException e) {
		logger.error("",e);
	}
	return source;
}
 
开发者ID:gncloud,项目名称:fastcatsearch3,代码行数:24,代码来源:ReadabilityExtractor.java

示例15: 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


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