You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MyInfo.java 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright (c) 2006-2017 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.parser.common;
  23. import com.dmdirc.parser.interfaces.Parser;
  24. /**
  25. * Contains User information.
  26. *
  27. * @see Parser
  28. */
  29. public class MyInfo {
  30. /** Nickname to attempt to use on IRC. */
  31. private String nickname;
  32. /** Realname string to use. */
  33. private String realname;
  34. /** Username to use, this doesn't matter when an ident server is running. */
  35. private String username;
  36. /**
  37. * Create a new MyInfo object.
  38. */
  39. public MyInfo() {
  40. String result;
  41. try {
  42. result = System.getProperty("user.name");
  43. } catch (final SecurityException e) {
  44. result = null;
  45. }
  46. if (result == null || result.isEmpty()) {
  47. nickname = "IRCParser";
  48. username = "IRCParser";
  49. realname = "DMDIrc IRCParser";
  50. } else {
  51. nickname = result;
  52. username = nickname;
  53. realname = nickname + " - DMDIrc";
  54. }
  55. }
  56. /**
  57. * Set the Nickname.
  58. *
  59. * @param newValue Value to set to.
  60. */
  61. public void setNickname(final String newValue) {
  62. if (newValue != null && !newValue.isEmpty()) {
  63. nickname = newValue;
  64. }
  65. }
  66. /**
  67. * Get the Nickname.
  68. *
  69. * @return Current Nickname
  70. */
  71. public String getNickname() {
  72. return nickname;
  73. }
  74. /**
  75. * Set the Realname.
  76. *
  77. * @param newValue Value to set to.
  78. */
  79. public void setRealname(final String newValue) {
  80. if (newValue != null && !newValue.isEmpty()) {
  81. realname = newValue;
  82. }
  83. }
  84. /**
  85. * Get the Realname.
  86. *
  87. * @return Current Realname
  88. */
  89. public String getRealname() {
  90. return realname;
  91. }
  92. /**
  93. * Set the Username.
  94. *
  95. * @param newValue Value to set to.
  96. */
  97. public void setUsername(final String newValue) {
  98. if (newValue != null && !newValue.isEmpty()) {
  99. username = newValue;
  100. }
  101. }
  102. /**
  103. * Get the Username.
  104. *
  105. * @return Current Username
  106. */
  107. public String getUsername() {
  108. return username;
  109. }
  110. }