Utility method used to convert a Number into a BigInteger.

@param value Number instance
@return BigInteger instance
192699
public static final BigInteger getBigInteger(Number value)
   {
      BigInteger result = null;
      if (value != null)
      {
         if (value instanceof BigInteger)
         {
            result = (BigInteger) value;
         }
         else
         {
            result = BigInteger.valueOf(Math.round(value.doubleValue()));
         }
      }
      return (result);
   }
448791
static BigDecimal decimal(String value) {
        BigDecimal result;
        if (value != null) {
            value = value.trim();
            Matcher matcher = DECIMAL_PATTERN.matcher(value);
            if (matcher.matches()) {
                result = new BigDecimal(matcher.group(1));
            } else {
                throw new IllegalArgumentException("Unknown format for value: " + value);
            }
        } else {
            result = null;
        }
        return result;
    }
971952
public static Integer isInteger(String value) {
		Validate.notNull(value);
		Validate.notEmpty(value);
		Integer intValue = null;
		try{
			intValue = 	Integer.parseInt(value);
		} catch(NumberFormatException e){
			throw new TypeException("Integer");
		}
		return intValue;
	}
549689
public static String spellBigNumber(final Number value)
    {
        BigDecimal v = new BigDecimal(value.toString());

        if (THOUSAND.compareTo(v.abs()) > 0)
            return value.toString();

        boolean isPlural = needPlural(v.unscaledValue().intValue());

        for (BigDecimal bigNum : bigDecExponents.keySet())
            if (bigNum.multiply(THOUSAND).compareTo(v.abs()) > 0)
                return context.get().formatMessage(
                        (isPlural) ? bigDecExponents.get(bigNum) + ".pl" : bigDecExponents.get(bigNum),
                        v.divide(bigNum));

        return value.toString();
    }
771263
private static Object toLong( BigDecimal value)
    {
    Object number;
        
    try
      {
      number =
        value.scale() == 0
        ? Long.valueOf( value.longValueExact())
        : null;
      }
    catch( Exception e)
      {
      number = null;
      }
        
    return number;
    }
702818
@Pure
	@Inline(value = "$2.valueOf($1.longValue())", imported = {BigInteger.class})
	public static BigInteger toBigInteger(AtomicDouble number) {
		return BigInteger.valueOf(number.longValue());
	}
193199
private static BigInteger decodeBigInteger(String value) {
		int radix = 10;
		int index = 0;
		boolean negative = false;

		// Handle minus sign, if present.
		if (value.startsWith("-")) {
			negative = true;
			index++;
		}

		// Handle radix specifier, if present.
		if (value.startsWith("0x", index) || value.startsWith("0X", index)) {
			index += 2;
			radix = 16;
		}
		else if (value.startsWith("#", index)) {
			index++;
			radix = 16;
		}
		else if (value.startsWith("0", index) && value.length() > 1 + index) {
			index++;
			radix = 8;
		}

		BigInteger result = new BigInteger(value.substring(index), radix);
		return (negative ? result.negate() : result);
	}
902924
public IntegerConstant getIntegerByValue(int value)
  {
    for (int i = 0; i < _entries.size(); i++) {
      ConstantPoolEntry entry = _entries.get(i);

      if (! (entry instanceof IntegerConstant))
        continue;

      IntegerConstant integerEntry = (IntegerConstant) entry;

      if (integerEntry.getValue() == value)
        return integerEntry;
    }

    return null;
  }
393824
public static int toIntExact(long value) {
        if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
            throw new ArithmeticException("integer overflow");
        }

        return (int) value;
    }
620347
private String getIntegerString(Number value)
   {
      return (value == null ? null : Integer.toString(value.intValue()));
   }
690997
public static int getInteger(
    Object  value)
  {
    if (value == null)
    {
        return 0;
    }

    if (value instanceof Number)
    {
        return ((Number) value).intValue();
    }

    return Integer.valueOf(value.toString()).intValue();

  }
500486
public static int calculateEncodedLength(BigInteger value) {
        if (value == null) {
            return 1;
        }
        int bytesLength = (value.bitLength() >> 3) + 1;
        return bytesLength < 0x7f ? (1 + bytesLength) : (5 + bytesLength);
    }
826238
public BigInteger toBigInteger(Object val) {
    if (val == null) {
      return BigInteger.ZERO;
    }
    else if (val instanceof BigInteger) {
      return (BigInteger) val;
    }
    else if (val instanceof Double) {
      if (!Double.isNaN(((Double) val).doubleValue())) {
        return new BigInteger(val.toString());
      }
      else {
        return BigInteger.ZERO;
      }
    }
    else if (val instanceof Number) {
      return new BigInteger(val.toString());
    }
    else if (val instanceof String) {
      String string = (String) val;
      if ("".equals(string.trim())) {
        return BigInteger.ZERO;
      }
      else {
        return new BigInteger(string);
      }
    }
    else if (val instanceof Character) {
      int i = ((Character) val).charValue();
      return BigInteger.valueOf(i);
    }

    throw new ArithmeticException("BigInteger coercion: " + val.getClass().getName() + ":(" + val + ")");
  }
783712
public static BigInteger read(String value) {
		if (!StringUtils.hasText(value)) return null;
		
		return new BigInteger(value);
	}
159376
public boolean containsInteger(int value) {
		for (int i = 1; i < maxPoolSize; i++) {
			if (types[i] == INTEGER && readInteger(i) == value) return true;
		}
		return false;
	}
61087
public IntegerConstant addInteger(int value)
  {
    IntegerConstant entry = getIntegerByValue(value);

    if (entry != null)
      return entry;

    entry = new IntegerConstant(this, _entries.size(), value);

    addConstant(entry);

    return entry;
  }
303222
public static int asInteger(Object value) {
        if (value instanceof Number) {
            return ((Number) value).intValue();
        } else if (value instanceof Numeric) {
            return ((Numeric) value).asInteger();
        } else if (value instanceof Boolean) {
            return ((Boolean) value) ? 1 : 0;
        } else if (value instanceof CharSequence) {
            try {
                return Integer.parseInt(value.toString());
            } catch (NumberFormatException nfe) {
                throw new IncompatibleValueException(
                        "Unable to parse string \"" + Strings.escape(value.toString()) +
                        "\" to an int", nfe);
            }
        } else if (value instanceof Date) {
            // Convert date timestamp to seconds since epoch.
            return (int) (((Date) value).getTime() / 1000);
        }
        throw new IncompatibleValueException("Unable to convert " + value.getClass().getSimpleName() + " to an int");
    }