Ignore:
Timestamp:
02/04/10 21:56:24 (2 years ago)
Author:
kasper
Message:
 
File:
1 copied

Legend:

Unmodified
Added
Removed
  • MetadataBeans/trunk/src/main/java/org/eobjects/metamodel/schema/MutableSchema.java

    r886 r887  
    2828import org.apache.commons.lang.builder.ToStringStyle; 
    2929 
    30 /** 
    31  * Represents a schema and it's metadata. Schemas represent a collection of 
    32  * tables. 
    33  *  
    34  * @see Table 
    35  */ 
    36 public class Schema implements Serializable, Comparable<Schema> { 
     30public class MutableSchema implements Serializable, Schema { 
    3731 
    3832        private static final long serialVersionUID = 4465197783868238863L; 
     
    4135        protected List<Table> _tables = new ArrayList<Table>(); 
    4236 
    43         public Schema() { 
    44         } 
    45  
    46         public Schema(String name) { 
     37        public MutableSchema() { 
     38        } 
     39 
     40        public MutableSchema(String name) { 
    4741                this(); 
    4842                _name = name; 
    4943        } 
    5044 
    51         public Schema(String name, Table... tables) { 
     45        public MutableSchema(String name, Table... tables) { 
    5246                this(name); 
    5347                setTables(tables); 
     
    5751         * @return the name of the schema 
    5852         */ 
     53        @Override 
    5954        public String getName() { 
    6055                return _name; 
     
    6459                _name = name; 
    6560                for (Table table : _tables) { 
    66                         table.fireSchemaChanged(); 
     61                        if (table instanceof MutableTable) { 
     62                                ((MutableTable) table).fireSchemaChanged(); 
     63                        } 
    6764                } 
    6865                return this; 
     
    7269         * @return the number of tables that reside in the schema 
    7370         */ 
     71        @Override 
    7472        public int getTableCount() { 
    7573                return _tables.size(); 
    7674        } 
    7775 
     76        @Override 
    7877        public int getTableCount(TableType type) { 
    7978                return getTables(type).length; 
     
    8382         * @return the tables that reside in the schema 
    8483         */ 
     84        @Override 
    8585        public Table[] getTables() { 
    8686                return _tables.toArray(new Table[_tables.size()]); 
    8787        } 
    8888 
     89        @Override 
    8990        public Table[] getTables(TableType type) { 
    9091                List<Table> result = new ArrayList<Table>(); 
     
    113114        } 
    114115 
    115         public Schema addTable(Table table) { 
     116        public MutableSchema addTable(Table table) { 
    116117                _tables.add(table); 
    117118                return this; 
     
    131132         *         found. 
    132133         */ 
     134        @Override 
    133135        public Table getTableByName(String tableName) { 
    134136                if (tableName != null) { 
     
    157159        } 
    158160 
     161        @Override 
    159162        public Relationship[] getRelationships() { 
    160163                List<Relationship> result = new ArrayList<Relationship>(); 
    161164                for (Table table : _tables) { 
    162165                        Relationship[] relations = table.getRelationships(); 
    163                         for (int i = 0; i < relations.length; i++) { 
    164                                 Relationship relation = relations[i]; 
     166                        for (Relationship relation : relations) { 
    165167                                boolean found = false; 
    166168                                for (Relationship existingRelation : result) { 
     
    179181        } 
    180182 
     183        @Override 
    181184        public int getRelationshipCount() { 
    182185                return getRelationships().length; 
     
    202205                        return true; 
    203206                } 
    204                 if (obj instanceof Schema) { 
     207                if (obj instanceof MutableSchema) { 
    205208                        Schema that = (Schema) obj; 
    206209                        return new EqualsBuilder().append(this.getName(), that.getName()) 
     
    210213        } 
    211214 
     215        @Override 
    212216        public int compareTo(Schema that) { 
    213217                CompareToBuilder ctb = new CompareToBuilder(); 
     
    217221        } 
    218222 
     223        @Override 
    219224        public String[] getTableNames() { 
    220225                ArrayList<String> result = new ArrayList<String>(); 
Note: See TracChangeset for help on using the changeset viewer.