/** * {@inheritDoc} */ @Override public NameValuePair[] getSubmitNameValuePairs() { final String name = getNameAttribute(); final String prefix; // a clicked image without name sends parameter x and y if (StringUtils.isEmpty(name)) { prefix = ""; } else { prefix = name + "."; } if (wasPositionSpecified_) { final NameValuePair valueX = new NameValuePair(prefix + 'x', Integer.toString(xPosition_)); final NameValuePair valueY = new NameValuePair(prefix + 'y', Integer.toString(yPosition_)); if (!prefix.isEmpty() && hasFeature(HTMLIMAGE_NAME_VALUE_PARAMS) && !getValueAttribute().isEmpty()) { return new NameValuePair[] {valueX, valueY, new NameValuePair(getNameAttribute(), getValueAttribute()) }; } return new NameValuePair[] {valueX, valueY}; } return new NameValuePair[]{new NameValuePair(getNameAttribute(), getValueAttribute())}; }
/** * {@inheritDoc} */ @Override public NameValuePair[] getSubmitNameValuePairs() { final String name = getNameAttribute(); final String prefix; // a clicked image without name sends parameter x and y if (StringUtils.isEmpty(name)) { prefix = ""; } else { prefix = name + "."; } if (wasPositionSpecified_) { final NameValuePair valueX = new NameValuePair(prefix + 'x', Integer.toString(xPosition_)); final NameValuePair valueY = new NameValuePair(prefix + 'y', Integer.toString(yPosition_)); if (!prefix.isEmpty() && hasFeature(HTMLIMAGE_NAME_VALUE_PARAMS) && !getValueAttribute().isEmpty()) { return new NameValuePair[] {valueX, valueY, new NameValuePair(getNameAttribute(), getValueAttribute()) }; } return new NameValuePair[] {valueX, valueY}; } return new NameValuePair[]{new NameValuePair(getNameAttribute(), getValueAttribute())}; }
/** * <p>Downloads the image contained by this image element.</p> * <p><span style="color:red">POTENTIAL PERFORMANCE KILLER - DOWNLOADS THE IMAGE - USE AT YOUR OWN RISK</span></p> * <p>If the image has not already been downloaded, this method triggers a download and caches the image.</p> * * @throws IOException if an error occurs while downloading the image */ private void downloadImageIfNeeded() throws IOException { if (!downloaded_) { // HTMLIMAGE_BLANK_SRC_AS_EMPTY final String src = getSrcAttribute(); if (!"".equals(src) && !(hasFeature(HTMLIMAGE_BLANK_SRC_AS_EMPTY) && StringUtils.isBlank(src))) { final HtmlPage page = (HtmlPage) getPage(); final WebClient webclient = page.getWebClient(); final URL url = page.getFullyQualifiedUrl(src); final String accept = webclient.getBrowserVersion().getImgAcceptHeader(); final WebRequest request = new WebRequest(url, accept); request.setCharset(page.getCharset()); request.setAdditionalHeader(HttpHeader.REFERER, page.getUrl().toExternalForm()); imageWebResponse_ = webclient.loadWebResponse(request); } if (imageData_ != null) { imageData_.close(); imageData_ = null; } downloaded_ = hasFeature(JS_IMAGE_COMPLETE_RETURNS_TRUE_FOR_NO_REQUEST) || (imageWebResponse_ != null && imageWebResponse_.getContentType().contains("image")); } }
/** * <p>Downloads the image contained by this image element.</p> * <p><span style="color:red">POTENTIAL PERFORMANCE KILLER - DOWNLOADS THE IMAGE - USE AT YOUR OWN RISK</span></p> * <p>If the image has not already been downloaded, this method triggers a download and caches the image.</p> * * @throws IOException if an error occurs while downloading the image */ private void downloadImageIfNeeded() throws IOException { if (!downloaded_) { // HTMLIMAGE_BLANK_SRC_AS_EMPTY final String src = getSrcAttribute(); if (!"".equals(src) && !(hasFeature(HTMLIMAGE_BLANK_SRC_AS_EMPTY) && StringUtils.isBlank(src))) { final HtmlPage page = (HtmlPage) getPage(); final WebClient webclient = page.getWebClient(); final URL url = page.getFullyQualifiedUrl(src); final String accept = webclient.getBrowserVersion().getImgAcceptHeader(); final WebRequest request = new WebRequest(url, accept); request.setCharset(page.getCharset()); request.setAdditionalHeader(HttpHeader.REFERER, page.getUrl().toExternalForm()); imageWebResponse_ = webclient.loadWebResponse(request); } if (imageData_ != null) { imageData_.close(); imageData_ = null; } downloaded_ = hasFeature(JS_IMAGE_COMPLETE_RETURNS_TRUE_FOR_NO_REQUEST) || (imageWebResponse_ != null && imageWebResponse_.getContentType().contains("image")); } }