001    package edu.rice.cs.javalanglevels.tree;
002    
003    import edu.rice.cs.javalanglevels.SourceInfo;
004    
005    /**
006     * Class DoStatement, 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 DoStatement extends Statement {
011      private final Statement _code;
012      private final Expression _condition;
013    
014      /**
015       * Constructs a DoStatement.
016       * @throws java.lang.IllegalArgumentException  If any parameter to the constructor is null.
017       */
018      public DoStatement(SourceInfo in_sourceInfo, Statement in_code, Expression in_condition) {
019        super(in_sourceInfo);
020    
021        if (in_code == null) {
022          throw new java.lang.IllegalArgumentException("Parameter 'code' to the DoStatement constructor was null. This class may not have null field values.");
023        }
024        _code = in_code;
025    
026        if (in_condition == null) {
027          throw new java.lang.IllegalArgumentException("Parameter 'condition' to the DoStatement constructor was null. This class may not have null field values.");
028        }
029        _condition = in_condition;
030      }
031    
032      final public Statement getCode() { return _code; }
033      final public Expression getCondition() { return _condition; }
034    
035      public <RetType> RetType visit(JExpressionIFVisitor<RetType> visitor) { return visitor.forDoStatement(this); }
036      public void visit(JExpressionIFVisitor_void visitor) { visitor.forDoStatement(this); }
037    
038      /**
039       * Implementation of toString that uses
040       * {@link #output} to generated nicely tabbed tree.
041       */
042      public java.lang.String toString() {
043        java.io.StringWriter w = new java.io.StringWriter();
044        output(w);
045        return w.toString();
046      }
047    
048      /**
049       * Prints this object out as a nicely tabbed tree.
050       */
051      public void output(java.io.Writer writer) {
052        outputHelp(new TabPrintWriter(writer, 2));
053      }
054    
055      public void outputHelp(TabPrintWriter writer) {
056        writer.print("DoStatement" + ":");
057        writer.indent();
058    
059        writer.startLine("");
060        writer.print("sourceInfo = ");
061        SourceInfo temp_sourceInfo = getSourceInfo();
062        if (temp_sourceInfo == null) {
063          writer.print("null");
064        } else {
065          writer.print(temp_sourceInfo);
066        }
067    
068        writer.startLine("");
069        writer.print("code = ");
070        Statement temp_code = getCode();
071        if (temp_code == null) {
072          writer.print("null");
073        } else {
074          temp_code.outputHelp(writer);
075        }
076    
077        writer.startLine("");
078        writer.print("condition = ");
079        Expression temp_condition = getCondition();
080        if (temp_condition == null) {
081          writer.print("null");
082        } else {
083          temp_condition.outputHelp(writer);
084        }
085        writer.unindent();
086      }
087    
088      /**
089       * Implementation of equals that is based on the values
090       * of the fields of the object. Thus, two objects 
091       * created with identical parameters will be equal.
092       */
093      public boolean equals(java.lang.Object obj) {
094        if (obj == null) return false;
095        if ((obj.getClass() != this.getClass()) || (obj.hashCode() != this.hashCode())) {
096          return false;
097        } else {
098          DoStatement casted = (DoStatement) obj;
099          if (! (getCode().equals(casted.getCode()))) return false;
100          if (! (getCondition().equals(casted.getCondition()))) return false;
101          return true;
102        }
103      }
104    
105      /**
106       * Implementation of hashCode that is consistent with
107       * equals. The value of the hashCode is formed by
108       * XORing the hashcode of the class object with
109       * the hashcodes of all the fields of the object.
110       */
111      protected int generateHashCode() {
112        int code = getClass().hashCode();
113        code ^= 0;
114        code ^= getCode().hashCode();
115        code ^= getCondition().hashCode();
116        return code;
117      }
118    }