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