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

net.anotheria.portalkit.engines.mailhunter.Transformation Maven / Gradle / Ivy

There is a newer version: 4.1.0
Show newest version
package net.anotheria.portalkit.engines.mailhunter;

import net.anotheria.portalkit.engines.mailhunter.transformer.LocalizedTransformer;

import java.util.ArrayList;
import java.util.List;


public class Transformation {

	private ArrayList transformers;

	private String locale;
	
	public Transformation(){
		transformers = new ArrayList();
	}
	
	public Transformation(Transformer aTransformer){
		this();
		addTransformer(aTransformer);
	}
	
	public Transformation(List someTransformers){
		this();
		transformers.addAll(someTransformers);
	}

	public String transform(String s) {
		return transform(s, "");
	}

	public String transform(String s, String locale) {

		for (int i = 0; i < transformers.size(); i++) {

			Transformer transformer = transformers.get(i);

			if (transformer instanceof LocalizedTransformer) {
				s = transformer.transform(s, locale);
			} else {
				s = transformer.transform(s);
			}
		}

		return s;
	}
	
	public void addTransformer(Transformer t){
		transformers.add(t);
	}
	
	public String describe(){
		String ret = "";
		for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy