/*
 * This file is released under terms of BSD license
 * See LICENSE file for more information
 */

package cx2x.xcodeml.xelement;

import org.w3c.dom.Element;
import cx2x.xcodeml.helper.*;

/**
 * The Xconstant represents the base of constants elements (7.1.1) element in
 * XcodeML intermediate representation. It includes (FintConstant,
 * FrealConstant, FcomplexConstant, FcharacterConstant, FlogicalConstant)
 *
 * Elements: contains value
 * Attributes:
 * - Optional: type (text), kind (text)
 *
 * @author clementval
 */

public class Xconstant extends XbaseElement {
  private String _value = null;
  private String _type = null;
  private String _kind = null;

  /**
   * Xelement standard ctor. Pass the base element to the base class and read
   * inner information (elements and attributes).
   * @param baseElement The root element of the Xelement
   */
  public Xconstant(Element baseElement){
    super(baseElement);
    readElementInformation();
  }

  /**
   * Read inner element information.
   */
  private void readElementInformation(){
    _value = baseElement.getTextContent();
    _type = XelementHelper.getAttributeValue(this,
      XelementName.ATTR_TYPE);
    _kind = XelementHelper.getAttributeValue(this,
      XelementName.ATTR_TYPE);
  }

  /**
   * Check whether the element has kind attribute.
   * @return True if the element has kind attribute. False otherwise.
   */
  public boolean hasKind(){
    return _kind != null;
  }

  /**
   * Set the kind attribute.
   * @param value Kind value.
   */
  public void setKind(String value){
    if(baseElement != null){
      baseElement.setAttribute(XelementName.ATTR_KIND, value);
      _kind = value;
    }
  }

  /**
   * Check whether the element has type attribute.
   * @return True if the element has type attribute. False otherwise.
   */
  public boolean hasType(){
    return _type != null;
  }

  /**
   * Set the type attribute.
   * @param value The type value.
   */
  public void setType(String value){
    if(baseElement != null){
      baseElement.setAttribute(XelementName.ATTR_TYPE, value);
      _type = value;
    }
  }

  /**
   * Get the constant value.
   * @return The constant value as String.
   */
  public String getValue(){
    return _value;
  }

  /**
   * Set the constant value.
   * @param value The constant value.
   */
  public void setValue(String value){
    if(baseElement != null){
      baseElement.setTextContent(value);
      _value = value;
    }
  }
}

@@ -1248,28 +1248,28 @@
 ntName.ATTR_
-TYPE
+KIND
 );%0A  %7D%0A%0A  /*
@@ -1680,32 +1680,160 @@
 lue;%0A    %7D%0A  %7D%0A%0A
+  /**%0A   * Get the kind value of the constant.%0A   * @return Kind value.%0A   */%0A  public String getKind()%7B%0A    return _kind;%0A  %7D%0A%0A
   /**%0A   * Check
@@ -2225,32 +2225,32 @@
  _type = value;%0A
-
     %7D%0A  %7D%0A%0A  /**
@@ -2236,32 +2236,150 @@
 lue;%0A    %7D%0A  %7D%0A%0A
+  /**%0A   * Get the constant type.%0A   * @return Constant type.%0A   */%0A  public String getType()%7B%0A    return _type;%0A  %7D%0A%0A
   /**%0A   * Get t

Add accessors and fix read of kind