For Programmers: Free Programming Magazines  


Home > Archive > Java Help > June 2005 > design critique









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author design critique
hawat.thufir@gmail.com

2005-06-04, 3:57 pm

the design, so far:

Test16 implements BasicTidy
BasicTidy has a few setter methods
ControlTidy instantiates aTidy, which is a BasicTidy
Test16 imports Tidy.jar from sourceforge.net
Test16 is basically sample code from sourceforge.net
Tidy.jar converts old html to xhtml

goal #1:

a GUI with a few textfields, the setter methods in BasicTidy


goal #2:

same as #1, but instead of passing a url as parameter, pass the path to
a file on
the local hard drive.

goal #3:

pass a directory for bulk tidy-izing.



just sorta looking for ideas, critiques, feedback, whatever :)


-Thufir





package atreides.tidyXhtml;

public interface BasicTidy{
public void setUrl(String url);
public void setOutFileName(String outFileName);
public void setErrOutFileName(String errOutFileName);
public void setXmlOut(boolean xmlOut);
}//BasicTidy
package atreides.tidyXhtml;

public class ControlTidy{


public static void main (String[] args) {
BasicTidy aTidy = new Test16();
String yahoo = "http://www.yahoo.com/";
String google = "http://www.google.com/";
aTidy.setUrl(yahoo);
}//main

}//ControlTidy
package atreides.tidyXhtml;

import java.io.IOException;
import java.net.URL;
import java.io.BufferedInputStream;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.FileWriter;
import org.w3c.tidy.Tidy;


public class Test16 implements Runnable, BasicTidy{

private String url;
private String outFileName;
private String errOutFileName;
private boolean xmlOut;

public Test16(){
this.url = "http://www.google.com/";
this.outFileName = "out.txt";
this.errOutFileName = "err.txt";
this.xmlOut = true;
}//Test16

public void run() {
URL u;
BufferedInputStream in;
FileOutputStream out;
Tidy tidy = new Tidy();

tidy.setXmlOut(xmlOut);
try {
tidy.setErrout(new PrintWriter(new
FileWriter(errOutFileName), true));
u = new URL(url);
in = new BufferedInputStream(u.openStream());
out = new FileOutputStream(outFileName);
tidy.parse(in, out);
}//try
catch ( IOException e ) {
System.out.println( this.toString() + e.toString() );
}//catch
}//run

public void setUrl (String url){
this.url = url;
}//setUrl

public void setOutFileName (String outFileName){
this.outFileName = outFileName;
}//setOutFileName

public void setErrOutFileName (String errOutFileName){
this.errOutFileName = errOutFileName;
}//setErrOutFileName

public void setXmlOut (boolean xmlOut) {
this.xmlOut = xmlOut;
}//setXmlOut

public static void main( String[] args ) {
}//main
}//Test16

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com