Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

CommandController.java 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Copyright (c) 2006-2015 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.interfaces;
  23. import com.dmdirc.commandparser.CommandInfo;
  24. import com.dmdirc.commandparser.CommandType;
  25. import com.dmdirc.commandparser.commands.Command;
  26. import com.dmdirc.commandparser.parsers.CommandParser;
  27. import java.util.List;
  28. import java.util.Map;
  29. /**
  30. * Manages a list of known commands, and facilitates loading default commands.
  31. */
  32. public interface CommandController {
  33. /**
  34. * Retrieves the command identified by the specified name, regardless of type.
  35. *
  36. * @param name The name to look for
  37. *
  38. * @return A command with a matching signature, or null if none were found
  39. */
  40. Map.Entry<CommandInfo, Command> getCommand(final String name);
  41. /**
  42. * Retrieves a command of the specified type with the specified name.
  43. *
  44. * @param type The type of the command to look for
  45. * @param name The name to look for
  46. *
  47. * @return A command with a matching signature, or null if none were found
  48. */
  49. Map.Entry<CommandInfo, Command> getCommand(final CommandType type, final String name);
  50. /**
  51. * Returns the current command character.
  52. *
  53. * @return the current command char
  54. */
  55. char getCommandChar();
  56. /**
  57. * Retrieves a list of the names of all commands of the specified type.
  58. *
  59. * @param type The type of command to list
  60. *
  61. * @return A list of command names
  62. */
  63. List<String> getCommandNames(final CommandType type);
  64. /**
  65. * Retrieves a map of all {@link CommandInfo}s and their associated {@link Command}s of the
  66. * specified type.
  67. *
  68. * @param type The type of command to list
  69. *
  70. * @return A map of commands
  71. *
  72. * @since 0.6.3m1
  73. */
  74. Map<CommandInfo, Command> getCommands(final CommandType type);
  75. /**
  76. * Returns the current silence character.
  77. *
  78. * @return the current silence char
  79. */
  80. char getSilenceChar();
  81. /**
  82. * Determines if the specified command is a valid channel command.
  83. *
  84. * @param command The name of the command to test
  85. *
  86. * @return True iff the command is a channel command, false otherwise
  87. */
  88. boolean isChannelCommand(final String command);
  89. /**
  90. * Loads all commands of the specified types into the specified parser.
  91. *
  92. * @see CommandType#getComponentTypes()
  93. * @since 0.6.3m1
  94. * @param parser The {@link CommandParser} to load commands in to
  95. * @param supertypes The types of commands that should be loaded
  96. */
  97. void loadCommands(final CommandParser parser, final CommandType... supertypes);
  98. /**
  99. * Registers a command with the command manager.
  100. *
  101. * @param command The command to be registered
  102. * @param info The information about the command
  103. *
  104. * @since 0.6.3m1
  105. */
  106. void registerCommand(final Command command, final CommandInfo info);
  107. /**
  108. * Unregisters a command with the command manager.
  109. *
  110. * @param info The information object for the command that should be unregistered
  111. *
  112. * @since 0.6.3m1
  113. */
  114. void unregisterCommand(final CommandInfo info);
  115. /**
  116. * Describes a command and its associated {@link CommandInfo} object.
  117. */
  118. interface CommandDetails {
  119. /**
  120. * Gets the command.
  121. *
  122. * @return The command.
  123. */
  124. Command getCommand();
  125. /**
  126. * Gets the command's information.
  127. *
  128. * @return The command information.
  129. */
  130. CommandInfo getInfo();
  131. }
  132. }