@Test public void testStringValues() { String dataStr = "lorem ipsum dolor sit amet"; CommandResult commandResult = new CommandResult(Neatle.createUUID(1), dataStr.getBytes(Charset.forName("UTF8")), BluetoothGatt.GATT_SUCCESS, 1); assertEquals(dataStr, commandResult.getValueAsString()); CommandResult commandResult2 = new CommandResult(Neatle.createUUID(1), null, BluetoothGatt.GATT_SUCCESS, 1); assertNull(commandResult2.getValueAsString()); CommandResult commandResult3 = new CommandResult(Neatle.createUUID(1), new byte[]{}, BluetoothGatt.GATT_SUCCESS, 1); assertEquals("", commandResult3.getValueAsString()); }
public String getValueAsString() { if (data == null) { return null; } else if (data.length == 0) { return ""; } else { return new String(data, Charset.forName("UTF8")); } }
CommandResult { public String getValueAsString() { if (data == null) { return null; } else if (data.length == 0) { return ""; } else { return new String(data, Charset.forName("UTF8")); } } }
CommandResult { public String getValueAsString() { if (data == null) { return null; } else if (data.length == 0) { return ""; } else { return new String(data, Charset.forName("UTF8")); } } CommandResult(UUID uuid, byte[] data, int status, long timestamp); }
CommandResult { public String getValueAsString() { if (data == null) { return null; } else if (data.length == 0) { return ""; } else { return new String(data, Charset.forName("UTF8")); } } CommandResult(UUID uuid, byte[] data, int status, long timestamp); byte[] getValue(); String getValueAsString(); int getValueAsInt(); Integer getFormattedIntValue(int formatType, int offset); UUID getUUID(); int getStatus(); long getTimestamp(); boolean wasSuccessful(); @Override String toString(); @RestrictTo(RestrictTo.Scope.LIBRARY) static CommandResult createCharacteristicRead(BluetoothGattCharacteristic characteristic, int status); @RestrictTo(RestrictTo.Scope.LIBRARY) static CommandResult createErrorResult(UUID characteristicUUID, int error); @RestrictTo(RestrictTo.Scope.LIBRARY) static CommandResult createEmptySuccess(UUID characteristicUUID); @RestrictTo(RestrictTo.Scope.LIBRARY) static CommandResult createCharacteristicChanged(BluetoothGattCharacteristic characteristic); }
CommandResult { public String getValueAsString() { if (data == null) { return null; } else if (data.length == 0) { return ""; } else { return new String(data, Charset.forName("UTF8")); } } CommandResult(UUID uuid, byte[] data, int status, long timestamp); byte[] getValue(); String getValueAsString(); int getValueAsInt(); Integer getFormattedIntValue(int formatType, int offset); UUID getUUID(); int getStatus(); long getTimestamp(); boolean wasSuccessful(); @Override String toString(); @RestrictTo(RestrictTo.Scope.LIBRARY) static CommandResult createCharacteristicRead(BluetoothGattCharacteristic characteristic, int status); @RestrictTo(RestrictTo.Scope.LIBRARY) static CommandResult createErrorResult(UUID characteristicUUID, int error); @RestrictTo(RestrictTo.Scope.LIBRARY) static CommandResult createEmptySuccess(UUID characteristicUUID); @RestrictTo(RestrictTo.Scope.LIBRARY) static CommandResult createCharacteristicChanged(BluetoothGattCharacteristic characteristic); static final int FORMAT_UINT8; static final int FORMAT_UINT16; static final int FORMAT_UINT32; static final int FORMAT_SINT8; static final int FORMAT_SINT16; static final int FORMAT_SINT32; }