
com.liferay.source.formatter.check.configuration.SuppressionsLoader Maven / Gradle / Ivy
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
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);
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 - 2025 Weber Informatics LLC | Privacy Policy