Package org.apache.commons.beanutils

Examples of org.apache.commons.beanutils.Converter.convert()


  {
    assert name != null;

    Converter c = ConvertUtils.lookup(java.lang.Double.class);

    return ((Double) c.convert(java.lang.Double.class, getParameterAsString(name))).doubleValue();
  }

  public double getParameterAsDouble(String name, double defaultValue)
  {
    assert name != null;
View Full Code Here


  {
    assert name != null;

    Converter c = ConvertUtils.lookup(java.lang.Float.class);

    return ((Float) c.convert(java.lang.Float.class, getParameterAsString(name))).floatValue();
  }

  public float getParameterAsFloat(String name, float defaultValue)
  {
    assert name != null;
View Full Code Here

  {
    assert name != null;

    Converter c = ConvertUtils.lookup(java.lang.Integer.class);

    return ((Integer) c.convert(java.lang.Integer.class, getParameterAsString(name))).intValue();
  }

  public int getParameterAsInt(String name, int defaultValue)
  {
    assert name != null;
View Full Code Here

  {
    assert name != null;

    Converter c = ConvertUtils.lookup(java.lang.Long.class);

    return ((Long) c.convert(java.lang.Long.class, getParameterAsString(name))).longValue();
  }

  public long getParameterAsLong(String name, long defaultValue)
  {
    assert name != null;
View Full Code Here

              throw new IllegalArgumentException("No converter found for class '" + type + "'");
            }

            try
            {
              c.convert(clazz, value);
            }
            catch (ConversionException ce)
            {
              req.addError(name, "Value '" + value + "' cannot be converted to a '" + type + "'");
            }
View Full Code Here

     */
    public void testConvertToString() {

        Converter converter = new CharacterConverter();

        assertEquals("Character Test", "N", converter.convert(String.class, new Character('N')));
        assertEquals("String Test",    "F", converter.convert(String.class, "FOO"));
        assertEquals("Integer Test",   "3", converter.convert(String.class, new Integer(321)));
        assertEquals("Null Test",     null, converter.convert(String.class, null));
    }

View Full Code Here

    public void testConvertToString() {

        Converter converter = new CharacterConverter();

        assertEquals("Character Test", "N", converter.convert(String.class, new Character('N')));
        assertEquals("String Test",    "F", converter.convert(String.class, "FOO"));
        assertEquals("Integer Test",   "3", converter.convert(String.class, new Integer(321)));
        assertEquals("Null Test",     null, converter.convert(String.class, null));
    }

    /**
 
View Full Code Here

        Converter converter = new CharacterConverter();

        assertEquals("Character Test", "N", converter.convert(String.class, new Character('N')));
        assertEquals("String Test",    "F", converter.convert(String.class, "FOO"));
        assertEquals("Integer Test",   "3", converter.convert(String.class, new Integer(321)));
        assertEquals("Null Test",     null, converter.convert(String.class, null));
    }

    /**
     * Test Conversion to Character
View Full Code Here

        Converter converter = new CharacterConverter();

        assertEquals("Character Test", "N", converter.convert(String.class, new Character('N')));
        assertEquals("String Test",    "F", converter.convert(String.class, "FOO"));
        assertEquals("Integer Test",   "3", converter.convert(String.class, new Integer(321)));
        assertEquals("Null Test",     null, converter.convert(String.class, null));
    }

    /**
     * Test Conversion to Character
     */
 
View Full Code Here

    /**
     * Test Conversion to Character
     */
    public void testConvertToCharacter() {
        Converter converter = new CharacterConverter();
        assertEquals("Character Test", new Character('N'), converter.convert(Character.class, new Character('N')));
        assertEquals("String Test",    new Character('F'), converter.convert(Character.class, "FOO"));
        assertEquals("Integer Test",   new Character('3'), converter.convert(Character.class, new Integer(321)));
        try {
            converter.convert(Character.class, null);
            fail("Expected a ConversionException for null value");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.