@Override protected Long doForward(String value) { return Long.decode(value); }
@Override protected Long doForward(String value) { return Long.decode(value); }
@Override protected Long doForward(String value) { return Long.decode(value); }
/** * <p>Convert a <code>String</code> to a <code>Long</code>; * since 3.1 it handles hex (0Xhhhh) and octal (0ddd) notations. * N.B. a leading zero means octal; spaces are not trimmed.</p> * * <p>Returns <code>null</code> if the string is <code>null</code>.</p> * * @param str a <code>String</code> to convert, may be null * @return converted <code>Long</code> (or null if the input is null) * @throws NumberFormatException if the value cannot be converted */ public static Long createLong(final String str) { if (str == null) { return null; } return Long.decode(str); }
@Override protected Long doForward(String value) { return Long.decode(value); }
private static int convertInt(String rawValue) { try { // Decode into long, because there are some large hex values in the android resource files // (e.g. config_notificationsBatteryLowARGB = 0xFFFF0000 in sdk 14). // Integer.decode() does not support large, i.e. negative values in hex numbers. // try parsing decimal number return (int) Long.parseLong(rawValue); } catch (NumberFormatException nfe) { // try parsing hex number return Long.decode(rawValue).intValue(); } }
private static int convertInt(String rawValue) { try { // Decode into long, because there are some large hex values in the android resource files // (e.g. config_notificationsBatteryLowARGB = 0xFFFF0000 in sdk 14). // Integer.decode() does not support large, i.e. negative values in hex numbers. // try parsing decimal number return (int) Long.parseLong(rawValue); } catch (NumberFormatException nfe) { // try parsing hex number return Long.decode(rawValue).intValue(); } }
public Long parseValue(final String string, final ClassLoader classLoader) throws IllegalArgumentException { return Long.decode(string.trim()); } });
public class DecodeLong { public static final void main(String[] params) { long l; l = Long.decode("37648"); System.out.println("l = " + l); } }
public int getInteger(String name, int defaultValue) { name = name.toLowerCase(Locale.ENGLISH); String value = prefs.get(name); if (value != null) { // Use Integer.decode() can't handle it if the highest bit is set. return (int)(long) Long.decode(value); } return defaultValue; }
/** * 将16进制的String转化为Long * * 当str为空或非数字字符串时抛NumberFormatException */ public static Long hexToLongObject(@NotNull String str) { // 统一行为,不要有时候抛NPE,有时候抛NumberFormatException if (str == null) { throw new NumberFormatException("null"); } return Long.decode(str); }
public Object fromString(String str) { long value = Long.decode(str).longValue(); if(value < Integer.MIN_VALUE || value > 0xFFFFFFFFl) { throw new NumberFormatException("For input string: \"" + str + '"'); } return new Integer((int)value); }
public TxnLogToolkit(String txnLogFileName, String zxidName) throws TxnLogToolkitException { txnLogFile = loadTxnFile(txnLogFileName); zxid = Long.decode(zxidName); }
/** * 将16进制的String转化为Long,出错时返回默认值. */ public static Long hexToLongObject(@Nullable String str, Long defaultValue) { if (StringUtils.isEmpty(str)) { return defaultValue; } try { return Long.decode(str); } catch (final NumberFormatException nfe) { return defaultValue; } }
/** * Returns the value as a long. * * @param columnIndex (1,2,...) * @return the value */ @Override public long getLong(int columnIndex) throws SQLException { Object o = get(columnIndex); if (o != null && !(o instanceof Number)) { o = Long.decode(o.toString()); } return o == null ? 0 : ((Number) o).longValue(); }
/** * Determines the integer value of the system property with the * specified name, or a default value. * * This behaves just like <code>Long.getLong(String,Long)</code>, except that it * also consults the <code>ServletContext</code>'s "init" parameters. If neither exist, * return the default value. * * @param name property name. * @param def a default value. * @param logLevel the level of the log if the provided system property name cannot be decoded into Long. * @return the {@code Long} value of the property. * If the property is missing, return the default value. * Result may be {@code null} only if the default value is {@code null}. */ public static Long getLong(String name, Long def, Level logLevel) { String v = getString(name); if (v != null) { try { return Long.decode(v); } catch (NumberFormatException e) { // Ignore, fallback to default if (LOGGER.isLoggable(logLevel)) { LOGGER.log(logLevel, "Property. Value is not long: {0} => {1}", new Object[] {name, v}); } } } return def; }
protected String expandInteger(String s) { long value; try { while (s.length() > 1 && s.startsWith("0")) s = s.substring(1); value = Long.decode(s).longValue(); } catch (NumberFormatException e) { logger.info("Cannot convert string \"" + s + "\" to long."); throw e; } return expandInteger(value); }
return (T) (isHexNumber(trimmed) ? Long.decode(trimmed) : Long.valueOf(trimmed));
@Signature(@Arg("value")) public static Memory decode(Environment env, Memory... args) { try { return LongMemory.valueOf(Long.decode(args[0].toString())); } catch (NumberFormatException e) { return Memory.FALSE; } }
@Test public void shouldForwardToSpecifiedIndex() { final long knownIndex = Long.decode(findAnExistingIndex()); basicReader().withStartIndex(knownIndex).execute(); assertThat(capturedOutput.size(), is(25)); // discard first message capturedOutput.poll(); assertThat(capturedOutput.poll().contains(Long.toHexString(knownIndex)), is(true)); }