From edf4e3b516fd975df00e86994dcaf3c3127e28a2 Mon Sep 17 00:00:00 2001 From: j-dimension Date: Thu, 15 Aug 2024 11:12:19 +0200 Subject: [PATCH] sonarqube fixes. issue #2395 --- .../client/assistant/AssistantResultDialog.java | 2 +- .../client/assistant/GenericAssistantDialog.java | 12 ++++++------ .../editors/documents/viewer/SoundplayerPanel.java | 2 +- .../client/editors/files/ArchiveFilePanel.java | 2 +- .../jlawyer/client/mail/MailContentUI.java | 4 ++-- .../jlawyer/client/mail/SendEmailDialog.java | 5 ++--- .../src/com/jdimension/jlawyer/ai/InputData.java | 2 ++ .../src/com/jdimension/jlawyer/ai/OutputData.java | 3 +++ 8 files changed, 18 insertions(+), 14 deletions(-) diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/assistant/AssistantResultDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/assistant/AssistantResultDialog.java index 25affe887..b280038ff 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/assistant/AssistantResultDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/assistant/AssistantResultDialog.java @@ -684,7 +684,7 @@ public AssistantResultDialog(java.awt.Frame parent, boolean modal, AiRequestStat if(status.getResponse().getOutputData()!=null && !status.getResponse().getOutputData().isEmpty()) { for(OutputData d: status.getResponse().getOutputData()) { - if(d.getType().equalsIgnoreCase("string")) { + if(d.getType().equalsIgnoreCase(OutputData.TYPE_STRING)) { this.taString.append(d.getStringData()); } } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/assistant/GenericAssistantDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/assistant/GenericAssistantDialog.java index 49c05271e..9627274b2 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/assistant/GenericAssistantDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/assistant/GenericAssistantDialog.java @@ -768,7 +768,7 @@ public GenericAssistantDialog(AssistantConfig config, AiCapability c, AssistantI this.taInputString.setText(""); for (InputData i : inputAdapter.getInputs(c)) { - if ("string".equalsIgnoreCase(i.getType())) { + if (InputData.TYPE_STRING.equalsIgnoreCase(i.getType())) { this.taInputString.append(i.getStringData()); this.taInputString.append(System.lineSeparator()); } else { @@ -1107,7 +1107,7 @@ private void startBackgroundTask() { protected Void doInBackground() throws Exception { List inputs=inputAdapter.getInputs(capability); for (InputData i : inputs) { - if ("string".equalsIgnoreCase(i.getType())) { + if (InputData.TYPE_STRING.equalsIgnoreCase(i.getType())) { i.setStringData(taInputString.getText()); } } @@ -1134,14 +1134,14 @@ protected void done() { if (status.getStatus().equalsIgnoreCase("error")) { taResult.setText(status.getStatus() + ": " + status.getStatusDetails()); } else { - StringBuilder result = new StringBuilder(); + StringBuilder resultString = new StringBuilder(); for (OutputData o : status.getResponse().getOutputData()) { - if (o.getType().equalsIgnoreCase("string")) { - result.append(o.getStringData()).append(System.lineSeparator()).append(System.lineSeparator()); + if (o.getType().equalsIgnoreCase(OutputData.TYPE_STRING)) { + resultString.append(o.getStringData()).append(System.lineSeparator()).append(System.lineSeparator()); } } - taResult.setText(result.toString()); + taResult.setText(resultString.toString()); } } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/viewer/SoundplayerPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/viewer/SoundplayerPanel.java index 500dd53a6..f5d012131 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/viewer/SoundplayerPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/documents/viewer/SoundplayerPanel.java @@ -962,7 +962,7 @@ public void processOutput(AiCapability c, AiRequestStatus status) { status.getResponse(); StringBuilder result=new StringBuilder(); for(OutputData o: status.getResponse().getOutputData()) { - if(o.getType().equalsIgnoreCase("string")) + if(o.getType().equalsIgnoreCase(OutputData.TYPE_STRING)) result.append(o.getStringData()).append(System.lineSeparator()).append(System.lineSeparator()); } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java index c5037744e..944394bc8 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java @@ -7363,7 +7363,7 @@ public List getInputs(AiCapability c) { InputData i = new InputData(); //i.setFileName("sound.wav"); - i.setType("string"); + i.setType(InputData.TYPE_STRING); i.setBase64(false); //i.setData(selectedText); i.setStringData(docText); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java index da2a88f69..d664cf09e 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java @@ -2156,7 +2156,7 @@ public List getInputs(AiCapability c) { ArrayList inputs = new ArrayList<>(); InputData i = new InputData(); //i.setFileName("sound.wav"); - i.setType("string"); + i.setType(InputData.TYPE_STRING); i.setBase64(false); //i.setData(selectedText); i.setStringData(selectedText); @@ -2176,7 +2176,7 @@ public void processOutput(AiCapability c, AiRequestStatus status) { } else { StringBuilder result = new StringBuilder(); for (OutputData o : status.getResponse().getOutputData()) { - if (o.getType().equalsIgnoreCase("string")) { + if (o.getType().equalsIgnoreCase(InputData.TYPE_STRING)) { result.append(o.getStringData()).append(System.lineSeparator()).append(System.lineSeparator()); } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEmailDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEmailDialog.java index 713dd6031..2970115e7 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEmailDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEmailDialog.java @@ -1204,8 +1204,7 @@ public List getInputs(AiCapability c) { ArrayList inputs = new ArrayList<>(); InputData i = new InputData(); - //i.setFileName("sound.wav"); - i.setType("string"); + i.setType(InputData.TYPE_STRING); i.setBase64(false); i.setStringData(contentText); @@ -1226,7 +1225,7 @@ public void processOutput(AiCapability c, AiRequestStatus status) { } else { StringBuilder result = new StringBuilder(); for (OutputData o : status.getResponse().getOutputData()) { - if (o.getType().equalsIgnoreCase("string")) { + if (o.getType().equalsIgnoreCase(OutputData.TYPE_STRING)) { result.append(o.getStringData()).append(System.lineSeparator()).append(System.lineSeparator()); } diff --git a/j-lawyer-fax/src/com/jdimension/jlawyer/ai/InputData.java b/j-lawyer-fax/src/com/jdimension/jlawyer/ai/InputData.java index 7a6bba713..ebfbfedc0 100644 --- a/j-lawyer-fax/src/com/jdimension/jlawyer/ai/InputData.java +++ b/j-lawyer-fax/src/com/jdimension/jlawyer/ai/InputData.java @@ -8,6 +8,8 @@ public class InputData implements Serializable { + public static final String TYPE_STRING="string"; + private String type; private String stringData; private byte[] data; diff --git a/j-lawyer-fax/src/com/jdimension/jlawyer/ai/OutputData.java b/j-lawyer-fax/src/com/jdimension/jlawyer/ai/OutputData.java index 8153194e4..81a0dd796 100644 --- a/j-lawyer-fax/src/com/jdimension/jlawyer/ai/OutputData.java +++ b/j-lawyer-fax/src/com/jdimension/jlawyer/ai/OutputData.java @@ -11,6 +11,9 @@ * @author jens */ public class OutputData implements Serializable { + + public static final String TYPE_STRING="string"; + private String type; private String stringData; private byte[] data;