@Override public Object fromString(Class targetClass, String s) { try { if (s == null) { return null; } Object o = (Object) s; return o; } catch (NumberFormatException e) { log.error("Number format exception, Caused by {}.", e); throw new PropertyAccessException(e); } }
LOG.error("Error in accessing field, Caused by:" + e.getMessage()); throw new LuceneIndexingException("Error in accessing field:" + field.getName(), e);
/** * Test method for * {@link com.impetus.kundera.property.accessor.EnumAccessor#fromString(java.lang.String)} * . */ @Test public void testGetInstance() { try { Day d = (Day) accessor.getInstance(Day.class); Assert.assertNull(d); } catch (PropertyAccessException e) { Assert.fail(e.getMessage()); } } }
@Override public final String fromBytes(Class targetClass, byte[] bytes) { try { return bytes != null ? new String(bytes, Constants.CHARSET_UTF8) : null; } catch (UnsupportedEncodingException e) { log.error("Unsupported encoding exception, Caused by {}.", e); throw new PropertyAccessException(e); } }
log.info(exp.getMessage() + ". Possible case of entity column in a super column family. Will be treated as a super column.");
@Override public final byte[] toBytes(Object s) throws PropertyAccessException { try { return s != null ? ((String) s).getBytes(Constants.CHARSET_UTF8) : null; } catch (UnsupportedEncodingException e) { log.error("Unsupported encoding exception, Caused by {}.", e); throw new PropertyAccessException(e); } }
/** * Test method for * {@link com.impetus.kundera.property.accessor.EnumAccessor#toBytes(java.lang.Object)} * . */ @Test public void testToBytes() { try { byte[] b = accessor.toBytes(day1); String s = new String(b, Constants.ENCODING); Assert.assertEquals(day1.MONDAY.name(), s); b = accessor.toBytes(null); Assert.assertNull(b); } catch (PropertyAccessException e) { Assert.fail(e.getMessage()); } catch (UnsupportedEncodingException e) { Assert.fail(e.getMessage()); } }
@Override public Byte fromString(Class targetClass, String s) { try { if (s == null) { return null; } Byte b = new Byte(s); return b; } catch (NumberFormatException e) { log.error("Number fromat exception, Caused by {}.", e); throw new PropertyAccessException(e); } }
log.info(exp.getMessage() + ". Possible case of entity column in a super column family. Will be treated as a super column.");
@Override public UUID fromString(Class targetClass, String s) throws PropertyAccessException { try { if (s == null) { return null; } return UUID.fromString(s); } catch (Exception e) { log.error("Error occured, Caused by {}.", e); throw new PropertyAccessException(e); } }
LOG.error("Error in accessing field, Caused by:" + e.getMessage()); throw new LuceneIndexingException("Error in creating indexes on associated columns", e);
@Override public Double fromString(Class targetClass, String s) { try { if (s == null) { return null; } Double d = new Double(s); return d; } catch (NumberFormatException e) { log.error("Number format exception, Caused by {}.", e); throw new PropertyAccessException(e); } }
/** * Test method for * {@link com.impetus.kundera.property.accessor.EnumAccessor#fromBytes(byte[])} * . */ @Test public void testFromBytes() { try { byte[] b = day1.name().getBytes(Constants.ENCODING); Day dd = (Day) accessor.fromBytes(Day.class, b); Assert.assertEquals(day1, dd); Object o = accessor.fromBytes(Day.class, null); Assert.assertNull(o); } catch (UnsupportedEncodingException e) { Assert.fail(e.getMessage()); } catch (PropertyAccessException e) { Assert.fail(e.getMessage()); } }
@Override public Boolean fromString(Class targetClass, String s) { try { if (s == null) { return null; } Boolean b = new Boolean(s); return b; } catch (NumberFormatException e) { log.error("Number format exception, Caused by {}.", e); throw new PropertyAccessException(e); } }
/** * Test method for * {@link com.impetus.kundera.property.accessor.EnumAccessor#fromString(java.lang.String)} * . */ @Test public void testGetCopy() { try { Day day = Day.MONDAY; Day d = (Day) accessor.getCopy(day); Assert.assertNotNull(d); Assert.assertTrue(day.equals(d)); d = (Day) accessor.getCopy(null); Assert.assertNull(d); } catch (PropertyAccessException e) { Assert.fail(e.getMessage()); } }
@Override public Float fromString(Class targetClass, String s) { try { if (s == null) { return null; } Float f = new Float(s); return f; } catch (NumberFormatException e) { log.error("Number format exception, Caused by {}.", e); throw new PropertyAccessException(e); } }
/** * Test method for * {@link com.impetus.kundera.property.accessor.EnumAccessor#fromString(java.lang.String)} * . */ @Test public void testFromString() { try { Day day11 = (Day) accessor.fromString(Day.class, day1.name()); Assert.assertEquals(day1, day11); Day day22 = (Day) accessor.fromString(Day.class, day2.name()); Assert.assertEquals(day2, day22); Day day = (Day) accessor.fromString(Day.class, null); Assert.assertNull(day); day = (Day) accessor.fromString(null, day1.name()); Assert.assertNull(day); day = (Day) accessor.fromString(null, null); Assert.assertNull(day); } catch (PropertyAccessException e) { Assert.fail(e.getMessage()); } }
@Override public Short fromString(Class targetClass, String s) { try { if (s == null) { return null; } Short sh = new Short(s); return sh; } catch (NumberFormatException e) { log.error("Number format exception, Caused by {}.", e); throw new PropertyAccessException(e); } }
log.info(exp.getMessage() + ". Possible case of entity column in a super column family. Will be treated as a super column.");
@Override public Integer fromString(Class targetClass, String s) { try { if (s == null) { return null; } Integer i = new Integer(s); return i; } catch (NumberFormatException e) { log .error("Number format exception, Caused by {}.", e); throw new PropertyAccessException(e); } }