1 | /******************************************************************************* | |
2 | * Copyhacked (H) 2012-2025. | |
3 | * This program and the accompanying materials | |
4 | * are made available under no term at all, use it like | |
5 | * you want, but share and discuss it | |
6 | * every time possible with every body. | |
7 | * | |
8 | * Contributors: | |
9 | * ron190 at ymail dot com - initial implementation | |
10 | *******************************************************************************/ | |
11 | package com.jsql.view.swing.manager.util; | |
12 | ||
13 | import com.jsql.util.LogLevelUtil; | |
14 | import com.jsql.util.bruter.ActionCoder; | |
15 | import com.jsql.view.swing.manager.ManagerCoder; | |
16 | import org.apache.commons.lang3.StringUtils; | |
17 | import org.apache.logging.log4j.LogManager; | |
18 | import org.apache.logging.log4j.Logger; | |
19 | ||
20 | import java.awt.event.ActionEvent; | |
21 | import java.awt.event.ActionListener; | |
22 | import java.io.IOException; | |
23 | import java.security.NoSuchAlgorithmException; | |
24 | ||
25 | /** | |
26 | * Action run when this.coderManager.encoding. | |
27 | */ | |
28 | public class CoderListener implements ActionListener { | |
29 | | |
30 | private static final Logger LOGGER = LogManager.getRootLogger(); | |
31 | | |
32 | private final ManagerCoder coderManager; | |
33 | | |
34 | public CoderListener(ManagerCoder coderManager) { | |
35 | this.coderManager = coderManager; | |
36 | } | |
37 | | |
38 | public void actionPerformed() { // type | |
39 |
1
1. actionPerformed : removed call to com/jsql/view/swing/manager/util/CoderListener::transform → NO_COVERAGE |
this.transform(this.coderManager.getMenuMethod().getText()); |
40 | } | |
41 | | |
42 | public void actionPerformed(String nameMethod) { // hover | |
43 |
1
1. actionPerformed : removed call to com/jsql/view/swing/manager/util/CoderListener::transform → NO_COVERAGE |
this.transform(nameMethod); |
44 | } | |
45 | | |
46 | @Override | |
47 | public void actionPerformed(ActionEvent actionEvent) { // click | |
48 |
1
1. actionPerformed : removed call to javax/swing/JLabel::setText → NO_COVERAGE |
this.coderManager.getMenuMethod().setText(actionEvent.getActionCommand()); |
49 |
1
1. actionPerformed : removed call to com/jsql/view/swing/manager/util/CoderListener::transform → NO_COVERAGE |
this.transform(this.coderManager.getMenuMethod().getText()); |
50 | } | |
51 | | |
52 | private void transform(String labelMethodMenu) { | |
53 | String nameMethod = labelMethodMenu.replace("Hash to ", StringUtils.EMPTY); | |
54 | String result; | |
55 | String textInput = this.coderManager.getTextInput().getText(); | |
56 | | |
57 | try { | |
58 | if ( | |
59 |
1
1. transform : negated conditional → NO_COVERAGE |
StringUtils.isEmpty(textInput) |
60 |
1
1. transform : negated conditional → NO_COVERAGE |
&& !ActionCoder.getHashesEmpty().contains(nameMethod) |
61 | ) { | |
62 | throw new IllegalArgumentException("text to convert not found"); | |
63 | } else { | |
64 | result = ActionCoder.forName(nameMethod).orElseThrow().run(textInput); | |
65 | } | |
66 | } catch ( | |
67 | IllegalArgumentException // also thrown by Base64 | |
68 | | IOException | |
69 | | NoSuchAlgorithmException e | |
70 | ) { | |
71 | result = "Coder failure: " + e.getMessage(); | |
72 | LOGGER.log(LogLevelUtil.IGNORE, e); | |
73 | } | |
74 | ||
75 |
1
1. transform : removed call to javax/swing/JTextArea::setText → NO_COVERAGE |
this.coderManager.getResult().setText(result); |
76 | } | |
77 | } | |
Mutations | ||
39 |
1.1 |
|
43 |
1.1 |
|
48 |
1.1 |
|
49 |
1.1 |
|
59 |
1.1 |
|
60 |
1.1 |
|
75 |
1.1 |