test_class.file: server-core/src/test/java/io/onedev/server/util/match/WildcardUtilsTest.java
test_class.identifier: WildcardUtilsTest
test_case.body: @Test
  	public void shouldApplyPattern() {
  		assertEquals("he*?lo:1-5", applyPattern("E*?l", "hello", false).toString());
  		assertEquals(null, applyPattern("*he ?d", "hello world", false));
  		assertEquals("*he*ld 2:0-6", applyPattern("*hE*ld", "hello world 2", false).toString());
  		assertEquals("hello:0-0", applyPattern("", "hello", false).toString());
  		assertEquals("*:0-1", applyPattern("*", "hello", false).toString());
  		assertEquals("**:0-2", applyPattern("**", "hello", false).toString());
  	}
test_case.class_method_signature: WildcardUtilsTest.shouldApplyPattern()
test_case.full_signature: @Test public void shouldApplyPattern()
test_case.identifier: shouldApplyPattern
test_case.invocations: assertEquals toString applyPattern assertEquals applyPattern assertEquals toString applyPattern assertEquals toString applyPattern assertEquals toString applyPattern assertEquals toString applyPattern
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void shouldApplyPattern()
focal_class.declarator: PATH_MATCHER = new PathMatcher()
focal_class.modifier: private static final
focal_class.original_string: private static final Matcher PATH_MATCHER = new PathMatcher();
focal_class.type: Matcher
focal_class.var_name: PATH_MATCHER
focal_class.declarator: STRING_MATCHER = new StringMatcher()
focal_class.modifier: private static final
focal_class.original_string: private static final Matcher STRING_MATCHER = new StringMatcher();
focal_class.type: Matcher
focal_class.var_name: STRING_MATCHER
focal_class.file: server-core/src/main/java/io/onedev/server/util/match/WildcardUtils.java
focal_class.identifier: WildcardUtils
focal_class.class_method_signature: WildcardUtils.matchPath(String pattern, String path)
focal_class.full_signature: public static boolean matchPath(String pattern, String path)
focal_class.identifier: matchPath
focal_class.modifiers: public static
focal_class.parameters: (String pattern, String path)
focal_class.return: boolean
focal_class.signature: boolean matchPath(String pattern, String path)
focal_class.class_method_signature: WildcardUtils.matchString(String pattern, String str)
focal_class.full_signature: public static boolean matchString(String pattern, String str)
focal_class.identifier: matchString
focal_class.modifiers: public static
focal_class.parameters: (String pattern, String str)
focal_class.return: boolean
focal_class.signature: boolean matchString(String pattern, String str)
focal_class.class_method_signature: WildcardUtils.indexOf(String str, String substr, int index)
focal_class.full_signature: private static int indexOf(String str, String substr, int index)
focal_class.identifier: indexOf
focal_class.modifiers: private static
focal_class.parameters: (String str, String substr, int index)
focal_class.return: int
focal_class.signature: int indexOf(String str, String substr, int index)
focal_class.class_method_signature: WildcardUtils.getLiteralRanges(String pattern)
focal_class.full_signature: public static List<LinearRange> getLiteralRanges(String pattern)
focal_class.identifier: getLiteralRanges
focal_class.modifiers: public static
focal_class.parameters: (String pattern)
focal_class.return: List<LinearRange>
focal_class.signature: List<LinearRange> getLiteralRanges(String pattern)
focal_class.class_method_signature: WildcardUtils.applyPattern(String pattern, String str, boolean caseSensitive)
focal_class.full_signature: @Nullable public static PatternApplied applyPattern(String pattern, String str, boolean caseSensitive)
focal_class.identifier: applyPattern
focal_class.modifiers: @Nullable public static
focal_class.parameters: (String pattern, String str, boolean caseSensitive)
focal_class.return: PatternApplied
focal_class.signature: PatternApplied applyPattern(String pattern, String str, boolean caseSensitive)
focal_class.class_method_signature: WildcardUtils.rangeOfMatch(String pattern, String str)
focal_class.full_signature: @Nullable public static LinearRange rangeOfMatch(String pattern, String str)
focal_class.identifier: rangeOfMatch
focal_class.modifiers: @Nullable public static
focal_class.parameters: (String pattern, String str)
focal_class.return: LinearRange
focal_class.signature: LinearRange rangeOfMatch(String pattern, String str)
focal_method.body: @Nullable
      public static PatternApplied applyPattern(String pattern, String str, boolean caseSensitive) {
  		String normalizedText;
  		String normalizedPattern;
  		if (caseSensitive) {
  			normalizedText = str;
  			normalizedPattern = pattern;
  		} else {
  			normalizedText = str.toLowerCase();
  			normalizedPattern = pattern.toLowerCase();
  		}
  		List<LinearRange> literalRanges = getLiteralRanges(normalizedPattern);
  
  		StringBuilder appliedText = new StringBuilder(pattern);
  		int first = -1;
  		int last = 0;
  		int pos = 0;
  		for (LinearRange literalRange: literalRanges) {
  			String literal = normalizedPattern.substring(literalRange.getFrom(), literalRange.getTo());
  			int index = indexOf(normalizedText, literal, pos);
  			if (index != -1) {
  				if (first == -1)
  					first = index;
  				pos = index+literal.length();
  				last = pos;
  
  				String temp = appliedText.toString();
  				appliedText = new StringBuilder(appliedText.substring(0, literalRange.getFrom()));
  				for (int i=0; i<literal.length(); i++) {
  					if (literal.charAt(i) == '?')
  						appliedText.append('?');
  					else
  						appliedText.append(str.charAt(index+i));
  				}
  				appliedText.append(temp.substring(literalRange.getTo()));				
  			} else {
  				return null;
  			}
  		}
  		if (first != -1 && pattern.charAt(0) != '*')
  			appliedText = new StringBuilder(str.substring(0, first) + appliedText.toString());
  		else 
  			first = 0;
  		if (pattern.length() == 0 || pattern.charAt(pattern.length()-1) != '*') {
  			String suffix = str.substring(last);
  			last = appliedText.length();
  			appliedText.append(suffix);
  		} else {
  			last = appliedText.length();
  		}
  		return new PatternApplied(appliedText.toString(), new LinearRange(first, last));
      }
focal_method.class_method_signature: WildcardUtils.applyPattern(String pattern, String str, boolean caseSensitive)
focal_method.full_signature: @Nullable public static PatternApplied applyPattern(String pattern, String str, boolean caseSensitive)
focal_method.identifier: applyPattern
focal_method.invocations: toLowerCase toLowerCase getLiteralRanges substring getFrom getTo indexOf length toString substring getFrom length charAt append append charAt append substring getTo charAt substring toString length charAt length substring length append length toString
focal_method.modifiers: @Nullable public static
focal_method.parameters: (String pattern, String str, boolean caseSensitive)
focal_method.return: PatternApplied
focal_method.signature: PatternApplied applyPattern(String pattern, String str, boolean caseSensitive)