*/
protected void appendOperator(StringBuffer buf, Operator op)
{
if (op.isConstant())
{
Operator parent = op.getParent();
Object value = op.getValue();
Column column = null;
Operator left = null;
if (parent instanceof ComparisonOperator)
{
left = ((ComparisonOperator)op.getParent()).getLeft();
if (parent.getOrdinal() == LikeOperator.ORDINAL && value != null)
{
value = m_adapter.getLikePattern((String)value);
}
}
else if (parent instanceof InOperator)
{
left = ((InOperator)op.getParent()).getOperand(0);
}
if (left instanceof AttributeOperator)
{
AttributeOperator aop = (AttributeOperator)left;
if (aop.getConverter() == null)
{
column = (Column)((Field)aop.getSource()).getItem();
}
}
if (column != null)
{
if ((column.isLiteral() || m_adapter.isLiteral()) &&
m_adapter.isLiteral(column.getType(), value) ||
getBindCount() == m_adapter.getMaxBindCount())
{
if (column.isTimeZoned() && value != null)
{
Timestamp ts = ((Timestamp)value);
long lTime = ts.getTime();
Timestamp tsLocal = new Timestamp(lTime + ((CalendarFactory)column.getConverter().getInstance(null))
.createCalendar().getTimeZone().getOffset(lTime));
tsLocal.setNanos(ts.getNanos());
value = tsLocal;
}
m_adapter.appendLiteral(buf, column.getType(), value);
}
else
{
m_adapter.appendBind(buf, getBindCount());
addBind(m_adapter.getBind(column), m_adapter.toBind(column, value));
}
}
else
{
if (value == null)
{
buf.append("null");
}
else
{
Primitive type = (Primitive)op.getType();
if (m_adapter.isLiteral() && m_adapter.isLiteral(type, value) ||
getBindCount() == m_adapter.getMaxBindCount())
{
m_adapter.appendLiteral(buf, type, value);
}
else
{
m_adapter.appendBind(buf, getBindCount(), type, value);
addBind(m_adapter.getBind(type), m_adapter.getInternal(type, value));
}
}
}
}
else
{
OperatorAppender appender = m_adapter.findOperatorAppender(op);
if (appender == null)
{
appender = s_appenderArray[op.getOrdinal()];
}
if (appender == null)
{
throw new PersistenceException("err.persistence.unsupportedOperator",
new Object[]{op.getSymbol()});
}
Operator parent = op.getParent();
String sSuffix = null;
if (op.getType() == Primitive.BOOLEAN)
{
if (op instanceof IfOperator)
{
if (parent instanceof Logical ||
parent instanceof IfOperator && op == ((IfOperator)parent).getCondition() ||
parent == null && (m_nGenMode == GEN_JOIN || m_nGenMode == GEN_WHERE || m_nGenMode == GEN_HAVING))
{
buf.append('(');
int i = buf.length();
buf.append(" <> ");
m_adapter.appendLiteral(buf, Primitive.BOOLEAN, Boolean.FALSE);
buf.append(')');
sSuffix = buf.substring(i);
buf.setLength(i);
}
}
else if (!(op instanceof AttributeOperator) &&
parent instanceof IfOperator &&
op != ((IfOperator)parent).getCondition())
{
sSuffix = m_adapter.appendBooleanPrefix(buf, op);
}
}
if (sSuffix == null && parent != null)
{
int nPriority = op.getPriority();
int nParentPriority = parent.getPriority();
boolean bReprioritize = false;
if (nPriority <= nParentPriority)
{
if (nPriority == nParentPriority)