public class OutputDataParser extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
(package private) FileInfo |
fileInfo |
(package private) OutputData |
outputData |
(package private) Request |
request |
Constructor and Description |
---|
OutputDataParser() |
Modifier and Type | Method and Description |
---|---|
private FileInfo |
checkFile(Header header,
java.io.File directory,
java.lang.String uri)
Checks the file requested by the client and sets the status code in
the input header according to the findings.
|
private int |
checkRequest(Header header)
Checks the request content and validity and modifies the header's
status code according to the findings.
|
private java.lang.String |
extractFileExtension(java.lang.String uri)
Extracts the file extension from a URI.
|
private java.lang.String |
fileExtensionToContentType(java.lang.String fileExtension)
Translates the input file extension into a content type.
|
OutputData |
parse(java.lang.String clientData,
java.io.File directory)
Parses input client data into an output data container containing
a suitable answer to the good/bad request in the form of a header
and a possible file, depending on the request.
|
private Request |
parseClientData(java.lang.String clientData)
Parses the string received from the client into a request container.
|
OutputData outputData
Request request
FileInfo fileInfo
private Request parseClientData(java.lang.String clientData)
clientData:
- String - The client data (the request in string
format).private int checkRequest(Header header)
header:
- Header - The header to be modified.private java.lang.String extractFileExtension(java.lang.String uri)
uri:
- String - The input URI.private FileInfo checkFile(Header header, java.io.File directory, java.lang.String uri)
header:
- Header - The header to be modified.directory:
- File - The start directory.uri:
- String - The URI.private java.lang.String fileExtensionToContentType(java.lang.String fileExtension)
fileExtension:
- String - The file extension to be translated.public OutputData parse(java.lang.String clientData, java.io.File directory)
clientData:
- String - The input client data.directory:
- File - The start directory.