For IntelliJ IDEA,
Android Studio or Eclipse



private void copyAttributes(org.jsoup.nodes.Node source, Element el) { for (Attribute attribute : source.attributes()) { // valid xml attribute names are: ^[a-zA-Z_:][-a-zA-Z0-9_:.] String key = attribute.getKey().replaceAll("[^-a-zA-Z0-9_:.]", ""); if (key.matches("[a-zA-Z_:][-a-zA-Z0-9_:.]*")) el.setAttribute(key, attribute.getValue()); } }
@Override public boolean matches(Element root, Element element) { List<org.jsoup.nodes.Attribute> values = element.attributes().asList(); for (org.jsoup.nodes.Attribute attribute : values) { if (lowerCase(attribute.getKey()).startsWith(keyPrefix)) return true; } return false; }
Document doc = Jsoup.parseBodyFragment(aText); Elements el = doc.getAllElements(); for (Element e : el) { Attributes at = e.attributes(); for (Attribute a : at) { e.removeAttr(a.getKey()); } } if(Jsoup.isValid(doc.body().html(), theLegalWhitelist)) return true; else return false;
/** * @param attributes A list of attribs * @return Returns a mutable map parsed out of the attribute list */ public static Map<String, String> parseAttribs(Attributes attributes) { Map<String, String> attrs = new LinkedHashMap<String, String>(attributes.size() + 4); for (Attribute a : attributes.asList()) if (!SKIP_ATTR.contains(a.getKey())) attrs.put(a.getKey(), a.getValue()); return attrs; }
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()); }
public void dumpHtmlTree(FormattingAppendable out, Node node) { out.line().append(node.nodeName()); for (Attribute attribute : node.attributes().asList()) { out.append(' ').append(attribute.getKey()).append("=\"").append(attribute.getValue()).append("\""); } out.line().indent(); for (Node child : node.childNodes()) { dumpHtmlTree(out, child); } out.unIndent(); }
private void getWholeDeclaration(Appendable accum, Document.OutputSettings out) throws IOException { for (Attribute attribute : attributes()) { if (!attribute.getKey().equals(nodeName())) { // skips coreValue (name) accum.append(' '); attribute.html(accum, out); } } }
public void copyAttributes(Element src) { Attributes attrs = src.attributes(); Iterator<Attribute> it = attrs.iterator(); Attribute attr; while (it.hasNext()) { attr = it.next(); this.attr(attr.getKey(), attr.getValue()); } } }
public void remove() { attributes.remove(attr.getKey()); } }
private static Map<String, String> getSignalToUrlMapping(Document scriptDocument) { return scriptDocument.getElementsByAttributeStarting(FORM_SIGNAL_ATTR_PREFIX).stream() .flatMap(element -> element.attributes().asList().stream()) .filter(allAttr -> allAttr.getKey().startsWith(FORM_SIGNAL_ATTR_PREFIX)) .collect(Collectors.toMap(e -> e.getKey().replace(FORM_SIGNAL_ATTR_PREFIX, StringUtils.EMPTY), Entry::getValue)); } }
private boolean isEventBinding(Attribute attribute) { String attributeName = attribute.getKey().toLowerCase(); return attributeName.startsWith("@") || attributeName.startsWith("v-on:"); }
public static List<String> getAttributeNamesForJSoupElement(Element element) { List<String> result = Util.newEmptyList(); for(Attribute attribute : element.attributes()) result.add(attribute.getKey()); result.add(HtmlSpecialAttributes.SPECIAL_ATTRIBUTE_CLASS_NAMES); result.add(HtmlSpecialAttributes.SPECIAL_ATTRIBUTE_HTML); result.add(HtmlSpecialAttributes.SPECIAL_ATTRIBUTE_INNER_HTML); result.add(HtmlSpecialAttributes.SPECIAL_ATTRIBUTE_TAG_NAME); result.add(HtmlSpecialAttributes.SPECIAL_ATTRIBUTE_TEXT); return result; } }
/** Set a new attribute, or replace an existing one by key. @param attribute attribute with case sensitive key @return these attributes, for chaining */ public Attributes put(Attribute attribute) { Validate.notNull(attribute); put(attribute.getKey(), attribute.getValue()); attribute.parent = this; return this; }
private boolean isAttributeBinding(Attribute attribute) { String attributeName = attribute.getKey().toLowerCase(); return attributeName.startsWith(":") || attributeName.startsWith("v-bind:"); }