FileInfo.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /**
  2. * Copyright (C) 2008 Happy Fish / YuQing
  3. * <p>
  4. * FastDFS Java Client may be copied only under the terms of the GNU Lesser
  5. * General Public License (LGPL).
  6. * Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
  7. */
  8. package com.kmall.common.fileserver.fastdfs;
  9. import java.text.SimpleDateFormat;
  10. import java.util.Date;
  11. /**
  12. * Server Info
  13. *
  14. * @author Happy Fish / YuQing
  15. * @version Version 1.23
  16. */
  17. public class FileInfo {
  18. protected String source_ip_addr;
  19. protected long file_size;
  20. protected Date create_timestamp;
  21. protected int crc32;
  22. /**
  23. * Constructor
  24. *
  25. * @param file_size the file size
  26. * @param create_timestamp create timestamp in seconds
  27. * @param crc32 the crc32 signature
  28. * @param source_ip_addr the source storage ip address
  29. */
  30. public FileInfo(long file_size, int create_timestamp, int crc32, String source_ip_addr) {
  31. this.file_size = file_size;
  32. this.create_timestamp = new Date(create_timestamp * 1000L);
  33. this.crc32 = crc32;
  34. this.source_ip_addr = source_ip_addr;
  35. }
  36. /**
  37. * get the source ip address of the file uploaded to
  38. *
  39. * @return the source ip address of the file uploaded to
  40. */
  41. public String getSourceIpAddr() {
  42. return this.source_ip_addr;
  43. }
  44. /**
  45. * set the source ip address of the file uploaded to
  46. *
  47. * @param source_ip_addr the source ip address
  48. */
  49. public void setSourceIpAddr(String source_ip_addr) {
  50. this.source_ip_addr = source_ip_addr;
  51. }
  52. /**
  53. * get the file size
  54. *
  55. * @return the file size
  56. */
  57. public long getFileSize() {
  58. return this.file_size;
  59. }
  60. /**
  61. * set the file size
  62. *
  63. * @param file_size the file size
  64. */
  65. public void setFileSize(long file_size) {
  66. this.file_size = file_size;
  67. }
  68. /**
  69. * get the create timestamp of the file
  70. *
  71. * @return the create timestamp of the file
  72. */
  73. public Date getCreateTimestamp() {
  74. return this.create_timestamp;
  75. }
  76. /**
  77. * set the create timestamp of the file
  78. *
  79. * @param create_timestamp create timestamp in seconds
  80. */
  81. public void setCreateTimestamp(int create_timestamp) {
  82. this.create_timestamp = new Date(create_timestamp * 1000L);
  83. }
  84. /**
  85. * get the file CRC32 signature
  86. *
  87. * @return the file CRC32 signature
  88. */
  89. public long getCrc32() {
  90. return this.crc32;
  91. }
  92. /**
  93. * set the create timestamp of the file
  94. *
  95. * @param crc32 the crc32 signature
  96. */
  97. public void setCrc32(int crc32) {
  98. this.crc32 = crc32;
  99. }
  100. /**
  101. * to string
  102. *
  103. * @return string
  104. */
  105. public String toString() {
  106. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  107. return "source_ip_addr = " + this.source_ip_addr + ", " +
  108. "file_size = " + this.file_size + ", " +
  109. "create_timestamp = " + df.format(this.create_timestamp) + ", " +
  110. "crc32 = " + this.crc32;
  111. }
  112. }