1 7 8 package org.enhydra.oyster.test; 9 10 import org.enhydra.oyster.exception.SMIMEException; 11 import java.io.ByteArrayInputStream ; 12 import java.io.File ; 13 import java.io.IOException ; 14 import java.io.UnsupportedEncodingException ; 15 import org.enhydra.oyster.util.ConvertAssist; 16 17 22 public class ExampleGenerator 23 { 24 25 28 private String yellow = null; 29 30 33 private String orange = null; 34 35 38 private String blue = null; 39 40 43 private String green = null; 44 45 48 private String red = null; 49 50 53 private int[] pic = { 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 54 0x19, 0x00, 0x19, 0x00, 0xb3, 0x00, 0x00, 0x00, 0x66, 55 0x33, 0x00, 0x99, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff, 56 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 57 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 58 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 59 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 60 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x19, 61 0x00, 0x00, 0x04, 0x3f, 0x30, 0x00, 0x20, 0xe9, 0xac, 62 0xf8, 0x6a, 0x9b, 0xad, 0xef, 0x60, 0x20, 0x8e, 0x64, 63 0x69, 0x92, 0x1b, 0x98, 0xae, 0xea, 0xb7, 0x7e, 0x67, 64 0x2c, 0xb7, 0x34, 0xfb, 0xd6, 0xf0, 0xac, 0x8f, 0x77, 65 0xef, 0xe2, 0xc0, 0x9d, 0xd0, 0x07, 0x74, 0x19, 0x83, 66 0x42, 0x1d, 0x71, 0x59, 0x3c, 0x5e, 0x92, 0x4a, 0xa7, 67 0x34, 0xd3, 0xa4, 0x41, 0x67, 0xcb, 0xa9, 0x76, 0x7b, 68 0xc5, 0x72, 0x6f, 0x11, 0x00, 0x3b }; 69 70 81 public void setResourceInExampleHtml(String name0, String value0) { 82 if(name0.equalsIgnoreCase("RED")) 83 red = new String (value0); 84 else if(name0.equalsIgnoreCase("BLUE")) 85 blue = new String (value0); 86 else if(name0.equalsIgnoreCase("GREEN")) 87 green = new String (value0); 88 else if(name0.equalsIgnoreCase("YELLOW")) 89 yellow = new String (value0); 90 else if(name0.equalsIgnoreCase("ORANGE")) 91 orange = new String (value0); 92 } 93 94 98 public String getHtmlString() { 99 100 if(red == null) 101 red = "./pictures/red.gif"; 102 if(blue == null) 103 blue = "./pictures/blue.gif"; 104 if(green == null) 105 green = "./pictures/green.gif"; 106 if(yellow == null) 107 yellow = "./pictures/yellow.jpg"; 108 if(orange == null) 109 orange = "./pictures/orange.jpg"; 110 111 return 112 "<html>" + "\r\n" + 113 "<head>" + "\r\n" + 114 "<meta http-equiv=\"Content-Language\" content=\"hr\">" + "\r\n" + 115 "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1250\">" + "\r\n" + 116 "<title>Test Page</title>" + "\r\n" + 117 "</head>" + "\r\n" + 118 "<body background=\"" + yellow + "\">" + "\r\n" + 119 "<p align=\"center\"><font color=\"#800080\" size=\"6\">HTML test for SMIME project</font></p>" + "\r\n" + 120 "<hr>" + "\r\n" + 121 "<p><b>Ordered and unordered lists:</b></p>" + "\r\n" + 122 "<ul>" + "\r\n" + 123 " <li><b>Text a</b>" + "\r\n" + 124 " <ol>" + "\r\n" + 125 " <li><b>No 1</b></li>" + "\r\n" + 126 " <li><b>No 2</b></li>" + "\r\n" + 127 " <li><b>No 3</b></li>" + "\r\n" + 128 " </ol></li>" + "\r\n" + 129 " <li><b>Text b</b></li>" + "\r\n" + 130 " <li><b>Text c</b></li>" + "\r\n" + 131 "</ul>" + "\r\n" + 132 "<div align=\"center\">" + "\r\n" + 133 " <center>" + "\r\n" + 134 " <table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\" align=\"left\" height=\"100\">" + "\r\n" + 135 " <tr>" + "\r\n" + 136 " <td background=\"" + orange + "\" width=\"275\"><b>Table1 Row1 Column1</b></td>" + "\r\n" + 137 " <td background=\"" + green + "\" width=\"275\"><b>Table1 Row1 Column2</b></td>" + "\r\n" + 138 " <td background=\"" + orange + "\" width=\"275\"><b>Table1 Row1 Column3</b></td>" + "\r\n" + 139 " </tr>" + "\r\n" + 140 " <tr>" + "\r\n" + 141 " <td background=\"" + green + "\" width=\"275\"><b>Table1 Row1 Column2</b></td>" + "\r\n" + 142 " <td background=\"" + orange + "\" width=\"275\"><b>Table1 Row2 Column2</b></td>" + "\r\n" + 143 " <td background=\"" + green + "\" width=\"275\"><b>Table1 Row2 Column3</b></td>" + "\r\n" + 144 " </tr>" + "\r\n" + 145 " </table>" + "\r\n" + 146 " </center>" + "\r\n" + 147 "</div>" + "\r\n" + 148 "<p> </p>" + "\r\n" + 149 "<p> </p>" + "\r\n" + 150 "<p> </p>" + "\r\n" + 151 "<br><br>" + "\r\n" + 152 "<p>" + "\r\n" + 153 "<b>Specijal characters:&, ©, >, <, ®, ±, ä, Ä, ë, Ë, ö, Ö, ß </b>" + "\r\n" + 154 "</p>" + "\r\n" + 155 "<br><br>" + "\r\n" + 156 "<div align=\"center\">" + "\r\n" + 157 " <center>" + "\r\n" + 158 " <table border=\"0\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\" align=\"left\">" + "\r\n" + 159 " <tr>" + "\r\n" + 160 " <td width=\"165\" bgcolor=\"#FFFFFF\"><b><img border=\"0\" SRC=\"" + blue + "\" width=\"25\" height=\"25\">" + "\r\n" + 161 " Picture1</b></td>" + "\r\n" + 162 " <td width=\"165\" bgcolor=\"#FFFFFF\"><b><img border=\"0\" SRC=\"" + green + "\" width=\"25\" height=\"25\">" + "\r\n" + 163 " Picture2</b></td>" + "\r\n" + 164 " <td width=\"165\" bgcolor=\"#FFFFFF\"><b><img border=\"0\" SRC=\"" + orange + "\" width=\"25\" height=\"25\">" + "\r\n" + 165 " Picture3</b></td>" + "\r\n" + 166 " <td width=\"166\" bgcolor=\"#FFFFFF\"><b><img border=\"0\" SRC=\"" + red + "\" width=\"25\" height=\"25\">" + "\r\n" + 167 " Picture4</b></td>" + "\r\n" + 168 " <td width=\"166\" bgcolor=\"#FFFFFF\"><b><img border=\"0\" SRC=\"" + yellow + "\" width=\"25\" height=\"25\">" + "\r\n" + 169 " Picture5</b></td>" + "\r\n" + 170 " </tr>" + "\r\n" + 171 " </table>" + "\r\n" + 172 " </center>" + "\r\n" + 173 "</div>" + "\r\n" + 174 "</body>" + "\r\n" + 175 "</html>"; 176 } 177 178 182 public ByteArrayInputStream getHtmlStream() throws UnsupportedEncodingException { 183 184 ByteArrayInputStream bais = new ByteArrayInputStream ( 185 getHtmlString().getBytes("ISO-8859-1")); 186 return bais; 187 } 188 189 190 194 public ByteArrayInputStream getZipStream() throws IOException , SMIMEException { 195 196 File zip = new File ("./test/Zip8Test1.zip"); 197 198 return new ByteArrayInputStream ( ConvertAssist.fileToByteArray(zip) ); 199 } 200 201 202 206 public ByteArrayInputStream getGifImage() { 207 208 byte[] temp = new byte[pic.length]; 209 for(int i=0; i!=pic.length; i++) 210 temp[i] = (byte)pic[i]; 211 return new ByteArrayInputStream (temp); 212 } 213 214 } | Popular Tags |