FileDocCategorySizeDatePackage
Template.javaAPI DocExample1190Sat Apr 23 22:35:36 BST 2005None

Template

public class Template extends Object

Fields Summary
Properties
values
Pattern
templateComment
Constructors Summary
Methods Summary
public java.lang.StringfillIn(java.lang.String text)

		Matcher matcher = templateComment.matcher( text );

		StringBuffer buffer = new StringBuffer();
		while( matcher.find() ) {
			String name = matcher.group(1);
			String value = values.getProperty( name );
			matcher.appendReplacement( buffer, value );
		}
		matcher.appendTail( buffer );
		return buffer.toString();
	
public static voidmain(java.lang.String[] args)

		String templateText = 
			"<html><head>\n"+
			"<body>\n"+
			"This is some text.\n"+
			"<!-- TEMPLATE:foo  -->\n"+
			"Some more text.\n"+
			"\n"+
			"<!--template:bar This is text -->\n"+
			"More text.\n"+
			"<!-- TEMPLATE:bar \n"+
			"-->\n"+
			"</body></html>\n";
			
		Template template = new Template();
		template.set( "foo", "FooTemplate");
		template.set( "bar", "BarTemplate");
		System.out.println( templateText );
		System.out.println( template.fillIn(templateText) );
	
public voidset(java.lang.String name, java.lang.String value)


	      	 
		values.setProperty( name, value );