001 package com.sptci.rwt;
002
003 import java.util.ArrayList;
004 import java.util.Collection;
005 import java.util.Collections;
006
007 /**
008 * An abstract metadata object that represents constraint types (primary
009 * and foreign keys).
010 *
011 * <p>© Copyright 2007 <a href='http://sptci.com/' target='_new'>Sans Pareil Technologies, Inc.</a></p>
012 * @author Rakesh Vidyadharan 2007-09-26
013 * @version $Id: KeyMetaData.java 4123 2008-05-25 21:49:01Z rakesh $
014 */
015 public class KeyMetaData extends MetaData
016 {
017 /**
018 * The name of the column(s) on which the key is defined.
019 *
020 * @see TableMetaData#getColumn
021 */
022 private Collection<ColumnMetaData> columns = new ArrayList<ColumnMetaData>();
023
024 /** A sequence number that indicates the sequence number with a key */
025 private int keySequence;
026
027 /** A reference to the table in which this key belongs. */
028 private TableMetaData table;
029
030 /**
031 * Returns {@link #columns}.
032 *
033 * @return The value/reference of/to column.
034 */
035 public Collection<ColumnMetaData> getColumns()
036 {
037 return Collections.unmodifiableCollection( columns );
038 }
039
040 /**
041 * Set {@link #columns}.
042 *
043 * @param columns The value to set.
044 */
045 protected void setColumns( final Collection<ColumnMetaData> columns )
046 {
047 this.columns.clear();
048 this.columns.addAll( columns );
049 }
050
051 /**
052 * Add the specified column to {@link #columns}.
053 *
054 * @param column The column to add.
055 */
056 protected void addColumn( final ColumnMetaData column )
057 {
058 this.columns.add( column );
059 }
060
061 /**
062 * Returns {@link #keySequence}.
063 *
064 * @return The value/reference of/to keySequence.
065 */
066 public int getKeySequence()
067 {
068 return keySequence;
069 }
070
071 /**
072 * Set {@link #keySequence}.
073 *
074 * @param keySequence The value to set.
075 */
076 protected void setKeySequence( final int keySequence )
077 {
078 this.keySequence = keySequence;
079 }
080
081 /**
082 * Returns {@link #table}.
083 *
084 * @return The value/reference of/to table.
085 */
086 public TableMetaData getTable()
087 {
088 return table;
089 }
090
091 /**
092 * Set {@link #table}.
093 *
094 * @param table The value to set.
095 */
096 protected void setTable( final TableMetaData table )
097 {
098 this.table = table;
099 }
100 }