/
area/
classes/net/sourceforge/pain/logic/
classes/net/sourceforge/pain/logic/event/
classes/net/sourceforge/pain/logic/fn/util/
classes/net/sourceforge/pain/network/console/
classes/net/sourceforge/pain/plugin/
classes/net/sourceforge/pain/plugin/reset/
classes/net/sourceforge/pain/plugin/shutdown/
classes/net/sourceforge/pain/plugin/social/
classest/net/sourceforge/pain/db/data/
doc/
doc/paindb/resources/
src/net/sourceforge/pain/logic/
src/net/sourceforge/pain/logic/event/
src/net/sourceforge/pain/logic/fn/util/
src/net/sourceforge/pain/network/console/
src/net/sourceforge/pain/network/console/telnet/
src/net/sourceforge/pain/plugin/
src/net/sourceforge/pain/plugin/command/
src/net/sourceforge/pain/plugin/reset/
src/net/sourceforge/pain/plugin/shutdown/
src/net/sourceforge/pain/plugin/social/
src/net/sourceforge/pain/util/
tests/
tests/net/sourceforge/pain/db/data/
package net.sourceforge.pain.db;

/**
 * All supported PAiN DB field types
 */
public final class DbType {

	public static final int BOOLEAN = 1;
	public static final int BYTE = 2;
	public static final int CHAR = 3;
	public static final int DOUBLE = 4;
	public static final int FLOAT = 5;
	public static final int INT = 6;
	public static final int LONG = 7;
	public static final int SHORT = 8;
	public static final int STRING = 9;
	public static final int REFERENCE = 10;

	public static final int ARRAY_OF_BYTE = 12;
	public static final int ARRAY_OF_CHAR = 13;
	public static final int ARRAY_OF_INT = 16;
	public static final int ARRAY_OF_STRING = 19;

	public static final int LINKED_LIST = 20; //only references list is supported!
	public static final int ARRAY_LIST = 21; //only references list is supported!
	public static final int INT_KEY_MAP = 22; // only int(Integers) allowed as keys, values are DbObject instances or null
	public static final int STRING_KEY_MAP = 23; // only Strings is allowed as keys, values are DbObject instances or null
	public static final int REFERENCE_SET = 24; // set of DbObjects
	public static final int STRING_SET = 25; // set of Strings
	public static final int STRING_MAP = 26; // map of strings with values of Strings

	private static String[] typeNames = new String[27];

	static {
		typeNames[BOOLEAN] = "boolean";
		typeNames[BYTE] = "byte";
		typeNames[CHAR] = "char";
		typeNames[DOUBLE] = "double";
		typeNames[FLOAT] = "float";
		typeNames[INT] = "int";
		typeNames[LONG] = "long";
		typeNames[SHORT] = "short";
		typeNames[STRING] = "String";
		typeNames[REFERENCE] = "reference";

		typeNames[ARRAY_OF_BYTE] = "byte[]";
		typeNames[ARRAY_OF_CHAR] = "char[]";
		typeNames[ARRAY_OF_INT] = "int[]";
		typeNames[ARRAY_OF_STRING] = "String[]";

		typeNames[LINKED_LIST] = "LinkedList";
		typeNames[ARRAY_LIST] = "ArrayList";
		typeNames[INT_KEY_MAP] = "IntKeyMap";
		typeNames[STRING_KEY_MAP] = "StringKeyMap";
		typeNames[REFERENCE_SET] = "ReferenceSet";
		typeNames[STRING_SET] = "StringSet";
		typeNames[STRING_MAP] = "StringMap";
	}


	static final boolean isValidDbType(final int type) {
		return (type > 0 && type <= 10) || type == 12 || type == 13 || type == 16 || (type >= 19 && type <= 26);
	}

	/** @return String name for the specified type*/
	public static String name(int type) {
		String name = (type > 0 && type < typeNames.length ? typeNames[type] : null);
		if (name == null) {
			throw new IllegalArgumentException("Illegal type:" + type);
		}
		return name;
	}

}