com.articulate.delphi.Table Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sigma-component Show documentation
Show all versions of sigma-component Show documentation
Sigma knowledge engineering system is an system for developing, viewing and debugging theories in first
order logic. It works with Knowledge Interchange Format (KIF) and is optimized for the Suggested Upper Merged
Ontology (SUMO) www.ontologyportal.org.
The newest version!
/** This code is copyright Articulate Software (c) 2005.
This software is released under the GNU Public License .
Users of this code also consent, by use of this code, to credit Articulate Software
and Ted Gordon in any writings, briefings, publications, presentations, or
other representations of any software which incorporates, builds on, or uses this
code. */
package com.articulate.delphi;
import java.util.*;
import java.io.*;
import java.text.*;
import com.articulate.sigma.*;
/** *****************************************************************
* A class that encrypts a string and checks it against another stored
* encrypted string, in order to validate a user login.
*/
public class Table {
/** The username who owns the table. */
public String username;
/** A HashMap of HashMap(s), which are the columns. The decision
* string are the keys of the rows and the criteria string are
* the keys of the columns. The interior HashMap(s) have
* integers of range 0-10 as their values, coded as Strings. */
public HashMap rows = new HashMap();
/** A HashMap of criteria string keys and string importance weight
* values, which are integers between 0 and 10, represented as Strings. */
public HashMap columnWeights = new HashMap();
/** *****************************************************************
*/
public void addRow(String text) {
if (rows.values().size() > 0) {
Iterator it = rows.keySet().iterator();
String decision = (String) it.next();
HashMap row = (HashMap) rows.get(decision);
HashMap newRow = new HashMap();
Iterator it2 = row.keySet().iterator();
while (it2.hasNext()) {
String key = new String((String) it2.next());
String value = new String((String) row.get(key));
newRow.put(key,"0");
}
rows.put(text,newRow);
}
else
rows.put(text,new HashMap());
}
/** *****************************************************************
*/
public void addColumn(String text) {
columnWeights.put(text,"0");
if (rows.values().size() > 0) {
Iterator it = rows.keySet().iterator();
while (it.hasNext()) {
String key = (String) it.next();
HashMap row = (HashMap) rows.get(key);
row.put(text,"0");
}
}
}
/** *****************************************************************
*/
public String printRecommendations() {
Pair[] recommendations = calculateRecommendations();
String best = recommendations[recommendations.length-1].str;
StringBuffer sb = new StringBuffer();
sb = sb.append("Best judgement: " + best + "");
if (recommendations.length > 1) {
sb = sb.append(" Other judgements, in order: ");
for (int i = 0; i < recommendations.length - 1 ; i++) {
sb = sb.append(recommendations[i].str);
if (i < recommendations.length - 2)
sb = sb.append(", ");
}
}
sb = sb.append("\n");
return sb.toString();
}
/** *****************************************************************
* Generate an HTML table from the "rows" variable in this class.
* If the option is for a readOnly table, just show the table values
* as text, otherwise, make them a menu with the stored value as the
* selected option.
*/
public String toHTML(boolean readOnly, String projectName, TableAverage average) {
ArrayList options = new ArrayList();
for (int i = 0; i < 11; i++) {
options.add(String.valueOf(i));
}
StringBuffer sb = new StringBuffer();
sb = sb.append("