void newFileMenuItem_actionPerformed( final ActionEvent e ) { final String classname = JOptionPane .showInputDialog("Please enter the fully qualified name of a class or interface to verify:"); if ((classname == null) || (classname.isEmpty())) { return; } VerifierFactory.getVerifier(classname); // let observers do the rest. classNamesJList.setSelectedValue(classname, true); }
/** * This method implements a demonstration program * of how to use the VerifierFactoryObserver. It transitively verifies * all class files encountered; this may take up a lot of time and, * more notably, memory. */ public static void main(String[] args){ if (args.length != 1){ System.out.println("Need exactly one argument: The root class to verify."); System.exit(1); } int dotclasspos = args[0].lastIndexOf(".class"); if (dotclasspos != -1) args[0] = args[0].substring(0,dotclasspos); args[0] = args[0].replace('/', '.'); TransitiveHull th = new TransitiveHull(); VerifierFactory.attach(th); VerifierFactory.getVerifier(args[0]); // the observer is called back and does the actual trick. VerifierFactory.detach(th); } }
public synchronized void update(String s){ int size = listeners.size(); Verifier[] verifiers = VerifierFactory.getVerifiers(); int num_of_verifiers = verifiers.length; cache.clear(); for (int i=0; i<num_of_verifiers; i++) { cache.add(verifiers[i].getClassName()); } for (int i=0; i<size; i++){ ListDataEvent e = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, num_of_verifiers-1); ((javax.swing.event.ListDataListener) (listeners.get(i))).contentsChanged(e); } }
public VerifierFactoryListModel() { VerifierFactory.attach(this); update(null); // fill cache. }
/** * Returns the (only) verifier responsible for the class with the given name. * Possibly a new Verifier object is transparently created. * @return the (only) verifier responsible for the class with the given name. */ public static Verifier getVerifier( final String fully_qualified_classname ) { Verifier v = hashMap.get(fully_qualified_classname); if (v == null) { v = new Verifier(fully_qualified_classname); hashMap.put(fully_qualified_classname, v); notify(fully_qualified_classname); } return v; }
public VerifierFactoryListModel() { VerifierFactory.attach(this); update(null); // fill cache. }
/** * Returns the (only) verifier responsible for the class with the given name. * Possibly a new Verifier object is transparently created. * @return the (only) verifier responsible for the class with the given name. */ public static Verifier getVerifier(String fully_qualified_classname){ fully_qualified_classname = fully_qualified_classname; Verifier v = (Verifier) (hashMap.get(fully_qualified_classname)); if (v==null){ v = new Verifier(fully_qualified_classname); hashMap.put(fully_qualified_classname, v); notify(fully_qualified_classname); } return v; }
void newFileMenuItem_actionPerformed(ActionEvent e) { String classname = JOptionPane.showInputDialog("Please enter the fully qualified name of a class or interface to verify:"); if ((classname == null) || (classname.equals(""))) return; VerifierFactory.getVerifier(classname); // let observers do the rest. classNamesJList.setSelectedValue(classname, true); }
/** * This method implements a demonstration program * of how to use the VerifierFactoryObserver. It transitively verifies * all class files encountered; this may take up a lot of time and, * more notably, memory. */ public static void main( final String[] args ) { if (args.length != 1) { System.out.println("Need exactly one argument: The root class to verify."); System.exit(1); } final int dotclasspos = args[0].lastIndexOf(".class"); if (dotclasspos != -1) { args[0] = args[0].substring(0, dotclasspos); } args[0] = args[0].replace('/', '.'); final TransitiveHull th = new TransitiveHull(); VerifierFactory.attach(th); VerifierFactory.getVerifier(args[0]); // the observer is called back and does the actual trick. VerifierFactory.detach(th); } }
@Override public synchronized void update(final String s) { final Verifier[] verifiers = VerifierFactory.getVerifiers(); final int num_of_verifiers = verifiers.length; cache.clear(); for (final Verifier verifier : verifiers) { cache.add(verifier.getClassName()); } for (final ListDataListener listener : listeners) { final ListDataEvent e = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, num_of_verifiers - 1); listener.contentsChanged(e); } }
/** Machine-generated. */ public void flushButton_ActionPerformed( final java.awt.event.ActionEvent actionEvent ) { VerifierFactory.getVerifier(class_name).flush(); Repository.removeClass(class_name); // Make sure it will be reloaded. getPass1Panel().setBackground(Color.gray); getPass1Panel().repaint(); getPass2Panel().setBackground(Color.gray); getPass2Panel().repaint(); getPass3Panel().setBackground(Color.gray); getPass3Panel().repaint(); }
/** Machine-generated. */ public void flushButton_ActionPerformed(java.awt.event.ActionEvent actionEvent) { VerifierFactory.getVerifier(class_name).flush(); Repository.removeClass(class_name); // Make sure it will be reloaded. getPass1Panel().setBackground(Color.gray); getPass1Panel().repaint(); getPass2Panel().setBackground(Color.gray); getPass2Panel().repaint(); getPass3Panel().setBackground(Color.gray); getPass3Panel().repaint(); }
synchronized void pass3aJList_valueChanged( final ListSelectionEvent e ) { if (e.getValueIsAdjusting()) { return; } final Verifier v = VerifierFactory.getVerifier(current_class); final StringBuilder all3amsg = new StringBuilder(); boolean all3aok = true; boolean rejected = false; for (int i = 0; i < pass3aJList.getModel().getSize(); i++) { if (pass3aJList.isSelectedIndex(i)) { final VerificationResult vr = v.doPass3a(i); if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED) { all3aok = false; rejected = true; } JavaClass jc = null; try { jc = Repository.lookupClass(v.getClassName()); all3amsg.append("Method '").append(jc.getMethods()[i]).append("': ") .append(vr.getMessage().replace('\n', ' ') ).append("\n\n"); } catch (final ClassNotFoundException ex) { // FIXME: handle the error ex.printStackTrace(); } } } pass3aTextPane.setText(all3amsg.toString()); pass3aTextPane.setBackground(all3aok ? Color.green : (rejected ? Color.red : Color.yellow)); }
/** Machine-generated. */ public void pass1Button_ActionPerformed( final java.awt.event.ActionEvent actionEvent ) { final Verifier v = VerifierFactory.getVerifier(class_name); final VerificationResult vr = v.doPass1(); if (vr.getStatus() == VerificationResult.VERIFIED_OK) { getPass1Panel().setBackground(Color.green); getPass1Panel().repaint(); } if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED) { getPass1Panel().setBackground(Color.red); getPass1Panel().repaint(); } }
/** Machine-generated. */ public void pass1Button_ActionPerformed(java.awt.event.ActionEvent actionEvent) { Verifier v = VerifierFactory.getVerifier(class_name); VerificationResult vr = v.doPass1(); if (vr.getStatus() == VerificationResult.VERIFIED_OK){ getPass1Panel().setBackground(Color.green); getPass1Panel().repaint(); } if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){ getPass1Panel().setBackground(Color.red); getPass1Panel().repaint(); } }
synchronized void pass3bJList_valueChanged( final ListSelectionEvent e ) { if (e.getValueIsAdjusting()) { return; } final Verifier v = VerifierFactory.getVerifier(current_class); final StringBuilder all3bmsg = new StringBuilder(); boolean all3bok = true; boolean rejected = false; for (int i = 0; i < pass3bJList.getModel().getSize(); i++) { if (pass3bJList.isSelectedIndex(i)) { final VerificationResult vr = v.doPass3b(i); if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED) { all3bok = false; rejected = true; } JavaClass jc = null; try { jc = Repository.lookupClass(v.getClassName()); all3bmsg.append("Method '").append(jc.getMethods()[i]).append("': ") .append(vr.getMessage().replace('\n', ' ')).append("\n\n"); } catch (final ClassNotFoundException ex) { // FIXME: handle the error ex.printStackTrace(); } } } pass3bTextPane.setText(all3bmsg.toString()); pass3bTextPane.setBackground(all3bok ? Color.green : (rejected ? Color.red : Color.yellow)); }
synchronized void pass3aJList_valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; Verifier v = VerifierFactory.getVerifier(current_class); String all3amsg = ""; boolean all3aok = true; boolean rejected = false; for (int i=0; i<pass3aJList.getModel().getSize(); i++){ if (pass3aJList.isSelectedIndex(i)){ VerificationResult vr = v.doPass3a(i); if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){ all3aok = false; rejected = true; } all3amsg += "Method '"+Repository.lookupClass(v.getClassName()).getMethods()[i]+"': "+vr.getMessage().replace('\n',' ')+"\n\n"; } } pass3aTextPane.setText(all3amsg); pass3aTextPane.setBackground(all3aok? Color.green : (rejected? Color.red : Color.yellow)); }
synchronized void pass3bJList_valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; Verifier v = VerifierFactory.getVerifier(current_class); String all3bmsg = ""; boolean all3bok = true; boolean rejected = false; for (int i=0; i<pass3bJList.getModel().getSize(); i++){ if (pass3bJList.isSelectedIndex(i)){ VerificationResult vr = v.doPass3b(i); if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){ all3bok = false; rejected = true; } all3bmsg += "Method '"+Repository.lookupClass(v.getClassName()).getMethods()[i]+"': "+vr.getMessage().replace('\n',' ')+"\n\n"; } } pass3bTextPane.setText(all3bmsg); pass3bTextPane.setBackground(all3bok? Color.green : (rejected? Color.red : Color.yellow)); }
/** Machine-generated. */ public void pass2Button_ActionPerformed( final java.awt.event.ActionEvent actionEvent ) { pass1Button_ActionPerformed(actionEvent); final Verifier v = VerifierFactory.getVerifier(class_name); final VerificationResult vr = v.doPass2(); if (vr.getStatus() == VerificationResult.VERIFIED_OK) { getPass2Panel().setBackground(Color.green); getPass2Panel().repaint(); } if (vr.getStatus() == VerificationResult.VERIFIED_NOTYET) { getPass2Panel().setBackground(Color.yellow); getPass2Panel().repaint(); } if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED) { getPass2Panel().setBackground(Color.red); getPass2Panel().repaint(); } }
/** Machine-generated. */ public void pass2Button_ActionPerformed(java.awt.event.ActionEvent actionEvent) { pass1Button_ActionPerformed(actionEvent); Verifier v = VerifierFactory.getVerifier(class_name); VerificationResult vr = v.doPass2(); if (vr.getStatus() == VerificationResult.VERIFIED_OK){ getPass2Panel().setBackground(Color.green); getPass2Panel().repaint(); } if (vr.getStatus() == VerificationResult.VERIFIED_NOTYET){ getPass2Panel().setBackground(Color.yellow); getPass2Panel().repaint(); } if (vr.getStatus() == VerificationResult.VERIFIED_REJECTED){ getPass2Panel().setBackground(Color.red); getPass2Panel().repaint(); } }