Skip to content

Commit 208fd51

Browse files
Private encodingByCookedName → encodingByLabel
This change renames the private encodingByCookedName map in the Encoding class to encodingByLabel (for consistency with Encoding spec terminology).
1 parent 44427c0 commit 208fd51

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/nu/validator/htmlparser/io/Encoding.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public class Encoding {
6363
"xjisautodetect", "xutf16bebom", "xutf16lebom", "xutf32bebom",
6464
"xutf32lebom", "xutf16oppositeendian", "xutf16platformendian",
6565
"xutf32oppositeendian", "xutf32platformendian" };
66+
private static Map<String, Encoding> encodingByLabel =
67+
new HashMap<String, Encoding>();
6668

6769
/* From the table at https://encoding.spec.whatwg.org/#names-and-labels,
6870
* everything in the Labels column, sorted */
@@ -339,14 +341,14 @@ asciiSuperset, isObscure(name),
339341
encodings.add(enc);
340342
Set<String> aliases = cs.aliases();
341343
for (String alias : aliases) {
342-
encodingByCookedName.put(toNameKey(alias).intern(), enc);
344+
encodingByLabel.put(toNameKey(alias).intern(), enc);
343345
}
344346
}
345347
}
346348
// Overwrite possible overlapping aliases with the real things--just in
347349
// case
348350
for (Encoding encoding : encodings) {
349-
encodingByCookedName.put(toNameKey(encoding.getCanonName()),
351+
encodingByLabel.put(toNameKey(encoding.getCanonName()),
350352
encoding);
351353
}
352354
UTF8 = forName("utf-8");
@@ -383,15 +385,15 @@ asciiSuperset, isObscure(name),
383385
} catch (UnsupportedCharsetException e) {
384386
}
385387
try {
386-
encodingByCookedName.put("x-x-big5", forName("big5"));
388+
encodingByLabel.put("x-x-big5", forName("big5"));
387389
} catch (UnsupportedCharsetException e) {
388390
}
389391
try {
390-
encodingByCookedName.put("euc-kr", forName("windows-949"));
392+
encodingByLabel.put("euc-kr", forName("windows-949"));
391393
} catch (UnsupportedCharsetException e) {
392394
}
393395
try {
394-
encodingByCookedName.put("ks_c_5601-1987", forName("windows-949"));
396+
encodingByLabel.put("ks_c_5601-1987", forName("windows-949"));
395397
} catch (UnsupportedCharsetException e) {
396398
}
397399
}
@@ -459,7 +461,7 @@ private static boolean isLikelyEbcdic(String canonName,
459461
}
460462

461463
public static Encoding forName(String name) {
462-
Encoding rv = encodingByCookedName.get(toNameKey(name));
464+
Encoding rv = encodingByLabel.get(toNameKey(name));
463465
if (rv == null) {
464466
throw new UnsupportedCharsetException(name);
465467
} else {
@@ -617,7 +619,7 @@ public Encoding getActualHtmlEncoding() {
617619
}
618620

619621
public static void main(String[] args) {
620-
for (Map.Entry<String, Encoding> entry : encodingByCookedName.entrySet()) {
622+
for (Map.Entry<String, Encoding> entry : encodingByLabel.entrySet()) {
621623
String name = entry.getKey();
622624
Encoding enc = entry.getValue();
623625
System.out.printf(

0 commit comments

Comments
 (0)