Class FilterCommandRegistry


  • public class FilterCommandRegistry
    extends java.lang.Object
    Registry for built-in filters
    Since:
    4.6
    • Field Detail

      • filterCommandRegistry

        private static java.util.Map<java.lang.String,​FilterCommandFactory> filterCommandRegistry
    • Constructor Detail

      • FilterCommandRegistry

        public FilterCommandRegistry()
    • Method Detail

      • register

        public static FilterCommandFactory register​(java.lang.String filterCommandName,
                                                    FilterCommandFactory factory)
        Register a FilterCommandFactory responsible for creating FilterCommands for a certain command name. If the factory f1 is registered for the name "jgit://builtin/x" then a call to getCommand("jgit://builtin/x", ...) will call f1(...) to create a new instance of FilterCommand
        Parameters:
        filterCommandName - the command name for which this factory is registered
        factory - the factory responsible for creating FilterCommands for the specified name
        Returns:
        the previous factory associated with commandName, or null if there was no mapping for commandName
      • unregister

        public static FilterCommandFactory unregister​(java.lang.String filterCommandName)
        Unregister the FilterCommandFactory registered for the given command name
        Parameters:
        filterCommandName - the FilterCommandFactory's filter command name
        Returns:
        the previous factory associated with filterCommandName, or null if there was no mapping for commandName
      • isRegistered

        public static boolean isRegistered​(java.lang.String filterCommandName)
        Check whether any FilterCommandFactory is registered for a given command name
        Parameters:
        filterCommandName - the name for which the registry should be checked
        Returns:
        true if any factory was registered for the name
      • getRegisteredFilterCommands

        public static java.util.Set<java.lang.String> getRegisteredFilterCommands()
        Get registered filter commands
        Returns:
        Set of commandNames for which a FilterCommandFactory is registered
      • createFilterCommand

        public static FilterCommand createFilterCommand​(java.lang.String filterCommandName,
                                                        Repository db,
                                                        java.io.InputStream in,
                                                        java.io.OutputStream out)
                                                 throws java.io.IOException
        Create a new FilterCommand for the given name. A factory must be registered for the name in advance.
        Parameters:
        filterCommandName - The name for which a new FilterCommand should be created
        db - the repository this command should work on
        in - the InputStream this FilterCommand should read from
        out - the OutputStream this FilterCommand should write to
        Returns:
        the command if a command could be created or null if there was no factory registered for that name
        Throws:
        java.io.IOException