Computes a length defined using an HTML attribute (e.g. width for tables).
@param value The attribute value
@param whole the value used as 100% when value is a percentage
@return the computed length
333872
public static int computeAttributeLength(String value, int whole) throws NumberFormatException
    {
        String sval = value.trim().toLowerCase();
        if (sval.endsWith("%"))
        {
            double val = Double.parseDouble(sval.substring(0, sval.length() - 1));
            return (int) Math.round(val * whole / 100.0);
        }
        else if (sval.endsWith("px"))
        {
            return (int) Math.rint(Double.parseDouble(sval.substring(0, sval.length() - 2)));
        }
        else
        {
            return (int) Math.rint(Double.parseDouble(sval));
        }
    }
102280
@Override
    public String tagValue(String value) {
        String formattedValue = StringEscapeUtils.escapeJson(delegate.tagValue(value));
        return StringUtils.truncate(formattedValue, TAG_VALUE_MAX_LENGTH);
    }
1374836
public double ptLength(TermLengthOrPercent spec, double whole)
    {
        float nval = spec.getValue();
        if (spec.isPercentage())
        {
            return (whole * nval) / 100;
        }
        else if (spec instanceof TermCalc)
        {
            final CalcArgs args = ((TermCalc) spec).getArgs();
            return args.evaluate(getPtEval().setWhole(whole));
        }
        else
        {
            final TermLength.Unit unit = spec.getUnit();
            if (unit == null)
                return 0;
            switch (unit)
            {
                case pt:
                    return nval;
                case in:
                    return nval * 72;
                case cm:
                    return (nval * 72) / 2.54;
                case mm:
                    return (nval * 72) / 25.4;
                case q:
                    return (nval * 72) / (2.54 * 40.0);
                case pc:
                    return nval * 12;
                case px:
                    return (nval * 72) / dpi;
                case em:
                    return (em * nval * 72) / dpi; //em is in pixels
                case rem:
                    return (rem * nval * 72) / dpi;
                case ex:
                    return (ex * nval * 72) / dpi;
                case ch:
                    return (ch * nval * 72) / dpi;
                case vw:
                    return (viewport.getVisibleRect().getWidth() * nval * 72) / (100.0 * dpi);
                case vh:
                    return (viewport.getVisibleRect().getHeight() * nval * 72) / (100.0 * dpi);
                case vmin:
                    return (Math.min(viewport.getVisibleRect().getWidth(), viewport.getVisibleRect().getHeight()) * nval * 72) / (100.0 * dpi);
                case vmax:
                    return (Math.max(viewport.getVisibleRect().getWidth(), viewport.getVisibleRect().getHeight()) * nval * 72) / (100.0 * dpi);
                default:
                    return 0;
            }
        }
    }
1070979
public static final Number parseExtendedAttributeCurrency(String value)
   {
      Number result;

      if (value == null)
      {
         result = null;
      }
      else
      {
         result = NumberHelper.getDouble(Double.parseDouble(correctNumberFormat(value)) / 100);
      }
      return result;
   }
998161
public static long getLength(ValueData value, int propType)
   {
      if (propType == PropertyType.BINARY)
      {
         return value.getLength();
      }
      else if (propType == PropertyType.NAME || propType == PropertyType.PATH)
      {
         return -1;
      }
      else
      {
         return value.toString().length();
      }
   }
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;
	}
1312781
public int lengthOf(String value) {
        int length = 0;
        if (value != null) {
            length = value.length();
        }
        return length;
    }
814891
public static String lTrim(final String value) {
        if (value == null) {
            return null;
        }

        String trimmed = value;
        int offset = 0;
        final int maxLength = value.length();
        while (offset < maxLength && (value.charAt(offset) == ' ' || value.charAt(offset) == '\t')) {
            offset++;
        }

        if (offset > 0) {
            trimmed = value.substring(offset);
        }

        return trimmed;
    }
422877
function checkLength(str) {
        var ctm = ctx.measureText(str);
        return ctm.width <= tm.width;
      }
615637
public static FractionNumber createMaxDenominator(final double value, int maxDenom, boolean wholeType) {
        final FractionNumber fractionNumber = new FractionNumber(value);
        fractionNumber.wholeType = wholeType;
        
        final SimpleFraction fraction = SimpleFraction.createFractionMaxDenominator(Math.abs(value), maxDenom);
        setupFractionPart(fraction, fractionNumber);
        
        return fractionNumber;
    }
336652
private int checkSkipWriteForFixLengthPart(AbstractPagedOutputView out) throws IOException {
		// skip if there is no enough size.
		int available = out.getSegmentSize() - out.getCurrentPositionInSegment();
		if (available < getSerializedRowFixedPartLength()) {
			out.advance();
			return available;
		}
		return 0;
	}
363944
public static int sizeOfInteger(int value) {
        int contentLength = 0;
        do {
            value >>>= 8;
            contentLength++;
        } while (value != 0);
        return DerUtils.sizeOf(ASN1_INTEGER_TAG_NUM, contentLength);
    }
519000
public static String filterHtmlAttributes(SoyValue value) {
    value = normalizeNull(value);
    if (isSanitizedContentOfKind(value, SanitizedContent.ContentKind.ATTRIBUTES)) {
      // We're guaranteed to be in a case where key=value pairs are expected. However, if it would
      // cause issues to directly abut this with more attributes, add a space. For example:
      // {$a}{$b} where $a is foo=bar and $b is boo=baz requires a space in between to be parsed
      // correctly, but not in the case where $a is foo="bar".
      // TODO: We should be able to get rid of this if the compiler can guarantee spaces between
      // adjacent print statements in attribute context at compile time.
      String content = value.coerceToString();
      if (content.length() > 0) {
        if (shouldAppendSpace(content.charAt(content.length() - 1))) {
          content += ' ';
        }
      }
      return content;
    }
    return filterHtmlAttributes(value.coerceToString());
  }
344875
private static int computeFieldSize(AttributeValue value) throws DBaseFileException, AttributeException {
		final DBaseFieldType dbftype = DBaseFieldType.fromAttributeType(value.getType());
		return dbftype.getFieldSize(value.getString());
	}
545895
function(value) {
      
      if (value === "text") {
        value = this.text().trim();
        
      } else if (value === "html") {
        value = this.html().trim();
        
      } else if (value === "val") {
        value = this.val();
      
      } else if (value.indexOf("attr:") === 0) {
        value = this.attr(value.substr(5));
      }
      
      return value;
    }
97351
function getLength(value) {
  if (typeof value !== 'object') {
    return 0;
  }

  if (isValue(value.length)) {
    return value.length;
  }

  return Object.keys(value).length;
}
423210
public static Duration parse(String value) {
		/*
		 * Implementation note: Regular expressions are not used to improve
		 * performance.
		 */

		if (value.length() == 0) {
			throw parseError(value);
		}

		int index = 0;
		char first = value.charAt(index);
		boolean prior = (first == '-');
		if (first == '-' || first == '+') {
			index++;
		}

		if (value.charAt(index) != 'P') {
			throw parseError(value);
		}

		Builder builder = new Builder();
		builder.prior(prior);

		StringBuilder buffer = new StringBuilder();
		for (int i = index + 1; i < value.length(); i++) {
			char c = value.charAt(i);

			if (c == 'T') {
				/*
				 * A "T" character is supposed to immediately precede the time
				 * component value(s). It is required by the syntax, but not
				 * really necessary. Ignore it.
				 */
				continue;
			}

			if (c >= '0' && c <= '9') {
				buffer.append(c);
				continue;
			}

			if (buffer.length() == 0) {
				throw parseError(value);
			}

			Integer num = Integer.valueOf(buffer.toString());
			buffer.setLength(0);

			switch (c) {
			case 'W':
				builder.weeks(num);
				break;
			case 'D':
				builder.days(num);
				break;
			case 'H':
				builder.hours(num);
				break;
			case 'M':
				builder.minutes(num);
				break;
			case 'S':
				builder.seconds(num);
				break;
			default:
				throw parseError(value);
			}
		}

		return builder.build();
	}