/** * @deprecated Use the CharSequence version * @see #toLong(CharSequence) */ @Deprecated public static Long toLong(String self) { return toLong((CharSequence) self); }
@Deprecated public static Long toLong(CharSequence self) { return StringGroovyMethods.toLong(self); }
@Deprecated public static Long toLong(String self) { return StringGroovyMethods.toLong(self); }
/** * Converts the text of this GPathResult to a Long object. * * @return the GPathResult, converted to a <code>Long</code> */ public Long toLong() { return StringGroovyMethods.toLong(text()); }
/** * Converts the text of this GPathResult to a Long object. * * @return the GPathResult, converted to a <code>Long</code> */ public Long toLong() { if(textIsEmptyOrNull()){ return null; } return StringGroovyMethods.toLong((CharSequence)text()); }
return (T) toBigInteger((CharSequence)self); } else if (c == Long.class || c == Long.TYPE) { return (T) toLong((CharSequence)self); } else if (c == Integer.class || c == Integer.TYPE) { return (T) toInteger((CharSequence)self);
public void testToMethods() throws Exception { assertEquals(StringGroovyMethods.toInteger("1"), new Integer(1)); assertEquals(StringGroovyMethods.toLong("1"), new Long(1)); assertEquals(StringGroovyMethods.toFloat("1"), new Float(1)); assertEquals(StringGroovyMethods.toDouble("1"), new Double(1)); assertEquals(StringGroovyMethods.toBigInteger("1"), new BigInteger("1")); assertEquals(StringGroovyMethods.toBigDecimal("1"), new BigDecimal("1")); assertEquals(StringGroovyMethods.toBoolean("True"), Boolean.TRUE); assertEquals(StringGroovyMethods.toBoolean("Y"), Boolean.TRUE); assertEquals(StringGroovyMethods.toBoolean(" y "), Boolean.TRUE); assertEquals(StringGroovyMethods.toBoolean("1"), Boolean.TRUE); assertEquals(StringGroovyMethods.toBoolean("false"), Boolean.FALSE); assertEquals(StringGroovyMethods.toBoolean("n"), Boolean.FALSE); assertEquals(StringGroovyMethods.toBoolean("0"), Boolean.FALSE); }
/** * Converts the text of this GPathResult to a Long object. * * @return the GPathResult, converted to a <code>Long</code> */ public Long toLong() { if(textIsEmptyOrNull()){ return null; } return StringGroovyMethods.toLong((CharSequence)text()); }