Skip to content

Commit 6598099

Browse files
committed
changes for Rat
1 parent 8488ff2 commit 6598099

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ limitations under the License.
2626
</parent>
2727

2828
<artifactId>plexus-utils</artifactId>
29-
<version>3.5.1</version>
29+
<version>3.5.2-SNAPSHOT</version>
3030

3131
<name>Plexus Common Utilities</name>
3232
<description>A collection of various utility classes to ease working with strings, files, command lines, XML and

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ private MatchPattern( String source, String separator )
6060

6161
}
6262

63+
/**
64+
* Gets the source pattern for this matchpattern.
65+
* @return the source string without Ant or Regex pattern markers.
66+
*/
67+
public String getSource() {
68+
return source;
69+
}
70+
6371
public boolean matchPath( String str, boolean isCaseSensitive )
6472
{
6573
if ( regexPattern != null )
@@ -116,7 +124,7 @@ public boolean startsWith( String string )
116124
return source.startsWith( string );
117125
}
118126

119-
static String[] tokenizePathToString( String path, String separator )
127+
public static String[] tokenizePathToString( String path, String separator )
120128
{
121129
List<String> ret = new ArrayList<String>();
122130
StringTokenizer st = new StringTokenizer( path, separator );

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ private MatchPatterns( MatchPattern[] patterns )
1818
this.patterns = patterns;
1919
}
2020

21+
/**
22+
* Gets a list of enclosed MatchPattern sources.
23+
* @return A list of enclosed MatchPattern sources.
24+
*/
25+
public List<String> getSources() {
26+
List<String> sources = new ArrayList<>();
27+
for (MatchPattern pattern : patterns) {
28+
sources.add(pattern.getSource());
29+
}
30+
return sources;
31+
}
32+
33+
2134
/**
2235
* <p>Checks these MatchPatterns against a specified string.</p>
2336
*

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public static boolean matchPatternStart( String pattern, String str, boolean isC
149149
}
150150
}
151151

152-
static boolean isAntPrefixedPattern( String pattern )
152+
public static boolean isAntPrefixedPattern( String pattern )
153153
{
154154
return pattern.length() > ( ANT_HANDLER_PREFIX.length() + PATTERN_HANDLER_SUFFIX.length() + 1 )
155155
&& pattern.startsWith( ANT_HANDLER_PREFIX ) && pattern.endsWith( PATTERN_HANDLER_SUFFIX );
@@ -281,7 +281,7 @@ private static String toOSRelatedPath( String pattern, String separator )
281281
return pattern;
282282
}
283283

284-
static boolean isRegexPrefixedPattern( String pattern )
284+
public static boolean isRegexPrefixedPattern( String pattern )
285285
{
286286
return pattern.length() > ( REGEX_HANDLER_PREFIX.length() + PATTERN_HANDLER_SUFFIX.length() + 1 )
287287
&& pattern.startsWith( REGEX_HANDLER_PREFIX ) && pattern.endsWith( PATTERN_HANDLER_SUFFIX );
@@ -834,4 +834,22 @@ public static String removeWhitespace( String input )
834834
}
835835
return result.toString();
836836
}
837+
838+
/**
839+
* Extract the pattern without the Regex or Ant prefix.
840+
* @param pattern the pattern to extract from.
841+
* @param separator the file name separator in the pattern.
842+
* @return The pattern without the Regex or Ant prefix.
843+
*/
844+
public static String extractPattern(final String pattern, final String separator) {
845+
if (isRegexPrefixedPattern(pattern)) {
846+
return pattern.substring(
847+
REGEX_HANDLER_PREFIX.length(), pattern.length() - PATTERN_HANDLER_SUFFIX.length());
848+
} else {
849+
String localPattern = isAntPrefixedPattern(pattern)
850+
? pattern.substring(ANT_HANDLER_PREFIX.length(), pattern.length() - PATTERN_HANDLER_SUFFIX.length())
851+
: pattern;
852+
return toOSRelatedPath(localPattern, separator);
853+
}
854+
}
837855
}

0 commit comments

Comments
 (0)