blob: c08bdc14cfbc0b5adacda74706c6d8c3e92dd276 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.language.detect;
import com.yahoo.language.Language;
import java.nio.charset.Charset;
import java.nio.charset.UnsupportedCharsetException;
/**
* @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
*/
public class Detection {
private final Language language;
private final String encodingName;
private final boolean local;
public Detection(Language language, String encodingName, boolean local) {
this.language = language;
this.encodingName = encodingName;
this.local = local;
}
public Language getLanguage() {
return language;
}
public Charset getEncoding() {
if (encodingName == null) {
return null;
}
try {
return Charset.forName(encodingName);
} catch (UnsupportedCharsetException e) {
// ignore
}
return null;
}
public String getEncodingName() {
return encodingName;
}
public boolean isLocal() {
return local;
}
}
|