@Override protected Object doRestore(final String data) { return new Color(Integer.parseInt(data, 16)); }
@Override protected String doEncode(final Object object) { final Color color = (Color) object; return Integer.toHexString(color.intValue()); }
@Override public String titleString(final Object object) { final Color color = (Color) object; return color.title(); }
public void testIsLessThan() throws Exception { assertTrue(Color.BLACK.isLessThan(Color.WHITE)); } }
@Override protected Object doRestore(final String data) { return new Color(Integer.parseInt(data, 16)); }
@Override protected String doEncode(final Object object) { final Color color = (Color) object; return Integer.toHexString(color.intValue()); }
@Override public String titleString(final Object object) { final Color color = (Color) object; return color.title(); }
public Object nullSafeGet(final ResultSet rs, final String[] names, final Object owner) throws HibernateException, SQLException { int color = rs.getInt(names[0]); if (rs.wasNull()) return null; return new Color(color); }
public int colorValue(final NakedObject object) { if (object == null) { return 0; } final Color color = (Color) object.getObject(); return color.intValue(); }
@Override protected Object doParse(final Object original, final String text) { try { if (text.startsWith("0x")) { return new Color(Integer.parseInt(text.substring(2), 16)); } else if (text.startsWith("#")) { return new Color(Integer.parseInt(text.substring(1), 16)); } else { return new Color(Integer.parseInt(text)); } } catch (final NumberFormatException e) { throw new TextEntryParseException("Not a number " + text, e); } }
public int colorValue(final NakedObject object) { if (object == null) { return 0; } final Color color = (Color) object.getObject(); return color.intValue(); }
@Override protected Object doParse(final Object original, final String text) { try { if (text.startsWith("0x")) { return new Color(Integer.parseInt(text.substring(2), 16)); } else if (text.startsWith("#")) { return new Color(Integer.parseInt(text.substring(1), 16)); } else { return new Color(Integer.parseInt(text)); } } catch (final NumberFormatException e) { throw new TextEntryParseException("Not a number " + text, e); } }
public void nullSafeSet(final PreparedStatement st, final Object value, final int index) throws HibernateException, SQLException { if (value == null) { st.setNull(index, Hibernate.INTEGER.sqlType()); } else { st.setInt(index, ((Color)value).intValue()); } }
public NakedObject createValue(final NakedObject object, final int colorAsInt) { final Color color = new Color(colorAsInt); return getRuntimeContext().adapterFor(color); }
public String titleStringWithMask(final Object object, final String usingMask) { final Color color = (Color) object; return titleString(new DecimalFormat(usingMask), color.intValue()); }
public NakedObject createValue(final NakedObject object, final int colorAsInt) { final Color color = new Color(colorAsInt); return getRuntimeContext().adapterFor(color); }
public void testNullSafeGetNotNull() throws Exception { final int value = 4; final MockControl<ResultSet> control = MockControl.createControl(ResultSet.class); final ResultSet rs = (ResultSet) control.getMock(); control.expectAndReturn(rs.getInt(names[0]), value); control.expectAndReturn(rs.wasNull(), false); control.replay(); // finished recording final ColorType type = new ColorType(); final Color returned = (Color) type.nullSafeGet(rs, names, null); assertEquals("color", value, returned.intValue()); control.verify(); }
public void testNullSafeSetNotNull() throws Exception { final int value = 5; final Color color = new Color(value); final MockControl<PreparedStatement> control = MockControl.createControl(PreparedStatement.class); final PreparedStatement ps = (PreparedStatement) control.getMock(); ps.setInt(1, value); control.replay(); // finished recording final ColorType type = new ColorType(); type.nullSafeSet(ps, color, 1); control.verify(); }