protected int indexOfAttributeInstance(String name) { if (attributes == null) { return -1; } if (!ownerDocument.config.isCaseSensitive()) { name = name.toLowerCase(); } for (int i = 0, attributesSize = attributes.size(); i < attributesSize; i++) { Attribute attr = attributes.get(i); if (attr.getName().equals(name)) { return i; } } return -1; }
protected Attribute getAttributeInstance(String name) { if (attributes == null) { return null; } if (!ownerDocument.config.isCaseSensitive()) { name = name.toLowerCase(); } for (int i = 0, attributesSize = attributes.size(); i < attributesSize; i++) { Attribute attr = attributes.get(i); if (attr.getName().equals(name)) { return attr; } } return null; }
/** * Returns <code>true</code> if node contains an attribute. */ public boolean hasAttribute(String name) { if (attributes == null) { return false; } if (!ownerDocument.config.isCaseSensitive()) { name = name.toLowerCase(); } for (int i = 0, attributesSize = attributes.size(); i < attributesSize; i++) { Attribute attr = attributes.get(i); if (attr.getName().equals(name)) { return true; } } return false; }
/** * Renders attribute name. */ protected String resolveAttributeName(final Node node, final Attribute attribute) { switch (attributeCase) { case DEFAULT: return attribute.getName(); case RAW: return attribute.getRawName(); case LOWERCASE: return attribute.getRawName().toLowerCase(); case UPPERCASE: return attribute.getRawName().toUpperCase(); } return null; }
/** * Sets attribute value. Value may be <code>null</code>. */ public void setAttribute(String name, final String value) { initAttributes(); String rawAttributeName = name; if (!ownerDocument.config.isCaseSensitive()) { name = name.toLowerCase(); } // search if attribute with the same name exist for (int i = 0, attributesSize = attributes.size(); i < attributesSize; i++) { Attribute attr = attributes.get(i); if (attr.getName().equals(name)) { attr.setValue(value); return; } } attributes.add(new Attribute(rawAttributeName, name, value)); }
@Test void testKelkoo() throws Exception { File file = new File(testDataRoot, "kelkoo.html"); Jerry jerry; try { jerry = Jerry.jerry().parse(FileUtil.readString(file)); } catch (Exception ex) { fail(ex.toString()); throw ex; } Element script = (Element) jerry.$("script").get(0); assertEquals("script", script.getNodeName()); assertEquals(6, script.getAttributesCount()); assertEquals("src", script.getAttribute(0).getName()); assertEquals("data-config", script.getAttribute(1).getName()); assertEquals("ext\\u00e9rieur|barbecue,", script.getAttribute(2).getName()); assertEquals("planchaaccessoires\":\"http:\\", script.getAttribute(3).getName()); assertEquals("www.kelkoo.fr\"}'", script.getAttribute(4).getName()); assertEquals("data-adsense-append", script.getAttribute(5).getName()); }
assertEquals("id", attr.getName()); assertEquals("w173", attr.getValue()); assertTrue(p.hasAttribute("id"));
/** * Returns <code>true</code> if node contains an attribute. */ public boolean hasAttribute(String name) { if (attributes == null) { return false; } for (int i = 0, attributesSize = attributes.size(); i < attributesSize; i++) { Attribute attr = attributes.get(i); if (attr.getName().equals(name)) { return true; } } return false; }
protected Attribute getAttributeInstance(String name) { if (attributes == null) { return null; } if (!ownerDocument.config.isCaseSensitive()) { name = name.toLowerCase(); } for (int i = 0, attributesSize = attributes.size(); i < attributesSize; i++) { Attribute attr = attributes.get(i); if (attr.getName().equals(name)) { return attr; } } return null; }
protected int indexOfAttributeInstance(String name) { if (attributes == null) { return -1; } if (!ownerDocument.config.isCaseSensitive()) { name = name.toLowerCase(); } for (int i = 0, attributesSize = attributes.size(); i < attributesSize; i++) { Attribute attr = attributes.get(i); if (attr.getName().equals(name)) { return i; } } return -1; }
protected Attribute getAttributeInstance(String name) { if (attributes == null) { return null; } if (!ownerDocument.config.isCaseSensitive()) { name = name.toLowerCase(); } for (int i = 0, attributesSize = attributes.size(); i < attributesSize; i++) { Attribute attr = attributes.get(i); if (attr.getName().equals(name)) { return attr; } } return null; }
protected int indexOfAttributeInstance(String name) { if (attributes == null) { return -1; } if (!ownerDocument.config.isCaseSensitive()) { name = name.toLowerCase(); } for (int i = 0, attributesSize = attributes.size(); i < attributesSize; i++) { Attribute attr = attributes.get(i); if (attr.getName().equals(name)) { return i; } } return -1; }
/** * Returns <code>true</code> if node contains an attribute. */ public boolean hasAttribute(String name) { if (attributes == null) { return false; } if (!ownerDocument.config.isCaseSensitive()) { name = name.toLowerCase(); } for (int i = 0, attributesSize = attributes.size(); i < attributesSize; i++) { Attribute attr = attributes.get(i); if (attr.getName().equals(name)) { return true; } } return false; }
/** * Renders attribute name. */ protected String resolveAttributeName(final Node node, final Attribute attribute) { switch (attributeCase) { case DEFAULT: return attribute.getName(); case RAW: return attribute.getRawName(); case LOWERCASE: return attribute.getRawName().toLowerCase(); case UPPERCASE: return attribute.getRawName().toUpperCase(); } return null; }
/** * Renders attribute name. */ protected String resolveAttributeName(Node node, Attribute attribute) { switch (attributeCase) { case DEFAULT: return attribute.getName(); case RAW: return attribute.getRawName(); case LOWERCASE: return attribute.getRawName().toLowerCase(); case UPPERCASE: return attribute.getRawName().toUpperCase(); } return null; }
/** * Sets attribute value. Value may be <code>null</code>. */ public void setAttribute(String name, final String value) { initAttributes(); String rawAttributeName = name; if (!ownerDocument.config.isCaseSensitive()) { name = name.toLowerCase(); } // search if attribute with the same name exist for (int i = 0, attributesSize = attributes.size(); i < attributesSize; i++) { Attribute attr = attributes.get(i); if (attr.getName().equals(name)) { attr.setValue(value); return; } } attributes.add(new Attribute(rawAttributeName, name, value)); }
/** * Sets attribute value. Value may be <code>null</code>. */ public void setAttribute(String name, String value) { initAttributes(); String rawAttributeName = name; if (!ownerDocument.config.isCaseSensitive()) { name = name.toLowerCase(); } // search if attribute with the same name exist for (int i = 0, attributesSize = attributes.size(); i < attributesSize; i++) { Attribute attr = attributes.get(i); if (attr.getName().equals(name)) { attr.setValue(value); return; } } attributes.add(new Attribute(rawAttributeName, name, value)); }