001    /*
002     * SonarQube, open source software quality management tool.
003     * Copyright (C) 2008-2014 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.web;
021    
022    import com.google.common.base.Objects;
023    import org.sonar.api.ServerExtension;
024    import org.sonar.colorizer.Tokenizer;
025    
026    import java.util.List;
027    
028    /**
029     * Extend the library sonar-colorizer to support new languages. By default only Java sources are colorized in Sonar.
030     * 
031     * @since 1.12
032     * @deprecated since 4.5.2 use {@link org.sonar.api.source.Highlightable}
033     */
034    @Deprecated
035    public abstract class CodeColorizerFormat implements ServerExtension {
036    
037      private String languageKey;
038    
039      /**
040       * @param languageKey the unique sonar key. Not null.
041       */
042      protected CodeColorizerFormat(String languageKey) {
043        this.languageKey = languageKey;
044      }
045    
046      public final String getLanguageKey() {
047        return languageKey;
048      }
049    
050      /**
051       * sonar-colorizer tokenizers for HTML output.
052       * 
053       * @return a not null list (empty if no tokenizers)
054       */
055      public abstract List<Tokenizer> getTokenizers();
056    
057      @Override
058      public boolean equals(Object o) {
059        if (this == o) {
060          return true;
061        }
062        if (!(o instanceof CodeColorizerFormat)) {
063          return false;
064        }
065    
066        CodeColorizerFormat format = (CodeColorizerFormat) o;
067        return languageKey.equals(format.languageKey);
068    
069      }
070    
071      @Override
072      public int hashCode() {
073        return languageKey.hashCode();
074      }
075    
076      @Override
077      public String toString() {
078        return Objects.toStringHelper(this)
079          .add("lang", languageKey)
080          .toString();
081      }
082    }