isac-java/src/java/isac/util/Variant.java
author Walther Neuper <walther.neuper@jku.at>
Fri, 26 Mar 2021 10:45:05 +0100
changeset 5239 b4e3883d7b66
parent 5229 6bf0e95981e3
permissions -rw-r--r--
reset mathematics-engine to Isabelle2015

note: for this version libisabelle was available,
which connects front-end (Java) and back-end (Isabelle/ML)
mhochrei@1085
     1
/****************************************************************** 
mkoschuc@2424
     2
 * Copyright (c) 2003, Mario Hochreiter, Student of 
mkoschuc@2424
     3
 * Software Engineering at FH-Hagenberg, Austria. 
mkoschuc@2424
     4
 * Project member of the isac team at the Institute for 
mkoschuc@2424
     5
 * Software-Technologie, Graz University of Technology, Austria. 
mkoschuc@2424
     6
 * 
mkoschuc@2424
     7
 * Use is subject to license terms.
mkoschuc@2424
     8
 ******************************************************************/
mhochrei@1085
     9
mhochrei@1085
    10
package isac.util;
mhochrei@1085
    11
wneuper@1901
    12
import isac.util.formulae.Specification;
wneuper@4758
    13
import isac.bridge.xml.DataTypes; //.scala
wneuper@1901
    14
walther@5239
    15
import edu.tum.cs.isabelle.api.XML; // from libisabelle-full.jar
wneuper@4708
    16
mhochrei@1085
    17
import java.io.Serializable;
mhochrei@1085
    18
import java.util.ArrayList;
mhochrei@1085
    19
mhochrei@1085
    20
/**
mkoschuc@2424
    21
 * Describes a way how a specific calculation will be calculated (which method
mkoschuc@2424
    22
 * will be used to solve this calculation).
mhochrei@1085
    23
 * 
mhochrei@1085
    24
 * @author Mario Hochreiter
mhochrei@1085
    25
 * @version 0.1
mkoschuc@2424
    26
 *  
mhochrei@1085
    27
 */
mhochrei@1085
    28
public class Variant implements Serializable {
mkoschuc@2424
    29
nsimic@3775
    30
    static final long serialVersionUID = 4983770207782569120L;
nsimic@3775
    31
nsimic@3775
    32
	/** strings betweend the isa tags */
nsimic@3775
    33
    protected ArrayList<String> isa_strings_;
mkoschuc@2424
    34
mkoschuc@2424
    35
    protected Specification spec_;
mkoschuc@2424
    36
mkoschuc@2424
    37
    public Variant() {
nsimic@3775
    38
        isa_strings_ = new ArrayList<String>();
mhochrei@1085
    39
    }
mkoschuc@2424
    40
mkoschuc@2424
    41
    /**
mkoschuc@2424
    42
     * Add a new isa string
mkoschuc@2424
    43
     * 
mkoschuc@2424
    44
     * @param isa
mkoschuc@2424
    45
     *            The isa string
mkoschuc@2424
    46
     */
mkoschuc@2424
    47
    public void addNewIsaString(String isa) {
mkoschuc@2424
    48
        isa_strings_.add(isa);
mkoschuc@2424
    49
    }
mkoschuc@2424
    50
mkoschuc@2424
    51
    public String toString() {
mkoschuc@2424
    52
        String content = "<TERMLIST>";
mkoschuc@2424
    53
        for (int index = 0; index < isa_strings_.size(); index++)
mkoschuc@2424
    54
            content += "<MATHML>\n<ISA>\n" + isa_strings_.get(index)
mkoschuc@2424
    55
                    + "\n</ISA>\n</MATHML>\n";
mkoschuc@2424
    56
mkoschuc@2424
    57
        if (spec_ != null) {
mkoschuc@2424
    58
            content += spec_;
mkoschuc@2424
    59
        }
mkoschuc@2424
    60
        content += "</TERMLIST>\n";
mkoschuc@2424
    61
        return content;
mkoschuc@2424
    62
    }
mkoschuc@2424
    63
mkoschuc@2424
    64
    /**
mkoschuc@2424
    65
     * Format the object in a way that the bridge can handle it
mkoschuc@2424
    66
     * 
mkoschuc@2424
    67
     * @return SML representation of this Variant
mkoschuc@2424
    68
     */
mkoschuc@2424
    69
    public String toSMLString() {
mkoschuc@2424
    70
        StringBuffer sb = new StringBuffer();
mkoschuc@2424
    71
mkoschuc@2424
    72
        int size = isa_strings_.size();
mkoschuc@2424
    73
        sb.append("[");
mkoschuc@2424
    74
        for (int i = 0; i < size; i++) {
mkoschuc@2424
    75
            sb.append("\"" + (String) isa_strings_.get(i) + "\"");
mkoschuc@2424
    76
            if (i < size - 1) sb.append(", ");
mkoschuc@2424
    77
        }
mkoschuc@2424
    78
        sb.append("],");
mkoschuc@2424
    79
        sb.append("(" + spec_.toSMLString() + ")");
mkoschuc@2424
    80
        return sb.toString();
mkoschuc@2424
    81
    }
wneuper@4708
    82
    /**
wneuper@4708
    83
     * Format the object in a way that libisabelle/PIDE can handle it
wneuper@4708
    84
     * @return XML representation of this Variant
wneuper@4708
    85
     */
walther@5239
    86
    // conversion is done in Scala, because it is much simpler there
wneuper@4708
    87
    public XML.Tree toXML() {
wneuper@4758
    88
    	return DataTypes.xml_of_Variant(this);
wneuper@4708
    89
    }
mkoschuc@2424
    90
mkoschuc@2424
    91
    public void setSpecification(Specification spec) {
mkoschuc@2424
    92
        this.spec_ = spec;
mkoschuc@2424
    93
    }
mkoschuc@2424
    94
mkoschuc@2424
    95
    public Specification getSpecification() {
mkoschuc@2424
    96
        return spec_;
mkoschuc@2424
    97
    }
wneuper@4725
    98
    public ArrayList<String> getIsaStrings() {
wneuper@4725
    99
        return isa_strings_;
wneuper@4725
   100
    }
mkoschuc@2424
   101
walther@5239
   102
}