### Question:
RipplePrintStream extends PrintStream { public void print(final Value v) throws RippleException { if (null == v) { throw new NullPointerException(); } if (v instanceof IRI) { printURI((IRI) v); } else if (v instanceof Literal) { printLiteral((Literal) v); } else if (v instanceof BNode) { print("_:"); print(((BNode) v).getID()); } else { print(v.toString()); } } RipplePrintStream(final OutputStream out, final Lexicon lexicon); void print(final Value v); void print(final Iterator<Statement> stmtIter); void printTypedLiteral(final String label, final IRI datatype); void printBoolean(final boolean v); void printInteger(final int v); void printDouble(final double v); void printDecimal(final BigDecimal v);  }### Answer:
@Test public void testLiterals() throws Exception { Model model = getTestModel(); ModelConnection mc = model.createConnection(); QueryEngine qe = new QueryEngine(model, null, System.out, System.err); ByteArrayOutputStream bos = new ByteArrayOutputStream(); RipplePrintStream ps = new RipplePrintStream(new PrintStream(bos), qe.getLexicon()); mc.setNamespace("xsd", "http: ps.print(42); assertEquals("42", bos.toString()); bos.reset(); ps.print(0); assertEquals("0", bos.toString()); bos.reset(); ps.print(-42); assertEquals("-42", bos.toString()); bos.reset(); ps.print(42.0); assertEquals("42.0", bos.toString()); bos.reset(); ps.print(0.0); assertEquals("0.0", bos.toString()); bos.reset(); ps.print(-42.0); assertEquals("-42.0", bos.toString()); bos.reset(); ps.print(true); assertEquals("true", bos.toString()); bos.reset(); ps.print(false); assertEquals("false", bos.toString()); bos.reset(); ps.close(); bos.close(); mc.close(); }