| 1 | // |
| 2 | // (c) Copyright, Moebius Solutions, 2002 |
| 3 | // |
| 4 | // All Rights Reserved |
| 5 | // |
| 6 | // This material may be reproduced by or for the U. S. Government |
| 7 | // pursuant to the copyright license under the clause at |
| 8 | // DFARS 252.227-7013 (OCT 1988). |
| 9 | // |
| 10 | /* |
| 11 | * $Id: ValuePrinter.java,v 1.1.1.5 2004/05/25 20:23:30 hastings Exp $ |
| 12 | */ |
| 13 | package com.moesol.generator.printer; |
| 14 | |
| 15 | import java.io.*; |
| 16 | |
| 17 | /** |
| 18 | * Print the value of an object. For primitive and array types |
| 19 | * subclasses print the value suitable for their language. |
| 20 | */ |
| 21 | public abstract class ValuePrinter { |
| 22 | public abstract void print(Object value, Writer out) throws IOException; |
| 23 | public String toString(Object value) { |
| 24 | try { |
| 25 | StringWriter sw = new StringWriter(); |
| 26 | print(value, sw); |
| 27 | return sw.toString(); |
| 28 | } catch (IOException e) { |
| 29 | throw new RuntimeException(e); |
| 30 | } |
| 31 | } |
| 32 | } |