Class WebDoc

java.lang.Object
ch.software_atelier.simpleflex.docs.WebDoc
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
ByteDoc, ErrorDoc, FileDoc, InputStreamDoc, JSONDoc, RedirectorDoc, RessourceDoc, StringDoc, TemplateDoc, XMLDoc, ZipDoc

public abstract class WebDoc extends Object implements Closeable
  • Field Details

    • DATA_STREAM

      public static final String DATA_STREAM
      This static var returns that the data of a WebDoc-Object is a stream.
      See Also:
    • DATA_BYTE

      public static final String 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

      public abstract String 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

      public abstract String 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

      public abstract InputStream 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

      public abstract String dataType()
      Specifies the Type of served data. Look at streamData() and/or byteData()
      Returns:
    • setHTTPCode

      public final void setHTTPCode(int code, String message)
      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

      public WebDoc.HTTPCode getHttpCode()
    • getHeaders

      public ArrayList<HeaderField> getHeaders()