class DITStructureRule extends AbstractNamedSchemaElement {

  public static DITStructureRule parse(final String definition)
    throws ParseException
  {
    final Matcher m = DEFINITION_PATTERN.matcher(definition);
    if (!m.matches()) {
      throw new ParseException("Invalid DIT structure rule definition: " + definition, definition.length());
    }

    final DITStructureRule dsrd = new DITStructureRule(Integer.parseInt(m.group(1).trim()));

    // CheckStyle:MagicNumber OFF
    // parse names
    if (m.group(2) != null) {
      dsrd.setNames(SchemaUtils.parseDescriptors(m.group(2).trim()));
    } else if (m.group(3) != null) {
      dsrd.setNames(SchemaUtils.parseDescriptors(m.group(3).trim()));
    }

    dsrd.setDescription(m.group(4) != null ? m.group(4).trim() : null);
    dsrd.setObsolete(m.group(5) != null);
    dsrd.setNameForm(m.group(6) != null ? m.group(6).trim() : null);

    // parse superior rules
    if (m.group(7) != null) {
      dsrd.setSuperiorRules(SchemaUtils.parseNumbers(m.group(7).trim()));
    } else if (m.group(8) != null) {
      dsrd.setSuperiorRules(SchemaUtils.parseNumbers(m.group(8).trim()));
    }

    // parse extensions
    if (m.group(9) != null) {
      dsrd.setExtensions(Extensions.parse(m.group(9).trim()));
    }
    return dsrd;
    // CheckStyle:MagicNumber ON
  }

  public  DITStructureRule(final int i);
  public  DITStructureRule(
    final int id,
    final String[] names,
    final String description,
    final boolean obsolete,
    final String nameForm,
    final int[] superiorRules,
    final Extensions extensions);

}