A young man who tried to take his own life by stepping in front of a train called a female garda a "whore, b***h and prostitute" when she tried to help him.
Swords District Court was told that Karlos Verbickas (22) asked the driver: "Why did you stop?"
Verbickas, of Belcamp Lane, Coolock, admitted a number of public order offences.
Judge John Cheatle ordered a probation report and adjourned sentencing to February.
Gda Philip Walsh said he and Gda Miriam O'Donovan were called to Clongriffin train station last April 1 after reports of a man being hit by a train.
When he arrived, Gda Walsh said emergency personnel were on the platform and were lifting a man into an ambulance.
Gda Walsh said Verbickas was very agitated and refused to accept medical treatment.
Both officers tried to calm Verbickas, but he subjected Gda O'Donovan to a tirade of abuse, calling her a "whore, b***h and prostitute".
Gda Walsh said Verbickas became violent towards Gda O'Donovan, who was out of work for two weeks with the injuries she received.
The court heard Verbickas was taken to Beaumont Hospital, but he discharged himself two hours later.
Defence lawyer Annette Kealy said Verbickas told gardai: "I was not in a right state of mind."
The train driver said Verbickas was standing on the track and "staring into space".
The driver, who applied the emergency brake to stop the train, said Verbickas asked him: "Why did you stop the train?"
Ms Kealy said Verbickas was in "such a state of agitation" that he does not remember the incident.
She said he suffered mental health problems and the incident at the train station was "an attempt to end everything".
She said Verbickas had left home because he was not getting on with his parents and was living in his car.