001    package edu.rice.cs.javalanglevels.tree;
002    
003    import edu.rice.cs.javalanglevels.SourceInfo;
004    
005    /**
006     * Class DoubleLiteral, a component of the JExpressionIF composite hierarchy.
007     * Note: null is not allowed as a value for any field.
008     * @version  Generated automatically by ASTGen at Sun Mar 04 23:01:27 CST 2012
009     */
010    public class DoubleLiteral extends LexicalLiteral {
011      private final double _value;
012    
013      /**
014       * Constructs a DoubleLiteral.
015       * @throws java.lang.IllegalArgumentException  If any parameter to the constructor is null.
016       */
017      public DoubleLiteral(SourceInfo in_sourceInfo, double in_value) {
018        super(in_sourceInfo);
019        _value = in_value;
020      }
021    
022      final public double getValue() { return _value; }
023    
024      public <RetType> RetType visit(JExpressionIFVisitor<RetType> visitor) { return visitor.forDoubleLiteral(this); }
025      public void visit(JExpressionIFVisitor_void visitor) { visitor.forDoubleLiteral(this); }
026    
027      /**
028       * Implementation of toString that uses
029       * {@link #output} to generated nicely tabbed tree.
030       */
031      public java.lang.String toString() {
032        java.io.StringWriter w = new java.io.StringWriter();
033        output(w);
034        return w.toString();
035      }
036    
037      /**
038       * Prints this object out as a nicely tabbed tree.
039       */
040      public void output(java.io.Writer writer) {
041        outputHelp(new TabPrintWriter(writer, 2));
042      }
043    
044      public void outputHelp(TabPrintWriter writer) {
045        writer.print("DoubleLiteral" + ":");
046        writer.indent();
047    
048        writer.startLine("");
049        writer.print("sourceInfo = ");
050        SourceInfo temp_sourceInfo = getSourceInfo();
051        if (temp_sourceInfo == null) {
052          writer.print("null");
053        } else {
054          writer.print(temp_sourceInfo);
055        }
056    
057        writer.startLine("");
058        writer.print("value = ");
059        double temp_value = getValue();
060        writer.print(temp_value);
061        writer.unindent();
062      }
063    
064      /**
065       * Implementation of equals that is based on the values
066       * of the fields of the object. Thus, two objects 
067       * created with identical parameters will be equal.
068       */
069      public boolean equals(java.lang.Object obj) {
070        if (obj == null) return false;
071        if ((obj.getClass() != this.getClass()) || (obj.hashCode() != this.hashCode())) {
072          return false;
073        } else {
074          DoubleLiteral casted = (DoubleLiteral) obj;
075          if (! (getValue() == casted.getValue())) return false;
076          return true;
077        }
078      }
079    
080      /**
081       * Implementation of hashCode that is consistent with
082       * equals. The value of the hashCode is formed by
083       * XORing the hashcode of the class object with
084       * the hashcodes of all the fields of the object.
085       */
086      protected int generateHashCode() {
087        int code = getClass().hashCode();
088        code ^= 0;
089        code ^= ((int) (java.lang.Double.doubleToLongBits(getValue())^(java.lang.Double.doubleToLongBits(getValue())>>>32)));
090        return code;
091      }
092    }