tv-provider/src/main/java/androidx/tvprovider/media/tv/TvContractCompat.java
public static @Genre String[] decode(@NonNull String genres) {
                if (TextUtils.isEmpty(genres)) {
                    // MNC and before will throw a NPE for {@code null} genres.
                    return EMPTY_STRING_ARRAY;
                }
                if (genres.indexOf(COMMA) == -1 && genres.indexOf(DOUBLE_QUOTE) == -1) {
                    return new String[] {genres.trim()};
                }
                StringBuilder sb = new StringBuilder();
                List<String> results = new ArrayList<>();
                int length = genres.length();
                boolean escape = false;
                for (int i = 0; i < length; ++i) {
                    char c = genres.charAt(i);
                    switch (c) {
                        case DOUBLE_QUOTE:
                            if (!escape) {
                                escape = true;
                                continue;
                            }
                            break;
                        case COMMA:
                            if (!escape) {
                                String string = sb.toString().trim();
                                if (string.length() > 0) {
                                    results.add(string);
                                }
                                sb = new StringBuilder();
                                continue;
                            }
                            break;
                    }
                    sb.append(c);
                    escape = false;
                }
                String string = sb.toString().trim();
                if (string.length() > 0) {
                    results.add(string);
                }
                return results.toArray(new String[results.size()]);
            }
/**
             * Decodes the genre strings from the text stored in the database.
             *
             * @param genres The encoded genre string retrieved from the
             *            {@link #COLUMN_BROADCAST_GENRE} or {@link #COLUMN_CANONICAL_GENRE} column.
             * @return genre strings.
             */
Decodes the genre strings from the text stored in the database.
@param genres The encoded genre string retrieved from the
#COLUMN_BROADCAST_GENRE or  #COLUMN_CANONICAL_GENRE column.
@return genre strings.
Decodes the genre strings from the text stored in the database . @param genres The encoded genre string retrieved from the #COLUMN_BROADCAST_GENRE or #COLUMN_CANONICAL_GENRE column . @return genre strings .
public static @Genre String[] decode(@NonNull String genres) {
                if (TextUtils.isEmpty(genres)) {
                    return EMPTY_STRING_ARRAY;
                }
                if (genres.indexOf(COMMA) == -1 && genres.indexOf(DOUBLE_QUOTE) == -1) {
                    return new String[] {genres.trim()};
                }
                StringBuilder sb = new StringBuilder();
                List<String> results = new ArrayList<>();
                int length = genres.length();
                boolean escape = false;
                for (int i = 0; i < length; ++i) {
                    char c = genres.charAt(i);
                    switch (c) {
                        case DOUBLE_QUOTE:
                            if (!escape) {
                                escape = true;
                                continue;
                            }
                            break;
                        case COMMA:
                            if (!escape) {
                                String string = sb.toString().trim();
                                if (string.length() > 0) {
                                    results.add(string);
                                }
                                sb = new StringBuilder();
                                continue;
                            }
                            break;
                    }
                    sb.append(c);
                    escape = false;
                }
                String string = sb.toString().trim();
                if (string.length() > 0) {
                    results.add(string);
                }
                return results.toArray(new String[results.size()]);
            }
public static @ Genre String [ ] decode ( @ NonNull String genres ) { if ( TextUtils . isEmpty ( genres ) ) { return EMPTY_STRING_ARRAY ; } if ( genres . indexOf ( COMMA ) == - 1 && genres . indexOf ( DOUBLE_QUOTE ) == - 1 ) { return new String [ ] { genres . trim ( ) } ; } StringBuilder sb = new StringBuilder ( ) ; List < String > results = new ArrayList < > ( ) ; int length = genres . length ( ) ; boolean escape = false ; for ( int i = 0 ; i < length ; ++ i ) { char c = genres . charAt ( i ) ; switch ( c ) { case DOUBLE_QUOTE : if ( ! escape ) { escape = true ; continue ; } break ; case COMMA : if ( ! escape ) { String string = sb . toString ( ) . trim ( ) ; if ( string . length ( ) > 0 ) { results . add ( string ) ; } sb = new StringBuilder ( ) ; continue ; } break ; } sb . append ( c ) ; escape = false ; } String string = sb . toString ( ) . trim ( ) ; if ( string . length ( ) > 0 ) { results . add ( string ) ; } return results . toArray ( new String [ results . size ( ) ] ) ; }
Decodes the genre strings from the text stored in the database.
Decodes the genre strings from the text stored in the database .
// MNC and before will throw a NPE for {@code null} genres.