28import java.nio.charset.StandardCharsets;
29import java.util.Arrays;
31import org.jau.util.BasicTypes;
44 private final byte[] value_;
46 private final int capacity_;
48 private boolean variable_length_;
52 final byte[] p = name.getBytes(StandardCharsets.UTF_8);
57 final byte[] p = name.getBytes(StandardCharsets.UTF_8);
62 final byte[] p = { (byte)0, (
byte)0 };
64 p[1] = (byte)(v >> 8);
69 final byte[] p =
new byte[
size];
70 Arrays.fill(p, (
byte)0);
81 final byte[] p =
new byte[
size];
82 final int max_size = Math.min(
size, s.length);
83 System.arraycopy(s, 0, p, 0, max_size);
98 this.variable_length_ = variable_length;
141 public int size() {
return value_.length; }
146 public byte[]
data() {
return value_; };
150 for(
int i=value_.length-1; 0 <= i; --i) {
163 public boolean equals(
final Object other) {
164 if(
this == other ) {
171 if( value_.length != o.value_.length ) {
174 for(
int i=0; i<value_.length; i++) {
175 if( value_[i] != o.value_[i] ) {
186 return "len "+len+
", size "+
size()+
", capacity "+
capacity()+
", "+
187 BasicTypes.bytesHexString(value_, 0,
size(),
true ) +
static String decodeUTF8String(final byte[] buffer, final int offset, final int size)
Decodes the given consecutive UTF-8 characters within buffer to String.
A copy of the native GATT value of DBGattChar or DBGattDesc.
static DBGattValue make(final int capacity, final int size, final byte[] s)
Convenience DBGattValue ctor function.
int capacity()
Return the set capacity for this value.
int size()
Return the size of this value, i.e.
static DBGattValue make(final byte[] p)
Convenience DBGattValue ctor function.
static DBGattValue make(final String name, final int capacity)
Convenience DBGattValue ctor function.
static DBGattValue make(final String name)
Convenience DBGattValue ctor function.
boolean equals(final Object other)
Only compares the actual value, not hasVariableLength() nor capacity().
DBGattValue(final byte[] value, final int capacity)
Constructor, using default variable_length = false.
void setVariableLength(final boolean v)
DBGattValue(final byte[] value, final int capacity, final boolean variable_length)
Constructor.
byte[] data()
Returns the actual data of this value.
static DBGattValue make(final int capacity, final int size)
Convenience DBGattValue ctor function.
boolean hasVariableLength()
Returns true if this value has variable length.
void bzero()
Fill value with zero bytes.
static DBGattValue make(final short v)
Convenience DBGattValue ctor function.