Class MZTabErrorList
- java.lang.Object
-
- uk.ac.ebi.pride.jmztab2.utils.errors.MZTabErrorList
-
public class MZTabErrorList extends java.lang.ObjectA limit max capacity list, if contains a couple ofMZTabErrorobjects. If overflow, system will raiseMZTabErrorOverflowException. Besides this, during add a newMZTabErrorobject, it'sMZTabErrorType.levelSHOULD equal or great than its level setting.- Since:
- 29/01/13
- Author:
- qingwei
-
-
Constructor Summary
Constructors Constructor Description MZTabErrorList()Generate a error list, which max size isMZTabProperties.MAX_ERROR_COUNT, and only allowMZTabErrorType.Level.Erroror greater level errors to be added into list.MZTabErrorList(MZTabErrorType.Level level)Generate a error list, which max size isMZTabProperties.MAX_ERROR_COUNTMZTabErrorList(MZTabErrorType.Level level, int maxErrorCount)Generate a error list, with given error level and maximum error count.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(MZTabError error)A limit max capacity list, if contains a couple ofMZTabErrorobjects.voidclear()Clear all errors stored in the error list.java.util.List<ValidationMessage>convertToValidationMessages()Converts this error list to a list of validation messages.static java.util.List<ValidationMessage>convertToValidationMessages(MZTabErrorList errorList)Converts the provided error list to a list of validation messages.MZTabErrorgetError(int index)Returns the element at the specified position in this list.java.util.List<MZTabError>getErrorList()Unmodifiable list of errorsMZTabErrorType.LevelgetLevel()Getter for the fieldlevel.intgetMaxErrorCount()Getter for the fieldmaxErrorCount.booleanisEmpty()Returnstrueif this list contains no elements.voidprint(java.io.OutputStream out)Print error list to output stream.voidsetLevel(MZTabErrorType.Level level)Define the level of the errors that are going to be store in the list.voidsetMaxErrorCount(int maxErrorCount)Define the maximum number of errors recorded by this list before anMZTabErrorOverflowExceptionis thrownintsize()Returns the number of elements in this list.java.lang.StringtoString()Print error list to string.
-
-
-
Constructor Detail
-
MZTabErrorList
public MZTabErrorList()
Generate a error list, which max size isMZTabProperties.MAX_ERROR_COUNT, and only allowMZTabErrorType.Level.Erroror greater level errors to be added into list.
-
MZTabErrorList
public MZTabErrorList(MZTabErrorType.Level level)
Generate a error list, which max size isMZTabProperties.MAX_ERROR_COUNT- Parameters:
level- if null, default level isMZTabErrorType.Level.Error
-
MZTabErrorList
public MZTabErrorList(MZTabErrorType.Level level, int maxErrorCount)
Generate a error list, with given error level and maximum error count.- Parameters:
level- if null, default level isMZTabErrorType.Level.ErrormaxErrorCount- the maximum number of errors recorded by this list before anMZTabErrorOverflowExceptionis thrown
-
-
Method Detail
-
getErrorList
public java.util.List<MZTabError> getErrorList()
Unmodifiable list of errors- Returns:
- error list
-
add
public boolean add(MZTabError error) throws MZTabErrorOverflowException
A limit max capacity list, if contains a couple ofMZTabErrorobjects. If overflow, system will raiseMZTabErrorOverflowException. Besides this, during add a newMZTabErrorobject, it'sMZTabErrorType.levelSHOULD equal or greater than its level setting.- Parameters:
error- SHOULD NOT set null- Returns:
- a boolean.
- Throws:
MZTabErrorOverflowException- if any.
-
getMaxErrorCount
public int getMaxErrorCount()
Getter for the field
maxErrorCount.- Returns:
- The maximum number of errors that are going to be reported before
the parser stops with an
MZTabErrorOverflowException
-
setMaxErrorCount
public void setMaxErrorCount(int maxErrorCount)
Define the maximum number of errors recorded by this list before anMZTabErrorOverflowExceptionis thrown- Parameters:
maxErrorCount- needs to be a positive number or zero will be set
-
getLevel
public MZTabErrorType.Level getLevel()
Getter for the field
level.- Returns:
- level of errors reported
MZTabErrorType.level
-
setLevel
public void setLevel(MZTabErrorType.Level level)
Define the level of the errors that are going to be store in the list. The incoming errors with an equal or highest level will be stored.- Parameters:
level-MZTabErrorType.level
-
clear
public void clear()
Clear all errors stored in the error list.
-
size
public int size()
Returns the number of elements in this list.- Returns:
- a int.
-
getError
public MZTabError getError(int index)
Returns the element at the specified position in this list.- Parameters:
index- index of the element to return- Returns:
- a
MZTabErrorobject.
-
isEmpty
public boolean isEmpty()
Returnstrueif this list contains no elements.- Returns:
- a boolean.
-
print
public void print(java.io.OutputStream out) throws java.io.IOExceptionPrint error list to output stream.- Parameters:
out- SHOULD NOT set null.- Throws:
java.io.IOException- if any.
-
toString
public java.lang.String toString()
Print error list to string.- Overrides:
toStringin classjava.lang.Object- Returns:
- a
Stringobject.
-
convertToValidationMessages
public static java.util.List<ValidationMessage> convertToValidationMessages(MZTabErrorList errorList) throws java.lang.IllegalStateException
Converts the provided error list to a list of validation messages.- Parameters:
errorList- the error list to convert.- Returns:
- a list of validation messages.
- Throws:
java.lang.IllegalStateException- for unhandled mappings ofValidationMessage.MessageTypeEnum.
-
convertToValidationMessages
public java.util.List<ValidationMessage> convertToValidationMessages() throws java.lang.IllegalStateException
Converts this error list to a list of validation messages.- Returns:
- a list of validation messages.
- Throws:
java.lang.IllegalStateException- for unhandled mappings ofValidationMessage.MessageTypeEnum.
-
-