001/* 
002 * Copyright 2018 Leibniz-Institut für Analytische Wissenschaften – ISAS – e.V..
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package uk.ac.ebi.pride.jmztab2.utils.parser;
017
018import de.isas.mztab2.model.Comment;
019import uk.ac.ebi.pride.jmztab2.utils.errors.MZTabErrorList;
020import uk.ac.ebi.pride.jmztab2.utils.errors.MZTabException;
021
022/**
023 * Comment line parser.
024 * Comment lines can be placed anywhere in an mzTab file. These lines must start with the three-letter
025 * code COM and are ignored by most parsers. Empty lines can also occur anywhere in an mzTab file and are ignored.
026 *
027 * @see MZTabLineParser
028 * @author qingwei
029 * @since 10/02/13
030 * 
031 */
032public class COMLineParser extends MZTabLineParser {
033
034    /**
035     * <p>Constructor for COMLineParser.</p>
036     *
037     * @param context a {@link uk.ac.ebi.pride.jmztab2.utils.parser.MZTabParserContext} object.
038     */
039    public COMLineParser(MZTabParserContext context) {
040        super(context);
041    }
042
043    /** {@inheritDoc} */
044    @Override
045    public void parse(int lineNumber, String line, MZTabErrorList errorList) throws MZTabException {
046        super.parse(lineNumber, line, errorList);
047    }
048
049    /**
050     * <p>getComment.</p>
051     *
052     * @return a {@link de.isas.mztab2.model.Comment} object.
053     */
054    public Comment getComment() {
055        String msg = items.length == 1 ? "" : items[1];
056        return new Comment().msg(msg).lineNumber(lineNumber);
057    }
058}