1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
package com.ozacc.mail.fetch.impl.sk_jp; |
7 |
|
|
8 |
|
import java.io.ByteArrayInputStream; |
9 |
|
import java.io.IOException; |
10 |
|
import java.io.InputStream; |
11 |
|
import java.io.OutputStream; |
12 |
|
import java.io.UnsupportedEncodingException; |
13 |
|
|
14 |
|
import javax.activation.DataSource; |
15 |
|
|
16 |
|
import com.ozacc.mail.fetch.impl.sk_jp.io.CharCodeConverter; |
17 |
|
import com.ozacc.mail.fetch.impl.sk_jp.io.UnicodeCorrector; |
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
public class JISDataSource implements DataSource { |
23 |
|
|
24 |
|
private byte[] data; |
25 |
|
|
26 |
0 |
public JISDataSource(String s) { |
27 |
|
try { |
28 |
0 |
data = CharCodeConverter.sjisToJis(UnicodeCorrector.getInstance("Windows-31J").correct( |
29 |
0 |
s).getBytes("Windows-31J")); |
30 |
0 |
} catch (UnsupportedEncodingException e) { |
31 |
0 |
throw new RuntimeException("CANT HAPPEN"); |
32 |
|
} |
33 |
0 |
} |
34 |
|
|
35 |
|
public String getContentType() { |
36 |
0 |
return "text/plain; charset=ISO-2022-JP"; |
37 |
|
} |
38 |
|
|
39 |
|
public InputStream getInputStream() throws IOException { |
40 |
0 |
if (data == null) |
41 |
0 |
throw new IOException("no data"); |
42 |
0 |
return new ByteArrayInputStream(data); |
43 |
|
} |
44 |
|
|
45 |
|
public OutputStream getOutputStream() throws IOException { |
46 |
0 |
throw new IOException("cannot do this"); |
47 |
|
} |
48 |
|
|
49 |
|
public String getName() { |
50 |
0 |
return "dummy"; |
51 |
|
} |
52 |
|
} |