Skip to content

Commit

Permalink
Make ProblemSummaryNode record
Browse files Browse the repository at this point in the history
  • Loading branch information
akurtakov committed Apr 2, 2024
1 parent fb3d945 commit bd8c70a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 30 deletions.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2022 IBM Corporation and others. All rights reserved.
* Copyright (c) 2000, 2024 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
Expand Down Expand Up @@ -279,12 +279,12 @@ private LogDocumentNode process(final Document document) {
if (nodeList.getLength() == 1) {
final Node problemSummaryNode = nodeList.item(0);
final NamedNodeMap problemSummaryMap = problemSummaryNode.getAttributes();
final ProblemSummaryNode summaryNode = new ProblemSummaryNode();
final ProblemSummaryNode summaryNode = new ProblemSummaryNode(
Integer.parseInt(problemSummaryMap.getNamedItem("problems").getNodeValue()),
Integer.parseInt(problemSummaryMap.getNamedItem("errors").getNodeValue()),
Integer.parseInt(problemSummaryMap.getNamedItem("warnings").getNodeValue()),
Integer.parseInt(problemSummaryMap.getNamedItem("infos").getNodeValue()));
documentNode.setProblemSummary(summaryNode);
summaryNode.numberOfProblems = Integer.parseInt(problemSummaryMap.getNamedItem("problems").getNodeValue()); //$NON-NLS-1$
summaryNode.numberOfErrors = Integer.parseInt(problemSummaryMap.getNamedItem("errors").getNodeValue()); //$NON-NLS-1$
summaryNode.numberOfWarnings = Integer.parseInt(problemSummaryMap.getNamedItem("warnings").getNodeValue()); //$NON-NLS-1$
summaryNode.numberOfInfos = Integer.parseInt(problemSummaryMap.getNamedItem("infos").getNodeValue()); //$NON-NLS-1$
}

nodeList = document.getElementsByTagName("problems"); //$NON-NLS-1$
Expand Down
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2020 IBM Corporation and others.
* Copyright (c) 2006, 2024 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -69,7 +69,7 @@ public void dump(final int formatVersion, final Map<String, String> options, fin
private void dumpVersion2(final Map<String, String> options, final LogDocumentNode documentNode) {
final String fileName = options.get(Converter.OUTPUT_FILE_NAME);
final ProblemSummaryNode summaryNode = documentNode.getSummaryNode();
if ((summaryNode == null) || (summaryNode.numberOfProblems == 0)) {
if ((summaryNode == null) || (summaryNode.numberOfProblems() == 0)) {
return;
}
try (final Writer writer = new BufferedWriter(new FileWriter(fileName))){
Expand All @@ -83,10 +83,10 @@ private void dumpVersion2(final Map<String, String> options, final LogDocumentNo
final ProblemSummaryNode problemSummaryNode = summaryNode;
writeTopAnchor(writer);
String pattern = messages.getString("problem.summary"); //$NON-NLS-1$
writer.write(MessageFormat.format(pattern, Integer.toString(problemSummaryNode.numberOfProblems),
Integer.toString(problemSummaryNode.numberOfErrors),
Integer.toString(problemSummaryNode.numberOfWarnings),
Integer.toString(problemSummaryNode.numberOfInfos)));
writer.write(MessageFormat.format(pattern, Integer.toString(problemSummaryNode.numberOfProblems()),
Integer.toString(problemSummaryNode.numberOfErrors()),
Integer.toString(problemSummaryNode.numberOfWarnings()),
Integer.toString(problemSummaryNode.numberOfInfos())));

writeAnchorsReferences(writer);
final ProblemsNode[] problemsNodes = documentNode.getProblems();
Expand Down
@@ -1,29 +1,24 @@
/*******************************************************************************
* Copyright (c) 2006, 2017 IBM Corporation and others. All rights reserved.
* Copyright (c) 2006, 2024 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
*
* Contributors: IBM Corporation - initial API and implementation
*******************************************************************************/

package org.eclipse.releng.build.tools.convert.dom;

public class ProblemSummaryNode {
public record ProblemSummaryNode(int numberOfProblems, int numberOfErrors, int numberOfWarnings, int numberOfInfos) {

public int numberOfProblems;
public int numberOfErrors;
public int numberOfWarnings;
public int numberOfInfos;

@Override
public String toString() {
final StringBuilder buffer = new StringBuilder();
buffer.append("problems : ") //$NON-NLS-1$
.append(numberOfProblems).append(" errors : ") //$NON-NLS-1$
.append(numberOfErrors).append(" warnings : ") //$NON-NLS-1$
.append(numberOfWarnings).append(" infos : ") //$NON_NLS-1$
.append(numberOfInfos);
return buffer.toString();
}
@Override
public String toString() {
final StringBuilder buffer = new StringBuilder();
buffer.append("problems : ") //$NON-NLS-1$
.append(numberOfProblems).append(" errors : ") //$NON-NLS-1$
.append(numberOfErrors).append(" warnings : ") //$NON-NLS-1$
.append(numberOfWarnings).append(" infos : ") // $NON_NLS-1$
.append(numberOfInfos);
return buffer.toString();
}
}

0 comments on commit bd8c70a

Please sign in to comment.