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


Java Attribute.getValue方法代码示例

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


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

示例1: testValidProtocol

import org.jsoup.nodes.Attribute; //导入方法依赖的package包/类
private boolean testValidProtocol(Element el, Attribute attr, Set<Protocol> protocols) {
    // try to resolve relative urls to abs, and optionally update the attribute so output html has abs.
    // rels without a baseuri get removed
    String value = el.absUrl(attr.getKey());
    if (value.length() == 0)
        value = attr.getValue(); // if it could not be made abs, run as-is to allow custom unknown protocols
    if (!preserveRelativeLinks)
        attr.setValue(value);
    
    for (Protocol protocol : protocols) {
        String prot = protocol.toString() + ":";
        if (value.toLowerCase().startsWith(prot)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:Nader-Sl,项目名称:BoL-API-Parser,代码行数:18,代码来源:Whitelist.java

示例2: getParams

import org.jsoup.nodes.Attribute; //导入方法依赖的package包/类
private JsonObject getParams(Attribute paramsAttribute) {
  final JsonObject result;
  if (paramsAttribute == null || StringUtils.isEmpty(paramsAttribute.getValue())) {
    result = new JsonObject();
  } else {
    result = new JsonObject(paramsAttribute.getValue());
  }
  return result;
}
 
开发者ID:Cognifide,项目名称:knotx,代码行数:10,代码来源:ServiceEntry.java

示例3: testValidProtocol

import org.jsoup.nodes.Attribute; //导入方法依赖的package包/类
private boolean testValidProtocol(Element el, Attribute attr, Set<Protocol> protocols) {
    // try to resolve relative urls to abs, and optionally update the attribute so output html has abs.
    // rels without a baseuri get removed
    String value = el.absUrl(attr.getKey());
    if (value.length() == 0)
        value = attr.getValue(); // if it could not be made abs, run as-is to allow custom unknown protocols
    if (!preserveRelativeLinks)
        attr.setValue(value);
    
    for (Protocol protocol : protocols) {
        String prot = protocol.toString();

        if (prot.equals("#")) { // allows anchor links
            if (isValidAnchor(value)) {
                return true;
            } else {
                continue;
            }
        }

        prot += ":";

        if (value.toLowerCase().startsWith(prot)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:cpusoft,项目名称:common,代码行数:29,代码来源:Whitelist.java

示例4: convertAttributesToCSS

import org.jsoup.nodes.Attribute; //导入方法依赖的package包/类
/**
 * Convertit les attributs de l'élément ciblés en leurs équivalents CSS
 * @param e l'élément à modifier
 */
public static void convertAttributesToCSS(Element e) {
    Map<String, String> styles = getStyleMap(e.attr("style"));
    for(Attribute attribute : e.attributes()) {
        String key = attribute.getKey();
        String value = attribute.getValue();
        String css = HTMLtoCSSAttribute.getValue(key);
        if(css!=null) {
            styles.put(css, value);
            e.removeAttr(key);
        }
    }
    setStyle(e, styles);
    if(!getStyle(e, "size").isEmpty()) {setStyleAttribute(e, "font-size", getFontSize(e)+"pt");}//Conversion de la taille en pt
}
 
开发者ID:Sharcoux,项目名称:MathEOS,代码行数:19,代码来源:JsoupTools.java

示例5: testValidProtocol

import org.jsoup.nodes.Attribute; //导入方法依赖的package包/类
private boolean testValidProtocol(Element el, Attribute attr, Set<Protocol> protocols) {
    // try to resolve relative urls to abs, and optionally update the attribute so output html has abs.
    // rels without a baseuri get removed
    String value = el.absUrl(attr.getKey());
    if (value.length() == 0)
        value = attr.getValue(); // if it could not be made abs, run as-is to allow custom unknown protocols
    if (!preserveRelativeLinks)
        attr.setValue(value);
    
    for (Protocol protocol : protocols) {
        String prot = protocol.toString();

        if (prot.equals("#")) { // allows anchor links
            if (isValidAnchor(value)) {
                return true;
            } else {
                continue;
            }
        }

        prot += ":";

        if (lowerCase(value).startsWith(prot)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:29,代码来源:Whitelist.java

示例6: urlFromAttr

import org.jsoup.nodes.Attribute; //导入方法依赖的package包/类
public static String urlFromAttr(Node node) {
  for (Attribute attr : node.attributes().asList()) {
    if (attr.getValue().contains("://")) {
      return attr.getValue();
    }
  }
  return null;
}
 
开发者ID:MachinePublishers,项目名称:ScreenSlicer,代码行数:9,代码来源:UrlUtil.java

示例7: translateAttribute

import org.jsoup.nodes.Attribute; //导入方法依赖的package包/类
private void translateAttribute(Attribute attribute, Element element, LanguageBundle bundle){
    String name = attribute.getKey();
    int firstHyphenIndex = name.indexOf('-');

    //Translate inner HTML
    if(firstHyphenIndex==-1){

        String translateKey = attribute.getValue();

        //inner HTML
        if(translateKey==null||translateKey.isEmpty())
            translateKey = element.html();

        if(translateKey.isEmpty())
            return;

        String translated = bundle.translate(translateKey);
        if(translated!=null)
            element.html(translated);
        return;

    }

    String targetAttrName = name.substring(firstHyphenIndex+1,name.length());

    if(attribute.getValue()!=null&&!attribute.getValue().isEmpty()){
        //Translate based in a key: do nothing if cant find the key
        String keyTranslation = bundle.translate(attribute.getValue());

        if(keyTranslation!=null)//Key translated successfully
            element.attr(targetAttrName,keyTranslation);

        return;
    }

    //Translate the value of the target attribute
    String targetAttrValue = element.attr(targetAttrName);
    if(targetAttrValue.isEmpty())
        return;

    String translatedValue = bundle.translate(targetAttrValue);

    if(translatedValue!=null)//Value translated successfully
        element.attr(targetAttrName,translatedValue);
}
 
开发者ID:Emerjoin,项目名称:Hi-Framework,代码行数:46,代码来源:DOMTranslator.java

示例8: ServiceEntry

import org.jsoup.nodes.Attribute; //导入方法依赖的package包/类
public ServiceEntry(Attribute serviceAttribute, Attribute paramsAttribute) {
  this.namespace = ServiceAttributeUtil.extractNamespace(serviceAttribute.getKey());
  this.name = serviceAttribute.getValue();
  this.params = getParams(paramsAttribute);
  this.cacheKey = String.format("%s|%s", getName(), getParams());
}
 
开发者ID:Cognifide,项目名称:knotx,代码行数:7,代码来源:ServiceEntry.java

示例9: execute

import org.jsoup.nodes.Attribute; //导入方法依赖的package包/类
@Override
public void execute(GnarMessage message, String[] args)
{
    boolean checked = false;

    for(Role r : ((GuildManager) getGnarManager()).getGuild().getRolesForUser(message.getAuthor())) {
        if(r.getName().equals("Fucking Teemo")) {
            checked = true;
        }
    }

    if(checked) {
        String tag = "";
        try {
            for (String s : args) {
                if (s.equals("_rule")) continue;
                if (tag.equals("")) {
                    tag += ("&tags=" + s);
                } else {
                    tag += ("+" + s);
                }
            }
        } catch (Exception ignore) {
        }

        try {

            String xml = "http://rule34.xxx/index.php?page=dapi&s=post&q=index" + tag;

            Document document = Jsoup.connect(xml).parser(Parser.xmlParser()).get();

            Elements posts = document.getElementsByTag("post");

            int rand = new Random().nextInt(posts.size());

            Element target = posts.get(rand);

            String url;

            Attributes att = target.attributes();

            Attribute att2 = att.asList().get(2);

            url = att2.getValue();

            message.reply("http:" + url);
        } catch (Exception e) {
            message.reply("Please refer to rule 35.");
        }
    } else {
        message.reply("Sorry, you must have the role `Fucking Teemo` to use this command!");
    }

}
 
开发者ID:Gnar-Team,项目名称:Legacy-GN4R,代码行数:55,代码来源:Rule34Command.java


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