* @param reader The reader object.
* @return True if the query should be executed.
*/
protected boolean isEnabled(Accessor reader)
{
Accessor dispGroup = (Accessor)reader.getValue("dispatchGroup");
if (dispGroup != null)
{
boolean bDispatched = ((Boolean)dispGroup.getValue("dispatched")).booleanValue();
if (dispGroup == reader)
{
if (bDispatched)
{
return false;
}
}
else if (((Boolean)reader.getValue("dispatched")).booleanValue() != bDispatched)
{
return false;
}
}
Accessor dispParent = (Accessor)reader.getValue("dispatchParent");
if (dispParent == null)
{
if (dispGroup != null && reader != dispGroup)
{
reader.setValue("dispatched", Boolean.TRUE);
}
return true;
}
InstanceList resultList = (InstanceList)dispParent.getValue("results");
if (resultList == null || resultList.isEmpty())
{
return false;
}
dispParent = resultList.getInstance(0);
Pair dispAssoc = (Pair)reader.getValue("dispatchAttribute");
Pair dispValues = (Pair)reader.getValue("dispatchValues");
if (dispAssoc == null)
{
Metaclass metaclass = dispParent.getMetaclass();
for (; dispValues != null; dispValues = dispValues.getNext())
{
if (m_context.getMetadata().getMetaclass(((Symbol)dispValues.getHead()).getName()).isUpcast(metaclass))
{
if (dispGroup != null)
{
dispGroup.setValue("dispatched", Boolean.TRUE);
if (reader != dispGroup)
{
reader.setValue("dispatched", Boolean.TRUE);
}
}
return true;
}
}
return false;
}
Object value;
for (value = dispParent; value != null && dispAssoc != null; dispAssoc = dispAssoc.getNext())
{
dispParent = (Accessor)value;
Attribute attribute = dispParent.getMetaclass().getAttribute(((Symbol)dispAssoc.getHead()).getName());
attribute.checkReadAccess(m_context.getPrivilegeSet());
value = dispParent.getValue(attribute.getOrdinal());
}
for (; dispValues != null; dispValues = dispValues.getNext())
{
if (Intrinsic.equal(value, dispValues.getHead()))