All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.plugins.web.visitor.WebSourceCode Maven / Gradle / Ivy

Go to download

Analyze HTML (also within PHP/Ruby/etc. templates) and JSP/JSF code.

The newest version!
/*
 * SonarQube Web Plugin
 * Copyright (C) 2010 SonarSource and Matthijs Galesloot
 * [email protected]
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.sonar.plugins.web.visitor;

import org.sonar.api.measures.Measure;
import org.sonar.api.measures.Metric;
import org.sonar.api.resources.Resource;
import org.sonar.api.rules.Violation;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

public class WebSourceCode {

  private final File file;
  private final Resource resource;
  private final List measures = new ArrayList();
  private final List violations = new ArrayList();
  private Set detailedLinesOfCode;
  private Set detailedLinesOfComments;

  public WebSourceCode(File file, Resource resource) {
    this.file = file;
    this.resource = resource;
  }

  public File getFile() {
    return file;
  }

  public void addMeasure(Metric metric, double value) {
    Measure measure = new Measure(metric, value);
    this.measures.add(measure);
  }

  public void addViolation(Violation violation) {
    this.violations.add(violation);
  }

  public Measure getMeasure(Metric metric) {
    for (Measure measure : measures) {
      if (measure.getMetric().equals(metric)) {
        return measure;
      }
    }
    return null;
  }

  public List getMeasures() {
    return measures;
  }

  public Resource getResource() {
    return resource;
  }

  public List getViolations() {
    return violations;
  }

  @Override
  public String toString() {
    return resource.getLongName();
  }

  public Set getDetailedLinesOfCode() {
    return detailedLinesOfCode;
  }

  public void setDetailedLinesOfCode(Set detailedLinesOfCode) {
    this.detailedLinesOfCode = detailedLinesOfCode;
  }

  public Set getDetailedLinesOfComments() {
    return detailedLinesOfComments;
  }

  public void setDetailedLinesOfComments(Set detailedLinesOfComments) {
    this.detailedLinesOfComments = detailedLinesOfComments;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy