/** * {@inheritDoc} */ @Override public String getNodeValue() { return getValue(); }
/** * {@inheritDoc} */ @Override public String getNodeValue() { return getValue(); }
/** * {@inheritDoc} */ @Override public String getNodeValue() { return getValue(); }
/** * {@inheritDoc} */ @Override public String getNodeValue() { return getValue(); }
/** * {@inheritDoc} */ @Override public String getNodeValue() { return getValue(); }
private String asString() { final Object resultObj = result_.get(0); if (resultObj instanceof DomAttr) { return ((DomAttr) resultObj).getValue(); } if (resultObj instanceof DomNode) { return ((DomNode) resultObj).asText(); } return resultObj.toString(); } }
private String asString() { final Object resultObj = result_.get(0); if (resultObj instanceof DomAttr) { return ((DomAttr) resultObj).getValue(); } if (resultObj instanceof DomNode) { return ((DomNode) resultObj).asText(); } return resultObj.toString(); } }
protected Map<String, DomAttr> getAttributesFor(final HtmlLink link) throws IOException { final Map<String, DomAttr> map = createAttributesCopyWithClonedAttribute(link, "href"); final DomAttr hrefAttr = map.get("href"); if (hrefAttr != null && StringUtils.isNotBlank(hrefAttr.getValue())) { final String protocol = link.getWebRequest().getUrl().getProtocol(); if ("http".equals(protocol) || "https".equals(protocol)) { final File file = createFile(hrefAttr.getValue(), ".css"); FileUtils.writeStringToFile(file, link.getWebResponse(true, null).getContentAsString(), ISO_8859_1); hrefAttr.setValue(outputDir_.getName() + FILE_SEPARATOR + file.getName()); } } return map; }
protected Map<String, DomAttr> getAttributesFor(final HtmlImage image) throws IOException { final Map<String, DomAttr> map = createAttributesCopyWithClonedAttribute(image, "src"); final DomAttr srcAttr = map.get("src"); if (srcAttr != null && StringUtils.isNotBlank(srcAttr.getValue())) { final WebResponse response = image.getWebResponse(true); final File file = createFile(srcAttr.getValue(), "." + getSuffix(response)); try (InputStream inputStream = response.getContentAsStream()) { FileUtils.copyInputStreamToFile(inputStream, file); } final String valueOnFileSystem = outputDir_.getName() + FILE_SEPARATOR + file.getName(); srcAttr.setValue(valueOnFileSystem); // this is the clone attribute node, not the original one of the page } return map; }
/** * Returns the attribute value. * @return the attribute value */ @JsxGetter public String getValue() { return getDomNodeOrDie().getValue(); }
protected Map<String, DomAttr> getAttributesFor(final HtmlLink link) { final Map<String, DomAttr> map = new HashMap<String, DomAttr>(link.getAttributesMap()); final String src = map.get("href").getValue(); try { final File file = createFile(src, ".css"); FileUtils.writeStringToFile(file, link.getWebResponse(true).getContentAsString()); map.get("href").setValue(outputDir_.getName() + File.separatorChar + file.getName()); } catch (final Exception e) { throw new RuntimeException(e); } return map; }
/** * Returns the value of this attribute. * @return the value of this attribute */ @JsxGetter public String getValue() { return getDomNodeOrDie().getValue(); }
protected Map<String, DomAttr> getAttributesFor(final HtmlLink link) throws IOException { final Map<String, DomAttr> map = createAttributesCopyWithClonedAttribute(link, "href"); final DomAttr hrefAttr = map.get("href"); if (hrefAttr != null && StringUtils.isNotBlank(hrefAttr.getValue())) { final String protocol = link.getWebRequest().getUrl().getProtocol(); if ("http".equals(protocol) || "https".equals(protocol)) { final File file = createFile(hrefAttr.getValue(), ".css"); FileUtils.writeStringToFile(file, link.getWebResponse(true, null).getContentAsString(), ISO_8859_1); hrefAttr.setValue(outputDir_.getName() + FILE_SEPARATOR + file.getName()); } } return map; }
protected Map<String, DomAttr> getAttributesFor(final HtmlLink link) { final Map<String, DomAttr> map = new HashMap<String, DomAttr>(link.getAttributesMap()); final String src = map.get("href").getValue(); try { final File file = createFile(src, ".css"); FileUtils.writeStringToFile(file, link.getWebResponse(true).getContentAsString()); map.get("href").setValue(outputDir_.getName() + File.separatorChar + file.getName()); } catch (final Exception e) { throw new RuntimeException(e); } return map; }
protected Map<String, DomAttr> getAttributesFor(final HtmlLink link) { final Map<String, DomAttr> map = new HashMap<String, DomAttr>(link.getAttributesMap()); final String src = map.get("href").getValue(); try { final File file = createFile(src, ".css"); FileUtils.writeStringToFile(file, link.getWebResponse(true).getContentAsString()); map.get("href").setValue(outputDir_.getName() + File.separatorChar + file.getName()); } catch (final Exception e) { throw new RuntimeException(e); } return map; }
/** * Returns the attribute value. * @return the attribute value */ @JsxGetter public String getValue() { return getDomNodeOrDie().getValue(); }
protected Map<String, DomAttr> getAttributesFor(final HtmlImage image) throws IOException { final Map<String, DomAttr> map = createAttributesCopyWithClonedAttribute(image, DomElement.SRC_ATTRIBUTE); final DomAttr srcAttr = map.get(DomElement.SRC_ATTRIBUTE); if (srcAttr != null && StringUtils.isNotBlank(srcAttr.getValue())) { final WebResponse response = image.getWebResponse(true); final File file = createFile(srcAttr.getValue(), "." + getSuffix(response)); try (InputStream inputStream = response.getContentAsStream()) { FileUtils.copyInputStreamToFile(inputStream, file); } final String valueOnFileSystem = outputDir_.getName() + FILE_SEPARATOR + file.getName(); srcAttr.setValue(valueOnFileSystem); // this is the clone attribute node, not the original one of the page } return map; }
/** * Returns the value of this attribute. * @return the value of this attribute */ @JsxGetter public String getValue() { return getDomNodeOrDie().getValue(); }
private static Map<String, DomAttr> createAttributesCopyWithClonedAttribute(final HtmlElement elt, final String attrName) { final Map<String, DomAttr> newMap = new HashMap<>(elt.getAttributesMap()); // clone the specified element, if possible final DomAttr attr = newMap.get(attrName); if (null == attr) { return newMap; } final DomAttr clonedAttr = new DomAttr(attr.getPage(), attr.getNamespaceURI(), attr.getQualifiedName(), attr.getValue(), attr.getSpecified()); newMap.put(attrName, clonedAttr); return newMap; }
private static Map<String, DomAttr> createAttributesCopyWithClonedAttribute(final HtmlElement elt, final String attrName) { final Map<String, DomAttr> newMap = new HashMap<>(elt.getAttributesMap()); // clone the specified element, if possible final DomAttr attr = newMap.get(attrName); if (null == attr) { return newMap; } final DomAttr clonedAttr = new DomAttr(attr.getPage(), attr.getNamespaceURI(), attr.getQualifiedName(), attr.getValue(), attr.getSpecified()); newMap.put(attrName, clonedAttr); return newMap; }