//# 0 errors, 145 messages
//#
/*
    //#ParserError.java:1:1: class: com.dmdirc.parser.irc.ParserError
    //#ParserError.java:1:1: method: com.dmdirc.parser.irc.ParserError.com.dmdirc.parser.irc.ParserError__static_init
 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.dmdirc.parser.irc;

/**
 * IRC Parser Error.
 *
 * @author Shane Mc Cormack
 */
public final class ParserError {
	/** Error is potentially Fatal, Desync 99% Guaranteed! */
	public static final int ERROR_FATAL = 1;
	/** Error is not fatal, but is more severe than a warning. */
	public static final int ERROR_ERROR = 2;
	/** Error was an unexpected occurance, but shouldn't be anything to worry about. */
	public static final int ERROR_WARNING = 4;
	/** Error is a user-error rather than a server error. */
	public static final int ERROR_USER = 8;
	/** Error was an exception from elsewhere. */
	public static final int ERROR_EXCEPTION = 16;
	
	/** Store the Error level. */
	private int errorLevel;
	/** Store the Error Information. */
	private String errorData;
	/** Store the Exception object. */
	private Exception exceptionInfo;
	
	/** Last line of server input before this exception was triggered. */
	private String lastLine = "";
	
	/**
	 * Create a new Error.
	 *
	 * @param level Set the error level.
	 * @param data String containing information about the error.
	 * @param line The last line of data recieved from the server before this exception.
	 */
	public ParserError(final int level, final String data, final String line) {
    //#ParserError.java:59: method: void com.dmdirc.parser.irc.ParserError.com.dmdirc.parser.irc.ParserError(int, String, String)
    //#input(void com.dmdirc.parser.irc.ParserError(int, String, String)): data
    //#input(void com.dmdirc.parser.irc.ParserError(int, String, String)): level
    //#input(void com.dmdirc.parser.irc.ParserError(int, String, String)): line
    //#input(void com.dmdirc.parser.irc.ParserError(int, String, String)): this
    //#output(void com.dmdirc.parser.irc.ParserError(int, String, String)): this.errorData
    //#output(void com.dmdirc.parser.irc.ParserError(int, String, String)): this.errorLevel
    //#output(void com.dmdirc.parser.irc.ParserError(int, String, String)): this.lastLine
    //#post(void com.dmdirc.parser.irc.ParserError(int, String, String)): this.errorData == data
    //#post(void com.dmdirc.parser.irc.ParserError(int, String, String)): init'ed(this.errorData)
    //#post(void com.dmdirc.parser.irc.ParserError(int, String, String)): this.errorLevel == level
    //#post(void com.dmdirc.parser.irc.ParserError(int, String, String)): init'ed(this.errorLevel)
    //#post(void com.dmdirc.parser.irc.ParserError(int, String, String)): this.lastLine == line
    //#post(void com.dmdirc.parser.irc.ParserError(int, String, String)): init'ed(this.lastLine)
		errorData = data;
		errorLevel = level;
		lastLine = line;
	}
    //#ParserError.java:63: end of method: void com.dmdirc.parser.irc.ParserError.com.dmdirc.parser.irc.ParserError(int, String, String)
	
	/**
	 * Check if this error is considered Fatal.
	 *
	 * @return Returns true for a fatal error, false for a non-fatal error
	 */
	public boolean isFatal() {
		return (errorLevel & ERROR_FATAL) == ERROR_FATAL;
    //#ParserError.java:71: method: bool com.dmdirc.parser.irc.ParserError.isFatal()
    //#input(bool isFatal()): this
    //#input(bool isFatal()): this.errorLevel
    //#output(bool isFatal()): return_value
    //#pre[2] (bool isFatal()): init'ed(this.errorLevel)
    //#post(bool isFatal()): init'ed(return_value)
    //#ParserError.java:71: end of method: bool com.dmdirc.parser.irc.ParserError.isFatal()
	}
	
	/**
	 * Check if this error is considered an error (less severe than fatal, worse than warning).
	 *
	 * @return Returns true for an "Error" level error, else false.
	 */
	public boolean isError() {
		return (errorLevel & ERROR_ERROR) == ERROR_ERROR;
    //#ParserError.java:80: method: bool com.dmdirc.parser.irc.ParserError.isError()
    //#input(bool isError()): this
    //#input(bool isError()): this.errorLevel
    //#output(bool isError()): return_value
    //#pre[2] (bool isError()): init'ed(this.errorLevel)
    //#post(bool isError()): init'ed(return_value)
    //#ParserError.java:80: end of method: bool com.dmdirc.parser.irc.ParserError.isError()
	}
	
	/**
	 * Check if this error is considered a warning.
	 *
	 * @return Returns true for a warning, else false.
	 */
	public boolean isWarning() {
		return (errorLevel & ERROR_WARNING) == ERROR_WARNING;
    //#ParserError.java:89: method: bool com.dmdirc.parser.irc.ParserError.isWarning()
    //#input(bool isWarning()): this
    //#input(bool isWarning()): this.errorLevel
    //#output(bool isWarning()): return_value
    //#pre[2] (bool isWarning()): init'ed(this.errorLevel)
    //#post(bool isWarning()): init'ed(return_value)
    //#ParserError.java:89: end of method: bool com.dmdirc.parser.irc.ParserError.isWarning()
	}
	
	/**
	 * Check if this error is considered a user-error rather than a server error.
	 * For DMDirc this will cause the error not to be reported to the developers
	 *
	 * @return Returns true for a user error, else false.
	 */
	public boolean isUserError() {
		return (errorLevel & ERROR_USER) == ERROR_USER;
    //#ParserError.java:99: method: bool com.dmdirc.parser.irc.ParserError.isUserError()
    //#input(bool isUserError()): this
    //#input(bool isUserError()): this.errorLevel
    //#output(bool isUserError()): return_value
    //#pre[2] (bool isUserError()): init'ed(this.errorLevel)
    //#post(bool isUserError()): init'ed(return_value)
    //#ParserError.java:99: end of method: bool com.dmdirc.parser.irc.ParserError.isUserError()
	}
	
	/**
	 * Check if this error was generated from an exception.
	 *
	 * @return Returns true if getException will return an exception.
	 */
	public boolean isException() {
		return (errorLevel & ERROR_EXCEPTION) == ERROR_EXCEPTION;
    //#ParserError.java:108: method: bool com.dmdirc.parser.irc.ParserError.isException()
    //#input(bool isException()): this
    //#input(bool isException()): this.errorLevel
    //#output(bool isException()): return_value
    //#pre[2] (bool isException()): init'ed(this.errorLevel)
    //#post(bool isException()): init'ed(return_value)
    //#ParserError.java:108: end of method: bool com.dmdirc.parser.irc.ParserError.isException()
	}
	
	/**
	 * Check if this error has a lastLine parameter.
	 *
	 * @return Returns true if getLastLine returns anything non null, non empty.
	 */
	public boolean hasLastLine() {
		return (lastLine != null && !lastLine.isEmpty());
    //#ParserError.java:117: method: bool com.dmdirc.parser.irc.ParserError.hasLastLine()
    //#input(bool hasLastLine()): this
    //#input(bool hasLastLine()): this.lastLine
    //#output(bool hasLastLine()): return_value
    //#pre[2] (bool hasLastLine()): init'ed(this.lastLine)
    //#post(bool hasLastLine()): init'ed(return_value)
    //#ParserError.java:117: end of method: bool com.dmdirc.parser.irc.ParserError.hasLastLine()
	}
	
	/**
	 * Set the Exception object.
	 *
	 * @param newException The exception object to store
	 */
	public void setException(final Exception newException) {
		exceptionInfo = newException;
    //#ParserError.java:126: method: void com.dmdirc.parser.irc.ParserError.setException(Exception)
    //#input(void setException(Exception)): newException
    //#input(void setException(Exception)): this
    //#input(void setException(Exception)): this.errorLevel
    //#output(void setException(Exception)): this.errorLevel
    //#output(void setException(Exception)): this.exceptionInfo
    //#pre[2] (void setException(Exception)): (soft) this.errorLevel <= 4_294_967_279
    //#post(void setException(Exception)): this.errorLevel == One-of{old this.errorLevel, old this.errorLevel + 16}
    //#post(void setException(Exception)): init'ed(this.errorLevel)
    //#post(void setException(Exception)): this.exceptionInfo == newException
    //#post(void setException(Exception)): init'ed(this.exceptionInfo)
    //#test_vector(void setException(Exception)): this.errorLevel & 16: {16}, {0..15}
		if (!this.isException()) {
			this.errorLevel = this.errorLevel + ERROR_EXCEPTION;
		}
	}
    //#ParserError.java:130: end of method: void com.dmdirc.parser.irc.ParserError.setException(Exception)
	
	/**
	 * Get the Exception object.
	 *
	 * @return Returns the exception object
	 */
	public Exception getException() {
		return exceptionInfo;
    //#ParserError.java:138: method: Exception com.dmdirc.parser.irc.ParserError.getException()
    //#input(Exception getException()): this
    //#input(Exception getException()): this.exceptionInfo
    //#output(Exception getException()): return_value
    //#pre[2] (Exception getException()): init'ed(this.exceptionInfo)
    //#post(Exception getException()): return_value == this.exceptionInfo
    //#post(Exception getException()): init'ed(return_value)
    //#ParserError.java:138: end of method: Exception com.dmdirc.parser.irc.ParserError.getException()
	}
	
	/**
	 * Get the full ErrorLevel.
	 *
	 * @return Returns the error level
	 */
	public int getLevel() {
		return errorLevel;
    //#ParserError.java:147: method: int com.dmdirc.parser.irc.ParserError.getLevel()
    //#input(int getLevel()): this
    //#input(int getLevel()): this.errorLevel
    //#output(int getLevel()): return_value
    //#pre[2] (int getLevel()): init'ed(this.errorLevel)
    //#post(int getLevel()): return_value == this.errorLevel
    //#post(int getLevel()): init'ed(return_value)
    //#ParserError.java:147: end of method: int com.dmdirc.parser.irc.ParserError.getLevel()
	}
	
	/**
	 * Get the Error information.
	 *
	 * @return Returns the error data
	 */
	public String getData() {
		return errorData;
    //#ParserError.java:156: method: String com.dmdirc.parser.irc.ParserError.getData()
    //#input(String getData()): this
    //#input(String getData()): this.errorData
    //#output(String getData()): return_value
    //#pre[2] (String getData()): init'ed(this.errorData)
    //#post(String getData()): return_value == this.errorData
    //#post(String getData()): init'ed(return_value)
    //#ParserError.java:156: end of method: String com.dmdirc.parser.irc.ParserError.getData()
	}
	
	/**
	 * Add to the error information.
	 *
	 * @param data Information to add to the end of the existing Data
	 */
	public void appendData(final String data) {
		errorData = errorData + '[' + data + ']';
    //#ParserError.java:165: method: void com.dmdirc.parser.irc.ParserError.appendData(String)
    //#input(void appendData(String)): data
    //#input(void appendData(String)): data._tainted
    //#input(void appendData(String)): this
    //#input(void appendData(String)): this.errorData
    //#input(void appendData(String)): this.errorData._tainted
    //#output(void appendData(String)): java.lang.StringBuilder:toString(...)._tainted
    //#output(void appendData(String)): this.errorData
    //#new obj(void appendData(String)): java.lang.StringBuilder:toString(...)
    //#pre[3] (void appendData(String)): init'ed(this.errorData)
    //#post(void appendData(String)): init'ed(java.lang.StringBuilder:toString(...)._tainted)
    //#post(void appendData(String)): this.errorData == &java.lang.StringBuilder:toString(...)
	}
    //#ParserError.java:166: end of method: void com.dmdirc.parser.irc.ParserError.appendData(String)
	
	/**
	 * Get the last line recieved from the server before this exception.
	 *
	 * @return Returns the error data
	 */
	public String getLastLine() {
		return lastLine;
    //#ParserError.java:174: method: String com.dmdirc.parser.irc.ParserError.getLastLine()
    //#input(String getLastLine()): this
    //#input(String getLastLine()): this.lastLine
    //#output(String getLastLine()): return_value
    //#pre[2] (String getLastLine()): init'ed(this.lastLine)
    //#post(String getLastLine()): return_value == this.lastLine
    //#post(String getLastLine()): init'ed(return_value)
    //#ParserError.java:174: end of method: String com.dmdirc.parser.irc.ParserError.getLastLine()
	}	

}
    //#output(com.dmdirc.parser.irc.ParserError__static_init): __Descendant_Table[com/dmdirc/parser/irc/ParserError]
    //#output(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.appendData(Ljava/lang/String;)V
    //#output(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.getData()Ljava/lang/String;
    //#output(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.getException()Ljava/lang/Exception;
    //#output(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.getLastLine()Ljava/lang/String;
    //#output(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.getLevel()I
    //#output(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.hasLastLine()Z
    //#output(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.isError()Z
    //#output(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.isException()Z
    //#output(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.isFatal()Z
    //#output(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.isUserError()Z
    //#output(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.isWarning()Z
    //#output(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.setException(Ljava/lang/Exception;)V
    //#post(com.dmdirc.parser.irc.ParserError__static_init): __Descendant_Table[com/dmdirc/parser/irc/ParserError] == &__Dispatch_Table
    //#post(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.appendData(Ljava/lang/String;)V == &appendData
    //#post(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.getData()Ljava/lang/String; == &getData
    //#post(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.getException()Ljava/lang/Exception; == &getException
    //#post(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.getLastLine()Ljava/lang/String; == &getLastLine
    //#post(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.getLevel()I == &getLevel
    //#post(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.hasLastLine()Z == &hasLastLine
    //#post(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.isError()Z == &isError
    //#post(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.isException()Z == &isException
    //#post(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.isFatal()Z == &isFatal
    //#post(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.isUserError()Z == &isUserError
    //#post(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.isWarning()Z == &isWarning
    //#post(com.dmdirc.parser.irc.ParserError__static_init): __Dispatch_Table.setException(Ljava/lang/Exception;)V == &setException
    //#ParserError.java:: end of method: com.dmdirc.parser.irc.ParserError.com.dmdirc.parser.irc.ParserError__static_init
    //#ParserError.java:: end of class: com.dmdirc.parser.irc.ParserError
