/**
   * Sets the value of the descriptor parameter. This attribute is required and can not be set to
   * <i>null</i>. <br>
   * Each parameter have its possible value types. See the reference (ABNT NBR 15606-2) to more
   * information.
   *
   * @param value value of the descriptor parameter. The type of the value will depends on the
   *     parameter name.
   * @throws XMLException if the value is null.
   */
  public void setValue(Object value) throws XMLException {
    if (value == null) throw new XMLException("Null value.");

    Object newvalue = null;
    if (value instanceof String) newvalue = convertValue((String) value);
    if (newvalue == null) newvalue = value;

    if (!matchNameAndType(name, newvalue))
      throw new XMLException("Parameter name and value type does not match.");

    Object aux = this.value;

    if (percentSign) {
      if (!(newvalue instanceof Double))
        throw new XMLException("A relative value must have type Double.");

      Double var = (Double) newvalue;
      if (var < 0 || var > 100)
        throw new XMLException("The relative value of the paramenter must be between 0 and 100");
    } else if (newvalue instanceof Double) {
      Double var = (Double) newvalue;
      if (!name.equals(NCLAttributes.FONT_SIZE) && (var < 0 || var > 1))
        throw new XMLException("The value of the paramenter must be between 0 and 1");
    }

    this.value = newvalue;

    notifyAltered(NCLElementAttributes.VALUE, aux, newvalue);
  }
  protected void loadName(Element element) throws XMLException {
    String att_name, att_var;

    // set the name (required)
    att_name = NCLElementAttributes.NAME.toString();
    if (!(att_var = element.getAttribute(att_name)).isEmpty())
      setName(NCLAttributes.getEnumType(att_var));
    else throw new NCLParsingException("Could not find " + att_name + " attribute.");
  }
  protected boolean matchNameAndType(NCLAttributes name, Object value) {
    if (name == null || value == null) return true;

    if (value instanceof Integer[])
      return name.equals(NCLAttributes.BOUNDS)
          || name.equals(NCLAttributes.SIZE)
          || name.equals(NCLAttributes.LOCATION);

    if (value instanceof Double[])
      return name.equals(NCLAttributes.BOUNDS)
          || name.equals(NCLAttributes.SIZE)
          || name.equals(NCLAttributes.LOCATION);

    if (value instanceof Boolean)
      return name.equals(NCLAttributes.REUSE_PLAYER) || name.equals(NCLAttributes.VISIBLE);

    if (value instanceof Integer)
      return name.equals(NCLAttributes.ZINDEX)
          || name.equals(NCLAttributes.TOP)
          || name.equals(NCLAttributes.LEFT)
          || name.equals(NCLAttributes.BOTTOM)
          || name.equals(NCLAttributes.RIGHT)
          || name.equals(NCLAttributes.WIDTH)
          || name.equals(NCLAttributes.HEIGHT)
          || name.equals(NCLAttributes.FONT_SIZE)
          || name.equals(NCLAttributes.TRANSPARENCY)
          || name.equals(NCLAttributes.SOUND_LEVEL)
          || name.equals(NCLAttributes.BALANCE_LEVEL)
          || name.equals(NCLAttributes.TREBLE_LEVEL)
          || name.equals(NCLAttributes.BASS_LEVEL);

    if (value instanceof Double)
      return name.equals(NCLAttributes.FONT_SIZE)
          || name.equals(NCLAttributes.TRANSPARENCY)
          || name.equals(NCLAttributes.SOUND_LEVEL)
          || name.equals(NCLAttributes.BALANCE_LEVEL)
          || name.equals(NCLAttributes.TREBLE_LEVEL)
          || name.equals(NCLAttributes.BASS_LEVEL)
          || name.equals(NCLAttributes.TOP)
          || name.equals(NCLAttributes.LEFT)
          || name.equals(NCLAttributes.BOTTOM)
          || name.equals(NCLAttributes.RIGHT)
          || name.equals(NCLAttributes.WIDTH)
          || name.equals(NCLAttributes.HEIGHT);

    if (value instanceof NCLColor)
      return name.equals(NCLAttributes.FONT_COLOR) || name.equals(NCLAttributes.BACKGROUND);

    if (value instanceof NCLFit) return name.equals(NCLAttributes.FIT);

    if (value instanceof NCLFontVariant) return name.equals(NCLAttributes.FONT_VARIANT);

    if (value instanceof NCLFontWeight) return name.equals(NCLAttributes.FONT_WEIGHT);

    if (value instanceof NCLPlayerLife) return name.equals(NCLAttributes.PLAYER_LIFE);

    if (value instanceof NCLScroll) return name.equals(NCLAttributes.SCROLL);

    if (value.equals("transparent")) return name.equals(NCLAttributes.BACKGROUND);

    if (value instanceof String)
      return name.equals(NCLAttributes.STYLE) || name.equals(NCLAttributes.FONT_FAMILY);

    return false;
  }
 protected String parseName() {
   NCLAttributes aux = getName();
   if (aux != null) return " name='" + aux.toString() + "'";
   else return "";
 }