Show MessageData.java syntax highlighted
/*
* PovClipse - Eclipse plugin for editing and rendering Povray sceene files.
* Copyright (C) 2006-2007 Wolfgang Moestl wmoestl@web.de
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package com.wm.povclipse.common;
/**
* Message bean holding a message string and message type information.
*
* @author Wolfgang Möstl
*/
public class MessageData {
public static final int TYPE_TRACE = 1;
public static final int TYPE_DEBUG = 2;
public static final int TYPE_INFO = 4;
public static final int TYPE_WARN = 8;
public static final int TYPE_ERROR = 16;
private int type = TYPE_TRACE;
private String message = "";
/**
* Private constructor.
* @param type The message type to be used.
* @param message The message String.
*/
private MessageData(int type, String message) {
this.type = type;
this.message = message;
}
/**
* Create a new <code>MessageData</code> of type <code>TYPE_ERROR</code>.
* @param message The message text to be set.
* @return The newly created <code>MessageData</code>.
*/
public static MessageData createErrorMessage(String message) {
return new MessageData(TYPE_ERROR, message);
}
/**
* Create a new <code>MessageData</code> of type <code>TYPE_WARN</code>.
* @param message The message text to be set.
* @return The newly created <code>MessageData</code>.
*/
public static MessageData createWarningMessage(String message) {
return new MessageData(TYPE_WARN, message);
}
/**
* Create a new <code>MessageData</code> of type <code>TYPE_INFO</code>.
* @param message The message text to be set.
* @return The newly created <code>MessageData</code>.
*/
public static MessageData createInfoMessage(String message) {
return new MessageData(TYPE_INFO, message);
}
/**
* Create a new <code>MessageData</code> of type <code>TYPE_DEBUG</code>.
* @param message The message text to be set.
* @return The newly created <code>MessageData</code>.
*/
public static MessageData createDebugMessage(String message) {
return new MessageData(TYPE_DEBUG, message);
}
/**
* Create a new <code>MessageData</code> of type <code>TYPE_TRACE</code>.
* @param message The message text to be set.
* @return The newly created <code>MessageData</code>.
*/
public static MessageData createTraceMessage(String message) {
return new MessageData(TYPE_TRACE, message);
}
/**
* @return The message text.
*/
public String getMessage() {
return message;
}
/**
* @return The message type
*/
public int getType() {
return type;
}
/**
* @return <code>true</code> if it is an <code>MessageData</code> of type
* <code>TYPE_ERROR</code>, <code>false</code> otherwise.
*/
public boolean isErrorMessage() { return type == TYPE_ERROR; }
/**
* @return <code>true</code> if it is an <code>MessageData</code> of type
* <code>TYPE_WARN</code>, <code>false</code> otherwise.
*/
public boolean isWarningMessage() { return type == TYPE_WARN; }
/**
* @return <code>true</code> if it is an <code>MessageData</code> of type
* <code>TYPE_INFO</code>, <code>false</code> otherwise.
*/
public boolean isInfoMessage() { return type == TYPE_INFO; }
/**
* @return <code>true</code> if it is an <code>MessageData</code> of type
* <code>TYPE_DEBUG</code>, <code>false</code> otherwise.
*/
public boolean isDebugMessage() { return type == TYPE_DEBUG; }
/**
* @return <code>true</code> if it is an <code>MessageData</code> of type
* <code>TYPE_TRACE</code>, <code>false</code> otherwise.
*/
public boolean isTraceMessage() { return type == TYPE_TRACE; }
}
See more files for this project here