View Javadoc

    1   /*
    2    * joey-gen and its relative products are published under the terms
    3    * of the Apache Software License.
    4    *
    5    * Created on 2004/08/15 14:54:07
    6    */
    7   package org.asyrinx.joey.gen.model.rdb.visitor;
    8
    9   import java.util.Iterator;
    10
    11  import org.asyrinx.joey.gen.model.EnumerationEntry;
    12  import org.asyrinx.joey.gen.model.rdb.Column;
    13  import org.asyrinx.joey.gen.model.rdb.Database;
    14  import org.asyrinx.joey.gen.model.rdb.Databases;
    15  import org.asyrinx.joey.gen.model.rdb.PrimaryKey;
    16  import org.asyrinx.joey.gen.model.rdb.RdbEnumeration;
    17  import org.asyrinx.joey.gen.model.rdb.ForeignKey;
    18  import org.asyrinx.joey.gen.model.rdb.ForeignKeyEntry;
    19  import org.asyrinx.joey.gen.model.rdb.Index;
    20  import org.asyrinx.joey.gen.model.rdb.IndexEntry;
    21  import org.asyrinx.joey.gen.model.rdb.RdbVisitor;
    22  import org.asyrinx.joey.gen.model.rdb.Table;
    23  import org.asyrinx.joey.gen.model.rdb.Unique;
    24
    25  /***
    26   * @author akima
    27   */
    28  public class RdbTopDownVisitor extends RdbVisitorWrapper {
    29
    30      /***
    31       * @param rdbVisitor
    32       */
    33      public RdbTopDownVisitor(RdbVisitor rdbVisitor) {
    34          super(rdbVisitor);
    35      }
    36
    37      /*
    38       * (non-Javadoc)
    39       *
    40       * @see org.asyrinx.joey.gen.model.rdb.RdbVisitor#visit(org.asyrinx.joey.gen.model.rdb.Column)
    41       */
    42      public void visit(Column column) {
    43          super.visit(column);
    44      }
    45
    46      /*
    47       * (non-Javadoc)
    48       *
    49       * @see org.asyrinx.joey.gen.model.rdb.RdbVisitor#visit(org.asyrinx.joey.gen.model.rdb.Database)
    50       */
    51      public void visit(Database database) {
    52          super.visit(database);
    53          for (Iterator iter = database.getEnumerations().iterator(); iter.hasNext();) {
    54              final RdbEnumeration element = (RdbEnumeration) iter.next();
    55              visit(element);
    56          }
    57          for (Iterator iter = database.getTables().iterator(); iter.hasNext();) {
    58              final Table element = (Table) iter.next();
    59              visit(element);
    60          }
    61      }
    62
    63      /*
    64       * (non-Javadoc)
    65       *
    66       * @see org.asyrinx.joey.gen.model.rdb.RdbVisitor#visit(org.asyrinx.joey.gen.model.rdb.Databases)
    67       */
    68      public void visit(Databases databases) {
    69          super.visit(databases);
    70          for (Iterator iter = databases.getDatabases().iterator(); iter.hasNext();) {
    71              final Database element = (Database) iter.next();
    72              visit(element);
    73          }
    74      }
    75
    76      /*
    77       * (non-Javadoc)
    78       *
    79       * @see org.asyrinx.joey.gen.model.rdb.RdbVisitor#visit(org.asyrinx.joey.gen.model.rdb.JavaEnumeration)
    80       */
    81      public void visit(RdbEnumeration enumeration) {
    82          super.visit(enumeration);
    83          for (Iterator iter = enumeration.iterator(); iter.hasNext();) {
    84              final EnumerationEntry element = (EnumerationEntry) iter.next();
    85              visit(element);
    86          }
    87      }
    88
    89      /*
    90       * (non-Javadoc)
    91       *
    92       * @see org.asyrinx.joey.gen.model.rdb.RdbVisitor#visit(org.asyrinx.joey.gen.model.rdb.EnumerationEntry)
    93       */
    94      public void visit(EnumerationEntry enumerationEntry) {
    95          super.visit(enumerationEntry);
    96      }
    97
    98      /*
    99       * (non-Javadoc)
    100      *
    101      * @see org.asyrinx.joey.gen.model.rdb.RdbVisitor#visit(org.asyrinx.joey.gen.model.rdb.ForeignKey)
    102      */
    103     public void visit(ForeignKey foreignKey) {
    104         super.visit(foreignKey);
    105         for (Iterator iter = foreignKey.iterator(); iter.hasNext();) {
    106             final ForeignKeyEntry element = (ForeignKeyEntry) iter.next();
    107             visit(element);
    108         }
    109     }
    110
    111     /*
    112      * (non-Javadoc)
    113      *
    114      * @see org.asyrinx.joey.gen.model.rdb.RdbVisitor#visit(org.asyrinx.joey.gen.model.rdb.ForeignKeyEntry)
    115      */
    116     public void visit(ForeignKeyEntry foreignKeyEntry) {
    117         super.visit(foreignKeyEntry);
    118     }
    119
    120     /*
    121      * (non-Javadoc)
    122      *
    123      * @see org.asyrinx.joey.gen.model.rdb.RdbVisitor#visit(org.asyrinx.joey.gen.model.rdb.Index)
    124      */
    125     public void visit(Index index) {
    126         super.visit(index);
    127         for (Iterator iter = index.iterator(); iter.hasNext();) {
    128             final IndexEntry element = (IndexEntry) iter.next();
    129             visit(element);
    130         }
    131     }
    132
    133     /*
    134      * (non-Javadoc)
    135      *
    136      * @see org.asyrinx.joey.gen.model.rdb.RdbVisitor#visit(org.asyrinx.joey.gen.model.rdb.IndexEntry)
    137      */
    138     public void visit(IndexEntry indexEntry) {
    139         super.visit(indexEntry);
    140     }
    141
    142     /*
    143      * (non-Javadoc)
    144      *
    145      * @see org.asyrinx.joey.gen.model.rdb.visitor.RdbVisitorWrapper#visit(org.asyrinx.joey.gen.model.rdb.PrimaryKey)
    146      */
    147     public void visit(PrimaryKey primaryKey) {
    148         super.visit(primaryKey);
    149     }
    150
    151     /*
    152      * (non-Javadoc)
    153      *
    154      * @see org.asyrinx.joey.gen.model.rdb.RdbVisitor#visit(org.asyrinx.joey.gen.model.rdb.Table)
    155      */
    156     public void visit(Table table) {
    157         super.visit(table);
    158         for (Iterator iter = table.getColumns().iterator(); iter.hasNext();) {
    159             final Column element = (Column) iter.next();
    160             visit(element);
    161         }
    162         visit(table.getPrimaryKey());
    163         for (Iterator iter = table.getIndexes().iterator(); iter.hasNext();) {
    164             final Index element = (Index) iter.next();
    165             visit(element);
    166         }
    167         for (Iterator iter = table.getUniques().iterator(); iter.hasNext();) {
    168             final Index element = (Index) iter.next();
    169             visit(element);
    170         }
    171         for (Iterator iter = table.getForeignKeys().iterator(); iter.hasNext();) {
    172             final ForeignKey element = (ForeignKey) iter.next();
    173             visit(element);
    174         }
    175     }
    176
    177     /*
    178      * (non-Javadoc)
    179      *
    180      * @see org.asyrinx.joey.gen.model.rdb.visitor.RdbVisitorWrapper#visit(org.asyrinx.joey.gen.model.rdb.Unique)
    181      */
    182     public void visit(Unique unique) {
    183         super.visit(unique);
    184         for (Iterator iter = unique.iterator(); iter.hasNext();) {
    185             final IndexEntry element = (IndexEntry) iter.next();
    186             visit(element);
    187         }
    188     }
    189 }