private boolean isMatch( List<String> patterns, String name ) { for ( String pattern1 : patterns ) { if ( SelectorUtils.matchPath( pattern1, name, isCaseSensitive ) ) { return true; } } return false; }
/** * Tests whether or not a string matches against a pattern. The pattern may contain two special characters:<br> * '*' means zero or more characters<br> * '?' means one and only one character * * @param pattern The pattern to match against. Must not be <code>null</code>. * @param str The string which must be matched against the pattern. Must not be <code>null</code>. * @return <code>true</code> if the string matches against the pattern, or <code>false</code> otherwise. */ public static boolean match( String pattern, String str ) { return match( pattern, str, true ); }
/** * <p>Tests whether or not a given path matches the start of a given pattern up to the first "**".</p> * * <p>This is not a general purpose test and should only be used if you can live with false positives. For example, * <code>pattern=**\a</code> and <code>str=b</code> will yield <code>true</code>.</p> * * @param pattern The pattern to match against. Must not be <code>null</code>. * @param str The path to match, as a String. Must not be <code>null</code>. * @return whether or not a given path matches the start of a given pattern up to the first "**". */ protected static boolean matchPatternStart( String pattern, String str ) { return SelectorUtils.matchPatternStart( pattern, str ); }
static boolean matchAntPathPatternStart( String[] patDirs, String str, String separator, boolean isCaseSensitive ) { String[] strDirs = tokenizePathToString( str, separator ); int patIdxStart = 0; int patIdxEnd = patDirs.length - 1; int strIdxStart = 0; int strIdxEnd = strDirs.length - 1; // up to first '**' while ( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd ) { String patDir = patDirs[patIdxStart]; if ( patDir.equals( "**" ) ) { break; } if ( !match( patDir, strDirs[strIdxStart], isCaseSensitive ) ) { return false; } patIdxStart++; strIdxStart++; } return strIdxStart > strIdxEnd || patIdxStart <= patIdxEnd; }
if ( isDoubleStar( patDir ) ) if ( !match( patDir, strDirs[strIdxStart], isCaseSensitive ) ) if ( !isDoubleStar( patDirs[i] ) ) if ( isDoubleStar( patDir ) ) if ( !match( patDir, strDirs[strIdxEnd], isCaseSensitive ) ) if ( !isDoubleStar( patDirs[i] ) ) for ( int i = patIdxStart + 1; i <= patIdxEnd; i++ ) if ( isDoubleStar( patDirs[i] ) ) if ( !match( subPat, subStr, isCaseSensitive ) ) if ( !isDoubleStar( patDirs[i] ) )
Vector patDirs = tokenizePath( pattern ); Vector strDirs = tokenizePath( str ); if ( !match( patDir, (String) strDirs.elementAt( strIdxStart ), isCaseSensitive ) )
Vector patDirs = tokenizePath( pattern ); Vector strDirs = tokenizePath( str ); if ( !match( patDir, (String) strDirs.elementAt( strIdxStart ), isCaseSensitive ) ) if ( !match( patDir, (String) strDirs.elementAt( strIdxEnd ), isCaseSensitive ) ) if ( !match( subPat, subStr, isCaseSensitive ) )
/** * Tests whether or not a given path matches a given pattern. * * @param pattern The pattern to match against. Must not be <code>null</code>. * @param str The path to match, as a String. Must not be <code>null</code>. * @return <code>true</code> if the pattern matches against the string, or <code>false</code> otherwise. */ public static boolean matchPath( String pattern, String str ) { return matchPath( pattern, str, true ); }
/** * Tests whether or not a string matches against a pattern. The pattern may contain two special characters:<br> * '*' means zero or more characters<br> * '?' means one and only one character * * @param pattern The pattern to match against. Must not be <code>null</code>. * @param str The string which must be matched against the pattern. Must not be <code>null</code>. * @return <code>true</code> if the string matches against the pattern, or <code>false</code> otherwise. */ public static boolean match( String pattern, String str ) { return SelectorUtils.match( pattern, str ); }
/** * <p>Tests whether or not a given path matches the start of a given pattern up to the first "**".</p> * * <p>This is not a general purpose test and should only be used if you can live with false positives. For example, * <code>pattern=**\a</code> and <code>str=b</code> will yield <code>true</code>.</p> * * @param pattern The pattern to match against. Must not be <code>null</code>. * @param str The path to match, as a String. Must not be <code>null</code>. * @return whether or not a given path matches the start of a given pattern up to the first "**". */ public static boolean matchPatternStart( String pattern, String str ) { return matchPatternStart( pattern, str, true ); }
/** * Tests whether or not a given path matches a given pattern. * * @param pattern The pattern to match against. Must not be <code>null</code>. * @param str The path to match, as a String. Must not be <code>null</code>. * @param isCaseSensitive Whether or not matching should be performed case sensitively. * @return <code>true</code> if the pattern matches against the string, or <code>false</code> otherwise. */ public static boolean matchPath( String pattern, String str, boolean isCaseSensitive ) { return matchPath( pattern, str, File.separator, isCaseSensitive ); }
/** * Tests whether or not a string matches against a pattern. The pattern may contain two special characters:<br> * '*' means zero or more characters<br> * '?' means one and only one character * * @param pattern The pattern to match against. Must not be <code>null</code>. * @param str The string which must be matched against the pattern. Must not be <code>null</code>. * @param isCaseSensitive Whether or not matching should be performed case sensitively. * @return <code>true</code> if the string matches against the pattern, or <code>false</code> otherwise. */ protected static boolean match( String pattern, String str, boolean isCaseSensitive ) { return SelectorUtils.match( pattern, str, isCaseSensitive ); }
/** * <p>Tests whether or not a given path matches the start of a given pattern up to the first "**".</p> * * <p>This is not a general purpose test and should only be used if you can live with false positives. For example, * <code>pattern=**\a</code> and <code>str=b</code> will yield <code>true</code>.</p> * * @param pattern The pattern to match against. Must not be <code>null</code>. * @param str The path to match, as a String. Must not be <code>null</code>. * @param isCaseSensitive Whether or not matching should be performed case sensitively. * @return whether or not a given path matches the start of a given pattern up to the first "**". */ protected static boolean matchPatternStart( String pattern, String str, boolean isCaseSensitive ) { return SelectorUtils.matchPatternStart( pattern, str, isCaseSensitive ); }
/** * Tests whether or not a given path matches a given pattern. * * @param pattern The pattern to match against. Must not be <code>null</code>. * @param str The path to match, as a String. Must not be <code>null</code>. * @param isCaseSensitive Whether or not matching should be performed case sensitively. * @return <code>true</code> if the pattern matches against the string, or <code>false</code> otherwise. */ protected static boolean matchPath( String pattern, String str, boolean isCaseSensitive ) { return SelectorUtils.matchPath( pattern, str, isCaseSensitive ); }
/** * Tests whether or not a string matches against a pattern. The pattern may contain two special characters:<br> * '*' means zero or more characters<br> * '?' means one and only one character * * @param pattern The pattern to match against. Must not be <code>null</code>. * @param str The string which must be matched against the pattern. Must not be <code>null</code>. * @param isCaseSensitive Whether or not matching should be performed case sensitively. * @return <code>true</code> if the string matches against the pattern, or <code>false</code> otherwise. */ public static boolean match( String pattern, String str, boolean isCaseSensitive ) { char[] patArr = pattern.toCharArray(); char[] strArr = str.toCharArray(); return match( patArr, strArr, isCaseSensitive ); }
/** * Tests whether or not a given path matches the start of a given * pattern up to the first "**". * <p> * This is not a general purpose test and should only be used if you * can live with false positives. For example, <code>pattern=**\a</code> * and <code>str=b</code> will yield <code>true</code>. * * @param pattern The pattern to match against. Must not be * <code>null</code>. * @param str The path to match, as a String. Must not be * <code>null</code>. * * @return whether or not a given path matches the start of a given * pattern up to the first "**". */ protected static boolean matchPatternStart( String pattern, String str ) { return SelectorUtils.matchPatternStart( pattern, str ); }
/** * Tests whether or not a given path matches a given pattern. * * @param pattern The pattern to match against. Must not be <code>null</code>. * @param str The path to match, as a String. Must not be <code>null</code>. * @return <code>true</code> if the pattern matches against the string, or <code>false</code> otherwise. */ protected static boolean matchPath( String pattern, String str ) { return SelectorUtils.matchPath( pattern, str ); }