1
2
3
4
5
6
7
8
9
10
11 package com.puppycrawl.tools.checkstyle.checks.avoidescapedunicodecharacters;
12
13 import java.util.concurrent.TimeUnit;
14
15 public class InputAvoidEscapedUnicodeCharacters2 {
16
17 private String unitAbbrev2 = "\u03bcs";
18
19 private String unitAbbrev3 = "\u03bcs";
20
21 private String unitAbbrev4 = "\u03bcs";
22
23 public Object fooString() {
24 String unitAbbrev = "μs";
25 String unitAbbrev2 = "\u03bcs";
26 String unitAbbrev3 = "\u03bcs";
27 String fakeUnicode = "asd\tsasd";
28 String fakeUnicode2 = "\\u23\\u123i\\u";
29 String content = null;
30 return "\ufeff" + content;
31 }
32
33 public Object fooChar() {
34 char unitAbbrev2 = '\u03bc';
35 char unitAbbrev3 = '\u03bc';
36 char content = 0;
37 return '\ufeff' + content;
38 }
39
40 public void multiplyString() {
41 String unitAbbrev2 = "asd\u03bcsasd";
42 String unitAbbrev3 = "aBc\u03bcssdf\u03bc";
43 String unitAbbrev4 = "\u03bcaBc\u03bcssdf\u03bc";
44 String allCharactersEscaped = "\u03bc\u03bc";
45 }
46
47 private static String abbreviate(TimeUnit unit) {
48 switch (unit) {
49 case NANOSECONDS:
50 return "ns";
51 case MICROSECONDS:
52 return "\u03bcs";
53 case MILLISECONDS:
54 return "ms";
55 case SECONDS:
56 return "s";
57 case MINUTES:
58 return "min";
59 case HOURS:
60 return "h";
61 case DAYS:
62 return "d";
63 default:
64 throw new AssertionError();
65 }
66 }
67
68 static final String WHITESPACE_TABLE = ""
69 + "\u2002\u3000\r\u0085\u200A\u2005\u2000\u3000\\"
70
71 + "\u2029\u000B\u3000\u2008\u2003\u205F\u3000\u1680"
72
73 + "\u0009\u0020\u2006\u2001\u202F\u00A0\u000C\u2009"
74
75 + "\u3000\u2004\u3000\u3000\u2028\n\u2007\u3000";
76
77 public boolean matches(char c) {
78 switch (c) {
79 case '\t':
80 case '\n':
81 case '\013':
82 case '\f':
83 case '\r':
84 case ' ':
85 case '\u0085':
86 case '\u1680':
87
88 case '\u2028':
89
90 case '\u2029':
91
92 case '\u205f':
93
94 case '\u3000':
95 return true;
96
97 case '\u2007':
98 return false;
99 default:
100
101 return c >= '\u2000' && c <= '\u200a';
102 }
103 }
104
105 private String unitAbbrev5 = "\u03bcs";
106 private String unitAbbrev6 = "\u03bcs";
107 private String unitAbbrev7 = "\u03bcs";
108 private String unitAbbrev8 = "\u03bcs";
109
110 void foo() {
111 for (char c = '\u0000'; c < '\uffff'; c++) {
112 if (c == '\u001b' ||
113 c == '\u2014')
114 continue;
115 }
116 }
117 private String unitAbbrev9 = "\u03bcs"; int i;
118
119 private String notAUnicodeEscaped1 = "\\u1234";
120
121 private String notAUnicodeEscaped2 = "\\\\u1234";
122
123 private String onlyEscaped = "\\\u1234";
124
125 private String sumilarToEscapedByB = "b\u1234";
126 private String sumilarToEscapedCommentedByB = "b\u1234";
127
128 private String sumilarToEscapedByF = "f\u1234";
129 private String sumilarToEscapedCommentedByF = "f\u1234";
130
131 private String sumilarToEscapedByR = "r\u1234";
132 private String sumilarToEscapedCommentedByR = "r\u1234";
133
134 private String sumilarToEscapedByN = "n\u1234";
135 private String sumilarToEscapedCommentedByN = "n\u1234";
136
137 private String sumilarToEscapedByT = "t\u1234";
138 private String sumilarToEscapedCommentedByT = "t\u1234";
139
140 private String validEscapeWithManyUs = "t\uuuuuuuuu1234";
141 private String validEscapeWithManyUsCommented = "t\uuuuuuuuu1234";
142 }