java.lang.Object
org.apache.olingo.client.core.communication.request.batch.ODataBatchUtilities

public class ODataBatchUtilities extends Object
Utility class for batch requests and responses.
  • Constructor Details

    • ODataBatchUtilities

      public ODataBatchUtilities()
  • Method Details

    • readBatchPart

      public static String readBatchPart(ODataBatchController batchController, boolean checkCurrent)
      Reads batch part taking source and delimiter (boundary) from given batch controller.

      Usually used to consume/discard useless lines.

      Parameters:
      batchController - batch controller.
      checkCurrent - if 'TRUE' the current line will be included into the delimiter verification.
      Returns:
      latest read line.
    • readBatchPart

      public static String readBatchPart(ODataBatchController batchController, int count)
      Reads the given number of line from the given batch wrapped into the batch controller.

      Usually used to consume/discard useless lines.

      Parameters:
      batchController - batch controller.
      count - number of batch line to be read.
      Returns:
      latest read line.
    • readBatchPart

      public static String readBatchPart(ODataBatchController controller, OutputStream os, boolean checkCurrent)
      Reads batch part taking source and delimiter (boundary) from given batch controller.

      Usually used to read an entire batch part.

      Parameters:
      controller - batch controller.
      os - destination stream of batch part (null to discard).
      checkCurrent - if 'TRUE' the current line will be included into the delimiter verification.
      Returns:
      latest read line.
    • readBatchPart

      public static String readBatchPart(ODataBatchController controller, OutputStream os, int count, boolean checkCurrent)
      Reads batch part taking source and delimiter (boundary) from given batch controller.

      Usually used to read an entire batch part.

      Parameters:
      controller - batch controller.
      os - destination stream of batch part (null to discard).
      count - number of batch line to be read.
      checkCurrent - if 'TRUE' the current line will be included into the delimiter verification.
      Returns:
      latest read line.
    • readHeaders

      public static Map<String,Collection<String>> readHeaders(ODataBatchLineIterator iterator)
      Reads headers from the batch starting from the given position.
      Parameters:
      iterator - batch iterator.
      Returns:
      Map of header name in header values.
    • readHeaders

      public static void readHeaders(ODataBatchLineIterator iterator, Map<String,Collection<String>> target)
      Reads headers from the batch starting from the given position.

      Retrieved headers will be added to the map given by target parameter.

      Parameters:
      iterator - batch iterator.
      target - destination of the retrieved headers.
    • addHeaderLine

      public static void addHeaderLine(String headerLine, Map<String,Collection<String>> targetMap)
      Parses and adds the given header line to the given target map.
      Parameters:
      headerLine - header line to be added.
      targetMap - target map.
    • getBoundaryFromHeader

      public static String getBoundaryFromHeader(Collection<String> contentType)
      Retrieved batch boundary from the given content-type header values.
      Parameters:
      contentType - content-types.
      Returns:
      batch boundary.
    • readResponseLine

      public static Map.Entry<Integer,String> readResponseLine(ODataBatchLineIterator iterator)
      Retrieves response line from the given position.
      Parameters:
      iterator - batch iterator.
      Returns:
      retrieved response line.
    • nextItemHeaders

      public static Map<String,Collection<String>> nextItemHeaders(ODataBatchLineIterator iterator, String boundary)
      Retrieves headers of the next batch item.
      Parameters:
      iterator - batch line iterator.
      boundary - batch boundary.
      Returns:
      batch item headers.
    • getItemType

      public static ODataBatchUtilities.BatchItemType getItemType(Map<String,Collection<String>> headers)
      Retrieves item type from item headers.
      Parameters:
      headers - batch item headers.
      Returns:
      batch item type.