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/16 5:08:55
    6    */
    7   package org.asyrinx.joey.gen.command.rdb;
    8
    9   import org.asyrinx.brownie.core.lang.NumberUtils;
    10  import org.asyrinx.joey.gen.model.Element;
    11
    12  /***
    13   * @author akima
    14   */
    15  public class CheckName extends RdbCommand {
    16
    17      /***
    18       *
    19       */
    20      public CheckName() {
    21          super();
    22      }
    23
    24      protected void check(Element element, String maxLengthProp) {
    25          final Object maxLength = element.getOption(maxLengthProp);
    26          if (maxLength == null)
    27              return;
    28          check(element, NumberUtils.toInt(maxLength, -1));
    29      }
    30
    31      protected void check(Element element, int maxLength) {
    32          if (maxLength < 0)
    33              return;
    34          final String name = element.getName();
    35          if (name.length() > maxLength)
    36              addError(element, "name is too long");
    37      }
    38
    39  }