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

com.redijedi.tapestry.internal.GenericValueEncoder Maven / Gradle / Ivy

The newest version!
package com.redijedi.tapestry.internal;

import org.apache.tapestry.ValueEncoder;

/**
 * @author torr
 * 
 */
public class GenericValueEncoder implements ValueEncoder {

	private final Iterable _source;

	public GenericValueEncoder(Iterable source) {
		_source = source;
	}

	public String toClient(Object value) {
		return value == null ? "" : value.toString();
	}

	public Object toValue(String clientValue) {
		for (Object o : _source) {
			if (o.toString() == clientValue) {
				return o;
			}
		}
		return null;
	}

}