Return a new {@link MeterValue} instance for the given String value. The value may
contain a simple number, or a {@link Duration duration string}.
@param value the source value
@return a {@link MeterValue} instance
489038
public static MeterValue valueOf(String value) {
        if (isNumber(value)) {
            return new MeterValue(Long.parseLong(value));
        }
        return new MeterValue(durationConverter.convert(value));
    }
742674
public static Range valueOf(final String value) {
        final int[] vals = parse(value);
        if (vals.length == 2) {
            return new Range(vals[0], vals[1]);
        }
        return null;
    }
1023700
public static Expression constant(final char value) {
    return new Expression(Type.CHAR_TYPE, Feature.CHEAP) {
      @Override
      protected void doGen(CodeBuilder mv) {
        mv.pushInt(value);
      }
    };
  }
121120
public final Latency withMean(double value) {
    double newValue = value;
    return new Latency(
        this.median,
        this.percentile98th,
        this.percentile99th,
        this.percentile999th,
        newValue,
        this.min,
        this.max);
  }
332345
public Expression<String> lte(String value) {
		String valueString = "'" + value + "'";
		return new Expression<String>(this, Operation.lte, valueString);
	}
1337928
public Datapoint addStringValue(long time, String value) {
        initialValues();
        checkType(TsdbConstants.TYPE_STRING);

        values.add(Lists.<JsonNode> newArrayList(new LongNode(time), new TextNode(value)));
        return this;
    }
254934
public static Version valueOf(final String value) {
        final Optional<Instant> time = parse(value);
        if (time.isPresent()) {
            return new Version(time.get());
        }
        return null;
    }
134940
@VisibleForTesting
  static TypedValue createTypedValue(Value value) {
    return value.match(
        typedValueDoubleFunction,
        typedValueLongFunction,
        typedValueDistributionFunction,
        typedValueSummaryFunction,
        Functions.<TypedValue>throwIllegalArgumentException());
  }
25770
public static Long getAsLong(Object value) {
		Long result = null;

		try {
			if (value instanceof String) {
				result = Long.valueOf((String) value);
			} else if (value instanceof Number) {
				result = ((Number) value).longValue();
			} else {
				result = null;
			}
		} catch (Exception e) {
			result = null;
		}

		return result == null ? 0 : result;
	}
433774
public static String getValueLabel(final Object value) {
        if (value == null) {
            return NULL_LABEL;
        }

        if (value instanceof HasLabelAdvice) {
            final String suggestedLabel = ((HasLabelAdvice) value).getSuggestedLabel();
            if (!Strings.isNullOrEmpty(suggestedLabel)) {
                return suggestedLabel;
            }
        }

        // format decimals
        if (value instanceof Double || value instanceof Float || value instanceof BigDecimal) {
            final NumberFormat format = NumberFormat.getNumberInstance();
            final String result = format.format((Number) value);
            logger.debug("Formatted decimal {} to: {}", value, result);
            return result;
        }

        // format dates
        if (value instanceof Date) {
            final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
            final String result = format.format((Date) value);
            logger.debug("Formatted date {} to: {}", value, result);
            return result;
        }

        return getLabel(value.toString());
    }
1325347
private long parseDuration(String value) {
	        long periodMS = 0L;
	        if (value!=null) {
	            String[] parts = value.split(":");
	            for (int i = 0; i < parts.length; i++) {
	                switch (i) {
	                    case 0: // hours
	                        periodMS += (Integer.parseInt(parts[i])) * 3600000L;
	                        break;
	                    case 1: // minutes
	                        periodMS += (Integer.parseInt(parts[i])) * 60000L;
	                        break;
	                    case 2: // seconds
	                        periodMS += (Integer.parseInt(parts[i])) * 1000L;
	                        break;
	                    case 3: // ms
	                        periodMS += (Integer.parseInt(parts[i]));
	                        break;
	                    default:
	                        break;
	                }
	            }
	        }
	        return periodMS;
	    }
401880
public static String valueSubstitution(final String value) {
        final String tmpProp = "java.io.tmpdir";
        final String tmpVar = "{tmp}";
        final String tmpRE = "{tmp}";

        final String homeProp = "user.home";
        final String homeVar = "{home}";
        final String homeRE = "{home}";

        final String nameProp = "user.name";
        final String nameVar = "{name}";
        final String nameRE = "{name}";

        final String cwdProp = "user.dir";
        final String cwdVar = "{dir}";
        final String cwdRE = "{dir}";

        final String bfHomeEnv = PathConstants.BELFRAMEWORK_HOME_ENV_VAR;
        final String bfHomeVar = "{belframework_home}";
        final String bfHomeRE = "{belframework_home}";

        String ret = value;

        if (value.contains(tmpVar)) {
            ret = ret.replace(tmpRE, getProperty(tmpProp));
        }
        if (value.contains(homeVar)) {
            ret = ret.replace(homeRE, getProperty(homeProp));
        }
        if (value.contains(nameVar)) {
            ret = ret.replace(nameRE, getProperty(nameProp));
        }
        if (value.contains(cwdVar)) {
            ret = ret.replace(cwdRE, getProperty(cwdProp));
        }
        if (value.contains(bfHomeVar)) {
            String bfHome = getenv(bfHomeEnv);
            if (bfHome == null) {
                bfHome = ""; //belframework home is not set. Use empty string.
            }
            ret = ret.replace(bfHomeRE, bfHome);
        }
        return ret;
    }
1167925
@Pure
	public static double fromMetersPerSecond(double value, SpeedUnit outputUnit) {
		switch (outputUnit) {
		case KILOMETERS_PER_HOUR:
			return value / 3.6;
		case MILLIMETERS_PER_SECOND:
			return value * 1000.;
		case METERS_PER_SECOND:
		default:
		}
		return value;
	}
106802
public ValueInterval<T, I, V> withValue(V value) {

        return new ValueInterval<>(this.interval, value);

    }
102767
function(value) {
        switch (typeof value) {
            case 'boolean':
                return 'Boolean';

            case 'number':
                return 'Number';

            case 'string':
                return 'String';

            case 'object':
                if (value === null) {
                    return 'Null';
                } else {
                    switch (Object.prototype.toString.call(value)) {
                        case '[object RegExp]':
                            return 'RegExp';

                        case '[object Array]':
                            return 'Array';

                        case '[object Object]':
                            switch (value.constructor) {
                                case JuttleMoment:
                                    if (value.moment) {
                                        return 'Date';
                                    }
                                    if (value.duration) {
                                        return 'Duration';
                                    }
                                    break;   // silence ESLint

                                case Filter:
                                    return 'Filter';

                                case Object:
                                    return 'Object';
                            }
                    }
                }
        }

        throw new Error('Invalid Juttle value: ' + value + '.');
    }
10527
public MetricBuilder withMinValue(Number value, String prettyPrintFormat) {
        min = new MetricValue(value.toString(), prettyPrintFormat);            
        return this;
    }
385507
public CALC val(Object value) {
        Num val = null;
        if (value instanceof Num)
            val = (Num)value;
        else
            val = new Num(value);
                
        infix.add(val);
        return getThis();
    }