/**
 * License Agreement.
 *
 * Rich Faces - Natural Ajax for Java Server Faces (JSF)
 *
 * Copyright (C) 2007 Exadel, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */

package org.ajax4jsf.templatecompiler.elements.html;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.HashMap;

/**
 * @author yukhovich
 * 
 */
public class HTMLTags {
	private static final String TEMPLATES_TEMPLATECOMPILER_TAGS_BIN = "META-INF/templates/templatecompiler/tags.bin";

	private static HashMap tags;

	private static boolean b = false;

	static {

		InputStream is = HTMLTags.class.getClassLoader().getResourceAsStream(
				TEMPLATES_TEMPLATECOMPILER_TAGS_BIN);
		try {
			ObjectInputStream in = new ObjectInputStream(is);

			tags = (HashMap) in.readObject();

			in.close();

			b = true;

		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static boolean getS() {
		return b;
	}

	public static ArrayList getAttributes(String tagName) {
		if (b) {
			return (ArrayList) tags.get(tagName);
		} else {
			return null;
		}
	}

}
