package org.w3c.jigsaw.tutorials;
import java.util.*;
import org.w3c.tools.resources.*;
import org.w3c.jigsaw.frames.*;
import org.w3c.jigsaw.html.*;
import org.w3c.jigsaw.http.* ;
import org.w3c.www.http.* ;
@version @author 
public class FancyFrame extends HTTPFrame {
    
    protected static int ATTR_MESSAGE = -1 ;
    static {
	Attribute a   = null ;
	Class     cls = null ;
	try {
	    cls = Class.forName("org.w3c.jigsaw.tutorials.FancyFrame");
	} catch (Exception ex) {
	    ex.printStackTrace() ;
	    System.exit(1) ;
	}
		 a = new StringAttribute("message", "Hello", Attribute.EDITABLE) ;
	 ATTR_MESSAGE = AttributeRegistry.registerAttribute(cls, a) ;
    }
    @return 
    public String getMessage() {
	return getString(ATTR_MESSAGE, null);
    }
    @param request@return @exception ProtocolException@exception NotAProtocolException
    protected Reply getFileResource(Request request) 
	throws ProtocolException, NotAProtocolException
    {
		FileResource fres = getFileResource();
		HtmlGenerator g = new HtmlGenerator("FancyFrame");
	g.append("<h1>FancyFrame output</h1>");
		g.append("<p>",getMessage(),"</p>");
		g.append("<h2> FileResource associated : </h2>");
	g.append("<ul><li>Identifier : ",fres.getIdentifier());
	g.append("<li>File : "+fres.getFile());
	g.append("<li>Last Modified Time : ",
		 new Date(fres.getLastModified()).toString(),
		 "</ul>");
		Reply reply = createDefaultReply(request, HTTP.OK) ;
	reply.setStream(g) ;
	return reply ;
    }
    @param request@return @exception ProtocolException@exception NotAProtocolException
    protected Reply getDirectoryResource(Request request) 
	throws ProtocolException, NotAProtocolException
    {
		DirectoryResource dres = getDirectoryResource();
		HtmlGenerator g = new HtmlGenerator("FancyFrame");
	g.append("<h1>FancyFrame output</h1>");
		g.append("<p>",getMessage(),"</p>");
		g.append("<h2> DirectoryResource associated : </h2>");
	g.append("<ul><li>Identifier : ",dres.getIdentifier());
	g.append("<li>Directory : "+dres.getDirectory());
	g.append("<li>Last Modified Time : ",
		 new Date(dres.getLastModified()).toString(),
		 "</ul>");
		Reply reply = createDefaultReply(request, HTTP.OK) ;
	reply.setStream(g) ;
	return reply ;
    }
    @param request@return @exception ProtocolException@exception NotAProtocolException
    protected Reply getOtherResource(Request request) 
	throws ProtocolException, NotAProtocolException
    {		FramedResource res = getResource();
		HtmlGenerator g = new HtmlGenerator("FancyFrame");
	g.append("<h1>FancyFrame output</h1>");
		g.append("<p>",getMessage(),"</p>");
		g.append("<h2> Resource associated : </h2>");
	g.append("<ul><li>Identifier : ",res.getIdentifier());
	g.append("<li>Last Modified Time : ",
		 new Date(res.getLastModified()).toString(),
		 "</ul>");
		Reply reply = createDefaultReply(request, HTTP.OK) ;
	reply.setStream(g) ;
	return reply ;
    }
    
}