Skip to content

Commit 8d66f94

Browse files
Claudenwslachiewicz
authored andcommitted
changes for Rat
1 parent 2805eab commit 8d66f94

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

‎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+
publicStringgetSource(){
68+
returnsource;
69+
}
70+
6371
publicbooleanmatchPath( Stringstr, booleanisCaseSensitive )
6472
{
6573
if ( regexPattern != null )
@@ -116,7 +124,7 @@ public boolean startsWith( String string )
116124
returnsource.startsWith( string );
117125
}
118126

119-
staticString[] tokenizePathToString( Stringpath, Stringseparator )
127+
publicstaticString[] tokenizePathToString( Stringpath, Stringseparator )
120128
{
121129
List<String> ret = newArrayList<String>();
122130
StringTokenizerst = newStringTokenizer( 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+
publicList<String> getSources(){
26+
List<String> sources = newArrayList<>();
27+
for (MatchPatternpattern : patterns){
28+
sources.add(pattern.getSource());
29+
}
30+
returnsources;
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-
staticbooleanisAntPrefixedPattern( Stringpattern )
152+
publicstaticbooleanisAntPrefixedPattern( Stringpattern )
153153
{
154154
returnpattern.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
returnpattern;
282282
}
283283

284-
staticbooleanisRegexPrefixedPattern( Stringpattern )
284+
publicstaticbooleanisRegexPrefixedPattern( Stringpattern )
285285
{
286286
returnpattern.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
returnresult.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+
publicstaticStringextractPattern(finalStringpattern, finalStringseparator){
845+
if (isRegexPrefixedPattern(pattern)){
846+
returnpattern.substring(
847+
REGEX_HANDLER_PREFIX.length(), pattern.length() - PATTERN_HANDLER_SUFFIX.length());
848+
} else{
849+
StringlocalPattern = isAntPrefixedPattern(pattern)
850+
? pattern.substring(ANT_HANDLER_PREFIX.length(), pattern.length() - PATTERN_HANDLER_SUFFIX.length())
851+
: pattern;
852+
returntoOSRelatedPath(localPattern, separator);
853+
}
854+
}
837855
}

0 commit comments

Comments
(0)