Пример #1
0
        public void parse(String line, ParseState state)
        {
            if (state.isMaster())
            {
                throw ParseException.create(ParseExceptionType.MEDIA_IN_MASTER, tagParser.getTag());
            }

            state.setMedia();
            lineParser.parse(line, state);
        }
Пример #2
0
        public override Playlist parse()
        {
            validateAvailable();

            ParseState      state           = new ParseState(mEncoding);
            TrackLineParser trackLineParser = new TrackLineParser();

            try
            {
                state.setMedia();

                while (mScanner.hasNext())
                {
                    String line = mScanner.next();
                    validateLine(line);

                    if (line.Length == 0 || isComment(line))
                    {
                        continue;
                    }
                    else
                    {
                        trackLineParser.parse(line, state);
                    }
                }

                Playlist playlist = new Playlist.Builder()
                                    .withMediaPlaylist(new MediaPlaylist.Builder()
                                                       .withTracks(state.getMedia().tracks)
                                                       .build())
                                    .build();

                PlaylistValidation validation = PlaylistValidation.from(playlist);

                if (validation.isValid())
                {
                    return(playlist);
                }
                else
                {
                    throw new PlaylistException(mScanner.getInput(), validation.getErrors());
                }
            }
            catch (ParseException exception)
            {
                exception.setInput(mScanner.getInput());
                throw exception;
            }
        }