/** * Returns {@code com.google.appengine.api.datastore.Text} value as string * representation. */ @Override protected String convertToString(Object value) throws Throwable { Text text = (Text) value; return text.getValue(); }
@Override public Object forPojo(Object value, Class<?> fieldType, ConverterLoadContext ctx, Object onPojo) { if (fieldType != String.class) return null; if (value instanceof Text) return ((Text)value).getValue(); else return value.toString(); } }
private <T> void setTextProperty(T object, Field field, Object value) throws IllegalAccessException { field.set(object, ((Text) value).getValue()); }
@Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { if (value != null) { Text text = (Text) value; button.setText(text.getValue()); } else { button.setText(null); } return button; }
@Override public NarrativeValue toFieldValue(Object hrdValue) { if(hrdValue instanceof Text) { return NarrativeValue.valueOf(((Text) hrdValue).getValue()); } else { return null; } } };
public static void serialize(SerializationStreamWriter streamWriter, Text instance) throws SerializationException { streamWriter.writeString(instance.getValue()); } }
private <T> void setLazyJsonProperty(T object, Field field, Object value) throws IllegalAccessException { String json = ((Text) value).getValue(); Type type = ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0]; field.set(object, LazyJson.$create(type, json)); }
private <T> void setJsonProperty(Repository r, T object, Field field, Object value) throws IllegalAccessException { String json = ((Text) value).getValue(); field.set(object, JsonUtils.from(r, json, field.getGenericType())); }
public static void putJsonValueFormatted(Map<String, Object> row, String fieldName, Object fieldValue, String fieldType) throws JSONException { // These strings have been interned so == works for comparison if ("string" == fieldType) { String stringValue; if (fieldValue instanceof Text) { stringValue = ((Text) fieldValue).getValue(); } else { stringValue = fieldValue.toString(); } row.put(fieldName, stringValue); } else if ("float" == fieldType) { row.put(fieldName, fieldValue); } else if ("integer" == fieldType) { if (fieldValue instanceof Date) { @SuppressWarnings("unused") long dateLong = ((Date) fieldValue).getTime(); row.put(fieldName, fieldValue); } else { row.put(fieldName, fieldValue); } } else { row.put(fieldName, fieldValue); } }
private static ObjectNode getTextNode(Text text) { ObjectNode dateNode = JsonUtils.getObjectMapper().createObjectNode(); dateNode.put("type", "text"); dateNode.put("value", text.getValue()); return dateNode; }
gs_handle = ((Text)gs_handle_obj).getValue();
if (body != null) dialog.setBody(body.getValue());
return gob.getValue();
@Test public void testTextType() { String propertyName = "textProp"; List<Entity> elist = doQuery(kindName, propertyName, null, false); Text text = (Text) elist.get(0).getProperty(propertyName); Text sameDat = (Text) elist.get(0).getProperty(propertyName); Text diffDat = (Text) elist.get(1).getProperty(propertyName); assertTrue(text.equals(sameDat)); assertFalse(text.equals(diffDat)); String getText = text.getValue(); assertTrue(getText.equals("english") || getText.equals("chinese") || getText.equals("japanese")); assertEquals(text.hashCode(), text.hashCode()); }
public void map(Entity entity) { emit1("total entities"); emit1("map calls in shard " + getContext().getShardNumber()); String name = entity.getKey().getName(); String payload = ((Text) entity.getProperty("payload")).getValue(); emit("total entity payload size", payload.length()); emit("total entity key size", name.length()); for (char c = 'a'; c <= 'z'; c++) { emit(toKey(c), countChar(payload, c)); } for (char c = '0'; c <= '9'; c++) { emit("occurrences of digit " + c + " in key", countChar(name, c)); } }
if (fieldVal instanceof Text) { fieldVal = ((Text) fieldVal).getValue();