CONOPT
Loading...
Searching...
No Matches
MsgHandler.java
Go to the documentation of this file.
1import java.io.IOException;
2import java.io.FileWriter;
3import jconopt.*;
4
5public class MsgHandler extends MessageHandler {
6 FileWriter fs;
7 FileWriter fd;
8
9 public MsgHandler(String name) {
10 try {
11 fs = new FileWriter(name + ".sta");
12 fd = new FileWriter(name + ".lst");
13 }
14 catch (Exception e) {
15 e.getStackTrace();
16 }
17 }
18
19 public void close() {
20 try {
21 fs.close();
22 fd.close();
23 }
24 catch (Exception e) {
25 e.getStackTrace();
26 }
27 }
28
29 public int message(int smsg, int dmsg, int nmsg, String[] msgv) {
30 try {
31 for (int i = 0; i < smsg; i++)
32 {
33 System.out.println(msgv[i]);
34 fs.write(msgv[i] + System.lineSeparator());
35 }
36
37 for (int i = 0; i < dmsg; i++)
38 {
39 fd.write(msgv[i] + System.lineSeparator());
40 }
41 }
42 catch (Exception e) {
43 e.getStackTrace();
44 }
45
46 return 0;
47 }
48
49 public int errorMessage(int rowno, int colno, int posno, String msg) {
50 String errormsg = "";
51 if (rowno == -1)
52 errormsg += "Variable " + colno + " : ";
53 else if (colno == -1)
54 errormsg += "Equation " + rowno + " : ";
55 else
56 errormsg += "Variable " + colno + " appearing in Equation " + rowno + " : ";
57
58 try {
59 fs.write(errormsg + System.lineSeparator());
60 fd.write(errormsg + System.lineSeparator());
61 }
62 catch (Exception e) {
63 e.getStackTrace();
64 }
65
66 return 0;
67 }
68}
int message(int smsg, int dmsg, int nmsg, String[] msgv)
int errorMessage(int rowno, int colno, int posno, String msg)
void close()
MsgHandler(String name)
MessageHandler(long cPtr, boolean cMemoryOwn)