@Override public Byte apply(String input) { return Byte.parseByte(input); } };
/** * Constructs a new MutableByte parsing the given string. * * @param value the string to parse, not null * @throws NumberFormatException if the string cannot be parsed into a byte * @since 2.5 */ public MutableByte(final String value) { super(); this.value = Byte.parseByte(value); }
/** * Constructs a new MutableByte parsing the given string. * * @param value the string to parse, not null * @throws NumberFormatException if the string cannot be parsed into a byte * @since 2.5 */ public MutableByte(String value) throws NumberFormatException { super(); this.value = Byte.parseByte(value); }
@Override public Byte formatTrimmed(String raw) throws Exception { return Byte.parseByte(raw, 10); }
public MutableByte(String value) { this.value = Byte.parseByte(value); }
public static Byte castToByte(Object val) { if (val == null) { return null; } if (val instanceof Byte) { return (Byte) val; } if (val instanceof String) { return Byte.parseByte((String) val); } return ((Number) val).byteValue(); }
/** Returns this value as a byte. * @throws IllegalStateException if this an array or object. */ public byte asByte () { switch (type) { case stringValue: return Byte.parseByte(stringValue); case doubleValue: return (byte)doubleValue; case longValue: return (byte)longValue; case booleanValue: return longValue != 0 ? (byte)1 : 0; } throw new IllegalStateException("Value cannot be converted to byte: " + type); }
/** Returns this value as a byte. * @throws IllegalStateException if this an array or object. */ public byte asByte () { switch (type) { case stringValue: return Byte.parseByte(stringValue); case doubleValue: return (byte)doubleValue; case longValue: return (byte)longValue; case booleanValue: return longValue != 0 ? (byte)1 : 0; } throw new IllegalStateException("Value cannot be converted to byte: " + type); }
String[] arr = {"-1", "0", "10", "20" }; for (int i = 0; i < arr.length; i++) { arr[i] = String.format("%02x", Byte.parseByte(arr[i])); } System.out.println(java.util.Arrays.toString(arr)); // prints "[ff, 00, 0a, 14]"
String response = "[-47, 1, 16, 84, 2, 101, 110, 83, 111, 109, 101, 32, 78, 70, 67, 32, 68, 97, 116, 97]"; // response from the Python script String[] byteValues = response.substring(1, response.length() - 1).split(","); byte[] bytes = new byte[byteValues.length]; for (int i=0, len=bytes.length; i<len; i++) { bytes[i] = Byte.parseByte(byteValues[i].trim()); } String str = new String(bytes);
@Override public byte convertToByte(CharSequence value) { if (value instanceof AsciiString && value.length() == 1) { return ((AsciiString) value).byteAt(0); } return Byte.parseByte(value.toString()); }
@Override public byte getByte(String name) { return Byte.parseByte(getFieldValue(name)); }
public static long tinyintPartitionKey(String value, String name) { try { return parseByte(value); } catch (NumberFormatException e) { throw new PrestoException(HIVE_INVALID_PARTITION_VALUE, format("Invalid partition value '%s' for TINYINT partition key: %s", value, name)); } }
@Override public byte convertToByte(CharSequence value) { if (value instanceof AsciiString && value.length() == 1) { return ((AsciiString) value).byteAt(0); } return Byte.parseByte(value.toString()); }
public byte getParameter(String key, byte defaultValue) { Number n = getNumbers().get(key); if (n != null) { return n.byteValue(); } String value = getParameter(key); if (StringUtils.isEmpty(value)) { return defaultValue; } byte b = Byte.parseByte(value); getNumbers().put(key, b); return b; }
public byte getParameter(String key, byte defaultValue) { Number n = getNumbers().get(key); if (n != null) { return n.byteValue(); } String value = getParameter(key); if (StringUtils.isEmpty(value)) { return defaultValue; } byte b = Byte.parseByte(value); getNumbers().put(key, b); return b; }
public byte getMethodParameter(String method, String key, byte defaultValue) { String methodKey = method + "." + key; Number n = getNumbers().get(methodKey); if (n != null) { return n.byteValue(); } String value = getMethodParameter(method, key); if (StringUtils.isEmpty(value)) { return defaultValue; } byte b = Byte.parseByte(value); getNumbers().put(methodKey, b); return b; }
public byte getMethodParameter(String method, String key, byte defaultValue) { String methodKey = method + "." + key; Number n = getNumbers().get(methodKey); if (n != null) { return n.byteValue(); } String value = getMethodParameter(method, key); if (StringUtils.isEmpty(value)) { return defaultValue; } byte b = Byte.parseByte(value); getNumbers().put(methodKey, b); return b; }
public byte readByte(String tag) throws IOException { Value v = next(); if (!"ex:i1".equals(v.getType())) { throw new IOException("Error deserializing "+tag+"."); } return Byte.parseByte(v.getValue()); }
@LiteralParameters("x") @ScalarOperator(CAST) @SqlType(StandardTypes.TINYINT) public static long castToTinyint(@SqlType("varchar(x)") Slice slice) { try { return Byte.parseByte(slice.toStringUtf8()); } catch (Exception e) { throw new PrestoException(INVALID_CAST_ARGUMENT, format("Cannot cast '%s' to TINYINT", slice.toStringUtf8())); } }