Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2b68c66

Browse files
Claudenwslachiewicz
authored andcommitted
updated documentation
1 parent 299af7a commit 2b68c66

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

src/main/java/org/codehaus/plexus/util/MatchPattern.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private MatchPattern(String source, String separator) {
5959
}
6060

6161
/**
62-
* Gets the source pattern for this matchpattern.
62+
* Gets the source pattern for this match pattern.
6363
* @return the source string without Ant or Regex pattern markers.
6464
*/
6565
public String getSource() {

src/main/java/org/codehaus/plexus/util/SelectorUtils.java

+19-12
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public static boolean matchPatternStart(String pattern, String str, boolean isCa
139139
}
140140
}
141141

142-
static boolean isAntPrefixedPattern(String pattern) {
142+
public static boolean isAntPrefixedPattern(String pattern) {
143143
return pattern.length() > (ANT_HANDLER_PREFIX.length() + PATTERN_HANDLER_SUFFIX.length() + 1)
144144
&& pattern.startsWith(ANT_HANDLER_PREFIX)
145145
&& pattern.endsWith(PATTERN_HANDLER_SUFFIX);
@@ -243,17 +243,6 @@ public static boolean matchPath(String pattern, String str, String separator, bo
243243
}
244244
}
245245

246-
public static String extractPattern(final String pattern, final String separator) {
247-
if (isRegexPrefixedPattern(pattern)) {
248-
return pattern.substring(REGEX_HANDLER_PREFIX.length(), pattern.length() - PATTERN_HANDLER_SUFFIX.length());
249-
} else {
250-
String localPattern = isAntPrefixedPattern(pattern)
251-
? pattern.substring(ANT_HANDLER_PREFIX.length(), pattern.length() - PATTERN_HANDLER_SUFFIX.length())
252-
: pattern;
253-
return toOSRelatedPath(localPattern, separator);
254-
}
255-
}
256-
257246
private static String toOSRelatedPath(String pattern, String separator) {
258247
if ("/".equals(separator)) {
259248
return pattern.replace("\\", separator);
@@ -719,4 +708,22 @@ public static String removeWhitespace(String input) {
719708
}
720709
return result.toString();
721710
}
711+
712+
/**
713+
* Extract the pattern without the Regex or Ant prefix. In the case of Ant style matches ensure
714+
* that the path uses specified separator.
715+
* @param pattern the pattern to extract from.
716+
* @param separator the system file name separator in the pattern.
717+
* @return The pattern without the Regex or Ant prefix.
718+
*/
719+
public static String extractPattern(final String pattern, final String separator) {
720+
if (isRegexPrefixedPattern(pattern)) {
721+
return pattern.substring(REGEX_HANDLER_PREFIX.length(), pattern.length() - PATTERN_HANDLER_SUFFIX.length());
722+
} else {
723+
String localPattern = isAntPrefixedPattern(pattern)
724+
? pattern.substring(ANT_HANDLER_PREFIX.length(), pattern.length() - PATTERN_HANDLER_SUFFIX.length())
725+
: pattern;
726+
return toOSRelatedPath(localPattern, separator);
727+
}
728+
}
722729
}

0 commit comments

Comments
 (0)