All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.iheartradio.m3u8.ParseException Maven / Gradle / Ivy

There is a newer version: 0.2.6
Show newest version
package com.iheartradio.m3u8;

/**
 * Represents a syntactic error in the input that prevented further parsing.
 */
public class ParseException extends Exception {
    private static final long serialVersionUID = -2217152001086567983L;

    private final String mMessageSuffix;

    public final ParseExceptionType type;

    private String mInput;

    static ParseException create(ParseExceptionType type, String tag) {
        return create(type, tag, null);
    }

    static ParseException create(ParseExceptionType type, String tag, String context) {
        final StringBuilder builder = new StringBuilder();

        if (tag != null) {
            builder.append(tag);
        }

        if (context != null) {
            if (builder.length() > 0) {
                builder.append(" - ");
            }

            builder.append(context);
        }

        if (builder.length() > 0) {
            return new ParseException(type, builder.toString());
        } else {
            return new ParseException(type);
        }
    }

    ParseException(ParseExceptionType type) {
        this(type, null);
    }

    ParseException(ParseExceptionType type, String messageSuffix) {
        this.type = type;
        mMessageSuffix = messageSuffix;
    }

    public String getInput() {
        return mInput;
    }

    void setInput(String input) {
        mInput = input;
    }

    public String getMessage() {
        if (mMessageSuffix == null) {
            return type.message;
        } else {
            return type.message + ": " + mMessageSuffix;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy