本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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
}
示例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;
}
示例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;
}
示例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);
}
示例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());
}
示例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!");
}
}