/**
 * 
 */
package gr.uoa.di.webui.search;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

/**
 * Simple utility class for common text operations.
 * 
 * TODO: Move class to proper package/module.
 * 
 * @author Vassilis Stoumpos stoumpos@di.uoa.gr
 */
public class TextUtils {

	/**
	 * A field name is valid if it contains no special characters and
	 * can be url-encoded without any modification.
	 * 
	 * @param name	The name to test.
	 * @return	Return <code>true</code> if <code>name</code> is valid,
	 * 			otherwise return <code>false</code>.
	 */
	static boolean isValidFieldName(String name) {
		try {
			String encode = URLEncoder.encode(name.trim(), "UTF-8");
			return encode.equals(name);
		
		} catch (UnsupportedEncodingException e) {
			return false;
		}
	}
}
