package com.primeton.dgs.kernel.core.dao.hibernate; import java.util.concurrent.atomic.AtomicInteger; public class HibernateStatementDynamicField extends HibernateStatementField { private static final long serialVersionUID = 1L; private String property; private String onEmpty; public String getProperty() { return this.property; } public void setProperty(String property) { this.property = property; } public String getOnEmpty() { return this.onEmpty; } public void setOnEmpty(String onEmpty) { this.onEmpty = onEmpty; } public boolean onEmpty() { return ("true".equalsIgnoreCase(this.onEmpty)) || ("yes".equalsIgnoreCase(this.onEmpty)); } public HibernateStatementDynamicField() { } public HibernateStatementDynamicField(String property, String onEmpty) { this.property = property; this.onEmpty = onEmpty; } public StringBuffer getRawText(Object vo) { return getText(vo, true, new AtomicInteger(0)); } @Override public StringBuffer getText(Object vo, AtomicInteger index) { return getText(vo, false, index); } private StringBuffer getText(Object vo, boolean isRaw, AtomicInteger index) { StringBuffer sb = null; boolean isEmptyValue = isEmpty(getBeanProperty(vo, this.property)); if ((onEmpty()) && (isEmptyValue)) { sb = isRaw ? getChildrenRawText(vo) : getChildrenText(vo, index); } if ((!onEmpty()) && (!isEmptyValue)) { sb = isRaw ? getChildrenRawText(vo) : getChildrenText(vo, index); } return sb; } }