package org.seasar.jsf.processor;

import java.util.Iterator;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.Tag;

import org.seasar.jsf.JsfConfig;
import org.seasar.jsf.JsfContext;
import org.seasar.jsf.TagPool;
import org.seasar.jsf.TagProcessor;
import org.seasar.jsf.taglib.TextTag;
import org.xml.sax.Attributes;

/**
 * @author higa
 *  
 */
public class TextProcessor implements TagProcessor {

	private String value;

	public TextProcessor() {
	}

	public TextProcessor(String value) {
		this.value = value;
	}
	
	public void setProperties(Tag tag, JsfContext jsfContext) {
		TextTag textTag = (TextTag) tag;
		textTag.setValue(value);
	}
	
	public Iterator getPropertyKeys() {
		return null;
	}

	public String getProperty(String name) {
		return null;
	}

	public void setProperty(String name, String value) {
	}
	
	public void setup(String namespaceURI, String localName,
			String qName, Attributes attributes, JsfConfig jsfConfig) {
	}

	public int getChildCount() {
		return 0;
	}

	public TagProcessor getChild(int index) {
		return null;
	}

	public void addChild(TagProcessor child) {
	}

	public TagProcessor getParent() {
		return null;
	}

	public void setParent(TagProcessor parent) {
	}

	public void process(JsfContext jsfContext, Tag parentTag)
			throws JspException {

		TagPool tagPool = jsfContext.getTagPool();
		Tag tag = tagPool.request(TextTag.class);
		try {
			tag.setPageContext(jsfContext.getPageContext());
			setProperties(tag, jsfContext);
			tag.doStartTag();
			tag.doEndTag();
		} finally {
			tag.release();
			tagPool.release(tag);
		}

	}

	public TagProcessor findAncestor(Class clazz) {
		return null;
	}
}