Coverage report

| %line | %branch
--- | --- | ---
com.ozacc.mail.fetch.impl.sk_jp.io.UnicodeCorrector |
0% |
0% |

1 |  |
     /*
2 |  |
      * @(#) $Id: UnicodeCorrector.java,v 1.1.2.1 2005/01/18 07:20:36 otsuka Exp $
3 |  |
      * $Revision: 1.1.2.1 $
4 |  |
      * Copyright (c) 2000 Shin Kinoshita All Rights Reserved.
5 |  |
      */
6 |  |
     package com.ozacc.mail.fetch.impl.sk_jp.io;
7 |  |
8 |  |
     import java.io.UnsupportedEncodingException;
9 |  |
     import java.util.HashMap;
10 |  |
     import java.util.Map;
11 |  |
12 |  |
     /**
13 |  |
      * UnicodeCorrector.
14 |  |
      * <p>
15 |  |
      * CorrectOutputStreamWriter¤ÇÍÑ¤¤¤é¤?¤?Ê¸»úÎó¥Ð¥Ã¥Õ¥¡ÊäÀµ¥¯¥é¥¹¤Ç¤¹¡£<br>
16 |  |
      * ½ÐÎÏ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ë¤è¤Ã¤ÆÊäÀµ¤¹¤Ù¤Ê¸»ú¥³¡¼¥É¤¬°Û¤Ê¤?¤Î¤Ç¡¢
17 |  |
      * ¼ÂºÝ¤ÎÊäÀµ½èÍ?¤Ï¥µ¥Ö¥¯¥é¥¹¤Ç¹Ô¤¤¤Þ¤¹¡£<br>
18 |  |
      *
19 |  |
      * ÂÐ±?¤·¤Æ¤¤¤?¤Î¤Ï°Ê²¼¤Î¥³¥ó¥Ð¡¼¥¿Ì¾¤Ç¤¹¡£
20 |  |
      * </p>
21 |  |
      * <UL>
22 |  |
      * <LI>ISO2022JP
23 |  |
      * <LI>ISO-2022-JP
24 |  |
      * <LI>EUC-JP
25 |  |
      * <LI>EUCJIS
26 |  |
      * <LI>SJIS
27 |  |
      * <LI>Shift_JIS
28 |  |
      * <LI>MS932
29 |  |
      * <LI>Windows-31J
30 |  |
      * </UL>
31 |  |
      * @author Shin
32 |  |
      * @version $Revision: 1.1.2.1 $ $Date: 2005/01/18 07:20:36 $
33 |  |
      */
34 | 0 |
     public abstract class UnicodeCorrector {
35 | 0 |
         private static final Map correctorMap = new HashMap();
36 |  |
         static {
37 |  |
             // x-sjis-cp932Åù¤Ç¤ª¤«¤·¤¯ÊÑ´¹¤µ¤?¤¿Unicode¤òÂ¾¤Î¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ç
38 |  |
             // ½ÐÎÏ¤¹¤?¾?¹ç¤Ç¤¹
39 | 0 |
             correctorMap.put("iso2022jp", FromCP932Corrector.class);
40 | 0 |
             correctorMap.put("iso-2022-jp", FromCP932Corrector.class);
41 | 0 |
             correctorMap.put("euc-jp", FromCP932Corrector.class);
42 | 0 |
             correctorMap.put("eucjis", FromCP932Corrector.class);
43 |  |
             // Æ±¤¸"SJIS"¤Ç¤âSun¤ÈMS-VM¤Ç¤Ï°Û¤Ê¤ê¤Þ¤¹¡£
44 |  |
             // Sun-JDK1.1¤ÏSJIS¤Ïx-sjis-jdk-1.1.7¤Ç¡¢MS-VM¤Ïx-sjis-cp932¤Ç¤¹¡£
45 |  |
             // ¤·¤«¤·¡¢MS-JDKÃæ¤Î¥¯¥é¥¹¥é¥¤¥Ö¥é¥ê¤À¤±¤Ïx-sjis-jdk-1.1.7Á?Åö¤Ë¤Ê¤?¤Î¤Ç
46 |  |
             // º¤¤Ã¤¿¤â¤Î¤Ç¤¹¡£(¥Õ¥¡¥¤¥?½ñ¤½Ð¤·Åù¤Î¤È¤¤Î¤ß¤ª¤«¤·¤¯¤Ê¤?)
47 |  |
             // ¤³¤?¤ÏWindows¥Í¥¤¥Æ¥£¥Ö¤ÊÊÑ´¹É½¤ÇÀ¸À®¤µ¤?¤¿Unicode¤?
48 |  |
             // x-sjis-jdk-1.1.7¤Ç½ÐÎÏ¤¹¤?¤¿¤á¤Î¤â¤Î¤Ç¤¹¡£
49 | 0 |
             correctorMap.put("sjis", FromCP932Corrector.class);
50 | 0 |
             correctorMap.put("shift_jis", FromCP932Corrector.class);
51 |  |
             // MS-VM¤Ç¥Õ¥¡¥¤¥?½ÐÎÏ¤ò¹Ô¤¦¾?¹ç¤Ë¸Â¤ê¡¢¤³¤Á¤é¤Ç¤Ê¤±¤?¤Ð¤Ê¤ê¤Þ¤»¤ó¡£
52 |  |
             //      correctorMap.put("sjis", ToCP932Corrector.class);
53 |  |
             // JDK1.2¤«¤é¤ÏWindows¤Î¥Ç¥Õ¥©¥?¥È¤¬"MS932"(x-sjis-cp932Á?Å?)¤È¤Ê¤ê¤Þ¤·¤¿¡£
54 |  |
             // ¤³¤?¤Ç¡¢Â¾¤Î¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤ÇÊÑ´¹¤µ¤?¤¿(Àµ¤·¤¤)Unicode¤¬"ms932"
55 |  |
             // ¤Ç¤Î½ÐÎÏ»?¤Ë¤ª¤«¤·¤¯¤Ê¤Ã¤Æ¤·¤Þ¤¤¤Þ¤¹¡£
56 |  |
             // ¤³¤?¤òÊäÀµ¤·¤Þ¤¹¡£
57 | 0 |
             correctorMap.put("ms932", ToCP932Corrector.class);
58 | 0 |
             correctorMap.put("windows-31j", ToCP932Corrector.class);
59 |  |
         }
60 |  |
61 |  |
         /**
62 |  |
          * Create an UnicodeCorrector that uses
63 |  |
          * the named character encoding.
64 |  |
          * @param  enc  Name of the encoding to be used
65 |  |
          * @exception  UnsupportedEncodingException
66 |  |
          *             If the named encoding is not supported
67 |  |
          */
68 |  |
         public static UnicodeCorrector getInstance(String enc)
69 |  |
                 throws UnsupportedEncodingException {
70 | 0 |
             Class correctorClass = (Class)correctorMap.get(enc.toLowerCase());
71 | 0 |
             if (correctorClass == null) {
72 | 0 |
                 throw new UnsupportedEncodingException(enc);
73 |  |
             }
74 |  |
             try {
75 | 0 |
                 return (UnicodeCorrector)correctorClass.newInstance();
76 | 0 |
             } catch (Exception e) {
77 | 0 |
                 throw new UnsupportedEncodingException(
78 | 0 |
                         correctorClass + " cannot get newInstance.\n" + e);
79 |  |
             }
80 |  |
         }
81 |  |
82 |  |
         /**
83 |  |
          * UnicodeÊ¸»úÇÛÎó¤ÎÊäÀµ¤ò¹Ô¤¤¤Þ¤¹¡£
84 |  |
          * <p>
85 |  |
          * ÆÃÄê¤ÎÊ¸»ú¤òÆÃÄ?¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ç½ÐÎÏ¤·¤è¤¦¤È¤·¤¿ºÝ¤Î
86 |  |
          * sun.io¥³¥ó¥Ð¡¼¥¿¤Ç¤ÏÀµ¾?¤ËÊÑ´¹¤Ç¤¤Ê¤¤ÉôÊ¬¤òÊäÀµ¤·¤Þ¤¹¡£
87 |  |
          * </p>
88 |  |
          * @param  cbuf  Buffer of characters
89 |  |
          * @param  off   Offset from which to start writing characters
90 |  |
          * @param  len   Number of characters to write
91 |  |
          * @return Result that corrected.
92 |  |
          *         Note:Return array is different from <code>cbuf</code>
93 |  |
          *              in case of different result size.
94 |  |
          */
95 |  |
         public char[] correct(class="keyword">char cbuf[], int off, int len) {
96 | 0 |
             StringBuffer buf = new StringBuffer();
97 | 0 |
             for (int i = off; i < len; i++) {
98 | 0 |
                 buf.append(correct(cbuf[i]));
99 |  |
             }
100 | 0 |
             return new String(buf).toCharArray();
101 |  |
         }
102 |  |
103 |  |
         public String correct(String s) {
104 | 0 |
             StringBuffer buf = new StringBuffer();
105 | 0 |
             for (int i = 0; i < s.length(); i++) {
106 | 0 |
                 buf.append(correct(s.charAt(i)));
107 |  |
             }
108 | 0 |
             return new String(buf);
109 |  |
         }
110 |  |
111 |  |
         // ÀÇ½Åª¤Ë¤³¤?¤òabstract¤Ë¤¹¤?¤Î¤Ï¤¿¤á¤é¤Ã¤¿¤¬¡¦¡¦¡¦
112 |  |
         public abstract char correct(class="keyword">char c);
113 |  |
114 |  |
         /**
115 |  |
          * ¿·¤·¤¤UnicodeCorrector¤òÄÉ²Ã¤·¤Þ¤¹¡£
116 |  |
          * <p>
117 |  |
          * ¤³¤Î¥½¡¼¥¹¥³¡¼¥É¤òÊÑ¤¨¤º¤Ë¡¢Æ°Åª¤Ë¿·¤¿¤Ê½ÐÎÏ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ë
118 |  |
          * ÂÐ±?¤·¤¿UnicodeCorrector¤òÅÐÏ¿¤·¤¿¤¤¾?¹ç¤ËÍÑ¤¤¤Þ¤¹¡£
119 |  |
          * </p>
120 |  |
          * @param enc ÂÐ±?¤¹¤?¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°Ì¾
121 |  |
          * @param correctorClass UnicodeCorrector¥µ¥Ö¥¯¥é¥¹¤ÎClass¥ª¥Ö¥¸¥§¥¯¥È
122 |  |
          */
123 |  |
         public static void addCorrector(String enc, Class correctorClass) {
124 | 0 |
             if (!correctorClass.isInstance(UnicodeCorrector.class)) {
125 | 0 |
                 throw new IllegalArgumentException(
126 | 0 |
                         "Corrector is not UnicodeCorrector type.");
127 |  |
             }
128 | 0 |
             correctorMap.put(enc, correctorClass);
129 | 0 |
         }
130 |  |
     }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.