Class TransferContent

java.lang.Object
marauroa.common.net.message.TransferContent

public class TransferContent extends Object
A helper class to transfer content from server to client.
Author:
miguel, hendrik
  • Field Details

    • name

      public String name
      Name of the content to transfer. Usually it is a file name.
    • timestamp

      public int timestamp
      When this content was created or any other way of stamping the content for version control.
    • data

      public byte[] data
      The content itself.
    • cacheable

      public boolean cacheable
      If the client can cache this content, this would be true.
    • ack

      public boolean ack
      If the client approved this content to be transfered it will be true.
  • Constructor Details

    • TransferContent

      public TransferContent()
      Constructor
    • TransferContent

      public TransferContent(String name, int timestamp, byte[] data)
      Constructor
      Parameters:
      name - name of the content
      timestamp - version control timestamp.
      data - data of the content.
  • Method Details

    • getHash

      public byte[] getHash()
      gets the hash
      Returns:
      hash
    • getTransmittedHash

      public byte[] getTransmittedHash()
      gets the transmitted hash, may be null.
      Returns:
      transmitted hash or null
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • writeREQ

      public void writeREQ(OutputSerializer out) throws IOException
      Write content as a request to client to approve it
      Parameters:
      out -
      Throws:
      IOException
    • writeREQToJson

      public void writeREQToJson(StringBuilder out)
      Write content as a request to client to approve it
      Parameters:
      out -
    • readREQ

      public void readREQ(InputSerializer in) throws IOException
      Reads the content transfer request.
      Parameters:
      in -
      Throws:
      IOException
    • writeACK

      public void writeACK(OutputSerializer out) throws IOException
      Write a content acceptance to server.
      Parameters:
      out -
      Throws:
      IOException
    • writeACKToJson

      public void writeACKToJson(StringBuilder out)
      writes an ACK to JSON
      Parameters:
      out - StringBuilder
    • readACK

      public void readACK(InputSerializer in) throws IOException
      Reads the content acceptance from client
      Parameters:
      in -
      Throws:
      IOException
    • readACKFromMap

      public void readACKFromMap(String contentName, Object accept)
      Reads the content acceptance from client
      Parameters:
      contentName - name of content
      accept - does the client what this content?
    • writeFULL

      public void writeFULL(OutputSerializer out) throws IOException
      Write the content data to client
      Parameters:
      out -
      Throws:
      IOException
    • writeFullToJson

      public void writeFullToJson(StringBuilder out)
      Write the content data to the server
      Parameters:
      out - output
    • readFULL

      public void readFULL(InputSerializer in) throws IOException
      Read the content data from server.
      Parameters:
      in -
      Throws:
      IOException