1 /******************************************************************
2 * Copyright (c) 2003, Mario Hochreiter, Student of
3 * Software Engineering at FH-Hagenberg, Austria.
4 * Project member of the isac team at the Institute for
5 * Software-Technologie, Graz University of Technology, Austria.
7 * Use is subject to license terms.
8 ******************************************************************/
12 import isac.bridge.xml.DataTypes; // from libisabelle-full.jar
13 import edu.tum.cs.isabelle.api.XML; // from libisabelle-full.jar
15 import java.io.Serializable;
16 import java.util.ArrayList;
17 import java.util.Iterator;
20 * Every calculation in the isac system starts with a formalization that
21 * characterizes the calculation. A formalization object can contain multiple
22 * <code>Variant</code> objects because a calculation can be calculated in
23 * different ways (using different methods to solve the calculation).
25 * @author Mario Hochreiter
29 public class Formalization implements Serializable {
31 static final long serialVersionUID = 4539906901989017369L;
33 protected ArrayList<Variant> variants_;
35 public Formalization() {
36 variants_ = new ArrayList<Variant>();
39 public void addNewVariant(Variant v) {
43 public ArrayList<Variant> getVariants() {
47 public Iterator<?> iterator() {
48 return new FormalizationIterator(this);
51 public String toString() {
52 String content = "<FORMALIZATION>\n";
53 for (int index = 0; index < variants_.size(); index++)
54 content += variants_.get(index) + "\n";
55 content += "</FORMALIZATION>\n";
60 * Format the object in a way that the bridge can handle it
62 * @return SML representation of this Formalization
64 public String toSMLString() {
65 // Use this String for empty Formalization:
66 // Calculation from scratch
68 if (variants_.isEmpty())
69 return "[([], (\"e_domID\", [\"e_pblID\"], [\"e_metID\"]))]";
70 //FIXME.WN04 e_domID, etc. will disappear soon: empty formalization
71 // would be "[([], (\"\", [], []))]"
72 StringBuffer sb = new StringBuffer();
73 int size = variants_.size();
78 Iterator<Variant> it = variants_.iterator();
79 while (it.hasNext()) {
80 v = (Variant) it.next();
82 sb.append(v.toSMLString());
95 * Format the object in a way that libisabelle/PIDE can handle it
96 * @return XML representation of this Formalization
98 public XML.Tree toXML() {
100 DataTypes.xml_of_str("equality (x+1=(2::real))");
102 return null; //XML.Tree
106 class FormalizationIterator implements Iterator<Object> {
110 FormalizationIterator(Formalization f) {
111 it_ = f.variants_.iterator();
114 public void remove() {
118 public boolean hasNext() {
119 return it_.hasNext();
122 public Object next() {