package com.javahonk.action;

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

public class DataForAutoComplete {
	static StringBuilder dataCache;
	static String[] data;
	static {

		dataCache = new StringBuilder();
		dataCache
				.append("Java Honk,Java Honk Test,Java Honk Test "
						+ "Successful,Java Honk Spring MVC,"
						+ "Java Honk autocomplete,Java Honk "
						+ "Spring MVC autocomplete List");

		data = dataCache.toString().split(",");
	}

	public static List<String> getName(String name) {

		List<String> returnMatchName = new ArrayList<String>();
		String[] data = dataCache.toString().split(",");
		for (String string : data) {
			if (string.toUpperCase().indexOf(name.toUpperCase()) != -1) {
				returnMatchName.add(string);
			}
		}

		return returnMatchName;
	}
}
