| java.lang.Object simple.http.serve.DefaultFormat
DefaultFormat | final class DefaultFormat implements Format(Code) | | The DefaultFormat object is used to provide pages
for the FileEngine that are consistant and have
a user specified format. This is used as the default system
format when there is no explicit specification of a default
using the system property "simple.http.serve.format". If
this property is specified a class loader will attempt to
load and instantiate a format of the specified type.
The Format of the FileEngine can
be changed from the DefaultFormat by simply
giving the VM the class name of the desired format like
java -Dsimple.http.serve.format=demo.example.FancyFormat
The FormatFactory produces the system default
Format implementaion. This is used with the
FileEngine.getInstance when the context object
is not explicitly used. This implementation only supports
the contents of directory resources. If the resource is
requested is not a directorys a FormatException
is thrown.
author: Niall Gallagher |
Method Summary | |
public String | getContentType() The contents generated by this object may not be in HTML format,
this is used to retrive the content type. | public byte[] | getContents(Context context, String target) This is used to produce the contents of the specified resource.
The Context is used to aquire a File
object that represents the request URI path on the system. | public byte[] | getMessage(Context context, String target, Report report) The HTTP protocol defines certain status codes the are to be sent
with descriptive message bodys, this method is used to create the
message body for that status code. |
getContentType | public String getContentType()(Code) | | The contents generated by this object may not be in HTML format,
this is used to retrive the content type. This is nessecary so
that if the contents generated by this Format is
not HTML that the correct MIME type is returned.
this returns the MIME type of the resulting contents |
getContents | public byte[] getContents(Context context, String target) throws FormatException(Code) | | This is used to produce the contents of the specified resource.
The Context is used to aquire a File
object that represents the request URI path on the system. This
is then be used to generate a page the provides a view of the
contents of the resource.
The path given is the request URI path that normally comes with
a HTTP/1.x request. The request URI is the string that identifies
the resource on the host that is required. The context is used
to convert that request URI into the system dependant name. The
request URI is similar to a UNIX path like /usr/bin/README. For
example if the browser requests http://some.host/pub/index.html
then the request URI is /pub/index.html.
Parameters: context - provides the format with a view of the system Parameters: target - the request URI that came with the HTTP request exception: FormatException - if there is not format possible for the requested resource |
getMessage | public byte[] getMessage(Context context, String target, Report report)(Code) | | The HTTP protocol defines certain status codes the are to be sent
with descriptive message bodys, this method is used to create the
message body for that status code. This method will generate a
message body that describes the error defined by the status code.
See the HTTP/1.1 specification for a description of the status
codes, RFC 2616.
The path given is the request URI path that normally comes with
a HTTP/1.x request. The request URI is the string that identifies
the resource on the host that is required. The context is used
to convert that request URI into the system dependant name. The
request URI is similar to a UNIX path like /usr/bin/README. For
example if the browser requests http://some.host/pub/index.html
then the request URI is /pub/index.html.
Parameters: context - provides the format with a view of the system Parameters: target - the request URI that came with the HTTP request Parameters: report - this provides information that can be used by thespecific implementation to present the page this returns a HTML description of the error messagethat caused the |
|
|