
4 Cal.App.4th 1151 (1992)
6 Cal. Rptr.2d 359
COUNTY OF LASSEN et al., Plaintiffs and Appellants,
v.
THE STATE OF CALIFORNIA et al., Defendants and Respondents.
Docket No. C010922.
Court of Appeals of California, Third District.
March 23, 1992.
*1152 COUNSEL
Downey, Brand, Seymour & Rohwer, Roberta L. Franklin and Sharon K. Sandeen for Plaintiffs and Appellants.
Daniel E. Lungren, Attorney General, Robert L. Mukai, Chief Assistant Attorney General, Cathy A. Neff and Ramon M. de la Guardia, Deputy Attorneys General, for Defendants and Respondents.
*1153 OPINION
SIMS, Acting P.J.
In July 1989, appellants County of Lassen (County) and Ron Jarrell, Sheriff of Lassen County, were sued in a class action federal civil rights suit by inmates of Lassen County jail who alleged that conditions in the jail were inadequate under the United States Constitution. (Barbara Doty et al. v. County of Lassen et al. (Doty v. County of Lassen (U.S. Dist. Ct. (E.D.Cal.) No. CIVS-89-1019-LKK-JFM) [pending action], hereafter the Doty action.)
The County thereafter filed a claim with the State Board of Control pursuant to the California Tort Claims Act (Gov. Code, § 810 et seq.), seeking indemnification from the state for costs and attorney fees incurred in defending the Doty action. The claim was denied.
Subsequently the County filed a complaint for declaratory relief and negligence against respondents the State of California, the Attorney General of the State of California, and the State Board of Corrections (hereafter collectively the State), seeking the relief previously sought in the County's tort claim. The state demurred to the complaint on the grounds that it failed to state a cause of action and that the suit was barred by governmental immunity. The trial court sustained the demurrer without leave to amend and thereupon entered judgment dismissing the action.[1] The County appeals only as to its cause of action for declaratory relief.[2] We shall affirm.

DISCUSSION

I
(1) In reviewing the sufficiency of an affirmative pleading against a general demurrer, "`We treat the demurrer as admitting all material facts properly pleaded, but not contentions, deductions or conclusions of fact or law. [Citation.] We also consider matters which may be judicially noticed.' [Citation.] Further, we give the complaint a reasonable interpretation, reading it as a whole and its parts in their context." (Blank v. Kirwan (1985) 39 Cal.3d 311, 318 [216 Cal. Rptr. 718, 703 P.2d 58].) If there is a reasonable possibility that the pleading liberally construed can state a cause of action, it *1154 is an abuse of discretion to sustain a demurrer without leave to amend. (Concerned Citizens of Costa Mesa, Inc. v. 32nd Dist. Agricultural Assn. (1986) 42 Cal.3d 929, 936 [231 Cal. Rptr. 748, 727 P.2d 1029].)

II
As it did below, the County on appeal asserts that it has stated or can state a cause of action for implied equitable indemnity against the State with respect to the costs and attorney fees incurred in defending the Doty action. We disagree.
(2) "`Indemnity is a shifting of responsibility from the shoulders of one person to another; and the duty to indemnify will be recognized in cases where community opinion would consider that in justice the responsibility should rest upon one rather than the other. This may be because of the relation of the parties to one another, and the consequent duty owed; or it may be because of a significant difference in kind or quality of their conduct.'" (American Motorcycle Assn. v. Superior Court (1978) 20 Cal.3d 578, 595, fn. 4 [146 Cal. Rptr. 182, 578 P.2d 899], quoting Prosser, Law of Torts (4th ed. 1971) § 52, p. 313.) The basic idea of indemnification is to spread or shift the burden of an obligation so that the responsible person will be motivated to effectuate a cure. (Id. at p. 596.) The right to noncontractual implied indemnity rests upon equitable considerations, and application of the right depends on the facts of each case. (Atchison, T. & S.F. Ry. Co. v. Lan Franco (1968) 267 Cal. App.2d 881, 885-886 [73 Cal. Rptr. 660].)
The County's complaint alleged the following facts, which we presume true for purposes of review: (1) the Fourteenth Amendment to the United States Constitution imposes on the State a mandatory duty to ensure that persons confined in jails within the State are not deprived of their constitutional rights; (2) the State is vested with the ultimate responsibility for setting forth rules and standards governing the operation of jails in California; (3) consistent with such obligation, the State has published "Minimum Jail Standards" which are contained in titles 15 and 24 of the California Code of Regulations; (4) the principal issues raised in the Doty action concern the constitutional sufficiency of the State's rules, regulations, and standards for the operation of jails; and (5) the County lacks the financial resources to defend against an attack on such rules, regulations, and standards.
In addition, the County asks us to take judicial notice of the following facts: (1) county jails are used principally to incarcerate persons convicted of or charged with violations of state law (Pen. Code, § 4000); and (2) the State *1155 asserts substantial control over the operation of county jails by virtue of Penal Code section 4000 et seq., Penal Code section 6030 et seq., and title 15, California Code of Regulations, section 1000 et seq.[3] We grant the County's request for judicial notice of these statutes and regulations. (Evid. Code, § 451, subd. (a).)[4]
(3) On the basis of the above facts, the County asserts that it is equitably entitled to indemnification from the State for the costs (including attorney fees) of defending the Doty action. The County reasons that it is the agent of the State in enforcing the State's laws against third persons and that an agent is entitled to indemnity from its principal for expenditures or losses incurred in discharge of the agent's authorized duties. The County further asserts that equity allows the recovery of attorney fees even when such recovery is not provided for by statute or contract. In addition, the County notes that the statutes which impose the burden of jail maintenance upon it predate Proposition 13 and asserts that given the present financial straits of California counties it is unfair for the State to continue to avoid its share of that burden in reliance on those statutes. Finally, the County asserts that "common sense and fairness" suggest that the entity which enacts laws should pay the costs of enforcing them, or at least of defending them against constitutional attack.
These arguments fail because the cost of defending lawsuits against the operation of county jails is necessarily included within the costs of operating those jails, which the counties are required to bear by statute.
As the County concedes, the Legislature has mandated that the normal costs of operating county jails in accordance with the State's minimum standards shall be borne by the counties. Penal Code section 4000 provides in pertinent part: "The common jails in the several counties of this State are kept by the sheriffs of the counties in which they are respectively situated, ..." Penal Code section 4015 provides: "The sheriff shall receive all persons committed to jail by competent authority. The board of supervisors shall provide the sheriff with necessary food, clothing, and bedding, for those prisoners, which shall be of a quality and quantity at least equal to the *1156 minimum standards and requirements prescribed by the Board of Corrections for the feeding, clothing, and care of prisoners in all county, city and other local jails and detention facilities. Except as provided in Section 4016, the expenses thereof shall be paid out of the county treasury."[5] (Italics added.) Most significantly, Government Code section 29602 provides in relevant part: "The expenses necessarily incurred in the support of persons charged with or convicted of crime and committed to the county jail ... are county charges."
We believe that legal expenses incurred in defending the conditions of a jail are indisputably "expenses necessarily incurred in the support of persons charged with or convicted of crime" within the meaning of Government Code section 29602.
It has been held that the equitable doctrine of estoppel may not be invoked where to do so would violate statutes or constitutional provisions that define the powers of a public agency. (Fleice v. Chualar Union Elementary School Dist. (1988) 206 Cal. App.3d 886, 893 [254 Cal. Rptr. 54]; see Longshore v. County of Ventura (1979) 25 Cal.3d 14, 28 [157 Cal. Rptr. 706, 598 P.2d 866]; El Camino Community College Dist. v. Superior Court (1985) 173 Cal. App.3d 606, 617 [219 Cal. Rptr. 236].) Similarly, the equitable doctrine of indemnity may not be used to contravene statutes that allocate to the County the duty of paying the expenses of county jails.
The County cites no case which has held that counties may obtain reimbursement from the State for the costs incurred in a legal action challenging the conditions of a county jail. Indeed, the only relevant case cited by the parties bolsters the State's position. In County of San Luis Obispo v. Abalone Alliance (1986) 178 Cal. App.3d 848 [223 Cal. Rptr. 846], the appellant county contended that it was entitled to recover from respondents the costs it incurred in abating a blockade set up by respondents and in processing their arrests. The court rejected this contention: "... [A] government entity may not, as the County seeks to do in this case, recover the costs of law enforcement absent authorizing legislation. `"... Under the general law, the expense of capture, detention, and prosecution of persons charged with crime is to be borne by the county...."' [Citations.]" (Id. at p. 859, italics added.)
The County asserts Abalone Alliance is inapposite because appellant there was seeking reimbursement from a private entity, whereas the County here *1157 seeks to have the public as a whole, through the State, pay for the cost of public services which benefit the whole. (See City of Flagstaff v. Atchison, Topeka & Santa Fe (9th Cir.1983) 719 F.2d 322, 323.) The County's distinction is unavailing. The rule of Abalone Alliance is not predicated on the nature of the entity from which a county seeks reimbursement: it is a blanket statement that reimbursement for law enforcement costs is unavailable unless authorized by statute. Here, as we have mentioned, the applicable statutes assign the cost of legal defense to the County.
The County notes that in enacting the County Correctional Facility Capital Expenditure Bond Act of 1986 (Pen. Code, § 4475 et seq.), the Legislature found and declared: "Due to fiscal constraints associated with loss of local property tax revenues, counties are unable to finance the construction of adequate jail and juvenile facilities." (Pen. Code, § 4476, subd. (e).)[6] The County sees this declaration as an acknowledgment by the Legislature that counties cannot equitably be expected to bear the full cost of any activity associated with the maintenance of existing jails, including lawsuits. On the contrary, in adopting the act in question the Legislature made a policy choice to help counties bear the financial burden of running jails by providing a new funding source for the construction of replacement facilities, not by subsidizing the operation of existing facilities or costs associated with their operation. If the County feels this policy choice was unwise or that the assistance provided under it is insufficient, the County's recourse is to seek additional funding from the Legislature.
We express no view with respect to whether the costs sought by the County may be recoverable as state-mandated costs. (See Cal. Const., art. XIII B.) The exclusive way for the County to claim such costs is pursuant to claim procedures before the Commission on State Mandates. (Gov. Code, § 17500; Kinlaw v. State of California (1991) 54 Cal.3d 326, 333 [285 Cal. Rptr. 66, 814 P.2d 1308]; County of Contra Costa v. State of California (1986) 177 Cal. App.3d 62 [222 Cal. Rptr. 750].) The County's complaint contains no suggestion that it has exhausted the requisite administrative procedure.
In light of our conclusion that no cause of action for equitable indemnity will lie, we need not determine whether the County's claim is barred by governmental immunity under the California Tort Claims Act (Gov. Code, § 810 et seq.).


*1158 DISPOSITION
The judgment is affirmed.
Scotland, J., and Nicholson, J., concurred.
NOTES
[1]  According to the parties, the federal court had not issued an opinion in the Doty action as of February 1991, when the trial court sustained the State's demurrer. However, the magistrate subsequently issued findings and recommendations adverse to the County, and the plaintiffs moved for an award of costs and attorney fees.
[2]  Although the notice of appeal indicates that the County appeals from the entire judgment, the County's appellate briefs raise no claim of error as to the trial court's ruling on the County's cause of action for negligence.
[3]  Penal Code sections 4000-4030 define the purposes for which county jails are to be maintained and prescribe detailed rules for their operation. Penal Code sections 6030-6031.5 provide that the State Board of Corrections shall establish minimum standards for local detention facilities and shall inspect those facilities to determine compliance with the standards. Title 15, California Code of Regulations, sections 1000-1282, set forth the minimum standards for local detention facilities adopted by the Board of Corrections.
[4]  The County refers in its briefs to a separate purported request for judicial notice of additional matters, including the allegations that the Doty action is one of at least 12 similar suits brought against California counties and that plaintiffs in the Doty action have moved for costs and attorney fees in excess of $446,000. However, no such request for judicial notice appears in the record; therefore we deny the purported request.
[5]  Section 4016 provides that county sheriffs may demand bond or deposit for the expense of detaining persons committed on process in civil actions.
[6]  See also Penal Code section 4496.02, subdivision (d) (County Correctional Facility Capital Expenditure and Youth Facility Bond Act of 1988).
