summaryrefslogtreecommitdiffstats
path: root/vespajlib/src/main/java/com/yahoo/text/Utf8PartialArray.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /vespajlib/src/main/java/com/yahoo/text/Utf8PartialArray.java
Publish
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/text/Utf8PartialArray.java')
-rw-r--r--vespajlib/src/main/java/com/yahoo/text/Utf8PartialArray.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/text/Utf8PartialArray.java b/vespajlib/src/main/java/com/yahoo/text/Utf8PartialArray.java
new file mode 100644
index 00000000000..c6032e751b7
--- /dev/null
+++ b/vespajlib/src/main/java/com/yahoo/text/Utf8PartialArray.java
@@ -0,0 +1,35 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.text;
+
+/**
+ * This wraps a window in a backing byte array. Without doing any copying.
+ * @author <a href="mailto:balder@yahoo-inc.com">Henning Baldersheim</a>
+ * @since 5.2
+ */
+public class Utf8PartialArray extends Utf8Array {
+ final int offset;
+ final int length;
+
+ /**
+ * Takes ownership of the given byte array. And keeps note of where
+ * the interesting utf8 sequence start and its length.
+ * @param utf8data The backing byte array.
+ * @param offset The start of the utf8 sequence.
+ * @param bytes The length of the utf8 sequence.
+ */
+ public Utf8PartialArray(byte[] utf8data, int offset, int bytes) {
+ super(utf8data);
+ this.offset = offset;
+ this.length = bytes;
+ }
+ @Override
+ public int getByteLength() {
+ return length;
+ }
+
+ @Override
+ protected int getByteOffset() {
+ return offset;
+ }
+
+}