All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.javanut.pronghorn.util.template.CharTemplate Maven / Gradle / Ivy

Go to download

Ring buffer based queuing utility for applications that require high performance and/or a small footprint. Well suited for embedded and stream based processing.

There is a newer version: 1.1.27
Show newest version
package com.javanut.pronghorn.util.template;

import java.io.IOException;

public class CharTemplate {

	CharTemplateData[] script;
	int count;
	
	public CharTemplate() {
		script = new CharTemplateData[8];
	}
	
	private void append(CharTemplateData fetchData) {
		
		if (count==script.length) {			
			CharTemplateData[] newScript = new CharTemplateData[script.length*2];
			System.arraycopy(script, 0, newScript, 0, script.length);
			script = newScript;
		}
		script[count++] = fetchData;
		
	}
	
	
	public CharTemplate add(final String text) {
	
		append(
					new CharTemplateData() {
						@Override
						public void fetch(Appendable target, T source) {
							
							try {
								target.append(text);
							} catch (IOException e) {
								throw new RuntimeException(e);
							}
							
						}					
					}
				);
		
		return this;
		
	}
	
    public CharTemplate add(CharTemplateData data) {		
    	append(data);    	
		return this;
	}
	
    public void render(Appendable target, T source) {
   
    	for(int i=0;i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy