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/12/27 12:05:27
    6    */
    7   package org.asyrinx.joey.gen.model.rdb;
    8
    9   import org.asyrinx.joey.gen.model.Element;
    10  import org.asyrinx.joey.gen.model.ElementSet;
    11  import org.asyrinx.joey.gen.model.command.ValidationError;
    12  import org.asyrinx.joey.gen.model.pattern.Pattern;
    13  import org.asyrinx.joey.gen.model.pattern.PatternRepository;
    14
    15  /***
    16   * @author takeshi
    17   */
    18  public class TablePattern extends ElementSet {
    19
    20      /***
    21       * @param parent
    22       */
    23      public TablePattern() {
    24          super(null, null, null);
    25      }
    26
    27      /***
    28       * @param parent
    29       * @param name
    30       * @param label
    31       */
    32      public TablePattern(Element parent, String name, String label) {
    33          super(parent, name, label);
    34      }
    35
    36      /***
    37       * @param name
    38       */
    39      public TablePattern(String name) {
    40          super(name);
    41      }
    42
    43      public boolean isEntity() {
    44          return true;
    45      }
    46
    47      public void add(TablePatternParam param) {
    48          super.add(param);
    49      }
    50
    51      public boolean contains(TablePatternParam param) {
    52          return super.contains(param);
    53      }
    54
    55      public TablePatternParam getParam(int idx) {
    56          return (TablePatternParam) super.getElement(idx);
    57      }
    58
    59      public TablePatternParam getParam(String name) {
    60          return (TablePatternParam) super.getElement(name);
    61      }
    62
    63      public TablePatternParam removeParam(String name) {
    64          return (TablePatternParam) super.removeElement(name);
    65      }
    66
    67      public Table getParent() {
    68          return (Table) super.getParentElement();
    69      }
    70
    71      public String getParameter(String paramName) {
    72          final TablePatternParam param = this.getParam(paramName);
    73          return (param == null) ? null : param.getValue();
    74      }
    75
    76      public Pattern toPattern() {
    77          final Pattern pattern = PatternRepository.getInstance().get(this.getName());
    78          if (pattern == null)
    79              throw new ValidationError("no pattern implementation", this);
    80          return pattern;
    81      }
    82
    83      public boolean isTarget(String templatePath) {
    84          return toPattern().isTarget(templatePath);
    85      }
    86
    87  }