You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.5 KiB
Java

package de.unibremen.informatik.hets.model;
import java.util.ArrayList;
import java.util.Iterator;
public class SpecDefn {
private ArrayList<Spec> specs;
private String name;
private String logic;
private String annotation;
public SpecDefn(String n, String l, String a) {
name = n;
logic = l;
annotation = a;
specs = new ArrayList<Spec>();
}
public void add(Spec spec) {
specs.add(spec);
}
public String getLogic() {
return logic;
}
public String toString() {
StringBuilder builder = new StringBuilder();
if (annotation != null && annotation != "") {
builder.append(annotation);
builder.append("\n");
}
builder.append("spec ");
builder.append(name);
builder.append(" =");
Iterator<Spec> it = specs.iterator();
while (it.hasNext()) {
Spec spec = it.next();
String annotation = spec.getAnnotation();
if (annotation != null) {
builder.append(" ");
builder.append(spec.getAnnotation());
}
if (!(spec instanceof Union)) {
builder.append("\n");
}
builder.append(spec.toString());
if (it.hasNext()) {
builder.append("then");
} else {
break;
}
}
builder.append("end");
builder.append("\n");
return builder.toString();
}
}