org.inxar.syntacs.translator
Interface Auditor

All Known Implementing Classes:
StandardAuditor

public interface Auditor

Auditor is a "global" repository for errors and warnings; a listener for complaints. If a translation component discovers an error or wishes to report a warning, it may do so through one of the notify() methods in this interface. The use of the word "audit" here specifically refers to one that hears or listens; it's not related to taxation :)


Method Summary
 int complaints()
          Returns the current number of complaints (errors() + warnings()).
 int errors()
          Returns the current number of errors.
 List getErrors()
          Returns an unmodifiable list of errors, where each member in the List is an Complaint.
 Properties getProperties()
          Gets the Properties instance.
 String getSource()
          Gets the name of the input source.
 List getWarnings()
          Returns an unmodifiable list of warnings, where each member in the List is an Complaint.
 boolean hasErrors()
          Returns true if there is at least one error, false otherwise.
 boolean hasWarnings()
          Returns true if there is at least one warning, false otherwise.
 boolean isEmpty()
          Returns true if there are no errors or warnings, false if there is at least one error or at least one warning.
 Complaint notify(Complaint complaint)
          Adds the given Complaint to the end of the the internal List of complaints and returns the same object to the caller.
 Complaint notify(int type, int line, String msg)
          Creates a new Complaint of the given type having the given message and given line number.
 Complaint notify(int type, String msg)
          Creates a new Complaint of the given type having the given message.
 Complaint notify(int type, String msg, Input in, int offset, int length)
          Creates a new Complaint of the given type having the given message at the given Input offset with the given length.
 void setProperties(Properties p)
          Sets the Properties instance.
 void setSource(String src)
          Sets the name of the input source.
 int warnings()
          Returns the current number of warnings.
 

Method Detail

getSource

public String getSource()
Gets the name of the input source.

setSource

public void setSource(String src)
Sets the name of the input source. This is useful in order to make more meaningful error messages.

getProperties

public Properties getProperties()
Gets the Properties instance.

setProperties

public void setProperties(Properties p)
Sets the Properties instance.

isEmpty

public boolean isEmpty()
Returns true if there are no errors or warnings, false if there is at least one error or at least one warning.

complaints

public int complaints()
Returns the current number of complaints (errors() + warnings()).

errors

public int errors()
Returns the current number of errors.

warnings

public int warnings()
Returns the current number of warnings.

hasErrors

public boolean hasErrors()
Returns true if there is at least one error, false otherwise.

hasWarnings

public boolean hasWarnings()
Returns true if there is at least one warning, false otherwise.

getErrors

public List getErrors()
Returns an unmodifiable list of errors, where each member in the List is an Complaint.

getWarnings

public List getWarnings()
Returns an unmodifiable list of warnings, where each member in the List is an Complaint.

notify

public Complaint notify(Complaint complaint)
Adds the given Complaint to the end of the the internal List of complaints and returns the same object to the caller.

notify

public Complaint notify(int type,
                        int line,
                        String msg)
Creates a new Complaint of the given type having the given message and given line number. The Complaint is appended to the internal List of complaints and also returned to the caller.

notify

public Complaint notify(int type,
                        String msg)
Creates a new Complaint of the given type having the given message. The Complaint is appended to the internal List of complaints and also returned to the caller.

notify

public Complaint notify(int type,
                        String msg,
                        Input in,
                        int offset,
                        int length)
Creates a new Complaint of the given type having the given message at the given Input offset with the given length. The Complaint is appended to the internal List of complaints and also returned to the caller. This method is generally used for syntactic errors.