Java 8 MatchResult - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 MatchResult class.

This code example shows how to use the following methods:group, groupCount
 
        // in a strict sense the assertion here is superfluous since the enclosing  
        // context in the caller already does a check if the group count is 4 and  
        // the execution branch in which this method is called will not be run if 
        // it isn't 4. 
        Assert.isLegal(4 == matchResult.groupCount(),
                "E: Match result from FMTSTR_PATTERN is malformed. Group count must be 4."); 
 
        final Map<String, String> result = new HashMap<String, String>(4);
 
        final String fmtString = matchResult.group(1);
        final String strChar = matchResult.group(2);
        final String interpToken = matchResult.group(3);
        final String interpValues = matchResult.group(4);
 
        result.put("FormatString", fmtString);
        result.put("StringCharacter", strChar);
        result.put("InterpolantToken", interpToken);
        result.put("InterpolationValues", interpValues);
 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:start
        GroupIndexMatchResult(MatchResult r) {
            this.r = r;
        } 
 
        public int start() { 
            return r.start();
        } 
 
        public int start(int group) {
            if (group > groupCount())
                throw new IndexOutOfBoundsException();
 
            return (group > 0) ? r.start(groupIndexes[group - 1]) : r.start();
        } 
 
        public int end() { 
            return r.end();
        } 
 
        public int end(int group) {
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:group
        return super.enhanceMetadata(document, metadata);
    } 
     
    @Override 
    protected boolean enhanceMetadata(MatchResult result, DocumentMetadata metadata) {
        int first = Integer.parseInt(result.group(3));
        int last = Integer.parseInt(result.group(4));
        if (first <= last && last - first < pages * 2) {
            metadata.setJournal(result.group(1).trim()
                .replaceAll("Published as: ", "").replaceAll(",$", ""));
            metadata.setVolume(result.group(2));
            metadata.setPages(result.group(3), result.group(4));
            return true; 
        } 
         
        return false; 
    } 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:end, start
        String subsPath = resultSubs.substitute(uri);
 
        if (!isFullURL(subsPath)) {
            MatchResult ruleMatchResult = resultSubs.getMatch();
 
            subsPath = path.substring(0, ruleMatchResult.start()) // before match
                       + subsPath // match
                       + path.substring(ruleMatchResult.end()); // after match
        } 
 
        if (log.isDebugEnabled()) { 
            log.debug("Rewriting \"{}\" to \"{}\"", StringEscapeUtil.escapeJava(path),
                      StringEscapeUtil.escapeJava(subsPath));
        } 
 
        return subsPath;
    } 
 
    public boolean substituteParameters(ParameterParser params, MatchResultSubstitution resultSubs) {
        boolean parameterSubstituted = false;
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:group
        return EnumSet.of(EnhancedField.JOURNAL);
    } 
 
    @Override 
    protected boolean enhanceMetadata(MatchResult result, DocumentMetadata metadata) {
        metadata.setJournal(result.group(1).trim()
                .replaceAll("Published as: ", "").replaceAll(",$", ""));
        metadata.setVolume(result.group(2));
        metadata.setIssue(result.group(3));
        
        return true; 
    } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:group
        return EnumSet.of(EnhancedField.JOURNAL, EnhancedField.VOLUME, EnhancedField.ISSUE);
    } 
 
    @Override 
    protected boolean enhanceMetadata(MatchResult result, DocumentMetadata metadata) {
        metadata.setJournal(result.group(1).trim()
                .replaceAll("Published as: ", "").replaceAll(",$", ""));
        metadata.setVolume(result.group(2));
        metadata.setIssue(result.group(3));
        
        return true; 
    } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:group, groupCount
		return "filter.emailto"; 
	} 
 
	@Override 
	public void replace(StringBuffer buffer, MatchResult matchResult, RenderContext context) {
		int count = matchResult.groupCount();
		if(count != 2){
			buffer.append(matchResult.group(0));
			return; 
		} 
		 
		String front = matchResult.group(1);
		String link = matchResult.group(2);
		 
		buffer.append(formatter.format(new Object[]{front,link, RenderUtil.getExternalEmailImage(context)}));
		 
	} 
	@Override 
	protected void replaceHTML(HTMLNode node, ListIterator<HTMLNode> nodeIter, RenderContext context) {
		node.reset("mailto:", true);
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:group, groupCount
		if(node.getPair() != null)
			node.getPair().reset("", true);
	} 
	@Override 
	public void replace(StringBuffer buffer, MatchResult matchResult, RenderContext context) {
		int count = matchResult.groupCount();
		if(count != 2){
			buffer.append(matchResult.group(0));
			return; 
		} 
		 
		String front = matchResult.group(1);
		String link = matchResult.group(2);
		String end = "";
		Matcher m = END_PATTERN.matcher(StringUtils.reverse(link));
		if(m.lookingAt()){
			end = StringUtils.reverse(m.group(1));
			link = link.substring(0, link.length() - end.length());
		} 
		 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:end, start
  // Use to order match results by: 
  //    length (longest first), 
  public final static Comparator<MatchResult> LENGTH_COMPARATOR =
    new Comparator<MatchResult>() { 
      public int compare(MatchResult e1, MatchResult e2) { 
        int len1 = e1.end() - e1.start(); 
        int len2 = e2.end() - e2.start(); 
        if (len1 == len2) { 
          return 0; 
        } else { 
          return (len1 > len2)? -1:1; 
        } 
      } 
    }; 
 
  public final static Comparator<MatchResult> OFFSET_COMPARATOR =
    new Comparator<MatchResult>() { 
      public int compare(MatchResult e1, MatchResult e2) { 
        if (e1.start() == e2.start()) { 
          if (e1.end() == e2.end()) { 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:group
  public Pattern getPattern() {
    return stackpattern;
  } 
 
  public Object getResult(String str, MatchResult m) {
    String pckg = m.group(1);
    pckg = pckg.substring(0, pckg.lastIndexOf(".",pckg.lastIndexOf(".")-1)+1);
    pckg = pckg.replace('.', File.separatorChar);
 
    String file = m.group(2);
 
    String sourcePath = HyperlinkFileCache.getSourcePath(pckg + file);
    if (sourcePath == null){
      return null; 
    }else{ 
      return new LinkDestination(sourcePath, new Integer(m.group(3)));
    } 
 
  } 
 
  public void onClick(Object result) {
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Java 8 MatchResult Questions & Answers:

See Code Examples for Java 8 MatchResult Methods: