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


Java Attributes.put方法代码示例

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


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

示例1: replacePlaceholderWithNode

import org.jsoup.nodes.Attributes; //导入方法依赖的package包/类
@Test
public void replacePlaceholderWithNode() {
    Map<String, Node> nodeIdMap = new HashMap<>();
    String html = "<div>";
    for (int i = 0; i < 5; i++) {
        Attributes attrs = new Attributes();
        String id = "id" + i;
        attrs.put("id", id);
        Element ele = new Element(Tag.valueOf("span"), "", attrs);
        ele.append("The original node");
        nodeIdMap.put(id, ele);

        Element placeholder = ArticleUtil.generatePlaceholderNode(id);
        html += placeholder.outerHtml();
    }
    html += "</div>";

    String results = ArticleUtil.replacePlaceholderWithNode(nodeIdMap, html);
    for (Node originalNode: nodeIdMap.values()) {
        assertThat(results).contains(originalNode.outerHtml());
    }
}
 
开发者ID:zanata,项目名称:zanata-mt,代码行数:23,代码来源:ArticleUtilTest.java

示例2: createSafeElement

import org.jsoup.nodes.Attributes; //导入方法依赖的package包/类
private ElementMeta createSafeElement(Element sourceEl) {
    String sourceTag = sourceEl.tagName();
    Attributes destAttrs = new Attributes();
    Element dest = new Element(Tag.valueOf(sourceTag), sourceEl.baseUri(), destAttrs);
    int numDiscarded = 0;

    Attributes sourceAttrs = sourceEl.attributes();
    for (Attribute sourceAttr : sourceAttrs) {
        if (whitelist.isSafeAttribute(sourceTag, sourceEl, sourceAttr))
            destAttrs.put(sourceAttr);
        else
            numDiscarded++;
    }
    Attributes enforcedAttrs = whitelist.getEnforcedAttributes(sourceTag);
    destAttrs.addAll(enforcedAttrs);

    return new ElementMeta(dest, numDiscarded);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:19,代码来源:Cleaner.java

示例3: addMeta

import org.jsoup.nodes.Attributes; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private void addMeta(Element head, String... attributes)
{
	Attributes attr = new Attributes();

	for (String attribute : attributes)
	{
		String[] keyValue = attribute.split("=");
		String key = keyValue[0];
		String value = keyValue[1];
		attr.put(key, value);
	}
	Element linkElement = new Element(Tag.valueOf("meta"), "", attr);
	head.appendChild(linkElement);

}
 
开发者ID:bsutton,项目名称:scoutmaster,代码行数:17,代码来源:VaadinServlet.java

示例4: generatePlaceholderNode

import org.jsoup.nodes.Attributes; //导入方法依赖的package包/类
/**
 * Generate a non-translatable element
 */
public static Element generatePlaceholderNode(@NotNull String id) {
    Attributes attrs = new Attributes();
    attrs.put("id", id);
    attrs.put("translate", "no");
    return new Element(Tag.valueOf("var"), "", attrs);
}
 
开发者ID:zanata,项目名称:zanata-mt,代码行数:10,代码来源:ArticleUtil.java

示例5: getEnforcedAttributes

import org.jsoup.nodes.Attributes; //导入方法依赖的package包/类
Attributes getEnforcedAttributes(String tagName) {
    Attributes attrs = new Attributes();
    TagName tag = TagName.valueOf(tagName);
    if (enforcedAttributes.containsKey(tag)) {
        Map<AttributeKey, AttributeValue> keyVals = enforcedAttributes.get(tag);
        for (Map.Entry<AttributeKey, AttributeValue> entry : keyVals.entrySet()) {
            attrs.put(entry.getKey().toString(), entry.getValue().toString());
        }
    }
    return attrs;
}
 
开发者ID:cpusoft,项目名称:common,代码行数:12,代码来源:Whitelist.java

示例6: createSafeElement

import org.jsoup.nodes.Attributes; //导入方法依赖的package包/类
/**
 * 按原Element重建一个新的Element
 * @param sourceEl
 * @return
 */
private static Element createSafeElement(Element sourceEl) {
	String sourceTag = sourceEl.tagName();
	Attributes destAttrs = new Attributes();
	Element dest = new Element(Tag.valueOf(sourceTag), sourceEl.baseUri(), destAttrs);
	Attributes sourceAttrs = sourceEl.attributes();
	for (Attribute sourceAttr : sourceAttrs) {
		destAttrs.put(sourceAttr);
	}
	return dest;
}
 
开发者ID:jayqqaa12,项目名称:jbase,代码行数:16,代码来源:HtmlFilter.java

示例7: attributesCaseNormalization

import org.jsoup.nodes.Attributes; //导入方法依赖的package包/类
@Test @MultiLocaleTest public void attributesCaseNormalization() throws Exception {
    ParseSettings parseSettings = new ParseSettings(false, false);
    Attributes attributes = new Attributes();
    attributes.put("ITEM", "1");

    Attributes normalizedAttributes = parseSettings.normalizeAttributes(attributes);

    assertEquals("item", normalizedAttributes.asList().get(0).getKey());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:10,代码来源:ParserSettingsTest.java

示例8: addLink

import org.jsoup.nodes.Attributes; //导入方法依赖的package包/类
private void addLink(Element head, String... attributes)
{
	Attributes attr = new Attributes();

	for (String attribute : attributes)
	{
		String[] keyValue = attribute.split("=");
		String key = keyValue[0];
		String value = keyValue[1];
		attr.put(key, value);
	}
	Element linkElement = new Element(Tag.valueOf("link"), "", attr);
	head.appendChild(linkElement);

}
 
开发者ID:bsutton,项目名称:scoutmaster,代码行数:16,代码来源:VaadinServlet.java

示例9: setUp

import org.jsoup.nodes.Attributes; //导入方法依赖的package包/类
@Before
public void setUp() {
    charsetAttributes = new Attributes();
    charsetAttributes.put("charset", "UTF-8");
    charsetElement = new Element(Tag.valueOf("meta"), "", charsetAttributes);
    
    dublinElementAttributes = new Attributes();
    dublinElementAttributes.put("name", "dcterms.title");
    dublinElementAttributes.put("content", "CT Abdomen");
    dublinElement = new Element(Tag.valueOf("meta"), "", dublinElementAttributes);
}
 
开发者ID:openmrs,项目名称:openmrs-module-radiology,代码行数:12,代码来源:MetaTagsValidationEngineTest.java


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