All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.antidot.sql.model.db.StdHeader Maven / Gradle / Ivy

There is a newer version: 2.2
Show newest version
/* 
 * Copyright 2011 Antidot [email protected]
 * https://github.com/antidot/db2triples
 * 
 * DB2Triples is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public License as 
 * published by the Free Software Foundation; either version 2 of 
 * the License, or (at your option) any later version.
 * 
 * DB2Triples 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 General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */

/**
 *
 * SQL model : Header
 *
 * Represents header of a database according to W3C database model.
 * In this case, header contains information about types of data stored
 * in column of tables.
 * 
 * Reference : Direct Mapping Definition, 
 * - A Direct Mapping of Relational Data to RDF W3C Working Draft 24 March 2011 
 * - A Direct Mapping of Relational Data to RDF W3C Working Draft 20 September 2011 
 *
 */
package net.antidot.sql.model.db;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

public class StdHeader implements Header {

	// Types stored
	private LinkedHashMap datatypes;

	public StdHeader(LinkedHashMap datatypes) {
		this.datatypes = datatypes;
	}

	public LinkedHashMap getDatatypes() {
		return datatypes;
	}

	public void setDatatypes(LinkedHashMap datatypes) {
		this.datatypes = datatypes;

	}

	public ArrayList getColumnNames() {
		ArrayList results = new ArrayList();
		Set> mapSet = datatypes.entrySet();
		Iterator> iter = mapSet.iterator();
		while (iter.hasNext()) {
			String columnName = iter.next().getKey();
			results.add(columnName);
		}
		return results;
	}

	public String toString() {
		String result = "{[Header:toString] datatypes = ";
		int i = 0;
		for (String columnName : getColumnNames()) {
			i++;
			result += columnName + " => " + datatypes.get(columnName);
			if (i < datatypes.size())
				result += ", ";
		}
		result += "}";
		return result;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy