private static final String DELIMITER = "/";
private final String mDomain;
- private final String mCountryCode;
private final String mRatingSystem;
private final String mRating;
private final String[] mSubRatings;
* Creates a TvContentRating object.
*
* @param domain The domain name.
- * @param countryCode The country code in ISO 3166-2 format or {@code null}.
* @param ratingSystem The rating system id.
* @param rating The content rating string.
* @param subRatings The string array of sub-ratings.
* @return A TvContentRating object, or null if creation failed.
*/
- public static TvContentRating createRating(String domain, String countryCode,
- String ratingSystem, String rating, String... subRatings) {
+ public static TvContentRating createRating(String domain, String ratingSystem,
+ String rating, String... subRatings) {
if (TextUtils.isEmpty(domain)) {
throw new IllegalArgumentException("domain cannot be empty");
}
if (TextUtils.isEmpty(rating)) {
throw new IllegalArgumentException("rating cannot be empty");
}
- return new TvContentRating(domain, countryCode, ratingSystem, rating, subRatings);
+ return new TvContentRating(domain, ratingSystem, rating, subRatings);
}
/**
* {@link #flattenToString}.
*
* @param ratingString The String that was returned by flattenToString().
- * @return a new TvContentRating containing the domain, countryCode, rating system, rating and
+ * @return a new TvContentRating containing the domain, rating system, rating and
* sub-ratings information was encoded in {@code ratingString}.
* @see #flattenToString
*/
throw new IllegalArgumentException("ratingString cannot be empty");
}
String[] strs = ratingString.split(DELIMITER);
- if (strs.length < 4) {
+ if (strs.length < 3) {
throw new IllegalArgumentException("Invalid rating string: " + ratingString);
}
- if (strs.length > 4) {
- String[] subRatings = new String[strs.length - 4];
- System.arraycopy(strs, 4, subRatings, 0, subRatings.length);
- return new TvContentRating(strs[0], strs[1], strs[2], strs[3], subRatings);
+ if (strs.length > 3) {
+ String[] subRatings = new String[strs.length - 3];
+ System.arraycopy(strs, 3, subRatings, 0, subRatings.length);
+ return new TvContentRating(strs[0], strs[1], strs[2], subRatings);
}
- return new TvContentRating(strs[0], strs[1], strs[2], strs[3], null);
+ return new TvContentRating(strs[0], strs[1], strs[2], null);
}
/**
* Constructs a TvContentRating object from a given rating and sub-rating constants.
*
- * @param rating The rating constant defined in this class.
+ * @param domain The domain name.
+ * @param ratingSystem The rating system id.
+ * @param rating The content rating string.
* @param subRatings The String array of sub-rating constants defined in this class.
*/
- private TvContentRating(String domain, String countryCode,
- String ratingSystem, String rating, String[] subRatings) {
+ private TvContentRating(
+ String domain, String ratingSystem, String rating, String[] subRatings) {
mDomain = domain;
- mCountryCode = countryCode;
mRatingSystem = ratingSystem;
mRating = rating;
mSubRatings = subRatings;
}
/**
- * Returns the country code in ISO 3166-2 format or {@code null}.
- */
- public String getCountry() {
- return mCountryCode;
- }
-
- /**
* Returns the rating system id.
*/
public String getRatingSystem() {
return Collections.unmodifiableList(Arrays.asList(mSubRatings));
}
-
/**
* Returns a String that unambiguously describes both the rating and sub-rating information
* contained in the TvContentRating. You can later recover the TvContentRating from this string
StringBuilder builder = new StringBuilder();
builder.append(mDomain);
builder.append(DELIMITER);
- builder.append(mCountryCode);
- builder.append(DELIMITER);
builder.append(mRatingSystem);
builder.append(DELIMITER);
builder.append(mRating);