@Override void setProto(long[] array, int i, com.google.protobuf.Value protoValue) { array[i] = Long.parseLong(protoValue.getStringValue()); }
@Override public String apply(com.google.protobuf.Value input) { return input.getKindCase() == KindCase.NULL_VALUE ? null : input.getStringValue(); } });
@Override protected String computeNext() { while (true) { if (!buffer.isEmpty()) { return buffer.pop(); } if (!iterator.hasNext()) { endOfData(); return null; } for (Value value : iterator.next().getValuesList()) { buffer.add(value.getStringValue()); } } } };
private static Object valueToObject(Value value) { switch (value.getKindCase()) { case NULL_VALUE: return null; case NUMBER_VALUE: return value.getNumberValue(); case STRING_VALUE: return value.getStringValue(); case BOOL_VALUE: return value.getBoolValue(); case STRUCT_VALUE: return new StructMap(value.getStructValue()); case LIST_VALUE: return Lists.transform(value.getListValue().getValuesList(), VALUE_TO_OBJECT); default: throw new IllegalArgumentException(String.format("Unsupported protobuf value %s", value)); } }
com.google.protobuf.Value merged = null; if (lastKind == KindCase.STRING_VALUE) { String lastStr = last.getStringValue(); String firstStr = first.getStringValue(); merged = com.google.protobuf.Value.newBuilder().setStringValue(lastStr + firstStr).build();
return any.getNumberValue(); case STRING_VALUE: return any.getStringValue(); case STRUCT_VALUE: Struct struct = any.getStructValue();
case 3: hash = (37 * hash) + STRING_VALUE_FIELD_NUMBER; hash = (53 * hash) + getStringValue().hashCode(); break; case 4:
private static double valueProtoToFloat64(com.google.protobuf.Value proto) { if (proto.getKindCase() == KindCase.STRING_VALUE) { switch (proto.getStringValue()) { case "-Infinity": return Double.NEGATIVE_INFINITY; case "Infinity": return Double.POSITIVE_INFINITY; case "NaN": return Double.NaN; default: // Fall-through to handling below to produce an error. } } if (proto.getKindCase() != KindCase.NUMBER_VALUE) { throw newSpannerException( ErrorCode.INTERNAL, "Invalid value for column type " + Type.float64() + " expected NUMBER_VALUE or STRING_VALUE with value one of" + " \"Infinity\", \"-Infinity\", or \"NaN\" but was " + proto.getKindCase() + (proto.getKindCase() == KindCase.STRING_VALUE ? " with value \"" + proto.getStringValue() + "\"" : "")); } return proto.getNumberValue(); }
case INT64: checkType(fieldType, proto, KindCase.STRING_VALUE); return Long.parseLong(proto.getStringValue()); case FLOAT64: return valueProtoToFloat64(proto); case STRING: checkType(fieldType, proto, KindCase.STRING_VALUE); return proto.getStringValue(); case BYTES: checkType(fieldType, proto, KindCase.STRING_VALUE); return ByteArray.fromBase64(proto.getStringValue()); case TIMESTAMP: checkType(fieldType, proto, KindCase.STRING_VALUE); return Timestamp.parseTimestamp(proto.getStringValue()); case DATE: checkType(fieldType, proto, KindCase.STRING_VALUE); return Date.parseDate(proto.getStringValue()); case ARRAY: checkType(fieldType, proto, KindCase.LIST_VALUE);
break; case 3: result = result && getStringValue() .equals(other.getStringValue()); break; case 4:
value.getKindCase() == KindCase.NULL_VALUE ? null : ByteArray.fromBase64(value.getStringValue())); value.getKindCase() == KindCase.NULL_VALUE ? null : Timestamp.parseTimestamp(value.getStringValue())); value.getKindCase() == KindCase.NULL_VALUE ? null : Date.parseDate(value.getStringValue()));
@Test public void testSimpleMapping() throws JsonGenerationException, JsonMappingException, IOException { ObjectMapper m = new JsonMapperProvider().get(); assertTrue(m.canSerialize(Any.class)); Struct struct1 = Struct.newBuilder().putFields( "some-key", Value.newBuilder().setStringValue("some-value").build() ).build(); Any source = Any.pack(struct1); StringWriter buf = new StringWriter(); m.writer().writeValue(buf, source); Any dest = m.reader().forType(Any.class).readValue(buf.toString()); assertEquals(source.getTypeUrl(), dest.getTypeUrl()); Struct struct2 = dest.unpack(Struct.class); assertTrue(struct2.containsFields("some-key")); assertEquals( struct1.getFieldsOrThrow("some-key").getStringValue(), struct2.getFieldsOrThrow("some-key").getStringValue() ); } }
? value.getStringValue() : new ArrayList<com.google.protobuf.Value>(value.getListValue().getValuesList()); while (current.getChunkedValue() && pos == current.getValuesCount()) { merged = (String) merged + newValue.getStringValue(); } else { concatLists(
/** * <pre> * Represents a string value. * </pre> * * <code>optional string string_value = 3;</code> */ public java.lang.String getStringValue() { return instance.getStringValue(); } /**
@Override void setProto(long[] array, int i, com.google.protobuf.Value protoValue) { array[i] = Long.parseLong(protoValue.getStringValue()); }
@Override public String apply(com.google.protobuf.Value input) { return input.getKindCase() == KindCase.NULL_VALUE ? null : input.getStringValue(); } });
/** * Grab the value of the provided SAM tag if it exists (returns null otherwise) * @param read the read whose SAM tags need to be searched * @param tag the desired tag * @return string corresponding to SAM tag or null if it doesn't exist */ public static String getSamTag(Read read, String tag) { ListValue value = read.getInfo().get(tag); if (value == null) { return null; } return value.getValues(0).getStringValue(); }
private static Object parseObject(String key, Value in, VCFHeaderLineType type) { // Case on type switch (in.getKindCase()) { case NULL_VALUE: throw new IllegalStateException(String.format("field %s contained " + "a null value", key)); case NUMBER_VALUE: return getNumberValue(in.getNumberValue(), type); case STRING_VALUE: return in.getStringValue(); case BOOL_VALUE: return (Boolean) in.getBoolValue(); default: throw new IllegalStateException(String.format("field %s contained a %s type, which" + " is not supported by VariantToVcf", key, getKind(in.getKindCase()))); } }
private static Object valueToObject(Value value) { switch (value.getKindCase()) { case NULL_VALUE: return null; case NUMBER_VALUE: return value.getNumberValue(); case STRING_VALUE: return value.getStringValue(); case BOOL_VALUE: return value.getBoolValue(); case STRUCT_VALUE: return new StructMap(value.getStructValue()); case LIST_VALUE: return Lists.transform(value.getListValue().getValuesList(), VALUE_TO_OBJECT); default: throw new IllegalArgumentException(String.format("Unsupported protobuf value %s", value)); } }
@Test public void itReadsStringValue() throws IOException { String json = "{\"value\":\"test\"}"; HasValue valueWrapper = camelCase().readValue(json, HasValue.class); assertThat(valueWrapper.hasValue()).isTrue(); Value value = valueWrapper.getValue(); switch (value.getKindCase()) { case STRING_VALUE: assertThat(value.getStringValue()).isEqualTo("test"); break; default: fail("Unexpected value kind: " + value.getKindCase()); } }