001    /*
002     * SonarQube, open source software quality management tool.
003     * Copyright (C) 2008-2013 SonarSource
004     * mailto:contact AT sonarsource DOT com
005     *
006     * SonarQube is free software; you can redistribute it and/or
007     * modify it under the terms of the GNU Lesser General Public
008     * License as published by the Free Software Foundation; either
009     * version 3 of the License, or (at your option) any later version.
010     *
011     * SonarQube is distributed in the hope that it will be useful,
012     * but WITHOUT ANY WARRANTY; without even the implied warranty of
013     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014     * Lesser General Public License for more details.
015     *
016     * You should have received a copy of the GNU Lesser General Public License
017     * along with this program; if not, write to the Free Software Foundation,
018     * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
019     */
020    package org.sonar.api.measures;
021    
022    import com.google.common.annotations.Beta;
023    
024    /**
025     * Provides access to measures for the lines of file.
026     * Examples:
027     * <ul>
028     * <li>line 1 is a line of code</li>
029     * <li>line 2 contains comment</li>
030     * <li>line 3 contains 2 branches</li>
031     * <li>author of line 4 is Simon</li>
032     * </ul>
033     * Numbering of lines starts from 1.
034     * Also note that you can't update what already was saved, however it is safe to call {@link #save()} several times.
035     * <p>
036     * Instances of this interface can be obtained using {@link FileLinesContextFactory}.
037     * <p/>
038     * This interface is not intended to be implemented by clients.
039     *
040     * @since 2.14
041     */
042    @Beta
043    public interface FileLinesContext {
044    
045      /**
046       * @throws UnsupportedOperationException on attempt to update already saved data
047       */
048      void setIntValue(String metricKey, int line, int value);
049    
050      /**
051       * @return value, or null if no such metric for given line
052       */
053      Integer getIntValue(String metricKey, int line);
054    
055      /**
056       * @throws UnsupportedOperationException on attempt to update already saved data
057       */
058      void setStringValue(String metricKey, int line, String value);
059    
060      /**
061       * @return value, or null if no such metric for given line
062       */
063      String getStringValue(String metricKey, int line);
064    
065      /**
066       * Saves unsaved values.
067       */
068      void save();
069    
070    }