* @param writer The destination writer.
* @throws IOException if the writer encounters an error.
*/
private static void printAssoc(Query query, PrintWriter writer) throws IOException
{
Query root = (writer.getWriter() instanceof QueryHolder) ?
((QueryHolder)writer.getWriter()).getQuery() : null;
if (query != root)
{
Query parent = query.getParent();
if (parent == null)
{
writer.write("@ ");
writer.write(query.getMetaclass().getName());
}
else
{
if (parent != root && !query.isInverse())
{
printAssoc(parent, writer);
}
writer.write(' ');
writer.write(query.getAttribute().getName());
if (parent != root && query.isInverse() &&
(root != null || parent.getParent() != root))
{
printAssoc(parent, writer);
}
}
}