When told that he would be held overnight at the Worcester County Jail and House of Correction in order to testify on Thursday against the police officer who allegedly attacked him, Gerald Jones broke into a profanity-laced outburst.

"(F---) all you racist white (mother-------)," Jones exclaimed at Worcester Superior Court Judge Richard Tucker and the attorneys in the courtroom. He also swore at Assistant Attorney General Gina Masotta, who is prosecuting the case, and called her a "stinking white (b----)."

Court officers quickly escorted Jones out of the courtroom.

Tucker and the attorneys had been discussing Jones' competency to stand trial. A court doctor found Jones competent enough to testify, but said that Jones claimed he needed counseling because of PTSD from the alleged attack and that he may lash out with anger.

Former Worcester police officer Michael Motyka, 52, is on trial charged with assault and battery with a dangerous weapon for the alleged Dec. 1, 2014, attack on Jones.

Jones was in police custody and inside a holding cell when authorities claim Motyka made racist comments toward him and kicked him. Jones is African-American and Motyka is white.

Before the outburst in court, Jones said that he did not fear coming to court and that he would show up tomorrow. He said that he would not come to court to testify if he was forced to stay in the House of Correction overnight.

"He feels like he is being treated like a defendant in this case," Jones' attorney, Kevin Larson said, pointing out that the alleged perpetrator in the case is free and that Jones is in handcuffs.

Motyka's jury-waived trial began Thursday. Testimony was delayed multiple days this week after Jones did not appear at court despite being subpoenaed. He had been hospitalized in Cambridge.

Jones said that he was discharged from the hospital and went to Newton court on his own to appear for a criminal case Wednesday morning. He was released on personal recognizance and then was apprehended to be brought to court in Worcester.

The Attorney General's Office began an investigation into the case in 2015 after the matter was referred by the Worcester District Attorney's Office.

Masotta has argued that Motyka lost his cool as Jones shouted a barrage of insults at him.

Motyka's defense lawyer, James J. Gribouski, has said his client acted in self-defense and was concerned Jones had a weapon on him.

Jones, who was 48 at the time, was handcuffed and shackled. He had been brought into the booking area at the police station on Nov. 30, 2014, after being arrested in connection to a robbery and assault on a cab driver. He was brought back to the station the next day after being accused of trying to assault a nurse during inmate intake at the Worcester County Jail and House of Correction.

Before Jones' appearance in court, a retired Worcester police officer who had worked with Motyka testified.

Michael Vacca told the court that Motyka was "one of the good guys," someone who would even bring his own orange cones when he was working a detail.

William LeBeau, an Army Reserve veteran who served under Motyka during the Gulf War, also testified on Motyka's character.

LeBeau described Motyka as "straight-laced" and "by-the-book," saying he would not allow others to mistreat the prisoners they watched during the war.

Motyka was charged with a civil rights violation when he was arrested in April 2015, but he was not indicted on that particular charge. He was a 17-year veteran of the Worcester Police Department and assigned to the Services Division, mainly working in the booking room and in the department's reception area.

Jones has a lengthy criminal record. He was paid $225,000 by the city of Worcester in an out-of-court settlement.

Attorneys have claimed that Motyka thought Jones had a weapon on him at the time of the incident.

Officer Jeffrey Toney, who was working in the booking room that day, did not see Motyka search Jones for a weapon. The officer testified he saw Motyka kick Jones in the stomach/waist area the morning of Dec. 1, 2014, while he was still shackled.

Motyka retired in August 2015. He is collecting a pension that he could lose if he is convicted.