import java.io.*;
import java.util.*;

class test_view{//テスト用。タグなどをチェックする。
    public static void main(String args[]){
	html_View v=new html_View(new PrintWriter(System.out));
	String tmp[]={"ssid","name","record"};
	v.print_item_data(tmp);
	v.print_item_data(tmp);
	v.print_item_data(tmp);
	v.print_item_data(tmp);
	v.close();
    }
}


//実際に使用するもの。
class html_View{
    
    boolean table_printing=false;
    my_print_writer out;
    html_template design=new html_design();//実際のデザインはこっちにある。これと、入力データを使用してhtmlファイルを作成する。
    String buffer="";
    
    html_View(PrintWriter out){
	try{
	    init_html_view(out);
	}catch(Exception e){
	}
    }
    void init_html_view(PrintWriter pw){
	try{
	    out=new my_print_writer(pw);
	}catch(Exception e){
	    System.err.println();
	}
    }
    void print_header(){
	print_header("");
    }
    void print_header(String s){
	try{
	    out.println(design.headder(s));
	}catch(Exception e){			
	}			
    }
    void print_headder(String s,String css){
	try{
	    out.println(design.headder(s,css));
	}catch(Exception e){
	}
    }
    void print_item_table(String[] head,ArrayList list){
	print_item_data(head);
	for(int i=0;i<list.size();i++){
	    print_item_data((String[])list.get(i));
	}
    }
    
    void print_item_table(ArrayList list){
	//	    print_error("run print_item_table");
	for(int i=0;i<list.size();i++){
	    print_item_data((String[])list.get(i));
	}
    }
    void print_item_data(String[] record){
	try{
	    if(!table_printing)flush();
	    String s="";
	    for(int i=0;i<record.length;i++){
		s+=design.table_td(record[i]);//tdタグを付加する。
	    }
	    buffer+=design.table_tr(s);//trタグを付加する。
	    table_printing=true;
	}catch(Exception e){			
	}
    }
    void print_futter(){
	flush();
	try{
	    out.println(design.futter());
	}catch(Exception e){			
	}
    }	
    void print(String s){
	flush();
	try{
	    out.println(s);
	}catch(Exception e){

	}
    }
    void flush(){//バッファ内のデータを書き出す。
	if(table_printing){
	    try{
		out.println(design.table(buffer));
	    }catch(Exception e){
	    }
	    buffer="";
	    table_printing=false;
	}
    }
    void close(){
	flush();
	try{
	    //		out.println(design.futter());
	    out.close();
	}catch(Exception e){
	}
    }
    void print_files(String file_name){
	try{
	    BufferedReader br=new BufferedReader(new FileReader(file_name));
	    String s;
	    while((s=br.readLine())!=null){
		out.println(s);
	    }
	    close();
	}catch(Exception e){
	    print_error(e.toString());
	}
    }
    void print_errors(String s){
	try{
	    out.println(design.h1(s));
	}catch(Exception e){
	}
    }
    void print_error(String s){
	print_header("ERROR");
	try{
	    out.println(design.h1(s));
	}catch(Exception e){
		}
	print_futter();
    }
    void print_error(String s[]){
	print_header("ERROR");
	try{
	    for(int i=0;i<s.length;i++){
		out.println(design.p(s[i]));
	    }
	}catch(Exception e){
	}
	print_futter();
    }
}

class my_print_writer{
    PrintWriter out;
    my_print_writer(PrintWriter pw){
	out=pw;
    }
    void println(String s) throws Exception{
	out.println(s);
    }
    void close() throws Exception{
	out.close();
    }
}

//idを使用する場合、スタイルシートに順次していなければならない。
class html_design extends html_template{
    String table(String s){
	return "<table border=1 align=center>\n"+s+"\n</table>";
    }
}

//あくまで、最低限の事を書く。それ以上のものは、extendsしてオーバーライドする必要がある。
abstract class html_template{
    String headder(String s){	
	return "<html><head>"+s+"</head><body>";
    }
    String headder(String s,String css){
	return "<html>"+"<head><META HTTP-EQUIV=\"Content-type\" CONTENT=\"text/html; charset=Shift_JIS\">\n"
	    +"<title>"+s+"</title>\n"
	    +"<link href=\""+css+"\" rel=\"stylesheet\" type=\"text/css\"></head>\n<body>\n";
    }
    String futter(){
	return "</body></html>";
    }
    String table(String s){
	return "<table>\n"+s+"\n</table>";
    }
    String table_tr(String s){
	return "\t<tr>"+s+"</tr>\n";
    }
    String table_td(String s){
	return "<td>"+s+"</td>";	
    }
    String comment(String s){
	return "<!--"+s+"-->";
    }
    String h1(String s){
	return "<h1>"+s+"</h1>";
    }
    String p(String s){
	return "<p>"+s+"</p>";
    }
}