org.eclipse.emf.common.util.BasicDiagnostic Maven / Gradle / Ivy
/**
* Copyright (c) 2004-2007 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 - Initial API and implementation
*/
package org.eclipse.emf.common.util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.common.EMFPlugin;
/**
* A basic implementation of a diagnostic that that also acts as a chain.
*/
public class BasicDiagnostic implements Diagnostic, DiagnosticChain
{
/**
* The severity.
* @see #getSeverity
*/
protected int severity;
/**
* The message.
* @see #getMessage
*/
protected String message;
/**
* The message.
* @see #getMessage
*/
protected List children;
/**
* The data.
* @see #getData
*/
protected List> data;
/**
* The source.
* @see #getSource
*/
protected String source;
/**
* The code.
* @see #getCode
*/
protected int code;
/**
* Default Constructor (no initialization for local parameters)
*/
public BasicDiagnostic()
{
super();
}
public BasicDiagnostic(String source, int code, String message, Object[] data)
{
this.source = source;
this.code = code;
this.message = message;
this.data = dataAsList(data);
}
public BasicDiagnostic(int severity, String source, int code, String message, Object[] data)
{
this(source, code, message, data);
this.severity = severity;
}
public BasicDiagnostic(String source, int code, List extends Diagnostic> children, String message, Object[] data)
{
this(source, code, message, data);
if (children != null)
{
for (Diagnostic diagnostic : children)
{
add(diagnostic);
}
}
}
protected List> dataAsList(Object [] data)
{
if (data == null)
{
return Collections.EMPTY_LIST;
}
else
{
Object [] copy = new Object [data.length];
System.arraycopy(data, 0, copy, 0, data.length);
return new BasicEList.UnmodifiableEList
© 2015 - 2025 Weber Informatics LLC | Privacy Policy