org.spdx.tools.compare.FileAttributionSheet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tools-java Show documentation
Show all versions of tools-java Show documentation
SPDX Command Line Tools using the Spdx-Java-Library
/**
* Copyright (c) 2013 Source Auditor Inc.
*
* 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.spdx.tools.compare;
import java.util.Collection;
import java.util.Iterator;
import org.apache.poi.ss.usermodel.Workbook;
import org.spdx.library.InvalidSPDXAnalysisException;
import org.spdx.library.model.SpdxFile;
import org.spdx.utility.compare.SpdxCompareException;
import org.spdx.utility.compare.SpdxComparer;
/**
* Sheet with results for file contributor comparison results
* @author Gary O'Neall
*
*/
public class FileAttributionSheet extends AbstractFileCompareSheet {
private static final int FILE_ATTRIBUTION_COL_WIDTH = 50;
public FileAttributionSheet(Workbook workbook, String sheetName) {
super(workbook, sheetName);
}
static void create(Workbook wb, String sheetName) {
AbstractFileCompareSheet.create(wb, sheetName, FILE_ATTRIBUTION_COL_WIDTH);
}
/* (non-Javadoc)
* @see org.spdx.compare.AbstractFileCompareSheet#valuesMatch(org.spdx.compare.SpdxComparer, org.spdx.rdfparser.SpdxFile, int, org.spdx.rdfparser.SpdxFile, int)
*/
@Override
boolean valuesMatch(SpdxComparer comparer, SpdxFile fileA, int docIndexA,
SpdxFile fileB, int docIndexB) throws SpdxCompareException, InvalidSPDXAnalysisException {
return SpdxComparer.stringCollectionsEqual(fileA.getAttributionText(), fileB.getAttributionText());
}
/* (non-Javadoc)
* @see org.spdx.compare.AbstractFileCompareSheet#getFileValue(org.spdx.rdfparser.SpdxFile)
*/
@Override
String getFileValue(SpdxFile spdxFile) throws InvalidSPDXAnalysisException {
StringBuilder sb = new StringBuilder();
Collection attribution = spdxFile.getAttributionText();
if (attribution != null && attribution.size() > 0) {
Iterator iter = attribution.iterator();
sb.append(iter.next());
while (iter.hasNext()) {
sb.append(", ");
sb.append(iter.next());
}
}
return sb.toString();
}
}