A Longford judge who made controversial remarks about two non-national defendants before him in court has apologised for his comments.