3838import java .util .regex .Pattern ;
3939
4040import org .apache .commons .io .IOUtils ;
41- import org .apache .commons .lang3 .StringUtils ;
4241import org .apache .commons .lang3 .math .NumberUtils ;
4342import org .apache .commons .logging .Log ;
4443import org .apache .commons .logging .LogFactory ;
101100import org .htmlunit .javascript .host .css .MediaList ;
102101import org .htmlunit .javascript .host .dom .Document ;
103102import org .htmlunit .util .MimeType ;
103+ import org .htmlunit .util .StringUtils ;
104104import org .htmlunit .util .UrlUtils ;
105105
106106/**
@@ -352,7 +352,7 @@ public static CssStyleSheet loadStylesheet(final HtmlElement element, final Html
352352
353353 final CssStyleSheet sheet ;
354354 final String contentType = response .getContentType ();
355- if (StringUtils .isEmpty (contentType ) || MimeType .TEXT_CSS .equals (contentType )) {
355+ if (StringUtils .isEmptyOrNull (contentType ) || MimeType .TEXT_CSS .equals (contentType )) {
356356 try (InputStream in = response .getContentAsStreamWithBomIfApplicable ()) {
357357 if (in == null ) {
358358 if (LOG .isWarnEnabled ()) {
@@ -562,33 +562,33 @@ static boolean selects(final BrowserVersion browserVersion,
562562 final AttributeCondition prefixAttributeCondition = (AttributeCondition ) condition ;
563563 final String prefixValue = prefixAttributeCondition .getValue ();
564564 if (prefixAttributeCondition .isCaseInSensitive ()) {
565- return !org . htmlunit . util . StringUtils .isEmptyString (prefixValue )
566- && org . htmlunit . util . StringUtils .startsWithIgnoreCase (
565+ return !StringUtils .isEmptyString (prefixValue )
566+ && StringUtils .startsWithIgnoreCase (
567567 element .getAttribute (prefixAttributeCondition .getLocalName ()), prefixValue );
568568 }
569- return !org . htmlunit . util . StringUtils .isEmptyString (prefixValue )
569+ return !StringUtils .isEmptyString (prefixValue )
570570 && element .getAttribute (prefixAttributeCondition .getLocalName ()).startsWith (prefixValue );
571571
572572 case SUFFIX_ATTRIBUTE_CONDITION :
573573 final AttributeCondition suffixAttributeCondition = (AttributeCondition ) condition ;
574574 final String suffixValue = suffixAttributeCondition .getValue ();
575575 if (suffixAttributeCondition .isCaseInSensitive ()) {
576- return !org . htmlunit . util . StringUtils .isEmptyString (suffixValue )
577- && org . htmlunit . util . StringUtils .endsWithIgnoreCase (
576+ return !StringUtils .isEmptyString (suffixValue )
577+ && StringUtils .endsWithIgnoreCase (
578578 element .getAttribute (suffixAttributeCondition .getLocalName ()), suffixValue );
579579 }
580- return !org . htmlunit . util . StringUtils .isEmptyString (suffixValue )
580+ return !StringUtils .isEmptyString (suffixValue )
581581 && element .getAttribute (suffixAttributeCondition .getLocalName ()).endsWith (suffixValue );
582582
583583 case SUBSTRING_ATTRIBUTE_CONDITION :
584584 final AttributeCondition substringAttributeCondition = (AttributeCondition ) condition ;
585585 final String substringValue = substringAttributeCondition .getValue ();
586586 if (substringAttributeCondition .isCaseInSensitive ()) {
587- return !org . htmlunit . util . StringUtils .isEmptyString (substringValue )
588- && org . htmlunit . util . StringUtils .containsIgnoreCase (
587+ return !StringUtils .isEmptyString (substringValue )
588+ && StringUtils .containsIgnoreCase (
589589 element .getAttribute (substringAttributeCondition .getLocalName ()), substringValue );
590590 }
591- return !org . htmlunit . util . StringUtils .isEmptyString (substringValue )
591+ return !StringUtils .isEmptyString (substringValue )
592592 && element .getAttribute (substringAttributeCondition .getLocalName ()).contains (substringValue );
593593
594594 case BEGIN_HYPHEN_ATTRIBUTE_CONDITION :
@@ -597,8 +597,8 @@ static boolean selects(final BrowserVersion browserVersion,
597597 final String a = element .getAttribute (beginHyphenAttributeCondition .getLocalName ());
598598 if (beginHyphenAttributeCondition .isCaseInSensitive ()) {
599599 return selectsHyphenSeparated (
600- org . htmlunit . util . StringUtils .toRootLowerCase (v ),
601- org . htmlunit . util . StringUtils .toRootLowerCase (a ));
600+ StringUtils .toRootLowerCase (v ),
601+ StringUtils .toRootLowerCase (a ));
602602 }
603603 return selectsHyphenSeparated (v , a );
604604
@@ -608,8 +608,8 @@ static boolean selects(final BrowserVersion browserVersion,
608608 final String a2 = element .getAttribute (oneOfAttributeCondition .getLocalName ());
609609 if (oneOfAttributeCondition .isCaseInSensitive ()) {
610610 return selectsOneOf (
611- org . htmlunit . util . StringUtils .toRootLowerCase (v2 ),
612- org . htmlunit . util . StringUtils .toRootLowerCase (a2 ));
611+ StringUtils .toRootLowerCase (v2 ),
612+ StringUtils .toRootLowerCase (a2 ));
613613 }
614614 return selectsOneOf (v2 , a2 );
615615
@@ -865,8 +865,8 @@ private static boolean selectsPseudoClass(final BrowserVersion browserVersion,
865865
866866 case "placeholder-shown" :
867867 return element instanceof HtmlInput
868- && StringUtils .isEmpty (((HtmlInput ) element ).getValue ())
869- && StringUtils .isNotEmpty (((HtmlInput ) element ).getPlaceholder ());
868+ && StringUtils .isEmptyOrNull (((HtmlInput ) element ).getValue ())
869+ && ! StringUtils .isEmptyOrNull (((HtmlInput ) element ).getPlaceholder ());
870870
871871 default :
872872 if (value .startsWith ("nth-child(" )) {
@@ -938,7 +938,7 @@ private static boolean getNthElement(final String nth, final int index) {
938938 int denominator = 0 ;
939939 if (nIndex != -1 ) {
940940 String value = nth .substring (0 , nIndex ).trim ();
941- if (org . htmlunit . util . StringUtils .equalsChar ('-' , value )) {
941+ if (StringUtils .equalsChar ('-' , value )) {
942942 denominator = -1 ;
943943 }
944944 else {
@@ -1135,7 +1135,8 @@ private static boolean isValidCondition(final Condition condition, final DomNode
11351135 }
11361136
11371137 if ("nth-child()" .equals (value )) {
1138- final String arg = StringUtils .substringBetween (condition .getValue (), "(" , ")" ).trim ();
1138+ final String arg = org .apache .commons .lang3 .StringUtils
1139+ .substringBetween (condition .getValue (), "(" , ")" ).trim ();
11391140 return "even" .equalsIgnoreCase (arg ) || "odd" .equalsIgnoreCase (arg )
11401141 || NTH_NUMERIC .matcher (arg ).matches ()
11411142 || NTH_COMPLEX .matcher (arg ).matches ();
@@ -1546,7 +1547,7 @@ private List<CSSStyleSheetImpl.SelectorEntry> selects(
15461547
15471548 if (isActive (index .getMediaList (), element .getPage ().getEnclosingWindow ())) {
15481549 final String elementName = element .getLowercaseName ();
1549- final String [] classes = org . htmlunit . util . StringUtils .splitAtJavaWhitespace (
1550+ final String [] classes = StringUtils .splitAtJavaWhitespace (
15501551 element .getAttributeDirect ("class" ));
15511552 final Iterator <CSSStyleSheetImpl .SelectorEntry > iter =
15521553 index .getSelectorEntriesIteratorFor (elementName , classes );
0 commit comments