The following document contains the results of PMD's CPD 4.2.2.
File | Line |
---|---|
org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java | 147 |
org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java | 218 |
private boolean matches( String token, final String pattern ) { boolean matches; // support full wildcard and implied wildcard if ( "*".equals( pattern ) || pattern.length() == 0 ) { matches = true; } // support contains wildcard else if ( pattern.startsWith( "*" ) && pattern.endsWith( "*" ) ) { String contains = pattern.substring( 1, pattern.length() - 1 ); matches = ( token.indexOf( contains ) != -1 ); } // support leading wildcard else if ( pattern.startsWith( "*" ) ) { String suffix = pattern.substring( 1, pattern.length() ); matches = token.endsWith( suffix ); } // support trailing wildcard else if ( pattern.endsWith( "*" ) ) { String prefix = pattern.substring( 0, pattern.length() - 1 ); matches = token.startsWith( prefix ); } // support versions range else if ( pattern.startsWith( "[" ) || pattern.startsWith( "(" )) { matches = isVersionIncludedInRange(token, pattern); } // support exact match else { matches = token.equals( pattern ); } return matches; } private boolean isVersionIncludedInRange(final String version, final String range) { try { return VersionRange.createFromVersionSpec(range).containsVersion(new DefaultArtifactVersion(version)); } catch (InvalidVersionSpecificationException e) { return false; } } |