Class FilterCommand

  • Direct Known Subclasses:
    CleanFilter, SmudgeFilter

    public abstract class FilterCommand
    extends java.lang.Object
    An abstraction for JGit's builtin implementations for hooks and filters. Instead of spawning an external processes to start a filter/hook and to pump data from/to stdin/stdout these builtin commmands may be used. They are constructed by FilterCommandFactory.
    Since:
    4.6
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.io.InputStream in
      The InputStream this command should read from
      protected java.io.OutputStream out
      The OutputStream this command should write to
    • Constructor Summary

      Constructors 
      Constructor Description
      FilterCommand​(java.io.InputStream in, java.io.OutputStream out)
      Constructor for FilterCommand
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      abstract int run()
      Execute the command.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • in

        protected java.io.InputStream in
        The InputStream this command should read from
      • out

        protected java.io.OutputStream out
        The OutputStream this command should write to
    • Constructor Detail

      • FilterCommand

        public FilterCommand​(java.io.InputStream in,
                             java.io.OutputStream out)
        Constructor for FilterCommand

        FilterCommand implementors are required to manage the in and out streams (close on success and/or exception).

        Parameters:
        in - The InputStream this command should read from
        out - The OutputStream this command should write to
    • Method Detail

      • run

        public abstract int run()
                         throws java.io.IOException
        Execute the command. The command is supposed to read data from in and to write the result to out. It returns the number of bytes it read from in. It should be called in a loop until it returns -1 signaling that the InputStream is completely processed.

        On successful completion (return -1) or on Exception, the streams in and out are closed by the implementation.

        Returns:
        the number of bytes read from the InputStream or -1. -1 means that the InputStream is completely processed.
        Throws:
        java.io.IOException - when IOException occurred while reading from in or writing to out