* @param stack the stack to print. May not be a nil list.
* @throws RippleException if something goes awry
*/
public void put(final RippleList stack) throws RippleException {
// Grab the topmost item on the stack.
RippleValue subject = stack.getFirst();
// View the list in right-to-left order
RippleList list = stack.invert();
String prefix = " [" + ++index + "]" + INDEX_SEPARATOR;
String prefixIndent = " ".substring(0, prefix.length());
printStream.print(prefix);
//printStream.print( "" + ++index + " ->" + INDEX_SEPARATOR );
//printStream.print( "rdf:_" + ++index + INDEX_SEPARATOR );
if (printEntireStack) {
list.printTo(printStream, false);
} else {
subject.printTo(printStream);
}
printStream.print("\n");
if (showEdges && !stack.isNil()) {
Collector<RippleValue> predicates = new Collector<RippleValue>();
helper.findPredicates(subject, predicates);
int predCount = 0;
for (Iterator<RippleValue> predIter = predicates.iterator();
predIter.hasNext(); ) {
printStream.print(prefixIndent);
printStream.print(INDENT);
// Stop after maxPredicates predicates have been displayed, unless
// maxPredicates < 0, which indicates an unlimited number of
// predicates.
if (maxPredicates >= 0 && ++predCount > maxPredicates) {
printStream.print("[...]\n");
break;
}
RippleValue predicate = predIter.next();
printStream.print(predicate);
printStream.print("\n");
Collector<RippleValue> objects = new Collector<RippleValue>();
StatementPatternQuery query = new StatementPatternQuery(subject, predicate, null);
modelConnection.query(query, objects, false);
int objCount = 0;
Collection<RippleValue> objColl;
if (deduplicateObjects) {
objColl = new HashSet<RippleValue>();
objColl.addAll(objects);
} else {
objColl = objects;
}
for (Iterator<RippleValue> objIter = objColl.iterator();
objIter.hasNext(); ) {
printStream.print(prefixIndent);
printStream.print(INDENT);
printStream.print(INDENT);
// Stop after maxObjects objects have been displayed, unless
// maxObjects < 0, which indicates an unlimited number of
// objects.
if (maxObjects >= 0 && ++objCount > maxObjects) {
printStream.print("[...]\n");
break;
}
RippleValue object = objIter.next();
printStream.print(object);
printStream.print((objIter.hasNext())
? ","
: (predIter.hasNext())
? ";" : ".");