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