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      protected void check(Element element, String maxLengthProp) {
    18          final Object maxLength = element.getOption(maxLengthProp);
    19          if (maxLength == null)
    20              return;
    21          check(element, NumberUtils.toInt(maxLength, -1));
    22      }
    23
    24      protected void check(Element element, int maxLength) {
    25          if (maxLength < 0)
    26              return;
    27          final String name = element.getName();
    28          if (name.length() > maxLength)
    29              addError(element, "name is too long");
    30      }
    31
    32  }