aboutsummaryrefslogtreecommitdiffstats
path: root/linguistics/src/main/java/com/yahoo/language/detect/Detection.java
blob: 5f820e6ba6cf53bdf0ac4050a86a7764689e6210 (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
48
// Copyright Yahoo. 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 Einar M R Rosenvinge
 */
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;
    }

}