@Test public void testStringToContentRatings_singleRating() { TvContentRating[] ratings = new TvContentRating[1]; ratings[0] = TvContentRating.createRating( "com.android.tv", "US_TV", "US_TV_PG", "US_TV_D", "US_TV_L", "US_TV_S", "US_TV_V"); assertArrayEquals(ratings, TvContractUtils.stringToContentRatings( "com.android.tv/US_TV/US_TV_PG/US_TV_D/US_TV_L/US_TV_S/US_TV_V")); }
public static TvContentRating[] stringToContentRatings(String commaSeparatedRatings) { if (TextUtils.isEmpty(commaSeparatedRatings)) { return EMPTY; } String[] ratings = commaSeparatedRatings.split("\\s*,\\s*", -1); List<TvContentRating> contentRatings = new ArrayList<>(ratings.length); for (String rating : ratings) { try { contentRatings.add(TvContentRating.unflattenFromString(rating)); } catch (IllegalArgumentException e) { Log.w(TAG, "Can't parse the content rating: '" + rating + "', skipping", e); } } return contentRatings.size() == 0 ? EMPTY : contentRatings.toArray(new TvContentRating[contentRatings.size()]); }
TvContractUtils { public static TvContentRating[] stringToContentRatings(String commaSeparatedRatings) { if (TextUtils.isEmpty(commaSeparatedRatings)) { return EMPTY; } String[] ratings = commaSeparatedRatings.split("\\s*,\\s*", -1); List<TvContentRating> contentRatings = new ArrayList<>(ratings.length); for (String rating : ratings) { try { contentRatings.add(TvContentRating.unflattenFromString(rating)); } catch (IllegalArgumentException e) { Log.w(TAG, "Can't parse the content rating: '" + rating + "', skipping", e); } } return contentRatings.size() == 0 ? EMPTY : contentRatings.toArray(new TvContentRating[contentRatings.size()]); } }
TvContractUtils { public static TvContentRating[] stringToContentRatings(String commaSeparatedRatings) { if (TextUtils.isEmpty(commaSeparatedRatings)) { return EMPTY; } String[] ratings = commaSeparatedRatings.split("\\s*,\\s*", -1); List<TvContentRating> contentRatings = new ArrayList<>(ratings.length); for (String rating : ratings) { try { contentRatings.add(TvContentRating.unflattenFromString(rating)); } catch (IllegalArgumentException e) { Log.w(TAG, "Can't parse the content rating: '" + rating + "', skipping", e); } } return contentRatings.size() == 0 ? EMPTY : contentRatings.toArray(new TvContentRating[contentRatings.size()]); } private  TvContractUtils(); }
TvContractUtils { public static TvContentRating[] stringToContentRatings(String commaSeparatedRatings) { if (TextUtils.isEmpty(commaSeparatedRatings)) { return EMPTY; } String[] ratings = commaSeparatedRatings.split("\\s*,\\s*", -1); List<TvContentRating> contentRatings = new ArrayList<>(ratings.length); for (String rating : ratings) { try { contentRatings.add(TvContentRating.unflattenFromString(rating)); } catch (IllegalArgumentException e) { Log.w(TAG, "Can't parse the content rating: '" + rating + "', skipping", e); } } return contentRatings.size() == 0 ? EMPTY : contentRatings.toArray(new TvContentRating[contentRatings.size()]); } private  TvContractUtils(); static TvContentRating[] stringToContentRatings(String commaSeparatedRatings); static String contentRatingsToString(TvContentRating[] contentRatings); static String[] stringToAudioLanguages(String commaSeparatedString); static String audioLanguagesToString(String[] audioLanguages); }
TvContractUtils { public static TvContentRating[] stringToContentRatings(String commaSeparatedRatings) { if (TextUtils.isEmpty(commaSeparatedRatings)) { return EMPTY; } String[] ratings = commaSeparatedRatings.split("\\s*,\\s*", -1); List<TvContentRating> contentRatings = new ArrayList<>(ratings.length); for (String rating : ratings) { try { contentRatings.add(TvContentRating.unflattenFromString(rating)); } catch (IllegalArgumentException e) { Log.w(TAG, "Can't parse the content rating: '" + rating + "', skipping", e); } } return contentRatings.size() == 0 ? EMPTY : contentRatings.toArray(new TvContentRating[contentRatings.size()]); } private  TvContractUtils(); static TvContentRating[] stringToContentRatings(String commaSeparatedRatings); static String contentRatingsToString(TvContentRating[] contentRatings); static String[] stringToAudioLanguages(String commaSeparatedString); static String audioLanguagesToString(String[] audioLanguages);  }