final Object[] row = new Object[max + 1];
if (operatorGraph == null) {
final LuposDocument document = new LuposDocument();
final LuposJTextPane textPane = new LuposJTextPane(document);
document.init(TurtleParser.createILuposParser(new LuposDocumentReader(document)), false);
textPane.setText(p.getName().toString(prefixInstance));
textPane.setEditable(false);
row[0] = textPane;
} else {
row[0] = p.getName().toString(prefixInstance);
}
int index = 1;
for (final Literal l : p.getParameters()) {
if (operatorGraph == null) {
final LuposDocument document = new LuposDocument();
final LuposJTextPane textPane = new LuposJTextPane(document);
document.init(TurtleParser.createILuposParser(new LuposDocumentReader(document)), false);
textPane.setText(l.toString(prefixInstance));
textPane.setEditable(false);
row[index++] = textPane;
} else {
row[index++] = l.toString(prefixInstance);
}
}
for (int i2 = index; i2 < max + 1; i2++) {
row[i2] = "";
}
rows[i++] = row;
}
tablesJTable[indexJTables++] = generateTable(rows, tableHead,
operatorGraph);
} else if (qr instanceof GraphResult) {
final GraphResult gr = (GraphResult) qr;
final String[] tableHead = { "Subject", "Predicate", "Object" };
final Object[][] rows = new Object[gr.getGraphResultTriples()
.size()][];
int i = 0;
for (final Triple t : gr.getGraphResultTriples()) {
if (operatorGraph == null) {
final LuposDocument documentSubject = new LuposDocument();
final LuposJTextPane textPaneSubject = new LuposJTextPane(documentSubject);
documentSubject.init(TurtleParser.createILuposParser(new LuposDocumentReader(documentSubject)), false);
textPaneSubject.setText(t.getSubject().toString(prefixInstance));
textPaneSubject.setEditable(false);
final LuposDocument documentPredicate = new LuposDocument();
final LuposJTextPane textPanePredicate = new LuposJTextPane(documentPredicate);
documentPredicate.init(TurtleParser.createILuposParser(new LuposDocumentReader(documentPredicate)), false);
textPanePredicate.setText(t.getPredicate().toString(prefixInstance));
textPanePredicate.setEditable(false);
final LuposDocument documentObject = new LuposDocument();
final LuposJTextPane textPaneObject = new LuposJTextPane(documentObject);
documentObject.init(TurtleParser.createILuposParser(new LuposDocumentReader(documentObject)), false);
textPaneObject.setText(t.getObject().toString(
prefixInstance));
textPaneObject.setEditable(false);
rows[i++] = new Object[] { textPaneSubject,
textPanePredicate, textPaneObject };
} else {
rows[i++] = new String[] {
t.getSubject().toString(prefixInstance),
t.getPredicate().toString(prefixInstance),
t.getObject().toString(prefixInstance) };
}
}
tablesJTable[indexJTables++] = generateTable(rows, tableHead,
operatorGraph);
} else {
final HashSet<Variable> variables = new HashSet<Variable>();
// get variables...
for (final Bindings ba : qr) {
variables.addAll(ba.getVariableSet());
}
// --- generate table head - begin ---
final String[] tableHead = new String[variables.size()];
int i = 0;
// result order is defined...
if (resultOrder != null && resultOrder.size() > 0) {
for (final String s : resultOrder) {
if (variables.contains(new Variable(s))) {
tableHead[i++] = "?" + s;
}
}
} else {
// result order is not defined...
for (final Variable v : variables) {
tableHead[i++] = v.toString();
}
}
// --- generate table head - end ---
// --- generate table rows - begin ---
final Object[][] rows = new Object[qr.size()][];
i = 0;
for (final Bindings ba : qr) {
final Object[] row = new Object[variables.size()];
int j = 0;
// result order is defined...
if (resultOrder != null && resultOrder.size() > 0) {
for (final String s : resultOrder) {
if (variables.contains(new Variable(s))) {
final Literal literal = ba.get(new Variable(s));
String value = "";
if (literal != null) {
value = literal.toString(prefixInstance);
}
if (operatorGraph == null) {
final LuposDocument document = new LuposDocument();
final LuposJTextPane textPane = new LuposJTextPane(document);
document.init(TurtleParser.createILuposParser(new LuposDocumentReader(document)), false);
textPane.setText(value);
textPane.setEditable(false);
row[j++] = textPane;
} else {
row[j++] = value;
}
}
}
} else { // result order is not defined...
for (final Variable variable : variables) {
final Literal literal = ba.get(variable);
String value = "";
if (literal != null) {
value = literal.toString(prefixInstance);
}
if (operatorGraph == null) {
final LuposDocument document = new LuposDocument();
final LuposJTextPane textPane = new LuposJTextPane(document);
document.init(TurtleParser.createILuposParser(new LuposDocumentReader(document)), false);
textPane.setText(value);
textPane.setEditable(false);
row[j++] = textPane;
} else {
row[j++] = value;
}