本文整理汇总了Java中org.jsoup.nodes.Node.attr方法的典型用法代码示例。如果您正苦于以下问题:Java Node.attr方法的具体用法?Java Node.attr怎么用?Java Node.attr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jsoup.nodes.Node
的用法示例。
在下文中一共展示了Node.attr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unlikely
import org.jsoup.nodes.Node; //导入方法依赖的package包/类
private boolean unlikely(Node e) {
if (e.attr("class") != null && e.attr("class").toLowerCase().contains("caption"))
return true;
String style = e.attr("style");
String clazz = e.attr("class");
return unlikelyPattern.matcher(style).find() || unlikelyPattern.matcher(clazz).find();
}
示例2: processNode
import org.jsoup.nodes.Node; //导入方法依赖的package包/类
/**
* Recursive method that will process the whole template DOM tree.
* @param node Current node being processed
*/
private void processNode(Node node)
{
context.setCurrentNode(node);
currentProp = null;
currentAttribute = null;
boolean nodeHasVFor = node.attributes().hasKey("v-for");
if (nodeHasVFor)
{
// Add a context layer for our v-for
context.addContextLayer();
// Process the v-for expression, and update our attribute
String processedVForValue = processVForValue(node.attr("v-for"));
node.attr("v-for", processedVForValue);
}
if (node instanceof TextNode)
{
processTextNode((TextNode) node);
}
else if (node instanceof Element)
{
processElementNode((Element) node);
}
// Recurse downwards
node.childNodes().
forEach(this::processNode);
if (nodeHasVFor)
{
// After downward recursion, pop the context layer
context.popContextLayer();
}
}
示例3: parseNode
import org.jsoup.nodes.Node; //导入方法依赖的package包/类
/**
* Parse a tr node to an event
*
* @param node
* @return an event
*/
private Event parseNode(String eventDate, Element node) {
Event result = new Event();
Node loca = node.childNode(0);
// TODO hello-gitty à terme remplacer l'event par l'immutable
//ImmutableKEvent.Builder builder = ImmutableKEvent.builder();
Optional<String> empire = Optional.empty();
Optional<String> province = Optional.empty();
Optional<String> ville = Optional.empty();
// Si au moins un noeud alors on récupére l'empire
if (loca.childNodeSize() > 0) {
Node empi = loca.childNode(0);
if (empi.hasAttr(Constantes.ATTR_SRC)) {
String im = empi.attr(Constantes.ATTR_SRC);
im = im.substring(im.length() - 5, im.length() - 4);
int pos = Util.parseInt(im) - 1;
empire = Optional.of(Constantes.EMPIRE_LIST[pos]);
}
}
// Si plus d'un noeud, le second c'est la province
if (loca.childNodeSize() > 1) {
province = Optional.of(Util.getText(loca.childNode(1)));
}
// Si plus d'un noeud, le troisieme c'est la ville
if (loca.childNodeSize() > 2) {
ville = Optional.of(Util.getText(loca.childNode(2)));
}
String data = node.childNode(2).toString();
String type = null;
if (data.startsWith(Constantes.TD_EVENT_ANIM)) {
data = data.substring(Constantes.TD_EVENT_ANIM.length());
type = "anim";
} else if ( data.startsWith(Constantes.TD_EVENT_NORMAL)) {
data = data.substring(Constantes.TD_EVENT_NORMAL.length());
type = "normal";
} else if ( data.startsWith(Constantes.TD_EVENT_MAJ)) {
data = data.substring(Constantes.TD_EVENT_MAJ.length());
type = "maj";
}
if (type != null) {
data = data.substring(0, data.length() - 5);
}
result.setData(data);
result.setType(type);
String heure = Util.getText(node.childNode(1));
heure = heure.replace("\u00A0", "").trim(); // Espace insecable pourri
result.setDateHeure(LocalDateTime.parse(eventDate + "T" + heure));
result.setVille(ville);
result.setProvince(province);
result.setEmpire(empire);
if (ville.isPresent()) {
this.datas.addVilles(ville.get());
}
if (province.isPresent()) {
this.datas.addProvinces(province.get());
}
if (empire.isPresent()) {
this.datas.addEmpire(empire.get());
}
return result;
}
示例4: 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());
}
}