NORRISTOWN, Pa. (AP) -- The former district attorney who declined a decade ago to bring sex-crime charges against Bill Cosby testified Tuesday that his decision binds his successors and forever closes the door on prosecuting the comedian.

Former Montgomery County District Attorney Bruce Castor took the stand as part of a bid by Cosby's lawyers to get the case against the TV star thrown out because of what they say is a non-prosecution agreement from Castor.

The current district attorney has said there is no record of any such agreement.

Cosby, 78, was arrested and charged in December with drugging and violating former Temple University athletic department employee Andrea Constand at his suburban Philadelphia mansion in 2004. He could get up to 10 years in prison if convicted.

Castor said Tuesday that he believed Constand was violated but that proving it would have been problematic because of serious flaws in the case, and so he declined to bring charges in 2005.

He said that he made the decision as a representative of the state -- as "the sovereign," as he put it, over and over -- and that it would last in perpetuity.

"For all time, yes," Castor said when pressed.

And he suggested that Cosby and his lawyer at the time had the same understanding, because Cosby later agreed to testify without invoking his Fifth Amendment right against self-incrimination in a lawsuit brought against him by Constand.

"Cosby would've had to have been nuts to say those things if there was any chance he could've been prosecuted," Castor said, referring to the damaging testimony unsealed last summer.

Castor said he hoped, correctly, at the time that the decision not to prosecute would free the comedian to testify in the lawsuit and help Constand win damages. She eventually settled for an undisclosed amount.

The former DA said he "wanted there to be some measure of justice" for Constand, explaining, "I thought making Mr. Cosby pay money was the best I was going to be able to set the stage for."

He added: "I was hopeful that I had made Ms. Constand a millionaire."

He said he relayed word to Cosby's then-attorney, Walter Phillips, that Cosby would not be charged. However, Castor said the two lawyers did not have an actual agreement that Cosby would testify in exchange for not being prosecuted.

Phillips has since died.

Kevin Steele, the newly elected DA who is pursuing the case, has said Cosby would need an immunity agreement in writing to get the case thrown out. He has said he has no evidence one exists.

It was not immediately clear when Common Pleas Judge Steven T. O'Neill would rule.

While Castor was called as witness by Cosby's side, the former DA said he is rooting for the prosecution.

"I'm not on your team here," Castor told Cosby lawyer Brian McMonagle. "I want them to win."

In a barrage of allegations that have destroyed Cosby's image as America's Dad, dozens of women have accused the former TV star of drugging and sexually assaulting them since the 1960s. But this is the only case in which he has been charged.

The unsealing of the testimony from Constand's lawsuit prompted Castor's successors to reopen the case and ultimately charge Cosby.

Cosby admitted in the deposition that he had affairs with young models and actresses, that he obtained quaaludes to give to women he wanted to have sex with and that he gave Constand three pills at his home. He said he reached into her pants but insisted it was consensual.

Castor defended his decision not to bring charges, testifying that he saw Constand's year-long delay in reporting the allegations, inconsistencies in her statements and her contact with a lawyer before going to police as problematic.

Castor said Constand's delay was of "enormous significance" in his consideration of the case. He said it thwarted his ability to test her hair or fingernails for evidence she was drugged.

Still, Castor said, he investigated the case thoroughly because he wanted to show authorities in Constand's native Canada that celebrities don't get preferential treatment in America.

Anne Poulin, a law professor at Villanova University, said the defense has a high bar to meet to get the case thrown out early on. But "if they can win without this ever going to trial, then they've done their client a big service."

In related news, a Los Angeles judge ordered Cosby to attend another deposition in a lawsuit filed by a woman who says the comic forced her to perform a sex act on him at the Playboy Mansion around 1974, when she was 15.

Also Tuesday, model Chloe Goins dropped a lawsuit accusing Cosby of drugging and sexually assaulting her at the Playboy Mansion in 2008. Goins gave no explanation.