summaryrefslogtreecommitdiffstats
path: root/linguistics/src/main/java/com/yahoo/language/detect/Detection.java
diff options
context:
space:
mode:
Diffstat (limited to 'linguistics/src/main/java/com/yahoo/language/detect/Detection.java')
-rw-r--r--linguistics/src/main/java/com/yahoo/language/detect/Detection.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/linguistics/src/main/java/com/yahoo/language/detect/Detection.java b/linguistics/src/main/java/com/yahoo/language/detect/Detection.java
new file mode 100644
index 00000000000..e70d70425d4
--- /dev/null
+++ b/linguistics/src/main/java/com/yahoo/language/detect/Detection.java
@@ -0,0 +1,47 @@
+// Copyright 2016 Yahoo Inc. 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;
+ }
+}