/** * Private helper to convert a string result. * * @param s The string to convert. */ private SoyValue convertResult(String s) { return StringData.forValue(s); }
@Override public SoyValue apply(String input) { return StringData.forValue(input); } });
@Override public SoyValue apply(String key) { return StringData.forValue(key); } });
@Override public SoyValue apply(String key) { return StringData.forValue(key); } });
@Override public SoyValue apply(String key) { return StringData.forValue(key); } });
/** * For any resource string/variable which has |blessStringAsTrustedResuorceUrlForLegacy directive * return the input value as is after converting it into SoyValue. */ public static SoyValue blessStringAsTrustedResourceUrlForLegacy(String value) { return StringData.forValue(value); }
@Override public SoyValue apply(String input) { return StringData.forValue(input); } });
@Override public SoyValue soyFromProto(Object field) { return StringData.forValue( BaseEncoding.base64().encode(((ByteString) field).toByteArray())); }
@Override public SoyValue apply(ByteString input) { return StringData.forValue(BaseEncoding.base64().encode(input.toByteArray())); } });
@Override public SoyValue apply(ByteString input) { return StringData.forValue(BaseEncoding.base64().encode(input.toByteArray())); } });
@Override public SoyValue soyFromProto(Object field) { return StringData.forValue( BaseEncoding.base64().encode(((ByteString) field).toByteArray())); }
@Nonnull @Override public Map<? extends SoyValue, ? extends SoyValueProvider> asJavaMap() { ImmutableMap.Builder<SoyValue, SoyValueProvider> builder = ImmutableMap.builder(); for (Map.Entry<String, ? extends SoyValueProvider> entry : providerMap.entrySet()) { builder.put(StringData.forValue(entry.getKey()), entry.getValue()); } return builder.build(); }
@Nonnull @Override public Map<? extends SoyValue, ? extends SoyValueProvider> asJavaMap() { ImmutableMap.Builder<SoyValue, SoyValueProvider> builder = ImmutableMap.builder(); for (Map.Entry<String, SoyData> entry : map.entrySet()) { builder.put(StringData.forValue(entry.getKey()), entry.getValue()); } return builder.build(); }
/** * Adds a data value. * * @param value The data to add. */ public void add(String value) { add(StringData.forValue(value)); }
@Override public SoyValue applyForJava(SoyValue value, List<SoyValue> args) { return StringData.forValue( BidiDirectivesRuntime.bidiSpanWrap(bidiGlobalDirProvider.get(), value)); }
/** * Sets a data value at a given index. * * @param index The index. * @param value The data to set. */ public void set(int index, String value) { set(index, StringData.forValue(value)); }
/** * Puts data into this data tree at the specified key string. * * @param keyStr One or more map keys and/or list indices (separated by '.' if multiple parts). * Indicates the path to the location within this data tree. * @param value The data to put at the specified location. */ public void put(String keyStr, String value) { put(keyStr, StringData.forValue(value)); }
@Override public JavaValue coerceToSoyString() { return TofuJavaValue.forSoyValue( StringData.forValue(soyValue.coerceToString()), sourceLocation); }
/** Performs the {@code +} operator on the two values. */ public static SoyValue plus(SoyValue operand0, SoyValue operand1) { if (operand0 instanceof IntegerData && operand1 instanceof IntegerData) { return IntegerData.forValue(operand0.longValue() + operand1.longValue()); } else if (operand0 instanceof NumberData && operand1 instanceof NumberData) { return FloatData.forValue(operand0.numberValue() + operand1.numberValue()); } else { // String concatenation is the fallback for other types (like in JS). Use the implemented // coerceToString() for the type. return StringData.forValue(operand0.coerceToString() + operand1.coerceToString()); } }