transform given value to a javascript parameter value

@param value The value to transform
@return value as string
540541
public static CharSequence toParameterValue(final JavaScriptInlineFunction value) {
        return value != null ? value.build() : Attr.nullValue();
    }
94913
public Color parse(String value)
    {
        if (value.length() <= 1) {
            throw new ConversionException(USAGE);
        }

        if (value.charAt(0) == '#') {
            return parseHtml(value);
        } else if (value.indexOf(',') != -1) {
            return parseRGB(value);
        } else {
            throw new ConversionException(USAGE);
        }
    }
1089457
public static String toJsonString(Object value) {
        if (value == null) {
            return "null";
        }
        else if (value.getClass().equals(String.class)) {
            return "\"" + StringUtils.jsonEncoding(value.toString()) + "\"";
        }
        // else it's a RawJson, Boolean or Number so no escaping or quotes
        else {
            return value.toString();
        }
    }
883978
@Override public Object transform(Object value) {
        if (value == null) {
            return value;
        } else if (value instanceof Boolean) {
            return value;
        } else if (value instanceof String) {
            return value;
        } else if (value instanceof Number) {
            return InternalUtils.toBigDecimal((Number)value);
        } else if (value instanceof byte[]) {
            return value;
        } else if (value instanceof ByteBuffer) {
            return copyBytesFrom((ByteBuffer)value);
        } else if (value instanceof Set) {
            @SuppressWarnings("unchecked")
            Set<Object> set = (Set<Object>) value;
            if (set.size() == 0)
                return value;
            Object element = set.iterator().next();
            if (element instanceof String) {
                return value;
            } else if (element instanceof BigDecimal) {
                return value;
            } else if (element instanceof Number) {
                @SuppressWarnings("unchecked")
                Set<Number> in = (Set<Number>) value;
                Set<BigDecimal> out = new LinkedHashSet<BigDecimal>(set.size());
                for (Number n : in)
                    out.add(InternalUtils.toBigDecimal(n));
                return out;
            } else if (element instanceof byte[]) {
                return value;
            } else if (element instanceof ByteBuffer) {
                @SuppressWarnings("unchecked")
                Set<ByteBuffer> bs = (Set<ByteBuffer>) value;
                Set<byte[]> out = new LinkedHashSet<byte[]>(bs.size());
                for (ByteBuffer bb: bs)
                    out.add(copyBytesFrom(bb));
                return out;
            } else {
                throw new UnsupportedOperationException("element type: "
                        + element.getClass());
            }
        } else if (value instanceof List) {
            @SuppressWarnings("unchecked")
            List<Object> in = (List<Object>) value;
            if (in.size() == 0)
                return in;
            List<Object> out = new ArrayList<Object>();
            for (Object v : in)
                out.add(transform(v));
            return out;
        } else if (value instanceof Map) {
            @SuppressWarnings("unchecked")
            Map<String, Object> in = (Map<String, Object>) value;
            if (in.size() == 0)
                return in;
            Map<String, Object> out = new LinkedHashMap<String, Object>(in.size());
            for (Map.Entry<String, Object> e : in.entrySet())
                out.put(e.getKey(), transform(e.getValue()));
            return out;
        } else {
            throw new UnsupportedOperationException("value type: "
                    + value.getClass());
        }
    }
1321330
function humanizeValueHtml(value) {
        var formattedValue = "";
        if (value === true) {
            formattedValue = '<i class="icon-check"></i>';
        }
        else if (value === false) {
            formattedValue = '<i class="icon-check-empty"></i>';
        }
        else {
            formattedValue = Core.humanizeValue(value);
        }
        return formattedValue;
    }
419220
public static CharSequence toParameterValue(final Object value) {
        if (value instanceof Long) {
            return toParameterValue((Long) value);
        } else if (value instanceof Integer) {
            return toParameterValue((Integer) value);
        } else if (value instanceof Boolean) {
            return toParameterValue((Boolean) value);
        } else if (value instanceof Float) {
            return toParameterValue((Float) value);
        } else if (value instanceof JavaScriptInlineFunction) {
            return toParameterValue((JavaScriptInlineFunction) value);
        } else if (value instanceof Duration) {
            return String.valueOf(((Duration) value).getMilliseconds());
        } else if (value instanceof Attr.MarkupId) {
            return ((Attr.MarkupId)value).quoted().toString();
        } else if (value instanceof Attr) {
            return value.toString();
        } else if (value instanceof JsonNode) {
            return Json.stringify(value);
        } else if (value instanceof Config) {
            return ((Config)value).toJsonString();
        }

        return value != null ? "'" + String.valueOf(value) + "'" : Attr.nullValue();
    }
224455
function(name, value) {
            var parameters = this.parameters;

            if (arguments.length < 1)
                return parameters[name] || parameters['/' + name];

            if (value !== parameters[name]) {
                parameters[name] = value;
            }
        }
988420
@Override
    public String tagValue(String value) {
        return StringEscapeUtils.escapeJson(delegate.tagValue(value));
    }
166362
@Override
    protected String convertToString(Object value) throws Throwable {
		Text text = (Text) value;
		return text.getValue();
    }
1155531
private static Object transformType(Object value) {
    if (value == null) {
      return null;
    }
    String valueString = value.toString();

    // check for boolean
    boolean boolValue = BooleanUtils.toBoolean(valueString);
    if (StringUtils.equals(valueString, Boolean.toString(boolValue))) {
      return boolValue;
    }

    // check for integer
    int intValue = NumberUtils.toInt(valueString);
    if (StringUtils.equals(valueString, Integer.toString(intValue))) {
      return intValue;
    }

    return value;
  }
426971
String convertToString(Object value) {
        if (value == null) {
            return null;
        } else if (value instanceof String) {
            return (String) value;
        } else if (value instanceof List) {
            List<?> list = ((List<?>) value);
            if (list.size() == 0) {
                return EvaluationContext.EMPTY_STRING;
            } else if (list.size() == 1) {
                String strValue = String.valueOf(list.get(0));
                return escapeValue(strValue);
            } else {
                StringBuilder builder = new StringBuilder();
                Iterator<?> iterator = list.iterator();
                while (iterator.hasNext()) {
                    String strValue = String.valueOf(iterator.next());
                    strValue = escapeValue(strValue);
                    builder.append(strValue);
                    if (iterator.hasNext()) {
                        builder.append(", ");
                    }
                }
                return builder.toString();
            }
        } else if (value instanceof String[]) {
            String[] array = (String[]) value;
            if (array.length == 0) {
                return EvaluationContext.EMPTY_STRING;
            } else if (array.length == 1) {
                return escapeValue(array[0]);
            } else {
                StringBuilder builder = new StringBuilder();
                for (int i = 0; i < array.length; i++) {
                    String strValue = escapeValue(array[i]);
                    builder.append(strValue);
                    if (i + 1 < array.length) {
                        builder.append(", ");
                    }
                }
                return builder.toString();
            }
        } else if (value.getClass().isArray()) {
            int size = Array.getLength(value);
            if (size == 0) {
                return EvaluationContext.EMPTY_STRING;
            } else if (size == 1) {
                String strValue = String.valueOf(Array.get(value, 0));
                return escapeValue(strValue);
            } else {
                StringBuilder builder = new StringBuilder();
                for (int i = 0; i < size; i++) {
                    String strValue = String.valueOf(Array.get(value, i));
                    strValue = escapeValue(strValue);
                    builder.append(strValue);
                    if (i + 1 < size) {
                        builder.append(", ");
                    }
                }
                return builder.toString();
            }
        } else {
            return value.toString();
        }
    }
1018916
protected function optimizeValueForJavaScript($value)
    {
        // For every transformable type, let's see if
        // it needs to be transformed for JS-use.
        foreach ($this->types as $transformer) {
            $js = $this->{"transform{$transformer}"}($value);
            if (! is_null($js)) {
                return $js;
            }
        }
    }
765070
public static String objectToString(Object value) {
    if (value == null) {
      return null;
    }
    if (value instanceof String) {
      return (String)value;
    }
    if (value instanceof String[]) {
      return StringUtils.join(encodeString((String[])value), ARRAY_DELIMITER);
    }
    else if (value instanceof Integer) {
      return Integer.toString((Integer)value);
    }
    else if (value instanceof Long) {
      return Long.toString((Long)value);
    }
    else if (value instanceof Double) {
      return Double.toString((Double)value);
    }
    else if (value instanceof Boolean) {
      return Boolean.toString((Boolean)value);
    }
    else if (value instanceof Map) {
      Map<?, ?> map = (Map<?, ?>)value;
      StringBuilder stringValue = new StringBuilder();
      Map.Entry<?, ?>[] entries = Iterators.toArray(map.entrySet().iterator(), Map.Entry.class);
      for (int i = 0; i < entries.length; i++) {
        Map.Entry<?, ?> entry = entries[i];
        String entryKey = encodeString(Objects.toString(entry.getKey(), ""));
        String entryValue = encodeString(Objects.toString(entry.getValue(), ""));
        stringValue.append(entryKey).append(KEY_VALUE_DELIMITER).append(entryValue);
        if (i < entries.length - 1) {
          stringValue.append(ARRAY_DELIMITER);
        }
      }
      return stringValue.toString();
    }
    throw new IllegalArgumentException("Unsupported type: " + value.getClass().getName());
  }
1170430
public static String normalizeHtml(SoyValue value) {
    value = normalizeNull(value);
    return normalizeHtml(value.coerceToString());
  }
1229355
function ValueToString(value) {
    if (value && typeof value === "object" && value.constructor === Array) {
      return JSON.stringify(value);
    }

    if (value && typeof value === "object" && value.constructor === Object) {
      return JSON.stringify(value);
    }

    /**
     * seeing some really weird cases where the above fail but "" + value
     * returns '[object Object]'
     */
    if (value && typeof value === "object") {
      return JSON.stringify(value);
    }

    if (value === null || typeof value === "undefined") {
      return "";
    }

    if (typeof value === "boolean") {
      if (value) {
        return "true";
      } else {
        return "false";
      }
    }

    if (typeof value === "number" && isFinite(value)) {
      return value.toString();
    }

    if (!!(value && value.constructor && value.call && value.apply)) {
      return value.toString();
    }

    return "" + value;
  }
621364
public static String escapeJsRegex(SoyValue value) {
    value = normalizeNull(value);
    return escapeJsRegex(value.coerceToString());
  }
302783
protected String replaceSimple(final String value) {
        String str = value;
        for(int i=0; i < numMap.length; i++) {
            str = str.replaceAll(String.valueOf(i), numMap[i]);
        }

        return str;
    }