/** * @deprecated Use the CharSequence version * @see #capitalize(CharSequence) */ @Deprecated public static String capitalize(String self) { return capitalize((CharSequence) self); }
/** * @deprecated Use the CharSequence version * @see #toBigDecimal(CharSequence) */ @Deprecated public static BigDecimal toBigDecimal(String self) { return toBigDecimal((CharSequence) self); }
/** * @deprecated Use the CharSequence version * @see #toBigInteger(CharSequence) */ @Deprecated public static BigInteger toBigInteger(String self) { return toBigInteger((CharSequence) self); }
private String[] tokenize(String pattern) { List<String> list = StringGroovyMethods.tokenize((CharSequence) pattern, (CharSequence) pathSeparator); return list.toArray(new String[0]); }
public static <T> T asType(String self, Class<T> c) { if (c == List.class) { return (T) toList((CharSequence)self); } else if (c == BigDecimal.class) { return (T) toBigDecimal((CharSequence)self); } else if (c == BigInteger.class) { 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); } else if (c == Short.class || c == Short.TYPE) { return (T) toShort((CharSequence)self); } else if (c == Byte.class || c == Byte.TYPE) { return (T) Byte.valueOf(self.trim()); } else if (c == Character.class || c == Character.TYPE) { return (T) toCharacter(self); } else if (c == Double.class || c == Double.TYPE) { return (T) toDouble((CharSequence)self); } else if (c == Float.class || c == Float.TYPE) { return (T) toFloat((CharSequence)self); } else if (c == File.class) { return (T) new File(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); }
/** * @deprecated Use the CharSequence version * @see #toInteger(CharSequence) */ @Deprecated public static Integer toInteger(String self) { return toInteger((CharSequence) self); }
/** * @deprecated Use the CharSequence version * @see #toLong(CharSequence) */ @Deprecated public static Long toLong(String self) { return toLong((CharSequence) self); }
@Deprecated public static Boolean toBoolean(String self) { return StringGroovyMethods.toBoolean(self); }
/** * @deprecated Use the CharSequence version * @see #padLeft(CharSequence, Number) */ @Deprecated public static String padLeft(String self, Number numberOfChars) { return padLeft((CharSequence) self, numberOfChars); }
/** * @deprecated Use the CharSequence version * @see #toFloat(CharSequence) */ @Deprecated public static Float toFloat(String self) { return toFloat((CharSequence) self); }
/** * @deprecated Use the CharSequence version * @see #toDouble(CharSequence) */ @Deprecated public static Double toDouble(String self) { return toDouble((CharSequence) self); }
@Deprecated @SuppressWarnings("unchecked") public static List<String> tokenize(String self) { return StringGroovyMethods.tokenize(self); }
@Deprecated public static Integer toInteger(CharSequence self) { return StringGroovyMethods.toInteger(self); }
@Deprecated public static Long toLong(String self) { return StringGroovyMethods.toLong(self); }
/** * Converts the text of this GPathResult to a Boolean object. * * @return the GPathResult, converted to a <code>Boolean</code> */ public Boolean toBoolean() { return StringGroovyMethods.toBoolean(text()); }
/** * @deprecated Use the CharSequence version * @see #padLeft(CharSequence, Number, CharSequence) */ @Deprecated public static String padLeft(String self, Number numberOfChars, String padding) { return padLeft((CharSequence) self, numberOfChars, (CharSequence) padding); }
@Deprecated public static Float toFloat(CharSequence self) { return StringGroovyMethods.toFloat(self); }
@Deprecated public static Double toDouble(String self) { return StringGroovyMethods.toDouble(self); }
/** * @deprecated Use the CharSequence version * @see #tokenize(CharSequence, Character) */ @Deprecated public static List<String> tokenize(String self, Character delimiter) { return tokenize((CharSequence) self, delimiter); }