A 15-year-old boy who displays "overly sexualised behaviours" is being held in a specialist unit and denied internet access, a High Court judge has been told.
The teenager was under constant observation and could only use a mobile to call four numbers, Mr Justice Keehan heard.
He had been moved to the unit two years ago because staff were specially trained to manage high levels of aggression.
The judge had been asked to make decisions on a number of legal issues relating to the boy's detention at a hearing in the Family Division of the High Court.
He has revealed detail of the "regime" under which the youngster is held in a ruling on the case.
Mr Justice Keehan said he had concluded the youngster was benefittng from being at the unit.
Neither the teenager nor the unit has been identified in the ruling.
The judge said the teenager was in the care of council social services bosses.
Lawyers representing the boy and the council had debated issues at the hearing - and outlined detail of his day-to-day life.
The judge said the boy had been taken from his family a decade ago.
"(He) was noted to exhibit overly sexualised behaviour towards other children and engaged in behaviours which placed himself and others at risk of harm," said Mr Justice Keehan in his ruling.
"He has had a troubled childhood."
The judge said the youngster had been moved to the unit after a number of foster placements broke down when his behaviour became "increasingly difficult".
Mr Justice Keehan added: "This unit was identified because the local authority concluded that (he) required a specialist residential unit with high levels of supervision and where staff were specifically trained to manage high levels of aggression and intimidation and to work with (him) to manage his sexualised behaviours."
The judge said the boy lived under a regime which meant that he: was never left alone or left alone with other residents; was subjected to constant observations by staff; could not leave the unit unsupervised; was not allowed internet access; could only use his mobile to call four numbers and could not travel on public transport.
External doors were locked at night and bedroom doors alarmed at night.
Internal doors were also locked if the boy's behaviour necessitated such a move.
Mr Justice Keehan said the unit was the right place for the boy to be.
"(His) placement in the unit has and will be for the foreseeable future in his best interests.
"He has clearly benefited from his placement there, as I believe he has recognised."
The judge added: "I very much hope he will continue to work co-operatively with the staff at the unit for his long-term future benefit."