alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Friki example source code file (b.txt)

This example Friki source code file (b.txt) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Friki tags/keywords

matcher, pattern, pattern, resultgenerator, resultgenerator, resultgeneratorsubstitution, resultgeneratorsubstitution, string, string

The Friki b.txt source code

package org.stringtree.regex;

class ResultGeneratorSubstitution
	implements jregex.Substitution
{
	private ResultGenerator gen;

	public ResultGeneratorSubstitution(ResultGenerator gen)
	{
		this.gen = gen;
	}

	public void appendSubstitution(jregex.MatchResult match, jregex.TextBuffer tb)
	{
		tb.append(gen.result(new Matcher((jregex.Matcher)match)));
    }
 }

public class Pattern
{
	public static String processor="jregex";
	protected jregex.Pattern pattern;

	public Pattern(jregex.Pattern pattern)
	{
		this.pattern = pattern;
	}

	public static Pattern compile(String text)
	{
		return new Pattern(new jregex.Pattern(text, jregex.REFlags.MULTILINE));
	}

	public Matcher matcher(String text)
	{
		return new Matcher(pattern.matcher(text));
	}

	public String replaceAll(String input, ResultGenerator generator)
	{
		jregex.Replacer replacer = new jregex.Replacer(pattern,
			new ResultGeneratorSubstitution(generator));
		return replacer.replace(input);
	}

	public String replaceAll(String input, String value)
	{
		jregex.Replacer replacer = pattern.replacer(value);
		return replacer.replace(input);
	}

	public String[] split(String input)
	{
		jregex.RETokenizer tok = pattern.tokenizer(input);
		tok.setEmptyEnabled(true);
		return tok.split();
	}
}

Other Friki examples (source code examples)

Here is a short list of links related to this Friki b.txt source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.