Coverage report

| %line | %branch
--- | --- | ---
com.ozacc.mail.impl.Cp932 |
28% |
62% |

1 |  |
     package com.ozacc.mail.impl;
2 |  |
3 |  |
     import java.util.Locale;
4 |  |
5 |  |
     /**
6 |  |
      * The Cp932 class contains a utility method for converting Microsoft's
7 |  |
      * Cp 932 into JIS.
8 |  |
      * <p>
9 |  |
      * <strong>Ã?:</strong> ¤³¤Î¥¯¥é¥¹¤Ïpublic¤Ç¤¹¤¬¡¢ozacc-mail library³°¤«¤é¤Ï»ÈÍÑ¤·¤Ê¤¤¤Ç¤¯¤À¤µ¤¤¡£
10 |  |
      *
11 |  |
      * @author Kazuhiro Kazama
12 |  |
      * @version 1.0 01/06/97
13 |  |
      *
14 |  |
      * @since 1.0.2
15 |  |
      */
16 | 9 |
     public class Cp932 {
17 |  |
18 | 9 |
     	private static boolean isCp932 = false;
19 |  |
20 |  |
     	static {
21 | 9 |
     		String p = System.getProperty("iscp932");
22 | 9 |
     		String os = System.getProperty("os.name");
23 | 9 |
     		if (Locale.getDefault().getLanguage().equals("ja")) {
24 | 9 |
     			if (p != null && Boolean.getBoolean(p))
25 | 0 |
     				isCp932 = true;
26 | 9 |
     			else if (os != null && (os.startsWith("Win")))
27 | 9 |
     				isCp932 = true;
28 |  |
     		}
29 |  |
     	}
30 |  |
31 |  |
     	/*
32 |  |
     	 * You can't use this constructor.
33 |  |
     	 */
34 | 0 |
     	private Cp932() {}
35 |  |
36 |  |
     	/*
37 |  |
     	 * This method converts Cp932 to JIS.
38 |  |
     	 */
39 |  |
     	public static String toJIS(String s) {
40 |  |
41 |  |
     		/* commented by otsuka
42 |  |
     		 *
43 |  |
     		 * if (!isCp932)
44 |  |
     		 * return s;
45 |  |
     		 */
46 |  |
47 | 180 |
     		StringBuffer sb = new StringBuffer();
48 |  |
     		char c;
49 | 902 |
     		for (int i = 0; i < s.length(); i++) {
50 | 722 |
     			c = s.charAt(i);
51 |  |
52 | 722 |
     			switch (c) {
53 |  |
     				case 0xff3c: // FULLWIDTH REVERSE SOLIDUS ->
54 | 0 |
     					c = 0x005c; // REVERSE SOLIDUS
55 | 0 |
     					break;
56 |  |
     				case 0xff5e: // FULLWIDTH TILDE ->
57 | 0 |
     					c = 0x301c; // WAVE DASH
58 | 0 |
     					break;
59 |  |
     				case 0x2225: // PARALLEL TO ->
60 | 0 |
     					c = 0x2016; // DOUBLE VERTICAL LINE
61 | 0 |
     					break;
62 |  |
     				case 0xff0d: // FULLWIDTH HYPHEN-MINUS ->
63 | 0 |
     					c = 0x2212; // MINUS SIGN
64 | 0 |
     					break;
65 |  |
     				case 0xffe0: // FULLWIDTH CENT SIGN ->
66 | 0 |
     					c = 0x00a2; // CENT SIGN
67 | 0 |
     					break;
68 |  |
     				case 0xffe1: // FULLWIDTH POUND SIGN ->
69 | 0 |
     					c = 0x00a3; // POUND SIGN
70 | 0 |
     					break;
71 |  |
     				case 0xffe2: // FULLWIDTH NOT SIGN ->
72 | 0 |
     					c = 0x00ac; // NOT SIGN
73 |  |
     					break;
74 |  |
     			}
75 | 722 |
     			sb.append(c);
76 |  |
     		}
77 | 180 |
     		return new String(sb);
78 |  |
     	}
79 |  |
80 |  |
     	/*
81 |  |
     	 * This method convert JIS to Cp932.
82 |  |
     	 */
83 |  |
     	public static String toCp932(String s) {
84 | 0 |
     		if (!isCp932)
85 | 0 |
     			return s;
86 | 0 |
     		StringBuffer sb = new StringBuffer();
87 |  |
     		char c;
88 | 0 |
     		for (int i = 0; i < s.length(); i++) {
89 | 0 |
     			c = s.charAt(i);
90 |  |
91 | 0 |
     			switch (c) {
92 |  |
     				case 0x005c: // REVERSE SOLIDUS ->
93 | 0 |
     					c = 0xff3c; // FULLWIDTH REVERSE SOLIDUS
94 | 0 |
     					break;
95 |  |
     				case 0x301c: // WAVE DASH ->
96 | 0 |
     					c = 0xff5e; // FULLWIDTH TILDE
97 | 0 |
     					break;
98 |  |
     				case 0x2016: // DOUBLE VERTICAL LINE ->
99 | 0 |
     					c = 0x2225; // PARALLEL TO
100 | 0 |
     					break;
101 |  |
     				case 0x2212: // MINUS SIGN ->
102 | 0 |
     					c = 0xff0d; // FULLWIDTH HYPHEN-MINUS
103 | 0 |
     					break;
104 |  |
     				case 0x00a2: // CENT SIGN ->
105 | 0 |
     					c = 0xffe0; // FULLWIDTH CENT SIGN
106 | 0 |
     					break;
107 |  |
     				case 0x00a3: // POUND SIGN ->
108 | 0 |
     					c = 0xffe1; // FULLWIDTH POUND SIGN
109 | 0 |
     					break;
110 |  |
     				case 0x00ac: // NOT SIGN ->
111 | 0 |
     					c = 0xffe2; // FULLWIDTH NOT SIGN
112 |  |
     					break;
113 |  |
     			}
114 | 0 |
     			sb.append(c);
115 |  |
     		}
116 | 0 |
     		return new String(sb);
117 |  |
     	}
118 |  |
     }

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