Convert a string to an integer.

@param value value to convert
@return converted value, or <code>null</code> if the supplied value was <code>null</code>
@throws IllegalArgumentException if the supplied value could not be parsed
430148
static Integer integer(String value) {
        Integer result;
        if (value != null) {
            value = value.trim();
            Matcher matcher = INTEGER_PATTERN.matcher(value);
            if (matcher.matches()) {
                result = Integer.parseInt(matcher.group(1).replace(" ", ""));
            } else {
                throw new IllegalArgumentException("Unknown format for value: " + value);
            }
        } else {
            result = null;
        }
        return result;
    }
34696
public static Integer checkNull(Integer value, Integer elseValue) {
        return isNull(value) ? elseValue : value;
    }
857823
public static AcceptStatus fromValue(int value) {
        AcceptStatus status = VALUES.get(value);
        if (status == null) {
            status = new AcceptStatus(value);
            VALUES.put(value, status);
        }
        return status;
    }
792457
public static int
intValue(String option) {
	String s = value(option);
	if (s != null) {
		try {
			int val = Integer.parseInt(s);
			if (val > 0)
				return (val);
		}
		catch (NumberFormatException e) {
		}
	}
	return (-1);
}
1143503
public static Integer parseInt(String param) {
		try {
			if (!StringUtils.isBlank(param)) {
				return Integer.valueOf(param);
			}
		} catch (Exception e) {
			throw new IllegalArgumentException("Parameter " + param + " is not a number.");
		}
		return null;
	}
1009831
public <T> T convert(String value, Class<T> to) {
        if (Strings.isEmpty(value) && !(String.class.equals(to) || String[].class.equals(to))) {
            return null;
        }

        if (String.class.equals(to)) {
            return to.cast(value);
        } else if (Integer.class.equals(to)) {
            return to.cast(Integer.valueOf(value));
        } else if (Double.class.equals(to)) {
            return to.cast(Double.valueOf(value));
        } else if (Long.class.equals(to)) {
            return to.cast(Long.valueOf(value));
        } else if (Boolean.class.equals(to)) {
            return to.cast(Boolean.valueOf(value));
        } else if (URL.class.equals(to)) {
            try {
                return to.cast(new URI(value).toURL());
            } catch (MalformedURLException e) {
                throw new IllegalArgumentException("Unable to convert value " + value + " to URL", e);
            } catch (URISyntaxException e) {
                throw new IllegalArgumentException("Unable to convert value " + value + " to URL", e);
            }
        } else if (URI.class.equals(to)) {
            try {
                return to.cast(new URI(value));
            } catch (URISyntaxException e) {
                throw new IllegalArgumentException("Unable to convert value " + value + " to URL", e);
            }
        } else {
            String trimmedValue = extractEnumName(value);
            if (to.isEnum()) {
                return (T) Enum.valueOf((Class<Enum>) to, trimmedValue.toUpperCase());
            } else if (String[].class.equals(to)) {
                final String[] convertedArray = value.split(",");
                if (convertedArray.length == 0) {
                    return to.cast(new String[0]);
                }

                trimElements(convertedArray);

                if (convertedArray.length == 1 && hasOnlyBlanks(convertedArray)) {
                    return to.cast(new String[0]);
                }

                return to.cast(convertedArray);
            } else if (Charset.class.equals(to)) {
                return to.cast(Charset.forName(trimmedValue.toUpperCase()));
            } else if (Class.class.equals(to)) {
                try {
                    Object clazz = Class.forName(value);
                    return to.cast(clazz);
                } catch (Exception e) {
                    throw new IllegalArgumentException("Unable to find class [" + value + "].", e);
                }
            } else // Try to create instance via reflection
            {
                try {
                    Object instance = Class.forName(value).newInstance();
                    return to.cast(instance);
                } catch (Exception e) {
                    throw new IllegalArgumentException(
                        "Unable to convert value [" + value + "] to a class [" + to.getName() + "].", e);
                }
            }
        }
    }
363622
@Override
    public Byte convert(Object value) {
        if (value instanceof Number) {
            double d = ((Number)value).doubleValue();
            if (Double.isNaN(d) || Math.round(d)!=d) throw new IllegalArgumentException("Not a valid byte: " + value);
            long l = ((Number)value).longValue();
            if (l>=Byte.MIN_VALUE && l<=Byte.MAX_VALUE) return Byte.valueOf((byte)l);
            else throw new IllegalArgumentException("Value too large for byte: " + value);
        } else if (value instanceof String) {
            return Byte.parseByte((String)value);
        } else return null;
    }
1071004
public static int toIntWithDefault(String value, int defaultValue) {

        int result = defaultValue;
        try {
            result = Integer.parseInt(value);
        } catch (@SuppressWarnings("unused") Exception e) {
            // Do nothing, return default.
        }
        return result;
    }
811160
public static Integer asInteger(Object value) {
    int intValue;
    switch (value.getClass().getCanonicalName()) {
      case "java.math.BigDecimal":
        intValue = ((BigDecimal) value).intValue();
        break;
      case "java.lang.Boolean":
        intValue = (Boolean) value ? 1 : 0;
        break;
      case "java.lang.Integer":
        intValue = (Integer) value;
        break;
      default:
        intValue = (Integer) value;
        break;
    }
    return intValue;
  }
294903
public static final Integer getInteger(String value)
   {
      Integer result;

      try
      {
         result = Integer.valueOf(Integer.parseInt(value));
      }

      catch (Exception ex)
      {
         result = null;
      }

      return (result);
   }
1188349
public static Color fromString(String value) {
    for (Converter converter : CONVERTERS) {
      Color color = converter.getColor(value);
      if (color != null) {
        return color;
      }
    }
    throw new IllegalArgumentException(
        String.format("Did not know how to convert %s into color", value)
    );
  }
170407
public static Integer readInteger(String value, Integer defaultValue) {
		if (!StringUtils.hasText(value)) return defaultValue;
		
		return Integer.valueOf(value);
	}
1159141
private int parseInteger(String value, int defaultValue)
	{
		try
		{
			return Integer.parseInt(value);
		}
		catch (NumberFormatException e)
		{
			return defaultValue;
		}
	}
158861
public static boolean isIntValue(final String value) {
        try {
            Integer.parseInt(value);
            return true;
        } catch (final NumberFormatException ex) {
            return false;
        }
    }
1105397
@Override
    public String convertTo(final Object value) {
        if (value == null) return "null";
        return convertTo(value.getClass(), value);
    }
1036910
public static int stringToInteger(String string) {
        string = string.trim();
        if (Checker.isNumber(string)) {
            return Integer.parseInt(string);
        }
        return -1;
    }
1251145
function encodeInteger(value) {
	if (value === null) {
		return values.NULL;
	} else if (!isNaN(value) && parseInt(value)==value) {
		return value + "";
	} else {
		throw new Error('Invalid integer value "' + value + '"');
	}
}