Skip to content

Commit

Permalink
updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudenw authored and slachiewicz committed Nov 5, 2024
1 parent 299af7a commit 2b68c66
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/codehaus/plexus/util/MatchPattern.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private MatchPattern(String source, String separator) {
}

/**
* Gets the source pattern for this matchpattern.
* Gets the source pattern for this match pattern.
* @return the source string without Ant or Regex pattern markers.
*/
public String getSource() {
Expand Down
31 changes: 19 additions & 12 deletions src/main/java/org/codehaus/plexus/util/SelectorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public static boolean matchPatternStart(String pattern, String str, boolean isCa
}
}

static boolean isAntPrefixedPattern(String pattern) {
public static boolean isAntPrefixedPattern(String pattern) {
return pattern.length() > (ANT_HANDLER_PREFIX.length() + PATTERN_HANDLER_SUFFIX.length() + 1)
&& pattern.startsWith(ANT_HANDLER_PREFIX)
&& pattern.endsWith(PATTERN_HANDLER_SUFFIX);
Expand Down Expand Up @@ -243,17 +243,6 @@ public static boolean matchPath(String pattern, String str, String separator, bo
}
}

public static String extractPattern(final String pattern, final String separator) {
if (isRegexPrefixedPattern(pattern)) {
return pattern.substring(REGEX_HANDLER_PREFIX.length(), pattern.length() - PATTERN_HANDLER_SUFFIX.length());
} else {
String localPattern = isAntPrefixedPattern(pattern)
? pattern.substring(ANT_HANDLER_PREFIX.length(), pattern.length() - PATTERN_HANDLER_SUFFIX.length())
: pattern;
return toOSRelatedPath(localPattern, separator);
}
}

private static String toOSRelatedPath(String pattern, String separator) {
if ("/".equals(separator)) {
return pattern.replace("\\", separator);
Expand Down Expand Up @@ -719,4 +708,22 @@ public static String removeWhitespace(String input) {
}
return result.toString();
}

/**
* Extract the pattern without the Regex or Ant prefix. In the case of Ant style matches ensure
* that the path uses specified separator.
* @param pattern the pattern to extract from.
* @param separator the system file name separator in the pattern.
* @return The pattern without the Regex or Ant prefix.
*/
public static String extractPattern(final String pattern, final String separator) {
if (isRegexPrefixedPattern(pattern)) {
return pattern.substring(REGEX_HANDLER_PREFIX.length(), pattern.length() - PATTERN_HANDLER_SUFFIX.length());
} else {
String localPattern = isAntPrefixedPattern(pattern)
? pattern.substring(ANT_HANDLER_PREFIX.length(), pattern.length() - PATTERN_HANDLER_SUFFIX.length())
: pattern;
return toOSRelatedPath(localPattern, separator);
}
}
}

0 comments on commit 2b68c66

Please sign in to comment.