src/org/objectweb/cjdbc/console/gui/threads/GuiParsingThread.java

説明を見る。
00001 00025 package org.objectweb.cjdbc.console.gui.threads; 00026 00027 import java.awt.event.KeyEvent; 00028 import java.awt.event.KeyListener; 00029 import java.util.ArrayList; 00030 00031 import javax.swing.JTextPane; 00032 import javax.swing.event.CaretEvent; 00033 import javax.swing.event.CaretListener; 00034 00035 import org.objectweb.cjdbc.common.xml.XmlValidator; 00036 00037 import com.wutka.dtd.DTD; 00038 import com.wutka.dtd.DTDParser; 00039 00046 public class GuiParsingThread extends Thread 00047 implements 00048 KeyListener, 00049 CaretListener 00050 { 00051 private JTextPane xmlTextPane; 00052 private JTextPane outputPane; 00053 private DTDParser dtdparser; 00054 private DTD dtd; 00055 00061 public GuiParsingThread(JTextPane xmlTextPane) 00062 { 00063 this.xmlTextPane = xmlTextPane; 00064 //xmlTextPane.addCaretListener(this); 00065 try 00066 { 00067 this.dtdparser = new DTDParser(this.getClass().getResource( 00068 "/c-jdbc-controller.dtd")); 00069 dtd = dtdparser.parse(); 00070 } 00071 catch (Exception e) 00072 { 00073 e.printStackTrace(); 00074 } 00075 } 00076 00082 public DTD getDtd() 00083 { 00084 return dtd; 00085 } 00086 00090 public void run() 00091 { 00092 while (true) 00093 { 00094 synchronized (this) 00095 { 00096 try 00097 { 00098 wait(); 00099 } 00100 catch (InterruptedException e) 00101 { 00102 } 00103 XmlValidator validator = new XmlValidator("c-jdbc-controller.dtd", 00104 xmlTextPane.getText()); 00105 StringBuffer buffer = new StringBuffer(); 00106 ArrayList exceptions = validator.getExceptions(); 00107 for (int i = 0; i < exceptions.size(); i++) 00108 buffer.append(((Exception) (exceptions.get(i))).getMessage() + "\n"); 00109 outputPane.setText(buffer.toString()); 00110 } 00111 } 00112 } 00113 00117 public void keyPressed(KeyEvent e) 00118 { 00119 synchronized (this) 00120 { 00121 this.notify(); 00122 } 00123 } 00124 00128 public void keyReleased(KeyEvent e) 00129 { 00130 } 00131 00135 public void keyTyped(KeyEvent e) 00136 { 00137 00138 } 00139 00145 public void setOutputPane(JTextPane rightPane) 00146 { 00147 this.outputPane = rightPane; 00148 } 00149 00153 public void caretUpdate(CaretEvent e) 00154 { 00155 // int pos = e.getDot(); 00156 // String string = xmlTextPane.getText(); 00157 // int low = string.indexOf("<", pos); 00158 // int sup = string.indexOf(">", pos); 00159 // int end = string.indexOf("/>", pos); 00160 // int close = string.indexOf("</", pos); 00161 // 00162 // System.out.println("low:" + low + ":sup:" + sup + ":end:" + end + 00163 // ":close:" 00164 // + close); 00165 // 00166 // String element = null; 00167 // if (low == -1 && end == -1 && close == -1) 00168 // { 00169 // //System.out.println("0"); 00170 // // end of the file last tag 00171 // if (sup == -1) 00172 // sup = string.length() - 2; 00173 // int ind = sup; 00174 // while (string.charAt(ind) != '/') 00175 // ind--; 00176 // element = string.substring(ind + 1, sup); 00177 // } 00178 // else if (lt(sup, low) && lt(sup, end) && lt(sup, close)) 00179 // { 00180 // //System.out.println("1"); 00181 // // we search for an opening tag, like <tag> 00182 // int ind = sup; 00183 // while (string.charAt(ind) != '<') 00184 // ind--; 00185 // element = string.substring(ind + 1, string.indexOf(' ', ind)); 00186 // } 00187 // else if (lt(end, sup) && lt(end, low) && lt(end, close)) 00188 // { 00189 // //System.out.println("2"); 00190 // //we search for a standalone closed tag <tag/> 00191 // int ind = end; 00192 // while (string.charAt(ind) != '<') 00193 // ind--; 00194 // element = string.substring(ind + 1, string.indexOf(' ', ind)); 00195 // } 00196 // else if (lt(low, sup) && lt(low, end) && lt(low, close)) 00197 // { 00198 // //System.out.println("3"); 00199 // //we search for the next starting tag <tag> 00200 // element = string.substring(low + 1, nextLow(string, low)); 00201 // } 00202 // else if (lt(close, sup) && lt(close, end) && close == low) 00203 // { 00204 // //System.out.println("4"); 00205 // //we search for the name of the closing tag <tag>...</tag> 00206 // int space = string.indexOf('>', close + 2); 00207 // element = string.substring(close + 2, space); 00208 // } 00209 // 00210 // DTDElement elm = (DTDElement) dtd.elements.get(element); 00211 // //System.out.println(element); 00212 // 00213 // Hashtable attributes = elm.attributes; 00214 // Enumeration enume = attributes.keys(); 00215 // while (enume.hasMoreElements()) 00216 // { 00217 // DTDAttribute att = (DTDAttribute) attributes.get(enume.nextElement()); 00218 // ////System.out.println(att.name+":"+att.defaultValue); 00219 // } 00220 00221 } 00222 00223 // private int nextLow(String string, int low) 00224 // { 00225 // int space = string.indexOf(' ', low); 00226 // int ll = string.indexOf('>', low); 00227 // int lc = string.indexOf('/', low); 00228 // int ref = 0; 00229 // if (lt(space, ll) && lt(space, lc)) 00230 // ref = space; 00231 // else if (lt(ll, space) && lt(ll, lc)) 00232 // ref = ll; 00233 // else if (lt(lc, space) && lt(lc, ll)) 00234 // ref = lc; 00235 // return ref; 00236 // } 00237 // 00238 // private boolean lt(int l1, int l2) 00239 // { 00240 // if (l1 < 0) 00241 // return false; 00242 // else if (l2 < 0 || l1 < l2) 00243 // return true; 00244 // else 00245 // return false; 00246 // } 00247 }

CJDBCversion1.0.4に対してTue Oct 12 15:15:59 2004に生成されました。 doxygen 1.3.8