edu.cmu.sei.aadl.modelsupport.errorreporting
Class AnalysisErrorReporterManager

java.lang.Object
  extended by edu.cmu.sei.aadl.modelsupport.errorreporting.AbstractErrorReporterManager
      extended by edu.cmu.sei.aadl.modelsupport.errorreporting.AnalysisErrorReporterManager
All Implemented Interfaces:
ErrorReporterManager, InternalErrorReporter

public final class AnalysisErrorReporterManager
extends AbstractErrorReporterManager

TODO: Fix this This class manages the creation and use of edu.cmu.sei.aadl.model.pluginsupport.AnalysisErrorReporter instances across a set of AADL text file resources. The manager keeps track of EMF Resource objects and not Eclipse IResource objects because the primary purpose of this class is to provide the correct error reporter when trying to interpret and resolve an already parsed model. So the errors are going to be found when using Element instances, but the errors reported on the AADL text file. This class solves the problem of mapping from the AObject to the text file.

It's probably redundant to have the methods take the filename as a parameter as they do, because the error reporters could already have the filename information, but the parser is already written to work that way. Also, I suppose we could have the situation where many files are used to create a single resource, in which case the filename would not be redundant.

The manager is supplied with a edu.cmu.sei.aadl.model.pluginsupport.ParseErrorReporterFactory instance that is used to create the error reporters.

This class purposely only depends on EMF, and not on Eclipse. That is, while it would be convienent to make explicit use of IResources here, we have chosen not to. Specific ParseErrorReporter may, of course, have whatever dependencies they like.

Author:
aarong
See Also:
edu.cmu.sei.aadl.model.pluginsupport.ParseErrorReporter, edu.cmu.sei.aadl.model.pluginsupport.ParseErrorReporterFactory

Field Summary
static AnalysisErrorReporterManager NULL_ERROR_MANANGER
          Singleton reference to an error manager that ignores all messages.
 
Constructor Summary
AnalysisErrorReporterManager(InternalErrorReporter ier, AnalysisErrorReporterFactory fact)
           
 
Method Summary
 void addPrefix(java.lang.String pre)
           
 void error(Element obj, java.lang.String msg)
          Report an error on an AObject (AADL object model object) using the error reporter associated with that object's Resource.
 void error(Element obj, java.lang.String msg, java.lang.String[] attrs, java.lang.Object[] values)
           
 int getNumErrors()
          Get the total number of errors reported across all the error reporters being managed.
 int getNumInfos()
          Get the total number of errors reported across all the error reporters being managed.
 int getNumMessages()
          Get the total number of errors and warnings across all the error reports being managed.
 int getNumWarnings()
          Get the total number of warnings reported across all the error reporters being managed.
 AnalysisErrorReporter getReporter(org.eclipse.emf.ecore.resource.Resource rsrc)
          Get the error reporter that is associated with the given Resource.
 void info(Element obj, java.lang.String msg)
          Report an information message on an AObject (AADL object model object) using the error reporter associated with that object's Resource.
 void info(Element obj, java.lang.String msg, java.lang.String[] attrs, java.lang.Object[] values)
           
 void removePrefix()
           
 void removeResource(org.eclipse.emf.ecore.resource.Resource rsrc)
          Stop managing the given Resource.
 void warning(Element obj, java.lang.String msg)
          Report a warning on an AObject (AADL object model object) using the error reporter associated with that object's Resource.
 void warning(Element obj, java.lang.String msg, java.lang.String[] attrs, java.lang.Object[] values)
           
 
Methods inherited from class edu.cmu.sei.aadl.modelsupport.errorreporting.AbstractErrorReporterManager
getNumInternalErrors, internalError, internalError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_ERROR_MANANGER

public static final AnalysisErrorReporterManager NULL_ERROR_MANANGER
Singleton reference to an error manager that ignores all messages.

Constructor Detail

AnalysisErrorReporterManager

public AnalysisErrorReporterManager(InternalErrorReporter ier,
                                    AnalysisErrorReporterFactory fact)
Method Detail

removeResource

public final void removeResource(org.eclipse.emf.ecore.resource.Resource rsrc)
Stop managing the given Resource.

Parameters:
rsrc - The resource to forget about.

getReporter

public final AnalysisErrorReporter getReporter(org.eclipse.emf.ecore.resource.Resource rsrc)
Get the error reporter that is associated with the given Resource. If the manager has not yet used the error reporter for the given resource, the ErrorReporter.deleteMessages() method is called on the reporter.

Throws:
java.lang.IllegalArgumentException - Thrown if a reporter cannot be found or created for the given Resource.
java.lang.NullPointerException - Thrown if rsrc is null.

getNumErrors

public final int getNumErrors()
Get the total number of errors reported across all the error reporters being managed.


getNumWarnings

public final int getNumWarnings()
Get the total number of warnings reported across all the error reporters being managed.


getNumInfos

public final int getNumInfos()
Get the total number of errors reported across all the error reporters being managed.


getNumMessages

public final int getNumMessages()
Get the total number of errors and warnings across all the error reports being managed.

See Also:
InternalErrorReporter.getNumInternalErrors()

addPrefix

public final void addPrefix(java.lang.String pre)

removePrefix

public final void removePrefix()

error

public void error(Element obj,
                  java.lang.String msg)
Report an error on an AObject (AADL object model object) using the error reporter associated with that object's Resource.

Parameters:
obj - the object to which the marker is pointing
msg - the message as string

error

public void error(Element obj,
                  java.lang.String msg,
                  java.lang.String[] attrs,
                  java.lang.Object[] values)

warning

public void warning(Element obj,
                    java.lang.String msg)
Report a warning on an AObject (AADL object model object) using the error reporter associated with that object's Resource.

Parameters:
obj - the object to which the marker is pointing
msg - the message as string

warning

public void warning(Element obj,
                    java.lang.String msg,
                    java.lang.String[] attrs,
                    java.lang.Object[] values)

info

public void info(Element obj,
                 java.lang.String msg)
Report an information message on an AObject (AADL object model object) using the error reporter associated with that object's Resource.

Parameters:
obj - the object to which the marker is pointing
msg - the message as string

info

public void info(Element obj,
                 java.lang.String msg,
                 java.lang.String[] attrs,
                 java.lang.Object[] values)