Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DataCls dc = new DataCls();
- dc.ExeComm("DROP TABLE IF EXISTS tblError;"
- + "CREATE TABLE tblError("
- + "FILE VARCHAR(255), "
- + "WORD VARCHAR(255), "
- + "LINE INT(10)"
- + ")");
- String[] col = new String[]{"File","Word","Line"};
- p.dtm.addColumn(col[0]);
- p.dtm.addColumn(col[1]);
- p.dtm.addColumn(col[2]);
- for(int i = 0; i < lstFile.getSize(); i++) {
- SpellChecker splChkr = new SpellChecker(dict);
- spellCheck splChk = p.new spellCheck();
- splChk.file = lstFile.getElementAt(i).toString();
- splChk.counter = 0;
- splChkr.addSpellCheckListener(splChk);
- String toCheck = p.readXHTML(new File(lstFile.getElementAt(i).toString()));
- splChkr.checkSpelling(new StringWordTokenizer(toCheck));
- }
- ResultSet rs = dc.ExeQuery("SELECT * FROM tblError");
- try {
- while (rs.next()) {
- String cont[] = new String[rs.getMetaData().getColumnCount()];
- for (int i = 0; i < rs.getMetaData().getColumnCount(); i++) {
- cont[i] = rs.getString(rs.getMetaData().getColumnName(i + 1).toString());
- }
- p.dtm.addRow(cont);
- }
- rs.close();
- tblView.setModel(p.dtm);
- }
- catch (SQLException e) {
- JOptionPane.showMessageDialog(rootPane, e);
- }
- JOptionPane.showMessageDialog(rootPane, "Spell checking completed.");
- this.setCursor(Cursor.DEFAULT_CURSOR);
- }
- catch(FileNotFoundException e) {
- JOptionPane.showMessageDialog(rootPane, "File loading error. rnrn" + e, "Error Occured.", JOptionPane.WARNING_MESSAGE);
- }
- catch(IOException f) {
- JOptionPane.showMessageDialog(rootPane, "File loading error. rnrn" + f, "Error Occured.", JOptionPane.WARNING_MESSAGE);
- }
- }
- public class spellCheck implements SpellCheckListener {
- String file = "";
- String lst = "";
- String[] rValue = {"","",""};
- int counter;
- String find = "";
- DataCls dat = new DataCls();
- @Override
- public void spellingError(SpellCheckEvent svt) {
- lst ="";
- lstError.addElement(svt.getInvalidWord().replace("'", "\'"));
- try {
- ResultSet rChk = dat.ExeQuery("SELECT MAX(LINE) FROM tblError WHERE FILE='" + new File(file).getName() + "'AND WORD='" + svt.getInvalidWord().replace("'", "''") + "'");
- int rwCnt = 0;
- while(rChk.next()) {rwCnt++;}
- if (rwCnt == 0) {
- try {
- BufferedReader br = new BufferedReader(new FileReader(file));
- int i = 0;
- String line;
- while((line = br.readLine()) != null) {
- i++;
- int index = line.indexOf(svt.getInvalidWord().replace("'", "\'"));
- if (index >= 0) {
- dat.ExeComm("INSERT INTO tblError(FILE,WORD,LINE) "
- + "VALUES ('" + new File(file).getName() +"','" + svt.getInvalidWord().replace("'", "\'") + "','" + i + "')");
- break;
- }
- }
- } catch (IOException e){
- System.out.println(e);
- }
- } else if (rwCnt > 0){
- ResultSet rs = dat.ExeQuery("SELECT MAX(LINE) FROM tblError WHERE FILE='" + new File(file).getName() + "' AND WORD='" + svt.getInvalidWord().replace("'", "''") + "'");
- rs.next();
- try {
- int iline = rs.getInt(1);
- try {
- BufferedReader br = new BufferedReader(new FileReader(file));
- int i = 0;
- String line;
- while((line = br.readLine()) != null){
- i++;
- int index = line.indexOf(svt.getInvalidWord().replace("'", "\'"));
- if (i > iline) {
- if (index >= 0) {
- dat.ExeComm("INSERT INTO tblError(FILE,WORD,LINE) "
- + "VALUES ('" + new File(file).getName() +"','" + svt.getInvalidWord().replace("'", "\'") + "','" + i + "')");
- break;
- }
- }
- }
- }
- catch (IOException e) {
- JOptionPane.showMessageDialog(null, e);
- }
- } catch (SQLException ex) {
- JOptionPane.showMessageDialog(null, ex);
- }
- }
- } catch (SQLException ex) {
- JOptionPane.showConfirmDialog(null, ex);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement