Skip to content

Commit 80b83d4

Browse files
committed
use our own string functions
1 parent ca70ad3 commit 80b83d4

28 files changed

+79
-77
lines changed

src/main/java/org/htmlunit/WebClient.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
import java.util.concurrent.ThreadFactory;
5555
import java.util.concurrent.ThreadPoolExecutor;
5656

57-
import org.apache.commons.lang3.StringUtils;
5857
import org.apache.commons.logging.Log;
5958
import org.apache.commons.logging.LogFactory;
6059
import org.apache.http.NoHttpResponseException;
@@ -98,6 +97,7 @@
9897
import org.htmlunit.util.HeaderUtils;
9998
import org.htmlunit.util.MimeType;
10099
import org.htmlunit.util.NameValuePair;
100+
import org.htmlunit.util.StringUtils;
101101
import org.htmlunit.util.UrlUtils;
102102
import org.htmlunit.websocket.JettyWebSocketAdapter.JettyWebSocketAdapterFactory;
103103
import org.htmlunit.websocket.WebSocketAdapter;
@@ -624,13 +624,13 @@ public Page loadWebResponseInto(final WebResponse webResponse, final WebWindow w
624624
&& (forceAttachmentWithFilename != null || attachmentHandler_.isAttachment(webResponse))) {
625625

626626
// check content disposition header for nothing provided
627-
if (StringUtils.isEmpty(forceAttachmentWithFilename)) {
627+
if (StringUtils.isEmptyOrNull(forceAttachmentWithFilename)) {
628628
final String disp = webResponse.getResponseHeaderValue(HttpHeader.CONTENT_DISPOSITION);
629629
forceAttachmentWithFilename = Attachment.getSuggestedFilename(disp);
630630
}
631631

632632
if (attachmentHandler_.handleAttachment(webResponse,
633-
StringUtils.isEmpty(forceAttachmentWithFilename) ? null : forceAttachmentWithFilename)) {
633+
StringUtils.isEmptyOrNull(forceAttachmentWithFilename) ? null : forceAttachmentWithFilename)) {
634634
// the handling is done by the attachment handler;
635635
// do not open a new window
636636
return webWindow.getEnclosedPage();
@@ -639,7 +639,8 @@ public Page loadWebResponseInto(final WebResponse webResponse, final WebWindow w
639639
final WebWindow w = openWindow(null, null, webWindow);
640640
final Page page = pageCreator_.createPage(webResponse, w);
641641
attachmentHandler_.handleAttachment(page,
642-
StringUtils.isEmpty(forceAttachmentWithFilename) ? null : forceAttachmentWithFilename);
642+
StringUtils.isEmptyOrNull(forceAttachmentWithFilename)
643+
? null : forceAttachmentWithFilename);
643644
return page;
644645
}
645646

@@ -1383,8 +1384,9 @@ private static WebResponse makeWebResponseForAboutUrl(final WebRequest webReques
13831384
return new StringWebResponse("", UrlUtils.URL_ABOUT_BLANK);
13841385
}
13851386

1386-
final String urlWithoutQuery = StringUtils.substringBefore(urlString, "?");
1387-
if (!"blank".equalsIgnoreCase(StringUtils.substringAfter(urlWithoutQuery, UrlUtils.ABOUT_SCHEME))) {
1387+
final String urlWithoutQuery = org.apache.commons.lang3.StringUtils.substringBefore(urlString, "?");
1388+
if (!"blank".equalsIgnoreCase(org.apache.commons.lang3.StringUtils
1389+
.substringAfter(urlWithoutQuery, UrlUtils.ABOUT_SCHEME))) {
13881390
throw new MalformedURLException(url + " is not supported, only about:blank is supported at the moment.");
13891391
}
13901392
return new StringWebResponse("", url);
@@ -1423,7 +1425,7 @@ private WebResponse makeWebResponseForFileUrl(final WebRequest webRequest) throw
14231425
compiledHeaders.add(new NameValuePair(HttpHeader.CONTENT_TYPE, MimeType.TEXT_HTML));
14241426
final WebResponseData responseData =
14251427
new WebResponseData(
1426-
org.htmlunit.util.StringUtils
1428+
StringUtils
14271429
.toByteArray("File: " + file.getAbsolutePath(), UTF_8),
14281430
404, "Not Found", compiledHeaders);
14291431
return new WebResponse(responseData, webRequest, 0);
@@ -1451,13 +1453,13 @@ private WebResponse makeWebResponseForBlobUrl(final WebRequest webRequest) {
14511453

14521454
final List<NameValuePair> headers = new ArrayList<>();
14531455
final String type = fileOrBlob.getType();
1454-
if (!StringUtils.isEmpty(type)) {
1456+
if (!StringUtils.isEmptyOrNull(type)) {
14551457
headers.add(new NameValuePair(HttpHeader.CONTENT_TYPE, fileOrBlob.getType()));
14561458
}
14571459
if (fileOrBlob instanceof org.htmlunit.javascript.host.file.File) {
14581460
final org.htmlunit.javascript.host.file.File file = (org.htmlunit.javascript.host.file.File) fileOrBlob;
14591461
final String fileName = file.getName();
1460-
if (!StringUtils.isEmpty(fileName)) {
1462+
if (!StringUtils.isEmptyOrNull(fileName)) {
14611463
// https://datatracker.ietf.org/doc/html/rfc6266#autoid-10
14621464
headers.add(new NameValuePair(HttpHeader.CONTENT_DISPOSITION, "inline; filename=\"" + fileName + "\""));
14631465
}

src/main/java/org/htmlunit/WebResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
import org.apache.commons.io.ByteOrderMark;
2929
import org.apache.commons.io.IOUtils;
3030
import org.apache.commons.io.input.BOMInputStream;
31-
import org.apache.commons.lang3.StringUtils;
3231
import org.apache.commons.logging.Log;
3332
import org.apache.commons.logging.LogFactory;
3433
import org.htmlunit.http.HttpStatus;
3534
import org.htmlunit.util.EncodingSniffer;
3635
import org.htmlunit.util.MimeType;
3736
import org.htmlunit.util.NameValuePair;
37+
import org.htmlunit.util.StringUtils;
3838

3939
/**
4040
* A response from a web server.

src/main/java/org/htmlunit/html/HtmlMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
import java.util.Map;
1818

19-
import org.apache.commons.lang3.StringUtils;
2019
import org.htmlunit.SgmlPage;
20+
import org.htmlunit.util.StringUtils;
2121

2222
/**
2323
* Wrapper for the HTML element "map".

src/main/java/org/htmlunit/html/HtmlNumberInput.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ protected void doType(final char c, final boolean lastType) {
9696
public String getValue() {
9797
final String raw = getRawValue();
9898

99-
if (StringUtils.isBlank(raw)) {
99+
if (org.htmlunit.util.StringUtils.isBlank(raw)) {
100100
return "";
101101
}
102102

@@ -133,7 +133,7 @@ public boolean isValid() {
133133
}
134134

135135
String rawValue = getRawValue();
136-
if (StringUtils.isBlank(rawValue)) {
136+
if (org.htmlunit.util.StringUtils.isBlank(rawValue)) {
137137
return true;
138138
}
139139

src/main/java/org/htmlunit/html/HtmlObject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
import java.util.Map;
1818

19-
import org.apache.commons.lang3.StringUtils;
2019
import org.apache.commons.logging.Log;
2120
import org.apache.commons.logging.LogFactory;
2221
import org.htmlunit.SgmlPage;
2322
import org.htmlunit.javascript.host.html.HTMLObjectElement;
23+
import org.htmlunit.util.StringUtils;
2424
import org.htmlunit.xml.XmlPage;
2525

2626
/**
@@ -312,7 +312,7 @@ public void setCustomValidity(final String message) {
312312

313313
@Override
314314
public boolean isCustomErrorValidityState() {
315-
return !StringUtils.isEmpty(customValidity_);
315+
return !StringUtils.isEmptyOrNull(customValidity_);
316316
}
317317

318318
@Override

src/main/java/org/htmlunit/html/HtmlOutput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public boolean isValid() {
8787
*/
8888
@Override
8989
public boolean isCustomErrorValidityState() {
90-
return !StringUtils.isEmpty(customValidity_);
90+
return !org.htmlunit.util.StringUtils.isEmptyOrNull(customValidity_);
9191
}
9292

9393
@Override

src/main/java/org/htmlunit/html/HtmlPage.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ JavaScriptLoadResult loadExternalJavaScriptFile(final String srcAttribute, final
979979
throws FailingHttpStatusCodeException {
980980

981981
final WebClient client = getWebClient();
982-
if (StringUtils.isBlank(srcAttribute) || !client.isJavaScriptEnabled()) {
982+
if (org.htmlunit.util.StringUtils.isBlank(srcAttribute) || !client.isJavaScriptEnabled()) {
983983
return JavaScriptLoadResult.NOOP;
984984
}
985985

@@ -1396,7 +1396,7 @@ private void executeRefreshIfNeeded() throws IOException {
13961396
}
13971397
}
13981398

1399-
if (StringUtils.isBlank(urlPart)) {
1399+
if (org.htmlunit.util.StringUtils.isBlank(urlPart)) {
14001400
//content='10; URL=' is treated as content='10'
14011401
url = getUrl();
14021402
}
@@ -2346,7 +2346,7 @@ else if (baseUrl_ != null) {
23462346
}
23472347
else {
23482348
final String href = base_.getHrefAttribute().trim();
2349-
if (StringUtils.isEmpty(href)) {
2349+
if (org.htmlunit.util.StringUtils.isEmptyOrNull(href)) {
23502350
baseUrl = getUrl();
23512351
}
23522352
else {

src/main/java/org/htmlunit/html/HtmlSelect.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
import java.util.List;
2424
import java.util.Map;
2525

26-
import org.apache.commons.lang3.StringUtils;
2726
import org.htmlunit.ElementNotFoundException;
2827
import org.htmlunit.Page;
2928
import org.htmlunit.SgmlPage;
3029
import org.htmlunit.WebAssert;
3130
import org.htmlunit.javascript.host.event.Event;
3231
import org.htmlunit.javascript.host.event.MouseEvent;
3332
import org.htmlunit.util.NameValuePair;
33+
import org.htmlunit.util.StringUtils;
3434
import org.w3c.dom.Node;
3535

3636
/**
@@ -660,7 +660,7 @@ public final String getOnChangeAttribute() {
660660
@Override
661661
protected void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue,
662662
final boolean notifyAttributeChangeListeners, final boolean notifyMutationObservers) {
663-
final String qualifiedNameLC = org.htmlunit.util.StringUtils.toRootLowerCase(qualifiedName);
663+
final String qualifiedNameLC = StringUtils.toRootLowerCase(qualifiedName);
664664
if (DomElement.NAME_ATTRIBUTE.equals(qualifiedNameLC)) {
665665
if (newNames_.isEmpty()) {
666666
newNames_ = new HashSet<>();
@@ -800,7 +800,7 @@ public boolean isValid() {
800800
*/
801801
@Override
802802
public boolean isCustomErrorValidityState() {
803-
return !StringUtils.isEmpty(customValidity_);
803+
return !StringUtils.isEmptyOrNull(customValidity_);
804804
}
805805

806806
@Override

src/main/java/org/htmlunit/html/HtmlTextArea.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
import java.util.HashSet;
2121
import java.util.Map;
2222

23-
import org.apache.commons.lang3.StringUtils;
2423
import org.htmlunit.SgmlPage;
2524
import org.htmlunit.html.impl.SelectableTextInput;
2625
import org.htmlunit.html.impl.SelectableTextSelectionDelegate;
2726
import org.htmlunit.javascript.host.event.Event;
2827
import org.htmlunit.javascript.host.event.MouseEvent;
2928
import org.htmlunit.util.NameValuePair;
29+
import org.htmlunit.util.StringUtils;
3030
import org.w3c.dom.Node;
3131

3232
/**
@@ -432,7 +432,7 @@ protected boolean printXml(final String indent, final boolean tagBefore, final P
432432
printOpeningTagContentAsXml(printWriter);
433433

434434
printWriter.print(">");
435-
printWriter.print(org.htmlunit.util.StringUtils.escapeXml(getText()));
435+
printWriter.print(StringUtils.escapeXml(getText()));
436436
printWriter.print("</textarea>");
437437
return true;
438438
}
@@ -518,7 +518,7 @@ public boolean isReadOnly() {
518518
@Override
519519
protected void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue,
520520
final boolean notifyAttributeChangeListeners, final boolean notifyMutationObservers) {
521-
final String qualifiedNameLC = org.htmlunit.util.StringUtils.toRootLowerCase(qualifiedName);
521+
final String qualifiedNameLC = StringUtils.toRootLowerCase(qualifiedName);
522522
if (DomElement.NAME_ATTRIBUTE.equals(qualifiedNameLC)) {
523523
if (newNames_.isEmpty()) {
524524
newNames_ = new HashSet<>();
@@ -630,7 +630,7 @@ public boolean isValid() {
630630
*/
631631
@Override
632632
public boolean isCustomErrorValidityState() {
633-
return !StringUtils.isEmpty(customValidity_);
633+
return !StringUtils.isEmptyOrNull(customValidity_);
634634
}
635635

636636
@Override

src/main/java/org/htmlunit/html/HtmlTimeInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
import java.util.Locale;
2424
import java.util.Map;
2525

26-
import org.apache.commons.lang3.StringUtils;
2726
import org.htmlunit.BrowserVersion;
2827
import org.htmlunit.SgmlPage;
28+
import org.htmlunit.util.StringUtils;
2929

3030
/**
3131
* Wrapper for the HTML element "input" where type is "time".

0 commit comments

Comments
 (0)