/*
 * Copyright (c) 2003, Morpho Project.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 3. Neither the name of the Morpho Project nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package jp.morpho.config;


/**
 * <P>
 * NodeTypes クラスは、Node データ型を識別するために使用するクラスです。
 * </P>
 * @author Kumiko Hiroi
 */
public class NodeTypes
{
//------------------------------------------------------------------------------
//フィールド
//------------------------------------------------------------------------------

	/** Node SET 型を識別します。 */
	public static final int SET				= 0x01;

	/** Node GET 型を識別します。 */
	public static final int GET				= 0x02;

	/** Node CALL 型を識別します。 */
	public static final int CALL			= 0x03;

	/** Node PUT 型を識別します。 */
	public static final int PUT		= 0x04;

	/** Node NEW 型を識別します。 */
	public static final int NEW				= 0x05;

	/** Node ARG 型を識別します。 */
	public static final int ARG	= 0x06;

	/** Node SYSTEMPROPERTY 型を識別します。 */
	public static final int SYSTEMPROPERTY	= 0x07;

	/** Node CONFIGURE 型を識別します。 */
	public static final int CONFIGURE	= 0x08;

	/** Node ADD 型を識別します。 */
	public static final int ADD	= 0x09;

	/**
	 * <P>
	 * タグの名前を返します。
	 * </P>
	 * @param tag タグ値
	 * @return タグの名前
	 */
	static public String getName(int tag)
	{
		switch (tag)
		{
			case SET:
				return "set";
			case GET:
				return "get";
			case CALL:
				return "call";
			case PUT:
				return "put";
			case NEW:
				return "new";
			case ARG:
				return "arg";
			case SYSTEMPROPERTY:
				return "SystemProperty";
			case CONFIGURE:
				return "configure";
			case ADD:
				return "add";
			default:
				return "";
		}
	}

	/**
	 * <P>
	 * タグ値を返します。
	 * </P>
	 * @param name タグの名前
	 * @return タグ値
	 */
	static public int getTag(String name)
	{
		if ("set".equals(name))
		{
			return SET;
		}
		else if ("get".equals(name))
		{
			return GET;
		}
		else if ("call".equals(name))
		{
			return CALL;
		}
		else if ("put".equals(name))
		{
			return PUT;
		}
		else if ("new".equals(name))
		{
			return NEW;
		}
		else if ("arg".equals(name))
		{
			return ARG;
		}
		else if ("SystemProperty".equals(name))
		{
			return SYSTEMPROPERTY;
		}
		else if ("configure".equals(name))
		{
			return CONFIGURE;
		}
		else if ("add".equals(name))
		{
			return ADD;
		}
		else
		{
			throw new IllegalStateException("Unknown tag: " + name);
		}
	}
}
