src/java/isac/util/formulae/CalcHead.java
changeset 1311 9f8179a0c170
child 1336 14874fd7d984
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/java/isac/util/formulae/CalcHead.java	Tue Jan 27 09:17:56 2004 +0100
     1.3 @@ -0,0 +1,222 @@
     1.4 +/*
     1.5 + * Created on Sep 11, 2003
     1.6 + */
     1.7 +package isac.util.formulae;
     1.8 +
     1.9 +import isac.util.Specification;
    1.10 +
    1.11 +/**
    1.12 + * @author isac
    1.13 + * Every calculation has a CalcHead, which consists of 
    1.14 + * Model and Specification of the calculation
    1.15 + * The CalcHead is empty at the beginning of the Specifying-phase
    1.16 + * and has to be filled before one can start
    1.17 + * the solving phase.
    1.18 + */
    1.19 +public class CalcHead extends CalcElement {
    1.20 +
    1.21 +  /**
    1.22 +   * Labels a CalcHead element as "correct"
    1.23 +   */
    1.24 +  public static final int CALCHEAD_CORRECT = 1;
    1.25 +
    1.26 +  /**
    1.27 +   * Labels a CalcHead element as "incorrect"
    1.28 +   */
    1.29 +  public static final int CALCHEAD_INCORRECT = 2;
    1.30 +
    1.31 +  /**
    1.32 +   * Labels a CalcHead element as "syntax error"
    1.33 +   */
    1.34 +  public static final int CALCHEAD_SYNTAXERROR = 3;
    1.35 +
    1.36 +  /**
    1.37 +   * Labels a CalcHead element as "incomplete"
    1.38 +   */
    1.39 +  public static final int CALCHEAD_INCOMPLETE = 4;
    1.40 +  
    1.41 +  /**
    1.42 +   * Labels a CalcHead element as "false"
    1.43 +   */
    1.44 +  public static final int CALCHEAD_FALSE = 5;
    1.45 +  
    1.46 +  /**
    1.47 +	* Labels a CalcHead element as to be filled in by the KI
    1.48 +	*/
    1.49 +  public static final int CALCHEAD_HELP_ME = 6;
    1.50 +  
    1.51 +  /**
    1.52 +	  * Labels a CalcHead element as superfluous
    1.53 +	  */
    1.54 +	public static final int CALCHEAD_SUPERFLUOUS = 7;
    1.55 +	
    1.56 +	/**
    1.57 +	  * Labels a CalcHead element as missing
    1.58 +	  */
    1.59 +	public static final int CALCHEAD_MISSING = 8;
    1.60 +	
    1.61 +	
    1.62 +  
    1.63 +  public static final int VIEWSTYLE_FULL = 2;
    1.64 +  public static final int VIEWSTYLE_SIMPLE_SOLVE = 3;
    1.65 + 
    1.66 +  private int calcTreeID = -4711; 
    1.67 +  
    1.68 +  private CalcHeadItemList given_, where_, find_, relate_;
    1.69 +  private Specification specification;
    1.70 +  private Position position;
    1.71 +  private String belongsTo;
    1.72 +  private String head; 
    1.73 +  
    1.74 +  private int calcHeadStatus;
    1.75 +  
    1.76 + 
    1.77 +  
    1.78 +
    1.79 +  /** Format the object in a way that the bridge can handle it 
    1.80 +   *  @return SML representation
    1.81 +   */
    1.82 +  public String toSMLString() {
    1.83 +  	//this should go to Formalization
    1.84 +    StringBuffer sb = new StringBuffer();
    1.85 +    sb.append("[([");
    1.86 +    if (getGiven() != null) {
    1.87 +      sb.append(getGiven().toSMLString());
    1.88 +    }
    1.89 +    if (getWhere() != null) {
    1.90 +      sb.append(",");
    1.91 +      sb.append(getWhere().toSMLString());
    1.92 +    }
    1.93 +    if (getFind() != null) {
    1.94 +      sb.append(",");
    1.95 +      sb.append(getFind().toSMLString());
    1.96 +    }
    1.97 +    if (getRelate() != null) {
    1.98 +      sb.append(",");
    1.99 +      sb.append(getRelate().toSMLString());
   1.100 +    }
   1.101 +    sb.append("],(");
   1.102 +    if (getSpecification() != null) {
   1.103 +      sb.append(specification.toSMLString());
   1.104 +    }
   1.105 +    sb.append("))]");
   1.106 +    return sb.toString();
   1.107 +  }
   1.108 +
   1.109 +  public String toSMLString2() {  	
   1.110 +  	//TODO FIXXXME hack to make checkCalcHead work
   1.111 +  	belongsTo = "Pbl";
   1.112 +  	
   1.113 +    StringBuffer sb = new StringBuffer();
   1.114 +    sb.append("((");
   1.115 +    sb.append(position.toSMLString());
   1.116 +    sb.append("),\"");
   1.117 +    sb.append(head);
   1.118 +    sb.append("\",[Given [");
   1.119 +    sb.append(given_.toSMLString());
   1.120 +    sb.append("],Find [");
   1.121 +    sb.append(find_.toSMLString());
   1.122 +    sb.append("],Relate [");
   1.123 +    sb.append(relate_.toSMLString());
   1.124 +    sb.append("]],"+belongsTo+",(");
   1.125 +    sb.append(specification.toSMLString());
   1.126 +    sb.append("))");    
   1.127 +    return sb.toString();
   1.128 +  }
   1.129 +
   1.130 +  /* (non-Javadoc)
   1.131 +   * @see isac.util.CalcElement#getMathML()
   1.132 +   */
   1.133 +  public String getMathML() {
   1.134 +    // TODO Auto-generated method stub
   1.135 +    return null;
   1.136 +  }
   1.137 +
   1.138 +  /* (non-Javadoc)
   1.139 +   * @see isac.util.CalcElement#getType()
   1.140 +   */
   1.141 +  public int getType() {
   1.142 +    return CALCEL_CALCHEAD;
   1.143 +  }
   1.144 +
   1.145 +  public CalcHeadItemList getFind() {
   1.146 +    return find_;
   1.147 +  }
   1.148 +
   1.149 +  public CalcHeadItemList getGiven() {
   1.150 +    return given_;
   1.151 +  }
   1.152 +
   1.153 +  public CalcHeadItemList getRelate() {
   1.154 +    return relate_;
   1.155 +  }
   1.156 +
   1.157 +  public CalcHeadItemList getWhere() {
   1.158 +    return where_;
   1.159 +  }
   1.160 +
   1.161 +  public void setFind(CalcHeadItemList el) {
   1.162 +    find_ = el;
   1.163 +  }
   1.164 +
   1.165 +  public void setGiven(CalcHeadItemList el) {
   1.166 +    given_ = el;
   1.167 +  }
   1.168 +
   1.169 +  public void setRelate(CalcHeadItemList el) {
   1.170 +    relate_ = el;
   1.171 +  }
   1.172 +
   1.173 +  public void setWhere(CalcHeadItemList el) {
   1.174 +    where_ = el;
   1.175 +  }
   1.176 +
   1.177 +  public Specification getSpecification() {
   1.178 +    return specification;
   1.179 +  }
   1.180 +
   1.181 +  public void setSpecification(Specification specification) {
   1.182 +    this.specification = specification;
   1.183 +  }
   1.184 +
   1.185 +  public Position getPosition() {
   1.186 +    return position;
   1.187 +  }
   1.188 +
   1.189 +  public void setPosition(Position position) {
   1.190 +    this.position = position;
   1.191 +  }
   1.192 +
   1.193 +  public String getBelongsTo() {
   1.194 +    return belongsTo;
   1.195 +  }
   1.196 +
   1.197 +  public void setBelongsTo(String string) {
   1.198 +    belongsTo = string;	
   1.199 +  }
   1.200 +
   1.201 +  public String getHead() {
   1.202 +    return head;    
   1.203 +  }
   1.204 +
   1.205 +  public void setHead(String string) {
   1.206 +    head = string;
   1.207 +  }
   1.208 + 
   1.209 +  public int getCalcTreeID() {
   1.210 +    return calcTreeID;
   1.211 +  }
   1.212 +
   1.213 +  public void setCalcTreeID(int id) {
   1.214 +    calcTreeID = id;
   1.215 +  }
   1.216 +  
   1.217 +  public int getCalcHeadStatus() {
   1.218 +    return calcHeadStatus;
   1.219 +  }
   1.220 +
   1.221 +  public void setCalcHeadStatus(int i) {
   1.222 +    calcHeadStatus = i;
   1.223 +  }
   1.224 +
   1.225 +}