Ejemplo n.º 1
0
  /**
   * Performs any initialization for this tag that may be needed while parsing a branch definition.
   *
   * @param templateFile The template file in which this tag is used.
   * @param branch The branch in which this tag is used.
   * @param arguments The set of arguments provided for this tag.
   * @param lineNumber The line number on which this tag appears in the template file.
   * @param warnings A list into which any appropriate warning messages may be placed.
   * @throws InitializationException If a problem occurs while initializing this tag.
   */
  public void initializeForBranch(
      TemplateFile templateFile,
      Branch branch,
      String[] arguments,
      int lineNumber,
      List<Message> warnings)
      throws InitializationException {
    if ((arguments.length < 1) || (arguments.length > 2)) {
      Message message =
          ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(
              getName(), lineNumber, 1, 2, arguments.length);
      throw new InitializationException(message);
    }

    String lowerName = toLowerCase(arguments[0]);
    AttributeType t = DirectoryServer.getAttributeType(lowerName, true);
    if (!branch.hasAttribute(t)) {
      Message message = ERR_MAKELDIF_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber);
      throw new InitializationException(message);
    }

    if (arguments.length == 2) {
      assertionValue = arguments[1];
    } else {
      assertionValue = null;
    }
  }