class TableTokenResolver implements TokenResolver {

   public String resolve(Token token, QueryContext ctx) {
      if (token.getType() != TokenType.TABLE) {
         throw new DalRuntimeException("Internal error: only TABLE token is supported by " + getClass());
      }

      SimpleTagToken table = (SimpleTagToken) token;
      String tableName = table.getAttribute("name", ctx.getEntityInfo().getLogicalName());
      String[] logicalNameAndAlias = ctx.getEntityInfo().getLogicalNameAndAlias(tableName);
      TableProvider tableProvider = m_manager.getTableProvider(logicalNameAndAlias[0]);
      String physicalTableName = tableProvider.getPhysicalTableName(ctx.getQueryHints(), tableName);

      switch (ctx.getQuery().getType()) {
      case SELECT:
         String alias = table.getAttribute("alias", logicalNameAndAlias[1]);

         ctx.setTableResolved(true);
         return m_naming.getTable(physicalTableName, alias);
      case INSERT:
         return m_naming.getTable(physicalTableName);
      case UPDATE:
         return m_naming.getTable(physicalTableName);
      case DELETE:
         return m_naming.getTable(physicalTableName);
      default:
         throw new DalRuntimeException("TABLE token does not support query type: " + ctx.getQuery().getType());
      }
   }

}