Skip to content

Commit b1a36b1

Browse files
author
Kate Ivanova
committed
Clean up manual porting for java's Matcher
DEVSIX-4850
1 parent e93ce23 commit b1a36b1

File tree

6 files changed

+14
-65
lines changed

6 files changed

+14
-65
lines changed

kernel/src/main/java/com/itextpdf/kernel/pdf/canvas/parser/listener/RegexBasedLocationExtractionStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public Collection<IPdfTextLocation> getResultantLocations() {
8989
Integer startIndex = getStartIndex(txt.indexMap, mat.start(), txt.text);
9090
Integer endIndex = getEndIndex(txt.indexMap, mat.end() - 1);
9191
if (startIndex != null && endIndex != null && startIndex <= endIndex) {
92-
for (Rectangle r : toRectangles(parseResult.subList(startIndex, endIndex + 1))) {
92+
for (Rectangle r : toRectangles(parseResult.subList(startIndex.intValue(), endIndex.intValue() + 1))) {
9393
retval.add(new DefaultPdfTextLocation(0, r, mat.group(0)));
9494
}
9595
}

styled-xml-parser/src/main/java/com/itextpdf/styledxmlparser/jsoup/PortUtil.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ public class PortUtil {
5454
public static final String escapedSingleBracket = "''";
5555
public static final String signedNumberFormat = ",number,+#;-#";
5656

57+
/**
58+
* @deprecated use {@link Matcher#find()} instead
59+
* */
60+
@Deprecated
5761
public static boolean hasMatch(Pattern pattern, String input) {
5862
return pattern.matcher(input).find();
5963
}
@@ -70,6 +74,10 @@ public static RandomAccessFile getReadOnlyRandomAccesFile(File file)throws FileN
7074
return new RandomAccessFile(file, "r");
7175
}
7276

77+
/**
78+
* @deprecated use {@link Matcher#find()} instead
79+
* */
80+
@Deprecated
7381
public static boolean isSuccessful(Matcher m) {
7482
return m.find();
7583
}

styled-xml-parser/src/main/java/com/itextpdf/styledxmlparser/jsoup/helper/DataUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ static ByteBuffer emptyByteBuffer() {
241241
static String getCharsetFromContentType(String contentType) {
242242
if (contentType == null) return null;
243243
Matcher m = charsetPattern.matcher(contentType);
244-
if (PortUtil.isSuccessful(m)) {
244+
if (m.find()) {
245245
String charset = m.group(1).trim();
246246
charset = charset.replace("charset=", "");
247247
return validateCharset(charset);

styled-xml-parser/src/main/java/com/itextpdf/styledxmlparser/jsoup/select/Evaluator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public AttributeWithValueMatching(String key, Pattern pattern) {
302302

303303
@Override
304304
public boolean matches(Element root, Element element) {
305-
return element.hasAttr(key) && PortUtil.hasMatch(pattern, element.attr(key));
305+
return element.hasAttr(key) && pattern.matcher(element.attr(key)).find();
306306
}
307307

308308
@Override
@@ -715,7 +715,7 @@ public Matches(Pattern pattern) {
715715

716716
@Override
717717
public boolean matches(Element root, Element element) {
718-
return PortUtil.hasMatch(pattern, element.text());
718+
return pattern.matcher(element.text()).find();
719719
}
720720

721721
@Override
@@ -736,7 +736,7 @@ public MatchesOwn(Pattern pattern) {
736736

737737
@Override
738738
public boolean matches(Element root, Element element) {
739-
return PortUtil.hasMatch(pattern, element.ownText());
739+
return pattern.matcher(element.ownText()).find();
740740
}
741741

742742
@Override

svg/src/main/java/com/itextpdf/svg/renderers/impl/PathSvgNodeRenderer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ This file is part of the iText (R) project.
6464
import com.itextpdf.svg.renderers.path.impl.SmoothSCurveTo;
6565
import com.itextpdf.svg.utils.SvgCoordinateUtils;
6666
import com.itextpdf.svg.utils.SvgCssUtils;
67-
import com.itextpdf.svg.utils.SvgRegexUtils;
6867

6968
import java.util.ArrayList;
7069
import java.util.Arrays;
@@ -301,7 +300,7 @@ private static String[] concatenate(String[] first, String[] second) {
301300

302301

303302
boolean containsInvalidAttributes(String attributes) {
304-
return SvgRegexUtils.containsAtLeastOneMatch(invalidRegexPattern, attributes);
303+
return invalidRegexPattern.matcher(attributes).find();
305304
}
306305

307306
Collection<String> parsePathOperations() {

svg/src/main/java/com/itextpdf/svg/utils/SvgRegexUtils.java

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)