1 36 package org.columba.ristretto.composer; 37 38 import java.io.InputStream ; 39 import java.nio.ByteBuffer ; 40 import java.util.Random ; 41 42 import org.columba.ristretto.coder.Base64; 43 import org.columba.ristretto.message.MimePart; 44 45 46 54 public abstract class MimePartRenderer { 55 private static final int BOUNDARY_LENGTH = 32; 56 57 private static Random random = new Random (); 58 59 60 71 public abstract String getRegisterString(); 72 73 74 81 public abstract InputStream render(MimePart part) throws Exception ; 82 83 84 89 protected CharSequence createUniqueBoundary() { 90 byte[] bytes = new byte[BOUNDARY_LENGTH]; 91 random.nextBytes(bytes); 92 93 return Base64.encode( ByteBuffer.wrap(bytes) ); 94 } 95 96 } 97 | Popular Tags |