All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.basex.http.rest.RESTSession Maven / Gradle / Ivy

The newest version!
package org.basex.http.rest;

import java.io.*;
import java.util.*;

import org.basex.core.*;
import org.basex.http.*;

/**
 * REST session.
 *
 * @author BaseX Team 2005-24, BSD License
 * @author Christian Gruen
 */
final class RESTSession implements Iterable {
  /** HTTP connection. */
  final HTTPConnection conn;
  /** Commands to be executed. */
  private final ArrayList commands = new ArrayList<>();

  /**
   * Constructor, specifying login data and an output stream.
   * @param conn HTTP connection
   */
  RESTSession(final HTTPConnection conn) {
    this.conn = conn;
  }

  /**
   * Adds a command to be executed.
   * @param cmd command
   * @return self reference
   */
  RESTSession add(final Command cmd) {
    commands.add(cmd);
    return this;
  }

  /**
   * Adds a command to be executed.
   * @param cmd command
   * @param is input stream
   * @return self reference
   */
  RESTSession add(final Command cmd, final InputStream is) {
    commands.add(cmd);
    cmd.setInput(is);
    return this;
  }

  /**
   * Clears the command list.
   */
  void clear() {
    commands.clear();
  }

  @Override
  public Iterator iterator() {
    return commands.iterator();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy