1 23 24 package org.apache.slide.projector.value; 25 26 import java.io.IOException ; 27 import java.util.logging.Level ; 28 import java.util.logging.Logger ; 29 30 import org.apache.slide.projector.util.StreamHelper; 31 32 import de.zeigermann.xml.XMLEncode; 33 import de.zeigermann.xml.XMLStringWriter; 34 import de.zeigermann.xml.XMLWriter; 35 36 40 public abstract class AbstractStreamableValue implements StreamableValue, PrintableValue { 41 private static Logger logger = Logger.getLogger(AbstractStreamableValue.class.getName()); 42 43 public StringBuffer print(StringBuffer buffer) { 44 try { 45 return buffer.append(StreamHelper.streamToString(this)); 46 } catch ( IOException exception ) { 47 logger.log(Level.SEVERE, "Exception while streaming value", exception); 48 return buffer; 49 } 50 } 51 52 public void save(XMLStringWriter writer) { 53 try { 54 writer.writeElementWithPCData(XMLWriter.createStartTag("value"), XMLEncode.xmlEncodeText(StreamHelper.streamToString(this)), XMLWriter.createEndTag("value")); 55 } catch (IOException e) { 56 writer.writeEmptyElement(XMLWriter.createEmptyTag("value")); 57 } 58 } 59 } 60 | Popular Tags |