List of usage examples for org.apache.commons.lang.builder ToStringBuilder reflectionToString
public static String reflectionToString(Object object, ToStringStyle style)
Forwards to ReflectionToStringBuilder
.
From source file:org.gsafeproject.audit.domain.Event.java
@Override public String toString() { return ToStringBuilder.reflectionToString(this, MyToStringBuilder.getInstance()); }
From source file:org.jbuilt.components.html.raw.base.AbstractCommandComponent.java
/** * Generic reflection-based toString.// w w w .j a v a 2s.c om * @see java.lang.Object#toString() */ @Override public String toString() { // TODO: change to not use reflection toString if (LOG.isWarnEnabled()) { // LOG.warn("Remember to over-ride toString " + ClassUtils.getShortClassName(getClass()) + "!"); } return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); }
From source file:org.jbuilt.components.html.raw.base.AbstractComponent.java
/** * Generic reflection-based toString./*from w w w . j a v a 2s . c o m*/ * @see java.lang.Object#toString() */ @Override public String toString() { // TODO: change to not use reflection toString if (LOG.isWarnEnabled()) { // LOG.warn("Remember to over-ride toString " + ClassUtils.getShortClassName(getClass()) + "!"); } return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); }
From source file:org.jbuilt.components.html.raw.base.AbstractFormComponent.java
/** * Generic reflection-based toString.//from w ww .j a v a2s. com * * @see java.lang.Object#toString() */ @Override public String toString() { // TODO: change to not use reflection toString if (LOG.isWarnEnabled()) { // LOG.warn("Remember to over-ride toString " + // ClassUtils.getShortClassName(getClass()) + "!"); } return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); }
From source file:org.jbuilt.utils.ClassClassMapEntry.java
/** * Generic reflection-based toString.//w w w . ja va 2s . c om * @see java.lang.Object#toString() */ @Override public String toString() { // TODO: change to not use reflection toString if (LOG.isWarnEnabled()) { //LOG.warn("Remember to over-ride toString " + ClassUtils.getShortClassName(getClass()) + "!"); } return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); }
From source file:org.jobjects.dao.annotation.Manager.java
/** * Persistance du bean annot avec DaoTable ainsi que DaoField. Si pour une * raison quelconque une problme survient, l'exception CreateException sera * leve.//from w w w.j a v a 2s.c o m * @param bean Le bean d'un type quelconque comportant des annotations daoTable et * DaoField * @return Un bean de mme type que celui pass en paramtre. Les donnes du * bean sont rafraichi partir de la base au cas o celle-ci aurait * modifi les donnes grace des trigger ou autre. * @throws CreateException * Exception leve au sur problme de persistance. */ public final T create(final T bean) throws CreateException { T returnValue = null; try { String msg = "Cannot create " + entityClass.getCanonicalName() + " : " + ToStringBuilder.reflectionToString(bean, ToStringStyle.MULTI_LINE_STYLE); if (null == sql_create) { sql_create = loadSqlCreate(usualTable, fields); } returnValue = entityClass.newInstance(); try { Connection connection = getConnection(); try { PreparedStatement pstmt = connection.prepareStatement(sql_create); try { int i = 1; for (Field field : fields) { Annotation[] annotations = field.getAnnotations(); for (Annotation annotation : annotations) { if (annotation instanceof DaoField) { Object obj = BeanUtils.getProperty(bean, field.getName()); if (obj == null) { pstmt.setNull(i++, ((DaoField) annotation).type()); } else { setAll(pstmt, i++, obj); } break; } } } pstmt.executeUpdate(); } finally { pstmt.close(); } pstmt = null; } finally { connection.close(); } connection = null; } catch (SQLException sqle) { log.error(msg, sqle); throw new CreateException(msg, sqle); } try { returnValue = load(bean); } catch (FinderException le) { log.error(msg, le); throw new CreateException(msg, le); } } catch (Exception e) { throw new CreateException(e); } return returnValue; }
From source file:org.jobjects.dao.annotation.Manager.java
/** * Retourne le bean partir de la clef primaire. Si la ligne n'existe pas * dans la base alors une exception FinderException est leve. * @param beanPk Le bean d'un type quelconque comportant des annotations daoTable et * DaoField. Il represente la clef primaire de la table. * @return Un bean de mme type que celui pass en paramtre. Les donnes du * bean sont rafraichi partir de la base au cas o celle-ci aurait * modifi les donnes grace des trigger ou autre. * @throws FinderException Returne un exception si le bean n'existe pas. *///from www. j a v a2s .c om public final T load(final P beanPk) throws FinderException { T returnValue = null; try { String msg = "Load error " + entityClass.getCanonicalName() + " : " + ToStringBuilder.reflectionToString(beanPk, ToStringStyle.MULTI_LINE_STYLE); try { Connection connection = getConnection(); try { if (null == sql_load) { sql_load = loadSqlLoad(usualTable, fields); } PreparedStatement pstmt = connection.prepareStatement(sql_load); try { int i = 1; for (Field field : fields) { Annotation[] annotations = field.getAnnotations(); for (Annotation annotation : annotations) { if (annotation instanceof DaoField) { if (((DaoField) annotation).isPrimary()) { Object obj = BeanUtils.getProperty(beanPk, field.getName()); if (obj == null) { pstmt.setNull(i++, ((DaoField) annotation).type()); } else { setAll(pstmt, i++, obj); } } break; } } } ResultSet rs = pstmt.executeQuery(); try { if (!rs.next()) { throw new FinderException(msg); } returnValue = entityClass.newInstance(); int j = 1; for (Field field : fields) { Annotation[] annotations = field.getAnnotations(); for (Annotation annotation : annotations) { if (annotation instanceof DaoField) { // field.set(returnValue, // rs.getObject(j++)); BeanUtils.setProperty(returnValue, field.getName(), rs.getObject(j++)); break; } } } } finally { rs.close(); } rs = null; } finally { pstmt.close(); } pstmt = null; } finally { connection.close(); } connection = null; } catch (SQLException sqle) { log.error(msg, sqle); throw new FinderException(msg, sqle); } } catch (Exception e) { throw new FinderException(e); } return returnValue; }
From source file:org.jobjects.dao.annotation.Manager.java
/** * @param bean le bean sauvegarder/*from w w w. j a v a 2s. c o m*/ * @return le bean sauvegard * @throws SaveException Problme de persistance */ public final T save(final T bean) throws SaveException { T returnValue = null; String msg = "Cannot save " + entityClass.getCanonicalName() + " : " + ToStringBuilder.reflectionToString(bean, ToStringStyle.MULTI_LINE_STYLE); try { if (isExist(bean)) { saveReal(bean); } else { create(bean); } returnValue = load(bean); } catch (Exception ce) { log.error(msg, ce); throw new SaveException(msg, ce); } return returnValue; }
From source file:org.jobjects.dao.annotation.Manager.java
/** * Sauvegarde le bean dans la base. Une exception SaveException peut tre * leve si un problme survient.//from w w w . j av a 2 s.co m * @param bean le bean sauvegarder * @return Un boolean positif si la mise en jour s'est relement pass. * @throws SaveException Problme de persistance */ private boolean saveReal(final T bean) throws SaveException { boolean returnValue = true; String msg = "Cannot save " + entityClass.getCanonicalName() + " : " + ToStringBuilder.reflectionToString(bean, ToStringStyle.MULTI_LINE_STYLE); try { Connection connection = getConnection(); try { if (null == sql_save) { sql_save = loadSqlSave(usualTable, fields); } PreparedStatement pstmt = connection.prepareStatement(sql_save); try { int i = 1; for (Field field : fields) { Annotation[] annotations = field.getAnnotations(); for (Annotation annotation : annotations) { if (annotation instanceof DaoField) { if (!((DaoField) annotation).isPrimary()) { Object obj = BeanUtils.getProperty(bean, field.getName()); if (obj == null) { pstmt.setNull(i++, ((DaoField) annotation).type()); } else { setAll(pstmt, i++, obj); } } break; } } } for (Field field : fields) { Annotation[] annotations = field.getAnnotations(); for (Annotation annotation : annotations) { if (annotation instanceof DaoField) { if (((DaoField) annotation).isPrimary()) { Object obj = BeanUtils.getProperty(bean, field.getName()); if (obj == null) { pstmt.setNull(i++, ((DaoField) annotation).type()); } else { setAll(pstmt, i++, obj); } } break; } } } returnValue = pstmt.executeUpdate() == 1; } finally { pstmt.close(); } pstmt = null; } finally { connection.close(); } connection = null; } catch (Exception sqle) { log.error(msg, sqle); throw new SaveException(msg, sqle); } return returnValue; }
From source file:org.jobjects.dao.annotation.Manager.java
/** * @param beanPk le bean supprimer/* ww w .j a v a 2s . c om*/ * @throws RemoveException Problme de suppression */ public final void remove(final P beanPk) throws RemoveException { String msg = "Delete error " + entityClass.getCanonicalName() + " : " + ToStringBuilder.reflectionToString(beanPk, ToStringStyle.MULTI_LINE_STYLE); try { Connection connection = getConnection(); try { if (null == sql_delete) { sql_delete = loadSqlDelete(usualTable, fields); } PreparedStatement pstmt = connection.prepareStatement(sql_delete); try { int i = 1; for (Field field : fields) { Annotation[] annotations = field.getAnnotations(); for (Annotation annotation : annotations) { if (annotation instanceof DaoField) { if (((DaoField) annotation).isPrimary()) { Object obj = BeanUtils.getProperty(beanPk, field.getName()); if (obj == null) { pstmt.setNull(i++, ((DaoField) annotation).type()); } else { setAll(pstmt, i++, obj); } } break; } } } pstmt.executeUpdate(); } finally { pstmt.close(); } pstmt = null; } finally { connection.close(); } connection = null; } catch (Exception sqle) { log.error(msg, sqle); throw new RemoveException(msg, sqle); } }