TvContentRating.java revision d22e37acac3a83199423692671e2b20050088426
1/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.media.tv;
18
19import android.annotation.SystemApi;
20import android.net.Uri;
21import android.text.TextUtils;
22
23import java.util.Arrays;
24import java.util.Collections;
25import java.util.List;
26
27/**
28 * A class representing a TV content rating.
29 * When a TV input service provides the content rating information of a program into TV provider,
30 * TvContentRating class will be used for generating the value of {@link
31 * TvContract.Programs#COLUMN_CONTENT_RATING}. To create an object of {@link TvContentRating}, use
32 * the {@link #createRating} method with valid arguments. The arguments could be a system defined
33 * strings, or a TV input service defined strings.
34 * TV input service defined strings are in an xml file defined in <code>&lt;{@link
35 * android.R.styleable#TvInputService tv-input}&gt;</code> with the {@link
36 * android.R.attr#contentRatingSystemXml contentRatingSystemXml} attribute by the TV input service.
37 *
38 * <h3> Content Rating System XML format </h3>
39 * The XML file for publishing content rating system should follow the DTD bellow:
40 * <p><pre class="prettyprint">
41 * &lt;?xml version="1.0" encoding="UTF-8"?&gt;
42 * &lt;!DOCTYPE rating-systems [
43 *     &lt;!ELEMENT rating-system-definitions (rating-system-definition+)&gt;
44 *     &lt;!ELEMENT rating-system-definition (
45 *         (sub-rating-definition*, rating-definition, sub-rating-definition*)+, order*)&gt;
46 *     &lt;!ATTLIST rating-system-definition
47 *         id          ID    #REQUIRED
48 *         displayName CDATA #IMPLIED
49 *         description CDATA #IMPLIED
50 *         country     CDATA #IMPLIED&gt;
51 *     &lt;!ELEMENT sub-rating-definition EMPTY&gt;
52 *     &lt;!ATTLIST sub-rating-definition
53 *         id          ID    #REQUIRED
54 *         displayName CDATA #IMPLIED
55 *         icon        CDATA #IMPLIED
56 *         description CDATA #IMPLIED&gt;
57 *     &lt;!ELEMENT rating-definition (sub-rating*))&gt;
58 *     &lt;!ATTLIST rating-definition
59 *         id          ID    #REQUIRED
60 *         displayName CDATA #IMPLIED
61 *         icon        CDATA #IMPLIED
62 *         description CDATA #IMPLIED&gt;
63 *     &lt;!ELEMENT sub-rating EMPTY&gt;
64 *     &lt;!ATTLIST sub-rating id IDREF #REQUIRED&gt;
65 *     &lt;!ELEMENT order (rating, rating+)&gt;
66 *     &lt;!ELEMENT rating EMPTY&gt;
67 *     &lt;!ATTLIST rating id IDREF #REQUIRED&gt;
68 * ]&gt;
69 * </pre></p>
70 *
71 * <h3>System defined rating strings</h3>
72 *
73 * <u>System defined string for {@code domain}</u>
74 * <table border="0" cellspacing="0" cellpadding="0">
75 *     <tr>
76 *         <td>String value</td>
77 *         <td>Comments</td>
78 *     </tr>
79 *     <tr>
80 *         <td>android.media.tv</td>
81 *         <td>Used for creating system defined content ratings</td>
82 *     </tr>
83 * </table>
84 *
85 * <u>System defined string for {@code ratingSystem}</u>
86 * <table border="0" cellspacing="0" cellpadding="0">
87 *     <tr>
88 *         <td>String value</td>
89 *         <td>Comments</td>
90 *     </tr>
91 *     <tr>
92 *         <td>AM_TV_RS</td>
93 *         <td>Range specific TV content rating system strings for Armenia</td>
94 *     </tr>
95 *     <tr>
96 *         <td>AM_TV_AS</td>
97 *         <td>Age specific TV content rating system strings for Armenia</td>
98 *     </tr>
99 *     <tr>
100 *         <td>AR_TV</td>
101 *         <td>TV content rating system for Argentina TV</td>
102 *     </tr>
103 *     <tr>
104 *         <td>AU_TV</td>
105 *         <td>TV content rating system for Australia TV</td>
106 *     </tr>
107 *     <tr>
108 *         <td>BG_TV</td>
109 *         <td>TV content rating system for Bulgaria TV</td>
110 *     </tr>
111 *     <tr>
112 *         <td>BR_TV</td>
113 *         <td>TV content rating system for Brazil TV</td>
114 *     </tr>
115 *     <tr>
116 *         <td>CA_TV</td>
117 *         <td>TV content rating system for Canada TV</td>
118 *     </tr>
119 *     <tr>
120 *         <td>CH_TV</td>
121 *         <td>TV content rating system for Switzerland TV</td>
122 *     </tr>
123 *     <tr>
124 *         <td>CL_TV</td>
125 *         <td>TV content rating system for Chile TV</td>
126 *     </tr>
127 *     <tr>
128 *         <td>DE_TV</td>
129 *         <td>TV content rating system for Germany TV</td>
130 *     </tr>
131 *     <tr>
132 *         <td>DK_TV</td>
133 *         <td>TV content rating system for Denmark TV</td>
134 *     </tr>
135 *     <tr>
136 *         <td>ES_TV</td>
137 *         <td>TV content rating system for Spain TV</td>
138 *     </tr>
139 *     <tr>
140 *         <td>FI_TV</td>
141 *         <td>TV content rating system for Finland TV</td>
142 *     </tr>
143 *     <tr>
144 *         <td>FR_TV</td>
145 *         <td>TV content rating system for France TV</td>
146 *     </tr>
147 *     <tr>
148 *         <td>GR_TV</td>
149 *         <td>TV content rating system for Greece TV</td>
150 *     </tr>
151 *     <tr>
152 *         <td>HK_TV</td>
153 *         <td>TV content rating system for Hong Kong TV</td>
154 *     </tr>
155 *     <tr>
156 *         <td>HU_TV</td>
157 *         <td>TV content rating system for Hungary TV</td>
158 *     </tr>
159 *     <tr>
160 *         <td>ID_TV</td>
161 *         <td>TV content rating system for Indonesia TV</td>
162 *     </tr>
163 *     <tr>
164 *         <td>IE_TV</td>
165 *         <td>TV content rating system for Ireland TV</td>
166 *     </tr>
167 *     <tr>
168 *         <td>IL_TV</td>
169 *         <td>TV content rating system for Israel TV</td>
170 *     </tr>
171 *     <tr>
172 *         <td>IN_TV</td>
173 *         <td>TV content rating system for India TV</td>
174 *     </tr>
175 *     <tr>
176 *         <td>IS_TV</td>
177 *         <td>TV content rating system for Iceland TV</td>
178 *     </tr>
179 *     <tr>
180 *         <td>KR_TV</td>
181 *         <td>TV content rating system for South Korea TV</td>
182 *     </tr>
183 *     <tr>
184 *         <td>MV_TV</td>
185 *         <td>TV content rating system for Maldives TV</td>
186 *     </tr>
187 *     <tr>
188 *         <td>MX_TV</td>
189 *         <td>TV content rating system for Mexico TV</td>
190 *     </tr>
191 *     <tr>
192 *         <td>MY_TV</td>
193 *         <td>TV content rating system for Malaysia TV</td>
194 *     </tr>
195 *     <tr>
196 *         <td>NL_TV</td>
197 *         <td>TV content rating system for Netherlands TV</td>
198 *     </tr>
199 *     <tr>
200 *         <td>NZ_FTV</td>
201 *         <td>New Zealand\'s free-to-air TV content rating system</td>
202 *     </tr>
203 *     <tr>
204 *         <td>NZ_PTV</td>
205 *         <td>New Zealand\'s pay TV content rating system</td>
206 *     </tr>
207 *     <tr>
208 *         <td>PE_TV</td>
209 *         <td>TV content rating system for some Peruvian channels in Peru</td>
210 *     </tr>
211 *     <tr>
212 *         <td>PE_ATV</td>
213 *         <td>TV content rating system for America Television in Peru that uses its own rating
214 *         </td>
215 *     </tr>
216 *     <tr>
217 *         <td>PH_TV</td>
218 *         <td>TV content rating system for Philippines TV</td>
219 *     </tr>
220 *     <tr>
221 *         <td>PL_TV</td>
222 *         <td>TV content rating system for Poland TV</td>
223 *     </tr>
224 *     <tr>
225 *         <td>PT_TV</td>
226 *         <td>TV content rating system for Portugal TV</td>
227 *     </tr>
228 *     <tr>
229 *         <td>RO_TV</td>
230 *         <td>TV content rating system for Romania TV</td>
231 *     </tr>
232 *     <tr>
233 *         <td>RU_TV</td>
234 *         <td>TV content rating system for Russia TV</td>
235 *     </tr>
236 *     <tr>
237 *         <td>RS_TV</td>
238 *         <td>TV content rating system for Serbia TV</td>
239 *     </tr>
240 *     <tr>
241 *         <td>SG_FTV</td>
242 *         <td>TV content rating system for Singapore TV</td>
243 *     </tr>
244 *     <tr>
245 *         <td>SG_PTV</td>
246 *         <td>TV content rating system for Singapore TV</td>
247 *     </tr>
248 *     <tr>
249 *         <td>SI_TV</td>
250 *         <td>TV content rating system for Slovenia TV</td>
251 *     </tr>
252 *     <tr>
253 *         <td>TH_TV</td>
254 *         <td>TV content rating system for Thailand TV</td>
255 *     </tr>
256 *     <tr>
257 *         <td>TR_TV</td>
258 *         <td>TV content rating system for Turkey TV</td>
259 *     </tr>
260 *     <tr>
261 *         <td>TW_TV</td>
262 *         <td>TV content rating system for Taiwan TV</td>
263 *     </tr>
264 *     <tr>
265 *         <td>UA_TV</td>
266 *         <td>TV content rating system for Ukraine TV</td>
267 *     </tr>
268 *     <tr>
269 *         <td>US_TVPG</td>
270 *         <td>The TV Parental Guidelines</td>
271 *     </tr>
272 *     <tr>
273 *         <td>VE_TV</td>
274 *         <td>TV content rating system for Venezuela TV</td>
275 *     </tr>
276 *     <tr>
277 *         <td>ZA_TV</td>
278 *         <td>TV content rating system for South Africa TV</td>
279 *     </tr>
280 * </table>
281 *
282 * <u>System defined string for {@code rating}</u>
283 * <table border="0" cellspacing="0" cellpadding="0">
284 *     <tr>
285 *         <td>String value</td>
286 *         <td>Comments</td>
287 *     </tr>
288 *     <tr>
289 *         <td>AM_TV_RS_Y</td>
290 *         <td>Suitable for ages 2–11</td>
291 *     </tr>
292 *     <tr>
293 *         <td>AM_TV_RS_Y7</td>
294 *         <td>Suitable for ages 7–16</td>
295 *     </tr>
296 *     <tr>
297 *         <td>AM_TV_RS_GA</td>
298 *         <td>Suitable for general audiences</td>
299 *     </tr>
300 *     <tr>
301 *         <td>AM_TV_RS_TW</td>
302 *         <td>Suitable for teens ages 9 and up</td>
303 *     </tr>
304 *     <tr>
305 *         <td>AM_TV_RS_T</td>
306 *         <td>Suitable for teens ages 12 and up</td>
307 *     </tr>
308 *     <tr>
309 *         <td>AM_TV_RS_A</td>
310 *         <td>Suitable only for adults ages 18 and up</td>
311 *     </tr>
312 *     <tr>
313 *         <td>AM_TV_AS_EC</td>
314 *         <td>Suitable for ages 2 and up</td>
315 *     </tr>
316 *     <tr>
317 *         <td>AM_TV_AS_E</td>
318 *         <td>Suitable for ages 5 and up</td>
319 *     </tr>
320 *     <tr>
321 *         <td>AM_TV_AS_E9</td>
322 *         <td>Suitable for ages 9 and up</td>
323 *     </tr>
324 *     <tr>
325 *         <td>AM_TV_AS_T</td>
326 *         <td>Suitable for ages 12 and up</td>
327 *     </tr>
328 *     <tr>
329 *         <td>AM_TV_AS_M</td>
330 *         <td>Suitable for ages 16 and up</td>
331 *     </tr>
332 *     <tr>
333 *         <td>AM_TV_AS_AO</td>
334 *         <td>Suitable for ages 17 and up</td>
335 *     </tr>
336 *     <tr>
337 *         <td>AR_TV_ALL</td>
338 *         <td>Suitable for all audiences. Programs may contain mild violence, language and mature
339 *         </td>
340 *     </tr>
341 *     <tr>
342 *         <td>AR_TV_13</td>
343 *         <td>Suitable for ages 13 and up. Programs may contain mild to moderate language and mild
344 *         and sexual references</td>
345 *     </tr>
346 *     <tr>
347 *         <td>AR_TV_16</td>
348 *         <td>Suitable for ages 16 and up. Programs may contain more intensive violence and coarse
349 *         partial nudity and moderate sexual references</td>
350 *     </tr>
351 *     <tr>
352 *         <td>AR_TV_18</td>
353 *         <td>Suitable for mature audiences only. Programs contain strong violence, coarse language
354 *         explicit sexual references</td>
355 *     </tr>
356 *     <tr>
357 *         <td>AU_TV_CTC</td>
358 *         <td>This has advertising approval, but is not yet classified</td>
359 *     </tr>
360 *     <tr>
361 *         <td>AU_TV_G</td>
362 *         <td>The content is very mild in impact, and suitable for everyone</td>
363 *     </tr>
364 *     <tr>
365 *         <td>AU_TV_PG</td>
366 *         <td>The content is mild in impact, but it may contain content that children find
367 *         or upsetting and may require the guidance or parents and guardians</td>
368 *     </tr>
369 *     <tr>
370 *         <td>AU_TV_M</td>
371 *         <td>The content is moderate in impact, and it is recommended for teenagers aged 15 years
372 *         over</td>
373 *     </tr>
374 *     <tr>
375 *         <td>AU_TV_MA15</td>
376 *         <td>The content is strong in impact, and it is legally restricted to persons 15 years and
377 *         </td>
378 *     </tr>
379 *     <tr>
380 *         <td>AU_TV_R18</td>
381 *         <td>The content is high in impact, and it is restricted to adults</td>
382 *     </tr>
383 *     <tr>
384 *         <td>AU_TV_X18</td>
385 *         <td>The content is restricted to adults. This classification is a special and legally
386 *         category which contains only sexually explicit content</td>
387 *     </tr>
388 *     <tr>
389 *         <td>BG_TV_A</td>
390 *         <td>Recommended to children. When the film confirms the ideals of humanism or popularizes
391 *         national and world cultures or contributes to upbringing children</td>
392 *     </tr>
393 *     <tr>
394 *         <td>BG_TV_B</td>
395 *         <td>No restrictive recommendations from the Committee. When the film is in no way
396 *         to the universal rules of morality in this country, has no restrictive recommendations
397 *         the Committee and does not fall in rating A</td>
398 *     </tr>
399 *     <tr>
400 *         <td>BG_TV_C</td>
401 *         <td>No persons under the age of 12 are admitted unless accompanied by an adult. When the
402 *         contains certain erotic scenes or scenes with drinking, taking drugs or stimulants or a
403 *         scenes of violence</td>
404 *     </tr>
405 *     <tr>
406 *         <td>BG_TV_D</td>
407 *         <td>No persons under the age of 16 are admitted. When the film contains quite a number of
408 *         scenes or scenes with drinking, taking drugs or stimulants or a considerable number of
409 *         showing violence</td>
410 *     </tr>
411 *     <tr>
412 *         <td>BG_TV_X</td>
413 *         <td>No persons under the age of 18 are admitted. When the film is naturalistically erotic
414 *         shows violence in an ostentatious manner</td>
415 *     </tr>
416 *     <tr>
417 *         <td>BR_TV_L</td>
418 *         <td>Content is suitable for all audiences</td>
419 *     </tr>
420 *     <tr>
421 *         <td>BR_TV_10</td>
422 *         <td>Content suitable for viewers over the age of 10</td>
423 *     </tr>
424 *     <tr>
425 *         <td>BR_TV_12</td>
426 *         <td>Content suitable for viewers over the age of 12</td>
427 *     </tr>
428 *     <tr>
429 *         <td>BR_TV_14</td>
430 *         <td>Content suitable for viewers over the age of 14</td>
431 *     </tr>
432 *     <tr>
433 *         <td>BR_TV_16</td>
434 *         <td>Content suitable for viewers over the age of 16</td>
435 *     </tr>
436 *     <tr>
437 *         <td>BR_TV_18</td>
438 *         <td>Content suitable for viewers over the age of 18</td>
439 *     </tr>
440 *     <tr>
441 *         <td>CA_TV_EXEMPT</td>
442 *         <td>Shows which are exempt from ratings (such as news and sports programming) will not
443 *         an on-screen rating at all</td>
444 *     </tr>
445 *     <tr>
446 *         <td>CA_TV_C</td>
447 *         <td>Programming suitable for children ages of 2–7 years. No profanity or sexual content
448 *         any level allowed. Contains little violence</td>
449 *     </tr>
450 *     <tr>
451 *         <td>CA_TV_C8</td>
452 *         <td>Suitable for children ages 8+. Low level violence and fantasy horror is allowed. No
453 *         language is allowed, but occasional "socially offensive and discriminatory" language is
454 *         if in the context of the story. No sexual content of any level allowed</td>
455 *     </tr>
456 *     <tr>
457 *         <td>CA_TV_G</td>
458 *         <td>Suitable for general audiences. Programming suitable for the entire family with mild
459 *         and mild profanity and/or censored language</td>
460 *     </tr>
461 *     <tr>
462 *         <td>CA_TV_PG</td>
463 *         <td>Parental guidance. Moderate violence and moderate profanity is allowed, as is brief
464 *         and sexual references if important to the context of the story</td>
465 *     </tr>
466 *     <tr>
467 *         <td>CA_TV_14</td>
468 *         <td>Programming intended for viewers ages 14 and older. May contain strong violence and
469 *         profanity, and depictions of sexual activity as long as they are within the context of a
470 *         </td>
471 *     </tr>
472 *     <tr>
473 *         <td>CA_TV_18</td>
474 *         <td>Programming intended for viewers ages 18 and older. May contain explicit violence and
475 *         activity</td>
476 *     </tr>
477 *     <tr>
478 *         <td>CH_TV_ALL</td>
479 *         <td>This program is suitable for all ages</td>
480 *     </tr>
481 *     <tr>
482 *         <td>CH_TV_RED</td>
483 *         <td>This program contains scenes that may hurt sensitive people, therefore the red symbol
484 *         be displayed</td>
485 *     </tr>
486 *     <tr>
487 *         <td>CL_TV_I</td>
488 *         <td>Programs suitable for all children</td>
489 *     </tr>
490 *     <tr>
491 *         <td>CL_TV_I7</td>
492 *         <td>Programs recommended for children ages 7 or older</td>
493 *     </tr>
494 *     <tr>
495 *         <td>CL_TV_I10</td>
496 *         <td>Programs recommended for children ages 10 or older</td>
497 *     </tr>
498 *     <tr>
499 *         <td>CL_TV_I12</td>
500 *         <td>Programs recommended for children and teens ages 12 or older</td>
501 *     </tr>
502 *     <tr>
503 *         <td>CL_TV_F</td>
504 *         <td>Programs suitable for a general audience, with content appropriate for all ages</td>
505 *     </tr>
506 *     <tr>
507 *         <td>CL_TV_R</td>
508 *         <td>Programs may content not suitable for children not accompanied by an adult</td>
509 *     </tr>
510 *     <tr>
511 *         <td>CL_TV_A</td>
512 *         <td>Programs suitable for adult audiences only (ages 18 or older), may contain coarse
513 *         and sexual or explicit situations</td>
514 *     </tr>
515 *     <tr>
516 *         <td>DE_TV_ALL</td>
517 *         <td>The program is suitable for all ages</td>
518 *     </tr>
519 *     <tr>
520 *         <td>DE_TV_12</td>
521 *         <td>The program is not suitable for viewers under the age of 12</td>
522 *     </tr>
523 *     <tr>
524 *         <td>DE_TV_16</td>
525 *         <td>The program is not suitable for viewers under the age of 16</td>
526 *     </tr>
527 *     <tr>
528 *         <td>DE_TV_18</td>
529 *         <td>The program is not suitable for viewers under the age of 18</td>
530 *     </tr>
531 *     <tr>
532 *         <td>DK_TV_G</td>
533 *         <td>programs suitable for all ages</td>
534 *     </tr>
535 *     <tr>
536 *         <td>DK_TV_Y</td>
537 *         <td>programs suitable children accompanied by an adult</td>
538 *     </tr>
539 *     <tr>
540 *         <td>DK_TV_R</td>
541 *         <td>programs containing material with more intensive content</td>
542 *     </tr>
543 *     <tr>
544 *         <td>DK_TV_B</td>
545 *         <td>programs containing explicit content and strictly for adults only</td>
546 *     </tr>
547 *     <tr>
548 *         <td>ES_TV_TP</td>
549 *         <td>Recommended for all ages</td>
550 *     </tr>
551 *     <tr>
552 *         <td>ES_TV_I</td>
553 *         <td>Specially recommended for preschoolers and kids</td>
554 *     </tr>
555 *     <tr>
556 *         <td>ES_TV_7</td>
557 *         <td>Recommended for people older than 7 years old</td>
558 *     </tr>
559 *     <tr>
560 *         <td>ES_TV_7I</td>
561 *         <td>Recommended for kids older than 7 years old</td>
562 *     </tr>
563 *     <tr>
564 *         <td>ES_TV_12</td>
565 *         <td>Recommended for people older than 12 years old</td>
566 *     </tr>
567 *     <tr>
568 *         <td>ES_TV_16</td>
569 *         <td>Recommended for people older than 16 years old</td>
570 *     </tr>
571 *     <tr>
572 *         <td>ES_TV_18</td>
573 *         <td>Recommended for people older than 18 years old</td>
574 *     </tr>
575 *     <tr>
576 *         <td>FI_TV_S</td>
577 *         <td>Allowed at all times</td>
578 *     </tr>
579 *     <tr>
580 *         <td>FI_TV_K7</td>
581 *         <td>Not recommended for children under 7</td>
582 *     </tr>
583 *     <tr>
584 *         <td>FI_TV_K12</td>
585 *         <td>Not recommended for children under 12</td>
586 *     </tr>
587 *     <tr>
588 *         <td>FI_TV_K16</td>
589 *         <td>Not recommended for children under 16</td>
590 *     </tr>
591 *     <tr>
592 *         <td>FI_TV_K18</td>
593 *         <td>Not recommended for children under 18</td>
594 *     </tr>
595 *     <tr>
596 *         <td>FR_TV_ALL</td>
597 *         <td>Appropriate for all ages</td>
598 *     </tr>
599 *     <tr>
600 *         <td>FR_TV_10</td>
601 *         <td>Not recommended for children under 10</td>
602 *     </tr>
603 *     <tr>
604 *         <td>FR_TV_12</td>
605 *         <td>Not recommended for children under 12</td>
606 *     </tr>
607 *     <tr>
608 *         <td>FR_TV_16</td>
609 *         <td>Not recommended for children under 16</td>
610 *     </tr>
611 *     <tr>
612 *         <td>FR_TV_18</td>
613 *         <td>Not recommended for persons under 18</td>
614 *     </tr>
615 *     <tr>
616 *         <td>GR_TV_all</td>
617 *         <td>Suitable for all ages</td>
618 *     </tr>
619 *     <tr>
620 *         <td>GR_TV_10</td>
621 *         <td>Parental consent suggested</td>
622 *     </tr>
623 *     <tr>
624 *         <td>GR_TV_12</td>
625 *         <td>Required parental consent</td>
626 *     </tr>
627 *     <tr>
628 *         <td>GR_TV_15</td>
629 *         <td>Suitable for minors over the age of 15</td>
630 *     </tr>
631 *     <tr>
632 *         <td>GR_TV_18</td>
633 *         <td>Suitable only for adults profanity before midnight is punishable by fine, except when
634 *         in the context of the program</td>
635 *     </tr>
636 *     <tr>
637 *         <td>HK_TV_G</td>
638 *         <td>For general audiences</td>
639 *     </tr>
640 *     <tr>
641 *         <td>HK_TV_PG</td>
642 *         <td>Programs are unsuitable for children, parental guidance is recommended</td>
643 *     </tr>
644 *     <tr>
645 *         <td>HK_TV_M</td>
646 *         <td>Programs are recommended only for adult viewers above the age of 18</td>
647 *     </tr>
648 *     <tr>
649 *         <td>HU_TV_U</td>
650 *         <td>Programs can be viewed by any age</td>
651 *     </tr>
652 *     <tr>
653 *         <td>HU_TV_CF</td>
654 *         <td>Programs recommended for children. It is an optional rating, there is no obligation
655 *         broadcasters to indicate it</td>
656 *     </tr>
657 *     <tr>
658 *         <td>HU_TV_6</td>
659 *         <td>Programs not recommended for children below the age of 6, may not contain any
660 *         or sexual content</td>
661 *     </tr>
662 *     <tr>
663 *         <td>HU_TV_12</td>
664 *         <td>Programs not recommended for children below the age of 12, may contain light sexual
665 *         or explicit language</td>
666 *     </tr>
667 *     <tr>
668 *         <td>HU_TV_16</td>
669 *         <td>Programs not recommended for teens and children below the age of 16, may contain more
670 *         violence and sexual content</td>
671 *     </tr>
672 *     <tr>
673 *         <td>HU_TV_18</td>
674 *         <td>The program is recommended only for adult viewers (for ages 18 and up), may contain
675 *         violence and explicit sexual content</td>
676 *     </tr>
677 *     <tr>
678 *         <td>ID_TV_P</td>
679 *         <td>Suitable for children from ages 2 through 11</td>
680 *     </tr>
681 *     <tr>
682 *         <td>ID_TV_A</td>
683 *         <td>Suitable for teens and children from ages 7 through 16</td>
684 *     </tr>
685 *     <tr>
686 *         <td>ID_TV_A_BO</td>
687 *         <td>Suitable for children ages 5 through 10, with parental guidance or permission</td>
688 *     </tr>
689 *     <tr>
690 *         <td>ID_TV_SU</td>
691 *         <td>Suitable for general audiences</td>
692 *     </tr>
693 *     <tr>
694 *         <td>ID_TV_BO</td>
695 *         <td>Parental guidance suggested for ages 5 and under</td>
696 *     </tr>
697 *     <tr>
698 *         <td>ID_TV_R</td>
699 *         <td>Suitable for teens from ages 13 through 17</td>
700 *     </tr>
701 *     <tr>
702 *         <td>ID_TV_R_BO</td>
703 *         <td>Suitable for teens with parental guidance or permission</td>
704 *     </tr>
705 *     <tr>
706 *         <td>ID_TV_D</td>
707 *         <td>Suitable for viewers over 18 and older only</td>
708 *     </tr>
709 *     <tr>
710 *         <td>IE_TV_GA</td>
711 *         <td>Suitable for all ages</td>
712 *     </tr>
713 *     <tr>
714 *         <td>IE_TV_Ch</td>
715 *         <td>Suitable for children ages 5 to 10, may contain comedic violence or action fantasy
716 *         </td>
717 *     </tr>
718 *     <tr>
719 *         <td>IE_TV_YA</td>
720 *         <td>Suitable for adolescent audiences, may contain thematic elements that would appeal to
721 *         </td>
722 *     </tr>
723 *     <tr>
724 *         <td>IE_TV_PS</td>
725 *         <td>Suitable for more mature viewers, more mature themes may be present</td>
726 *     </tr>
727 *     <tr>
728 *         <td>IE_TV_MA</td>
729 *         <td>Most restrictive classification, allowing for heavy subject matter and coarse
730 *         </td>
731 *     </tr>
732 *     <tr>
733 *         <td>IL_TV_G</td>
734 *         <td>General audience; anyone, regardless of age, can view the program, usually news and
735 *         programming</td>
736 *     </tr>
737 *     <tr>
738 *         <td>IL_TV_12</td>
739 *         <td>Suitable for teens and children ages 12 and over, no child under 12 are permitted to
740 *         the program</td>
741 *     </tr>
742 *     <tr>
743 *         <td>IL_TV_15</td>
744 *         <td>Suitable for teens ages 15 and over, no child under 15 may view the programme</td>
745 *     </tr>
746 *     <tr>
747 *         <td>IL_TV_18</td>
748 *         <td>Suitable for adults only, no minors may view the programme</td>
749 *     </tr>
750 *     <tr>
751 *         <td>IL_TV_E</td>
752 *         <td>Exempt from classification</td>
753 *     </tr>
754 *     <tr>
755 *         <td>IN_TV_U</td>
756 *         <td>Unrestricted public exhibition</td>
757 *     </tr>
758 *     <tr>
759 *         <td>IN_TV_U/A</td>
760 *         <td>Unrestricted public exhibition, but with a caution regarding parental guidance to
761 *         under 12 years of age</td>
762 *     </tr>
763 *     <tr>
764 *         <td>IN_TV_A</td>
765 *         <td>Public exhibition restricted to adults 18 years of age and older only</td>
766 *     </tr>
767 *     <tr>
768 *         <td>IN_TV_S</td>
769 *         <td>Public exhibition restricted to members of any profession or any class of persons
770 *         <td>Public exhibition restricted to members of any profession or any class of persons
771 *         </td>
772 *     </tr>
773 *     <tr>
774 *         <td>IS_TV_L</td>
775 *         <td>Programs suitable for all ages</td>
776 *     </tr>
777 *     <tr>
778 *         <td>IS_TV_7</td>
779 *         <td>Programs suitable for ages 7 and older</td>
780 *     </tr>
781 *     <tr>
782 *         <td>IS_TV_10</td>
783 *         <td>Programs suitable for ages 10 and older</td>
784 *     </tr>
785 *     <tr>
786 *         <td>IS_TV_12</td>
787 *         <td>Programs suitable for ages 12 and older</td>
788 *     </tr>
789 *     <tr>
790 *         <td>IS_TV_14</td>
791 *         <td>Programs suitable for ages 14 and older</td>
792 *     </tr>
793 *     <tr>
794 *         <td>IS_TV_16</td>
795 *         <td>Programs suitable for ages 16 and older</td>
796 *     </tr>
797 *     <tr>
798 *         <td>IS_TV_18</td>
799 *         <td>Programs suitable for ages 18 and older</td>
800 *     </tr>
801 *     <tr>
802 *         <td>KR_TV_All</td>
803 *         <td>Appropriate for all ages</td>
804 *     </tr>
805 *     <tr>
806 *         <td>KR_TV_7</td>
807 *         <td>May contain material inappropriate for children younger than 7, and parental
808 *         should be used</td>
809 *     </tr>
810 *     <tr>
811 *         <td>KR_TV_12</td>
812 *         <td>May deemed inappropriate for those younger than 12, and parental discretion should be
813 *         </td>
814 *     </tr>
815 *     <tr>
816 *         <td>KR_TV_15</td>
817 *         <td>May be inappropriate for children under 15, and that parental discretion should be
818 *         </td>
819 *     </tr>
820 *     <tr>
821 *         <td>KR_TV_19</td>
822 *         <td>For adults only</td>
823 *     </tr>
824 *     <tr>
825 *         <td>MV_TV_Y</td>
826 *         <td>Young children</td>
827 *     </tr>
828 *     <tr>
829 *         <td>MV_TV_G</td>
830 *         <td>General viewing for all ages</td>
831 *     </tr>
832 *     <tr>
833 *         <td>MV_TV_PG</td>
834 *         <td>Parental guidance is required unaccompanied children</td>
835 *     </tr>
836 *     <tr>
837 *         <td>MV_TV_PG-12</td>
838 *         <td>Parental guidance is required for children under the age of 12</td>
839 *     </tr>
840 *     <tr>
841 *         <td>MV_TV_12</td>
842 *         <td>Teens and children aged 12 and older may watch, otherwise restricted</td>
843 *     </tr>
844 *     <tr>
845 *         <td>MV_TV_15</td>
846 *         <td>Restricted to viewers aged 15 and above</td>
847 *     </tr>
848 *     <tr>
849 *         <td>MV_TV_18</td>
850 *         <td>Restricted to viewers aged 18 and above</td>
851 *     </tr>
852 *     <tr>
853 *         <td>MV_TV_21</td>
854 *         <td>Restricted to viewers aged 21 and above</td>
855 *     </tr>
856 *     <tr>
857 *         <td>MV_TV_X</td>
858 *         <td>Most restrictive classification, only adults ages 25 and above may view</td>
859 *     </tr>
860 *     <tr>
861 *         <td>MX_TV_A</td>
862 *         <td>Appropriate for all ages, parental guidance is recommended for children under 7 years
863 *         <td>Appropriate for all ages, parental guidance is recommended for children under 7 years
864 *         </td>
865 *     </tr>
866 *     <tr>
867 *         <td>MX_TV_B</td>
868 *         <td>Designed for ages 12 and older, may contain some sexual situations, mild violence,
869 *         mild language</td>
870 *     </tr>
871 *     <tr>
872 *         <td>MX_TV_B-15</td>
873 *         <td>Designed for ages 15 and up, slightly more intensive than the \'A\' and \'B\' ratings
874 *         <td>Designed for ages 15 and up, slightly more intensive than the \'A\' and \'B\' ratings
875 *         </td>
876 *     </tr>
877 *     <tr>
878 *         <td>MX_TV_C</td>
879 *         <td>Designed to be viewed by adults aged 18 or older only, generally more intensive
880 *         </td>
881 *     </tr>
882 *     <tr>
883 *         <td>MX_TV_D</td>
884 *         <td>Designed to be viewed only by mature adults (at least 21 years of age and over),
885 *         extreme content matter</td>
886 *     </tr>
887 *     <tr>
888 *         <td>MX_TV_RC</td>
889 *         <td>Banned from public television in Mexico</td>
890 *     </tr>
891 *     <tr>
892 *         <td>MY_TV_U</td>
893 *         <td>General viewing for all ages, can be broadcast anytime</td>
894 *     </tr>
895 *     <tr>
896 *         <td>MY_TV_P13</td>
897 *         <td>For viewers ages 13 and above, children under 13 needs parental guidance, can be
898 *         anytime, but some elements may only be broadcast at night</td>
899 *     </tr>
900 *     <tr>
901 *         <td>MY_TV_18</td>
902 *         <td>For viewers ages 18 and above only</td>
903 *     </tr>
904 *     <tr>
905 *         <td>NL_TV_AL</td>
906 *         <td>All Ages</td>
907 *     </tr>
908 *     <tr>
909 *         <td>NL_TV_6</td>
910 *         <td>Parental advisory for children under 6</td>
911 *     </tr>
912 *     <tr>
913 *         <td>NL_TV_9</td>
914 *         <td>Parental advisory for children under 9</td>
915 *     </tr>
916 *     <tr>
917 *         <td>NL_TV_12</td>
918 *         <td>Parental advisory for children under 12</td>
919 *     </tr>
920 *     <tr>
921 *         <td>NL_TV_16</td>
922 *         <td>Parental advisory for children under 16</td>
923 *     </tr>
924 *     <tr>
925 *         <td>NZ_FTV_G</td>
926 *         <td>These exclude material likely to harm children under 14 and can screen at any time.
927 *         may not necessarily be designed for younger viewers, but must not contain material likely
928 *         cause them undue distress or discomfort</td>
929 *     </tr>
930 *     <tr>
931 *         <td>NZ_FTV_PGR</td>
932 *         <td>Programmes more suited to more mature viewers. These are not necessarily unsuitable
933 *         children, but viewer discretion is advised, and parents and guardians are encouraged to
934 *         younger viewers</td>
935 *     </tr>
936 *     <tr>
937 *         <td>NZ_FTV_AO</td>
938 *         <td>Contain material of an adult nature handled in such a way that it is unsuitable for
939 *         </td>
940 *     </tr>
941 *     <tr>
942 *         <td>NZ_PTV_G</td>
943 *         <td>suitable for general audiences</td>
944 *     </tr>
945 *     <tr>
946 *         <td>NZ_PTV_PG</td>
947 *         <td>Parental guidance recommended for under 10</td>
948 *     </tr>
949 *     <tr>
950 *         <td>NZ_PTV_M</td>
951 *         <td>Suitable for mature audiences 13 and up</td>
952 *     </tr>
953 *     <tr>
954 *         <td>NZ_PTV_16</td>
955 *         <td>Suitable for viewers 16 and up</td>
956 *     </tr>
957 *     <tr>
958 *         <td>NZ_PTV_18</td>
959 *         <td>Suitable for viewers 18 and up</td>
960 *     </tr>
961 *     <tr>
962 *         <td>PE_TV_A</td>
963 *         <td>Suitable for all audiences</td>
964 *     </tr>
965 *     <tr>
966 *         <td>PE_TV_14</td>
967 *         <td>Suitable for people aged 14 and above only</td>
968 *     </tr>
969 *     <tr>
970 *         <td>PE_TV_18</td>
971 *         <td>Suitable for people aged 18 and above only</td>
972 *     </tr>
973 *     <tr>
974 *         <td>PE_ATV_GP</td>
975 *         <td>General audience</td>
976 *     </tr>
977 *     <tr>
978 *         <td>PE_ATV_PG</td>
979 *         <td>Parental guidance required for under 6</td>
980 *     </tr>
981 *     <tr>
982 *         <td>PE_ATV_14</td>
983 *         <td>Suitable for people aged 14 and above only</td>
984 *     </tr>
985 *     <tr>
986 *         <td>PE_ATV_18</td>
987 *         <td>Suitable for people aged 18 and above only</td>
988 *     </tr>
989 *     <tr>
990 *         <td>PH_TV_G</td>
991 *         <td>Suitable for all public viewers</td>
992 *     </tr>
993 *     <tr>
994 *         <td>PH_TV_PG</td>
995 *         <td>Programmes rated PG may contain scenes or other content that are unsuitable for
996 *         without the guidance of a parent</td>
997 *     </tr>
998 *     <tr>
999 *         <td>PH_TV_SPG</td>
1000 *         <td>Contains mature themes or moderate to intense violence, which may be deemed unfit for
1001 *         to watch without strict parental supervision</td>
1002 *     </tr>
1003 *     <tr>
1004 *         <td>PL_TV_G</td>
1005 *         <td>Positive or neutral view of the world, little to no violence, non-sexual love, and no
1006 *         content</td>
1007 *     </tr>
1008 *     <tr>
1009 *         <td>PL_TV_7</td>
1010 *         <td>Age 7 and above. May additionally contain some mild language, bloodless violence, and
1011 *         more negative view of the world</td>
1012 *     </tr>
1013 *     <tr>
1014 *         <td>PL_TV_12</td>
1015 *         <td>Age 12 and above. May contain some foul language, some violence, and some sexual
1016 *         </td>
1017 *     </tr>
1018 *     <tr>
1019 *         <td>PL_TV_16</td>
1020 *         <td>Age 16 and above. Deviant social behaviour, world filled with violence and sexuality,
1021 *         picture of adulthood, display of physical force, especially in controversial social
1022 *         immoral behaviour without ethic dilemma, putting the blame on the victim, excessive
1023 *         on material possessions</td>
1024 *     </tr>
1025 *     <tr>
1026 *         <td>PL_TV_18</td>
1027 *         <td>Age 18 and above. One-sided display of the joys of adult life without showing
1028 *         social justification of violent behaviour, excessive vulgarity, use of racial slurs and
1029 *         stereotypes, explicit sexual content, praise of aggression or vulgarity</td>
1030 *     </tr>
1031 *     <tr>
1032 *         <td>PT_TV_T</td>
1033 *         <td>Suitable for all</td>
1034 *     </tr>
1035 *     <tr>
1036 *         <td>PT_TV_10</td>
1037 *         <td>May not be suitable for children under 10, parental guidance advised</td>
1038 *     </tr>
1039 *     <tr>
1040 *         <td>PT_TV_12</td>
1041 *         <td>May not be suitable for children under 12, parental guidance advised</td>
1042 *     </tr>
1043 *     <tr>
1044 *         <td>PT_TV_16</td>
1045 *         <td>Not suitable for children under 16</td>
1046 *     </tr>
1047 *     <tr>
1048 *         <td>RO_TV_Y</td>
1049 *         <td>Young Ages</td>
1050 *     </tr>
1051 *     <tr>
1052 *         <td>RO_TV_G</td>
1053 *         <td>General Exhibition</td>
1054 *     </tr>
1055 *     <tr>
1056 *         <td>RO_TV_AP</td>
1057 *         <td>Parental guidance is recommended for children below the age of 12</td>
1058 *     </tr>
1059 *     <tr>
1060 *         <td>RO_TV_12</td>
1061 *         <td>Forbidden for children under 12 years of age</td>
1062 *     </tr>
1063 *     <tr>
1064 *         <td>RO_TV_15</td>
1065 *         <td>Forbidden for children under 15 years of age</td>
1066 *     </tr>
1067 *     <tr>
1068 *         <td>RO_TV_18</td>
1069 *         <td>Forbidden for children under 18 years of age</td>
1070 *     </tr>
1071 *     <tr>
1072 *         <td>RU_TV_0</td>
1073 *         <td>Can be watched by Any Age</td>
1074 *     </tr>
1075 *     <tr>
1076 *         <td>RU_TV_6</td>
1077 *         <td>Only kids the age of 6 or older can watch</td>
1078 *     </tr>
1079 *     <tr>
1080 *         <td>RU_TV_12</td>
1081 *         <td>Only kids the age of 12 or older can watch</td>
1082 *     </tr>
1083 *     <tr>
1084 *         <td>RU_TV_16</td>
1085 *         <td>Only teens the age of 16 or older can watch</td>
1086 *     </tr>
1087 *     <tr>
1088 *         <td>RU_TV_18</td>
1089 *         <td>Restricted to children ONLY people 18 or older</td>
1090 *     </tr>
1091 *     <tr>
1092 *         <td>RS_TV_G</td>
1093 *         <td>Program suitable for all ages</td>
1094 *     </tr>
1095 *     <tr>
1096 *         <td>RS_TV_12</td>
1097 *         <td>Program not suitable for children under the age of 12</td>
1098 *     </tr>
1099 *     <tr>
1100 *         <td>RS_TV_14</td>
1101 *         <td>Program not suitable for children/teens under the age of 14</td>
1102 *     </tr>
1103 *     <tr>
1104 *         <td>RS_TV_15</td>
1105 *         <td>Program not suitable for children/teens under the age of 15</td>
1106 *     </tr>
1107 *     <tr>
1108 *         <td>RS_TV_16</td>
1109 *         <td>Program not suitable for children/teens under the age of 16</td>
1110 *     </tr>
1111 *     <tr>
1112 *         <td>RS_TV_17</td>
1113 *         <td>Program not suitable for children/teens under the age of 17</td>
1114 *     </tr>
1115 *     <tr>
1116 *         <td>RS_TV_18</td>
1117 *         <td>Program not suitable for minors under the age of 18</td>
1118 *     </tr>
1119 *     <tr>
1120 *         <td>SG_FTV_PG</td>
1121 *         <td>Suitable for most but parents should guide their young</td>
1122 *     </tr>
1123 *     <tr>
1124 *         <td>SG_FTV_PG13</td>
1125 *         <td>Parental Guidance Strongly Cautioned – Suitable for 13 And Above</td>
1126 *     </tr>
1127 *     <tr>
1128 *         <td>SG_PTV_NC16</td>
1129 *         <td>No Children Under 16</td>
1130 *     </tr>
1131 *     <tr>
1132 *         <td>SG_PTV_M18</td>
1133 *         <td>Nobody under age 18 is admitted</td>
1134 *     </tr>
1135 *     <tr>
1136 *         <td>SI_TV_VS</td>
1137 *         <td>Parental guidance suggested (for children under 6)</td>
1138 *     </tr>
1139 *     <tr>
1140 *         <td>SI_TV_12</td>
1141 *         <td>Content suitable for teens over 12 years</td>
1142 *     </tr>
1143 *     <tr>
1144 *         <td>SI_TV_15</td>
1145 *         <td>Content suitable for teens over 15 years</td>
1146 *     </tr>
1147 *     <tr>
1148 *         <td>SI_TV_AD</td>
1149 *         <td>Content exclusively for adults</td>
1150 *     </tr>
1151 *     <tr>
1152 *         <td>TH_TV_P</td>
1153 *         <td>Content suitable for primary school aged children</td>
1154 *     </tr>
1155 *     <tr>
1156 *         <td>TH_TV_C</td>
1157 *         <td>Content suitable for children between 6–12 years old</td>
1158 *     </tr>
1159 *     <tr>
1160 *         <td>TH_TV_G</td>
1161 *         <td>Content suitable for general audiences</td>
1162 *     </tr>
1163 *     <tr>
1164 *         <td>TH_TV_PG13</td>
1165 *         <td>Content suitable for people aged 13 and above, but can be watched by those who are
1166 *         the recommended age if parental guidance is provided</td>
1167 *     </tr>
1168 *     <tr>
1169 *         <td>TH_TV_PG18</td>
1170 *         <td>Content suitable for people aged above 18 years old; those who are younger that 18
1171 *         be provided with parental guidance</td>
1172 *     </tr>
1173 *     <tr>
1174 *         <td>TH_TV_A</td>
1175 *         <td>Content unsuitable for children and youngsters</td>
1176 *     </tr>
1177 *     <tr>
1178 *         <td>TR_TV_G</td>
1179 *         <td>General audience. Suitable for all ages</td>
1180 *     </tr>
1181 *     <tr>
1182 *         <td>TR_TV_7</td>
1183 *         <td>Suitable for ages 7 and over</td>
1184 *     </tr>
1185 *     <tr>
1186 *         <td>TR_TV_13</td>
1187 *         <td>Suitable for ages 13 and over</td>
1188 *     </tr>
1189 *     <tr>
1190 *         <td>TR_TV_18</td>
1191 *         <td>Suitable for ages 13 and over</td>
1192 *     </tr>
1193 *     <tr>
1194 *         <td>TW_TV_G</td>
1195 *         <td>For all ages</td>
1196 *     </tr>
1197 *     <tr>
1198 *         <td>TW_TV_P</td>
1199 *         <td>Not suitable for children under 6 years old. People aged 6 but under 12 require
1200 *         from accompanying adults to watch</td>
1201 *     </tr>
1202 *     <tr>
1203 *         <td>TW_TV_PG</td>
1204 *         <td>Not suitable for people under 12 years of age. Parental guidance is required for
1205 *         aged 12 but under 18</td>
1206 *     </tr>
1207 *     <tr>
1208 *         <td>TW_TV_R</td>
1209 *         <td>For adults only and people under 18 years of age must not watch</td>
1210 *     </tr>
1211 *     <tr>
1212 *         <td>UA_TV_G</td>
1213 *         <td>This program does not have age restrictions</td>
1214 *     </tr>
1215 *     <tr>
1216 *         <td>UA_TV_Y</td>
1217 *         <td>Children must view this program with parents. In it program there are fragments,
1218 *         unsuitable for children</td>
1219 *     </tr>
1220 *     <tr>
1221 *         <td>UA_TV_R</td>
1222 *         <td>This program is only for adult viewers. In it there are scenes with nudity, drug use,
1223 *         violence</td>
1224 *     </tr>
1225 *     <tr>
1226 *         <td>US_TVPG_TV_Y</td>
1227 *         <td>This program is designed to be appropriate for all children</td>
1228 *     </tr>
1229 *     <tr>
1230 *         <td>US_TVPG_TV_Y7</td>
1231 *         <td>This program is designed for children age 7 and above</td>
1232 *     </tr>
1233 *     <tr>
1234 *         <td>US_TVPG_TV_G</td>
1235 *         <td>Most parents would find this program suitable for all ages</td>
1236 *     </tr>
1237 *     <tr>
1238 *         <td>US_TVPG_TV_PG</td>
1239 *         <td>This program contains material that parents may find unsuitable for younger children
1240 *         <td>This program contains material that parents may find unsuitable for younger children
1241 *         </td>
1242 *     </tr>
1243 *     <tr>
1244 *         <td>US_TVPG_TV_14</td>
1245 *         <td>This program contains some material that many parents would find unsuitable for
1246 *         under 14 years of age</td>
1247 *     </tr>
1248 *     <tr>
1249 *         <td>US_TVPG_TV_MA</td>
1250 *         <td>This program is specifically designed to be viewed by adults and therefore may be
1251 *         for children under 17</td>
1252 *     </tr>
1253 *     <tr>
1254 *         <td>VE_TV_TU</td>
1255 *         <td>For all ages</td>
1256 *     </tr>
1257 *     <tr>
1258 *         <td>VE_TV_SU</td>
1259 *         <td>Parental guidance for young viewers</td>
1260 *     </tr>
1261 *     <tr>
1262 *         <td>VE_TV_A</td>
1263 *         <td>Mature viewers</td>
1264 *     </tr>
1265 *     <tr>
1266 *         <td>ZA_TV_F</td>
1267 *         <td>This is a program/film that does not contain any obscenity, and is suitable for
1268 *         viewing. A logo must be displayed in the corner of the screen for 30 seconds after each
1269 *         break</td>
1270 *     </tr>
1271 *     <tr>
1272 *         <td>ZA_TV_PG</td>
1273 *         <td>Children under 6 may watch this program/film, but must be accompanied by an adult.
1274 *         program contains an adult related theme, which might include very mild language, violence
1275 *         sexual innuendo. A logo must be displayed in the corner of the screen for one minute
1276 *         each commercial break</td>
1277 *     </tr>
1278 *     <tr>
1279 *         <td>ZA_TV_13</td>
1280 *         <td>Children under 13 are prohibited from watching this program/film. This program
1281 *         mild language, violence and sexual innuendo. A logo must be displayed in the corner of
1282 *         screen for two minutes after each commercial break</td>
1283 *     </tr>
1284 *     <tr>
1285 *         <td>ZA_TV_16</td>
1286 *         <td>Children under 16 are prohibited from watching this program/film. It contains
1287 *         violence, language, and some sexual situations. In the case of television, this program
1288 *         only be broadcast after 9pm–4:30am. A logo must be displayed in the corner of the screen
1289 *         five minutes after each commercial break. A full-screen warning must be issued before the
1290 *         of the program. If the program is longer than an hour, a warning must be displayed every
1291 *         an hour</td>
1292 *     </tr>
1293 *     <tr>
1294 *         <td>ZA_TV_18</td>
1295 *         <td>Children under 18 are prohibited from watching this program/film. It contains extreme
1296 *         language and/or graphic sexual content. In the case of television, this program may only
1297 *         broadcast from 10pm–4:30am. A logo must be displayed in the corner of the screen for the
1298 *         of the program. A full-screen warning must be issued before the start of the program and
1299 *         each commercial break</td>
1300 *     </tr>
1301 *     <tr>
1302 *         <td>ZA_TV_R18</td>
1303 *         <td>This is reserved for films of an extreme sexual nature (pornography). R18 films may
1304 *         be distributed in the form of video and DVD in a controlled environment (e.g. Adult
1305 *         No public viewing of this film may take place. R18 films may not be broadcast on
1306 *         and in cinemas</td>
1307 *     </tr>
1308 * </table>
1309 *
1310 * <u>System defined string for {@code subRating}</u>
1311 * <table border="0" cellspacing="0" cellpadding="0">
1312 *     <tr>
1313 *         <td>String value</td>
1314 *         <td>Comments</td>
1315 *     </tr>
1316 *     <tr>
1317 *         <td>NL_TV_V</td>
1318 *         <td>Violence</td>
1319 *     </tr>
1320 *     <tr>
1321 *         <td>NL_TV_F</td>
1322 *         <td>Scary or Disturbing Content</td>
1323 *     </tr>
1324 *     <tr>
1325 *         <td>NL_TV_S</td>
1326 *         <td>Sexual Content</td>
1327 *     </tr>
1328 *     <tr>
1329 *         <td>NL_TV_D</td>
1330 *         <td>Discrimination</td>
1331 *     </tr>
1332 *     <tr>
1333 *         <td>NL_TV_DA</td>
1334 *         <td>Drug and/or Alcohol abuse</td>
1335 *     </tr>
1336 *     <tr>
1337 *         <td>NL_TV_L</td>
1338 *         <td>Bad Language</td>
1339 *     </tr>
1340 *     <tr>
1341 *         <td>NZ_PTV_C</td>
1342 *         <td>Content may offend</td>
1343 *     </tr>
1344 *     <tr>
1345 *         <td>NZ_PTV_V</td>
1346 *         <td>Violence</td>
1347 *     </tr>
1348 *     <tr>
1349 *         <td>NZ_PTV_L</td>
1350 *         <td>Language</td>
1351 *     </tr>
1352 *     <tr>
1353 *         <td>NZ_PTV_S</td>
1354 *         <td>Sexual content</td>
1355 *     </tr>
1356 *     <tr>
1357 *         <td>US_TVPG_D</td>
1358 *         <td>Suggestive dialogue (Usually means talks about sex)</td>
1359 *     </tr>
1360 *     <tr>
1361 *         <td>US_TVPG_L</td>
1362 *         <td>Coarse language</td>
1363 *     </tr>
1364 *     <tr>
1365 *         <td>US_TVPG_S</td>
1366 *         <td>Sexual content</td>
1367 *     </tr>
1368 *     <tr>
1369 *         <td>US_TVPG_V</td>
1370 *         <td>Violence</td>
1371 *     </tr>
1372 *     <tr>
1373 *         <td>US_TVPG_FV</td>
1374 *         <td>Fantasy violence (Children\'s programming only)</td>
1375 *     </tr>
1376 *     <tr>
1377 *         <td>ZA_TV_D</td>
1378 *         <td>Drug</td>
1379 *     </tr>
1380 *     <tr>
1381 *         <td>ZA_TV_V</td>
1382 *         <td>Violence</td>
1383 *     </tr>
1384 *     <tr>
1385 *         <td>ZA_TV_N</td>
1386 *         <td>Nudity</td>
1387 *     </tr>
1388 *     <tr>
1389 *         <td>ZA_TV_P</td>
1390 *         <td>Prejudice</td>
1391 *     </tr>
1392 *     <tr>
1393 *         <td>ZA_TV_S</td>
1394 *         <td>Sex</td>
1395 *     </tr>
1396 *     <tr>
1397 *         <td>ZA_TV_L</td>
1398 *         <td>Language</td>
1399 *     </tr>
1400 * </table>
1401 */
1402public final class TvContentRating {
1403    /** @hide */
1404    public static final Uri SYSTEM_CONTENT_RATING_SYSTEM_XML = Uri.parse(
1405            "android.resource://system/" + com.android.internal.R.xml.tv_content_rating_systems);
1406
1407    // TODO: Consider to use other DELIMITER. In some countries such as India may use this delimiter
1408    // in the main ratings.
1409    private static final String DELIMITER = "/";
1410
1411    private final String mDomain;
1412    private final String mRatingSystem;
1413    private final String mRating;
1414    private final String[] mSubRatings;
1415
1416    /**
1417     * Creates a TvContentRating object.
1418     *
1419     * @param domain The domain name.
1420     * @param ratingSystem The rating system id.
1421     * @param rating The content rating string.
1422     * @param subRatings The string array of sub-ratings.
1423     * @return A TvContentRating object, or null if creation failed.
1424     */
1425    public static TvContentRating createRating(String domain, String ratingSystem,
1426            String rating, String... subRatings) {
1427        if (TextUtils.isEmpty(domain)) {
1428            throw new IllegalArgumentException("domain cannot be empty");
1429        }
1430        if (TextUtils.isEmpty(ratingSystem)) {
1431            throw new IllegalArgumentException("ratingSystem cannot be empty");
1432        }
1433        if (TextUtils.isEmpty(rating)) {
1434            throw new IllegalArgumentException("rating cannot be empty");
1435        }
1436        return new TvContentRating(domain, ratingSystem, rating, subRatings);
1437    }
1438
1439    /**
1440     * Recovers a TvContentRating from a String that was previously created with
1441     * {@link #flattenToString}.
1442     *
1443     * @param ratingString The String that was returned by flattenToString().
1444     * @return a new TvContentRating containing the domain, rating system, rating and
1445     *         sub-ratings information was encoded in {@code ratingString}.
1446     * @see #flattenToString
1447     */
1448    public static TvContentRating unflattenFromString(String ratingString) {
1449        if (TextUtils.isEmpty(ratingString)) {
1450            throw new IllegalArgumentException("ratingString cannot be empty");
1451        }
1452        String[] strs = ratingString.split(DELIMITER);
1453        if (strs.length < 3) {
1454            throw new IllegalArgumentException("Invalid rating string: " + ratingString);
1455        }
1456        if (strs.length > 3) {
1457            String[] subRatings = new String[strs.length - 3];
1458            System.arraycopy(strs, 3, subRatings, 0, subRatings.length);
1459            return new TvContentRating(strs[0], strs[1], strs[2], subRatings);
1460        }
1461        return new TvContentRating(strs[0], strs[1], strs[2], null);
1462    }
1463
1464    /**
1465     * Constructs a TvContentRating object from a given rating and sub-rating constants.
1466     *
1467     * @param domain The domain name.
1468     * @param ratingSystem The rating system id.
1469     * @param rating The content rating string.
1470     * @param subRatings The String array of sub-rating constants defined in this class.
1471     */
1472    private TvContentRating(
1473            String domain, String ratingSystem, String rating, String[] subRatings) {
1474        mDomain = domain;
1475        mRatingSystem = ratingSystem;
1476        mRating = rating;
1477        mSubRatings = (subRatings == null || subRatings.length == 0) ? null : subRatings;
1478    }
1479
1480    /**
1481     * Returns the domain.
1482     */
1483    public String getDomain() {
1484        return mDomain;
1485    }
1486
1487    /**
1488     * Returns the rating system id.
1489     */
1490    public String getRatingSystem() {
1491        return mRatingSystem;
1492    }
1493
1494    /**
1495     * Returns the main rating.
1496     */
1497    public String getMainRating() {
1498        return mRating;
1499    }
1500
1501    /**
1502     * Returns the unmodifiable {@code List} of sub-rating strings.
1503     */
1504    public List<String> getSubRatings() {
1505        if (mSubRatings == null) {
1506            return null;
1507        }
1508        return Collections.unmodifiableList(Arrays.asList(mSubRatings));
1509    }
1510
1511    /**
1512     * Returns a String that unambiguously describes both the rating and sub-rating information
1513     * contained in the TvContentRating. You can later recover the TvContentRating from this string
1514     * through {@link #unflattenFromString}.
1515     *
1516     * @return a new String holding rating/sub-rating information, which can later be stored in the
1517     *         database and settings.
1518     * @see #unflattenFromString
1519     */
1520    public String flattenToString() {
1521        StringBuilder builder = new StringBuilder();
1522        builder.append(mDomain);
1523        builder.append(DELIMITER);
1524        builder.append(mRatingSystem);
1525        builder.append(DELIMITER);
1526        builder.append(mRating);
1527        if (mSubRatings != null) {
1528            for (String subRating : mSubRatings) {
1529                builder.append(DELIMITER);
1530                builder.append(subRating);
1531            }
1532        }
1533        return builder.toString();
1534    }
1535
1536    /**
1537     * Returns true if this rating has the same main rating as the specified rating and when this
1538     * rating's sub-ratings contain the other's.
1539     * <p>
1540     * For example, a TvContentRating object that represents TV-PG with S(Sexual content) and
1541     * V(Violence) contains TV-PG, TV-PG/S, TV-PG/V and itself.
1542     * </p>
1543     *
1544     * @param rating The {@link TvContentRating} to check.
1545     * @return {@code true} if this object contains {@code rating}, {@code false} otherwise.
1546     * @hide
1547     */
1548    @SystemApi
1549    public final boolean contains(TvContentRating rating) {
1550        if (rating == null) {
1551            throw new IllegalArgumentException("rating cannot be null");
1552        }
1553        if (!rating.getMainRating().equals(mRating)) {
1554            return false;
1555        }
1556        if (!rating.getDomain().equals(mDomain) ||
1557                !rating.getRatingSystem().equals(mRatingSystem) ||
1558                !rating.getMainRating().equals(mRating)) {
1559            return false;
1560        }
1561        List<String> subRatings = getSubRatings();
1562        List<String> subRatingsOther = rating.getSubRatings();
1563        if (subRatings == null && subRatingsOther == null) {
1564            return true;
1565        } else if (subRatings == null && subRatingsOther != null) {
1566            return false;
1567        } else if (subRatings != null && subRatingsOther == null) {
1568            return true;
1569        } else {
1570            return subRatings.containsAll(subRatingsOther);
1571        }
1572    }
1573}
1574