package nl.hugojanssen.sqlgraph.model.sql;

import nl.hugojanssen.sqlgraph.shared.SQLConstants;
import nl.hugojanssen.sqlgraph.shared.SQLProperties;

import org.apache.log4j.Logger;

public class SQLTable
{
	/** The logger */
	private final static Logger LOG = Logger.getLogger( SQLTable.class );

	private String schema;

	private final String name;

	/**
	 * @param model
	 * @param schema
	 * @param name
	 */
	public SQLTable( String schema, String name )
	{
		LOG.debug( "Create new SQLTable " + name );
		this.schema = schema;
		this.name = name;

		this.validateState();
	}

	private void validateState()
	{
		//TODO: name cannot be null
		if ( this.schema == null || this.schema.isEmpty() )
		{
			this.schema = SQLProperties.getInstance().getProperty( SQLConstants.KEY_DB_DEFAULT_SCHEMA );
			LOG.warn( "No schema specified, assuming default " + this.schema );
		}
	}

	@Override
	public String toString()
	{
		return "[" + this.getSchema() + "].[" + this.getName() + "]";
	}

	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = 1;
		result = prime * result + ( ( this.name == null ) ? 0 : this.name.hashCode() );
		result = prime * result + ( ( this.schema == null ) ? 0 : this.schema.hashCode() );
		return result;
	}

	@Override
	public boolean equals( Object obj )
	{
		if ( this == obj )
		{
			return true;
		}
		if ( obj == null )
		{
			return false;
		}
		if ( this.getClass() != obj.getClass() )
		{
			return false;
		}
		SQLTable other = (SQLTable) obj;
		if ( this.name == null )
		{
			if ( other.name != null )
			{
				return false;
			}
		}
		else if ( !this.name.equals( other.name ) )
		{
			return false;
		}
		if ( this.schema == null )
		{
			if ( other.schema != null )
			{
				return false;
			}
		}
		else if ( !this.schema.equals( other.schema ) )
		{
			return false;
		}
		return true;
	}

	public String getName()
	{
		return this.name;
	}

	public String getSchema()
	{
		return this.schema;
	}
}
@@ -176,16 +176,248 @@
 ogger;%0A%0A
+/**%0A * A %3Ccode%3ESQLTable%3C/code%3E object represents a database table. It has a name and a database schema. When no database%0A * schema is provided, a default schema will be inferred from the properties file.%0A * %0A * @author hjanssen%0A */%0A
 public c
@@ -590,49 +590,337 @@
 %09 * 
-@par
+Construct a new %3Ccode%3ESQLTable%3C/code%3E object with the specified database schema and table name. A n
 am
+e
  m
-odel%0A%09 * @param schema%0A%09 * @param
+ust be%0A%09 * provided, while a database schema is optional. When no schema is specified, the default database schema is read%0A%09 * from the properties.xml file.%0A%09 * %0A%09 * @param schema the database schema%0A%09 * @param name the table
  nam
@@ -1132,16 +1132,17 @@
 %0A%09%7B%0A%09%09//
+ 
 TODO: na
@@ -1148,11 +1148,13 @@
 ame 
-can
+must 
 not 
@@ -1390,24 +1390,84 @@
  );%0A%09%09%7D%0A%09%7D%0A%0A
+%09/* (non-Javadoc)%0A%09 * @see java.lang.Object#toString()%0A%09 */%0A
 %09@Override%0A%09
@@ -1558,24 +1558,84 @@
  + %22%5D%22;%0A%09%7D%0A%0A
+%09/* (non-Javadoc)%0A%09 * @see java.lang.Object#hashCode()%0A%09 */%0A
 %09@Override%0A%09
@@ -1890,16 +1890,90 @@
 lt;%0A%09%7D%0A%0A
+%09/* (non-Javadoc)%0A%09 * @see java.lang.Object#equals(java.lang.Object)%0A%09 */%0A
 %09@Overri
@@ -2567,58 +2567,256 @@
 %7D%0A%0A%09
-public String getName()%0A%09%7B%0A%09%09return this.name;%0A%09%7D%0A
+/**%0A%09 * Returns the name for this table.%0A%09 * %0A%09 * @return the name for this table%0A%09 */%0A%09public String getName()%0A%09%7B%0A%09%09return this.name;%0A%09%7D%0A%0A%09/**%0A%09 * Returns the database schema for this table.%0A%09 * %0A%09 * @return the database schema for this table%0A%09 */
 %0A%09pu

Add documentation