1   /*
2    * SPDX-FileCopyrightText: none
3    * SPDX-License-Identifier: CC0-1.0
4    */
5   
6   package dev.metaschema.core.metapath.item.atomic.impl;
7   
8   import java.nio.ByteBuffer;
9   
10  import dev.metaschema.core.datatype.adapter.AbstractBinaryAdapter;
11  import dev.metaschema.core.metapath.item.atomic.IAnyAtomicItem;
12  import edu.umd.cs.findbugs.annotations.NonNull;
13  
14  /**
15   * Represents a binary string of bytes.
16   */
17  public interface IBinaryItem extends IAnyAtomicItem {
18  
19    /**
20     * Get the "wrapped" byte buffer value.
21     *
22     * @return the underlying byte buffer value
23     */
24    @NonNull
25    ByteBuffer asByteBuffer();
26  
27    /**
28     * Get the underlying bytes for this item.
29     *
30     * @return the array of bytes
31     */
32    @NonNull
33    default byte[] asBytes() {
34      return AbstractBinaryAdapter.bufferToBytes(asByteBuffer(), true);
35    }
36  }