com.liferay.source.formatter.check.configuration.SuppressionsLoader Maven / Gradle / Ivy
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
package com.liferay.source.formatter.check.configuration;
import com.liferay.petra.string.CharPool;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.source.formatter.check.util.SourceUtil;
import com.liferay.source.formatter.util.CheckType;
import com.liferay.source.formatter.util.FileUtil;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
/**
* @author Hugo Huijser
*/
public class SuppressionsLoader {
public static SourceFormatterSuppressions loadSuppressions(
String baseDirName, List files,
Map propertiesMap)
throws DocumentException, IOException {
SourceFormatterSuppressions sourceFormatterSuppressions =
new SourceFormatterSuppressions();
for (File file : files) {
String content = FileUtil.read(file);
Document document = SourceUtil.readXML(content);
if (document == null) {
throw new DocumentException();
}
Element rootElement = document.getRootElement();
String absolutePath = SourceUtil.getAbsolutePath(file);
sourceFormatterSuppressions = _loadCheckstyleSuppressions(
sourceFormatterSuppressions,
rootElement.element(_CHECKSTYLE_ATTRIBUTE_NAME), absolutePath);
sourceFormatterSuppressions = _loadSourceChecksSuppressions(
sourceFormatterSuppressions,
rootElement.element(_SOURCE_CHECK_ATTRIBUTE_NAME),
absolutePath);
}
for (Map.Entry mapEntry :
propertiesMap.entrySet()) {
Properties properties = mapEntry.getValue();
for (Map.Entry
© 2015 - 2024 Weber Informatics LLC | Privacy Policy