package it.unibz.krdb.sql;

import java.util.HashMap;
import java.util.List;

public class DBMetadata {
	
	public interface DataDefinition {
		public String getName();
		public String getAttributeName(int pos);
		public int countAttribute();
		public String toString();
	}
	
	private HashMap<String, DataDefinition> schema = new HashMap<String, DataDefinition>();
		
	public void add(DataDefinition value) {
		schema.put(value.getName(), value);
	}
	
	public void add(List<DataDefinition> list) {
		for (DataDefinition value : list) {
			add(value);
		}
	}
	
	public DataDefinition getDefinition(String name) {
		return schema.get(name);
	}
	
	public String getAttributeName(String tableName, int pos) {
		DataDefinition dd = schema.get(tableName);
		return dd.getAttributeName(pos);
	}
	
	public String getFullQualifiedAttributeName(String tableName, int pos) {		
		String value = String.format("%s.%s", tableName, getAttributeName(tableName, pos));
		return value;
	}
}

@@ -381,295 +381,1030 @@
 %09%0D%0A%09
-public void add(DataDefinition value) %7B%0D%0A%09%09schema.put(value.getName(), value);%0D%0A%09%7D%0D%0A%09%0D%0A%09public void add(List%3CDataDefinition%3E list) %7B%0D%0A%09%09for (DataDefinition value : list) %7B%0D%0A%09%09%09add(value);%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%09%0D%0A%09public DataDefinition getDefinition(String name) %7B%0D%0A%09%09return schema.get(name);%0D%0A%09%7D%0D%0A%09
+/**%0D%0A%09 * Inserts a new data definition to this meta data object.%0D%0A%09 * %0D%0A%09 * @param value%0D%0A%09 * %09%09%09The data definition. It can be a %7B@link TableDefinition%7D or a %7B@link ViewDefinition%7D%0D%0A%09 * %09%09%09object.%0D%0A%09 */%0D%0A%09public void add(DataDefinition value) %7B%0D%0A%09%09schema.put(value.getName(), value);%0D%0A%09%7D%0D%0A%09%0D%0A%09/**%0D%0A%09 * Inserts a list of data definition in batch.%0D%0A%09 * %0D%0A%09 * @param list%0D%0A%09 * %09%09%09A list of data definition.%0D%0A%09 */%0D%0A%09public void add(List%3CDataDefinition%3E list) %7B%0D%0A%09%09for (DataDefinition value : list) %7B%0D%0A%09%09%09add(value);%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%09%0D%0A%09/**%0D%0A%09 * Retrieves the data definition object based on its name. The name can be either%0D%0A%09 * a table name or a view name.%0D%0A%09 * %0D%0A%09 * @param name%0D%0A%09 * %09%09%09The string name.%0D%0A%09 */%0D%0A%09public DataDefinition getDefinition(String name) %7B%0D%0A%09%09return schema.get(name);%0D%0A%09%7D%0D%0A%09%0D%0A%09/**%0D%0A%09 * Returns the attribute name based on the table/view name and its position in the meta data.%0D%0A%09 * %0D%0A%09 * @param name%0D%0A%09 * %09%09%09Can be a table name or a view name.%0D%0A%09 * @param pos%0D%0A%09 * %09%09%09The index position.%0D%0A%09 * @return%0D%0A%09 */
 %0D%0A%09p
@@ -1432,38 +1432,33 @@
 buteName(String 
-tableN
+n
 ame, int pos) %7B%0D
@@ -1484,25 +1484,23 @@
 d = 
-schema.get(tableN
+getDefinition(n
 ame)
@@ -1541,24 +1541,271 @@
 s);%0D%0A%09%7D%0D%0A%09%0D%0A
+%09/**%0D%0A%09 * Returns the attribute full-qualified name based on the table/view name and its position in the meta data.%0D%0A%09 * %0D%0A%09 * @param name%0D%0A%09 * %09%09%09Can be a table name or a view name.%0D%0A%09 * @param pos%0D%0A%09 * %09%09%09The index position.%0D%0A%09 * @return%0D%0A%09 */%0D%0A
 %09public Stri
@@ -1844,22 +1844,17 @@
 (String 
-tableN
+n
 ame, int
@@ -1904,22 +1904,17 @@
 %25s.%25s%22, 
-tableN
+n
 ame, get
@@ -1931,14 +1931,9 @@
 ame(
-tableN
+n
 ame,

Add JavaDoc.