| jsbdoc.java |
jsbdoc.java: Command Line Tool / Invisible Bean |
* Note: Currently does not support parsing * of secondary JS files referenced by optional * SRC attribute of JSB_CONSTRUCTOR tag. *
* @see main * * @version 1.0 * @author garys@netscape.com */ public class jsbdoc implements Serializable { private String fileName; /** * Constructs a jsbdoc Bean with the a default fileName. */ public jsbdoc() { this("jsbdoc.jsb"); } /** * Constructs a jsbdoc Bean with the specified fileName. * @param fileName the fileName of the JSB to be doc'd */ public jsbdoc(String fileName) { super(); this.fileName = fileName; } public String getFileName() { return fileName; } public void setFileName(String newFileName) { fileName = newFileName; } public void generateJSBDoc() { try { String JSBname = fileName.substring(0, fileName.lastIndexOf(".")); System.out.println("Generating documention for JSB "+ JSBname); String docFileName = JSBname +".html"; ReadFile rf = new ReadFile(fileName); System.out.println("Generating "+ docFileName ); ParseJSB p = new ParseJSB(JSBname); p.setFileLines(rf.getFileLines()); p.setParsedDoc(); WriteFile wr = new WriteFile(docFileName, p.getParsedDoc()); } catch (Exception e) { System.out.println("jsbdoc Exception:\n" + e); } } /** * cmd-line option for jsbdoc */ public static void cmdLine(String fileName) { try { String JSBname = fileName.substring(0, fileName.lastIndexOf(".")); System.out.println("Generating documention for JSB "+ JSBname); String docFileName = JSBname +"_jsb.html"; ReadFile rf = new ReadFile(fileName); System.out.println("Generating "+ docFileName ); ParseJSB p = new ParseJSB(JSBname); p.setFileLines(rf.getFileLines()); p.setParsedDoc(); WriteFile wr = new WriteFile(docFileName, p.getParsedDoc()); } catch (Exception e) { System.out.println("jsbdoc Exception:\n" + e); } } /** * for cmd-line option * usage: java jsbdoc [filename] */ public static void main(String args[]) { try { String fileName = args[0]; cmdLine(fileName); } catch (Exception e) { System.out.println("usage: java jsbdoc [filename]"); } } // Methods for registering listeners: public void addPropertyChangeListener(PropertyChangeListener l) { changes.addPropertyChangeListener(l); } public void removePropertyChangeListener(PropertyChangeListener l) { changes.removePropertyChangeListener(l); } // Support for serialization private void readObject(java.io.ObjectInputStream s) throws java.lang.ClassNotFoundException, java.io.IOException { s.defaultReadObject(); } private PropertyChangeSupport changes = new PropertyChangeSupport(this); }