blob: 22eb69ecab7e670f57391c44b7b10e742647fc2b [file] [log] [blame]
//------------------------------------------------------------------------------
// Copyright (c) 2005, 2006 IBM Corporation and others.
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// Contributors:
// IBM Corporation - initial implementation
//------------------------------------------------------------------------------
package org.eclipse.epf.library.configuration;
/**
* An ErrorInfo object holds the error message info caused by an element. The
* ErrorInfo object is owned by the owner element which has this error
*
* @author Jinhua Xi
* @since 1.0
*/
public class ErrorInfo {
public static final int NONE = 0;
public static final int ERROR = 1;
public static final int WARNING = 2;
public static final int CHILD_ERROR = 4;
public static final int CHILD_WARNING = 8;
/**
* this defines the relationship between the owner element and the cause element.
* The owner element references to the the cause element
*/
public static final int REFERENCE_TO = 16;
/**
* this defines the relationship between the owner element and the cause element.
* The owner element is referenced by the the cause element
*/
public static final int REFERENCED_BY = 32;
private int errorType;
private Object ownerElement;
private Object causeElement;
private String errorMessage;
private int relation = 0;
/**
* constructor
*
* @param errorType int the error type
* @param message String the error message
* @param ownerElement Object, the element that owns this error
* @param causeElement Object, the element that caused this error
* @param relation int the relathioship between the owner element and the cause element.
*/
public ErrorInfo(int errorType, String message, Object ownerElement,
Object causeElement, int relation) {
this.ownerElement = ownerElement;
this.causeElement = causeElement;
this.errorType = errorType;
this.errorMessage = message;
this.relation = relation;
}
/**
*
* @return int
*/
public int getRelation() {
return relation;
}
/**
*
* @return Object
*/
public Object getOwnerElement() {
return ownerElement;
}
/**
*
* @return Object
*/
public Object getCauseElement() {
return causeElement;
}
/**
*
* @return String
*/
public String getErrorMessage() {
return errorMessage;
}
/**
*
* @return int
*/
public int getErrorType() {
return errorType;
}
/**
*
* @return boolean
*/
public boolean isError() {
return (errorType & ERROR) > 0;
}
/**
*
* @return boolean
*/
public boolean isWarning() {
return (errorType & WARNING) > 0;
}
/**
*
* @return boolean
*/
public boolean isChildError() {
return (errorType & CHILD_ERROR) > 0;
}
/**
*
* @return boolean
*/
public boolean isChildWarning() {
return (errorType & CHILD_WARNING) > 0;
}
}