1 50 51 package org.openlaszlo.iv.flash.api; 52 53 import java.io.*; 54 import java.lang.reflect.Constructor ; 55 import org.openlaszlo.iv.flash.util.*; 56 57 71 public abstract class FlashItem { 72 73 78 public abstract void write( FlashOutput fob ); 79 80 86 public abstract void printContent( PrintStream out, String indent ); 87 88 97 protected FlashItem copyInto( FlashItem item, ScriptCopier copier ) { 98 return item; 99 } 100 101 108 public FlashItem getCopy( ScriptCopier copier ) { 109 try { 110 Constructor c = getClass().getConstructor( new Class [] {} ); 111 FlashItem o = (FlashItem) c.newInstance( new Object [] {} ); 112 return copyInto( o, copier ); 113 } catch( Exception e ) { 114 return null; 115 } 116 } 117 118 public String toString() { 119 ByteArrayOutputStream bos = new ByteArrayOutputStream(); 120 PrintStream ps = new PrintStream(bos); 121 printContent(ps, ""); 122 ps.flush(); 123 return bos.toString(); 124 } 125 } 126 127 | Popular Tags |