Class WebDoc
java.lang.Object
ch.software_atelier.simpleflex.docs.WebDoc
- Direct Known Subclasses:
ByteDoc,ErrorDoc,FileDoc,InputStreamDoc,JSONDoc,RedirectorDoc,RessourceDoc,StringDoc,TemplateDoc,XMLDoc,ZipDoc
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract byte[]byteData()If you want to return the documents data as a byte[], you have to do that here.abstract voidclose()This method is called after the transmission.abstract StringdataType()Specifies the Type of served data.abstract Stringmime()This method has to return the MIME-Type of the Document.abstract Stringname()This method has to return the FileName of the Document.final voidsetHTTPCode(int code, String message) Sets the HTTP Response Code.abstract longsize()This method has to return the size of the Document in bytes.abstract InputStreamIf you want to return the documents data as a Stream, you have to do that here.
-
Field Details
-
DATA_STREAM
This static var returns that the data of a WebDoc-Object is a stream.- See Also:
-
DATA_BYTE
This static var defines that the data of a WebDoc-Object is a byte[].- See Also:
-
-
Constructor Details
-
WebDoc
public WebDoc()
-
-
Method Details
-
size
public abstract long size()This method has to return the size of the Document in bytes.- Returns:
-
mime
This method has to return the MIME-Type of the Document. Example: text/plain. You can also use the static Method Utils.getMime(String ext) to get the MIME-Type of a File-Extension.- Returns:
-
name
This method has to return the FileName of the Document.- Returns:
-
byteData
public abstract byte[] byteData()If you want to return the documents data as a byte[], you have to do that here. Be sure, that the method dataType() returns WebDoc.DATA_BYTE! Else just return null or something else. If the method dataType() does not return WebDoc.DATA_BYTE, this method will never be called.- Returns:
-
streamData
If you want to return the documents data as a Stream, you have to do that here. Be sure, that the method dataType() returns WebDoc.DATA_STREAM! Else just return null or something else. If the method dataType() does not return WebDoc.DATA_STREAM, this method will never be called. The Stream will be closed by the Server-App so you have nothing to do with that.- Returns:
-
dataType
Specifies the Type of served data. Look at streamData() and/or byteData()- Returns:
-
close
public abstract void close()This method is called after the transmission. It can be used to cleanup something. -
setHTTPCode
Sets the HTTP Response Code. Default is 200 - OK. HTTPCodes.getMsg() returns the message for all known codes, defined by the RFC.- Parameters:
code-message-
-
getHttpCode
-
getHeaders
-