diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
commit | 72231250ed81e10d66bfe70701e64fa5fe50f712 (patch) | |
tree | 2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /linguistics/src/main/java/com/yahoo/language/detect/AbstractDetector.java |
Publish
Diffstat (limited to 'linguistics/src/main/java/com/yahoo/language/detect/AbstractDetector.java')
-rw-r--r-- | linguistics/src/main/java/com/yahoo/language/detect/AbstractDetector.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/linguistics/src/main/java/com/yahoo/language/detect/AbstractDetector.java b/linguistics/src/main/java/com/yahoo/language/detect/AbstractDetector.java new file mode 100644 index 00000000000..f80f876d248 --- /dev/null +++ b/linguistics/src/main/java/com/yahoo/language/detect/AbstractDetector.java @@ -0,0 +1,25 @@ +// 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.text.Utf8; + +import java.nio.ByteBuffer; + +/** + * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a> + */ +public abstract class AbstractDetector implements Detector { + + @Override + public final Detection detect(String input, Hint hint) { + byte[] buf = Utf8.toBytes(input); + return detect(buf, 0, buf.length, hint); + } + + @Override + public final Detection detect(ByteBuffer input, Hint hint) { + byte[] buf = new byte[input.remaining()]; + input.get(buf, 0, buf.length); + return detect(buf, 0, buf.length, hint); + } +} |