CONOPT
Loading...
Searching...
No Matches
MsgHandler.java
Go to the documentation of this file.
1import java.io.IOException;
2import java.io.FileWriter;
3import conopt.*;
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
36 public int message(int smsg, int dmsg, int nmsg, String[] msgv) {
37 try {
38 for (int i = 0; i < smsg; i++)
39 {
40 System.out.println(msgv[i]);
41 fs.write(msgv[i] + System.lineSeparator());
42 }
43
44 for (int i = 0; i < dmsg; i++)
45 {
46 fd.write(msgv[i] + System.lineSeparator());
47 }
48 }
49 catch (Exception e) {
50 e.getStackTrace();
51 }
52
53 return 0;
54 }
55
63 public int errorMessage(int rowno, int colno, int posno, String msg) {
64 String errormsg = "";
65 if (rowno == -1)
66 errormsg += "Variable " + colno + " : ";
67 else if (colno == -1)
68 errormsg += "Equation " + rowno + " : ";
69 else
70 errormsg += "Variable " + colno + " appearing in Equation " + rowno + " : ";
71
72 try {
73 fs.write(errormsg + System.lineSeparator());
74 fd.write(errormsg + System.lineSeparator());
75 }
76 catch (Exception e) {
77 e.getStackTrace();
78 }
79
80 return 0;
81 }
82}
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)