Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ServerEntry.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes
  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.addons.serverlists;
  23. import com.dmdirc.Server;
  24. import java.net.URI;
  25. /**
  26. * Describes an entry for a server within a {@link ServerGroup}.
  27. *
  28. * @since 0.6.4
  29. * @author chris
  30. */
  31. public class ServerEntry extends ServerGroupItemBase {
  32. /** The address of the server in question. */
  33. private URI address;
  34. /** The group that owns this entry. */
  35. private final ServerGroup group;
  36. /**
  37. * Creates a new server entry.
  38. *
  39. * @param group The group that owns this entry
  40. * @param name The name of this server
  41. * @param address The address of this server
  42. * @param profile The name of the profile to be used by this server
  43. */
  44. public ServerEntry(final ServerGroup group, final String name,
  45. final URI address, final String profile) {
  46. setName(name);
  47. setProfile(profile);
  48. this.address = address;
  49. this.group = group;
  50. }
  51. /** {@inheritDoc} */
  52. @Override
  53. public ServerGroup getGroup() {
  54. return group;
  55. }
  56. /** {@inheritDoc} */
  57. @Override
  58. protected ServerGroup getParent() {
  59. return getGroup();
  60. }
  61. /**
  62. * Retrieves the address used by this server.
  63. *
  64. * @return This server's address
  65. */
  66. @Override
  67. public URI getAddress() {
  68. return address;
  69. }
  70. /**
  71. * Sets the address for this server entry.
  72. *
  73. * @param address The new address for this entry
  74. */
  75. public void setAddress(final URI address) {
  76. setModified(true);
  77. this.address = address;
  78. }
  79. /** {@inheritDoc} */
  80. @Override
  81. public void connect() {
  82. final Server server = new Server(address, getProfileIdentity());
  83. server.connect();
  84. }
  85. /** {@inheritDoc} */
  86. @Override
  87. public String toString() {
  88. return "[" + getName() + ": address: " + getAddress() + "]";
  89. }
  90. }