class MatchingRuleUse extends AbstractNamedSchemaElement {

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

    final MatchingRuleUse mrud = new MatchingRuleUse(m.group(1).trim());

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

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

    // parse applies attribute types
    if (m.group(6) != null) {
      mrud.setAppliesAttributeTypes(SchemaUtils.parseOIDs(m.group(6).trim()));
    } else if (m.group(7) != null) {
      mrud.setAppliesAttributeTypes(SchemaUtils.parseOIDs(m.group(7).trim()));
    }

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

  public  MatchingRuleUse(final String s);
  public  MatchingRuleUse(
    final String oid,
    final String[] names,
    final String description,
    final boolean obsolete,
    final String[] appliesAttributeTypes,
    final Extensions extensions);

}