SearchContext.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * Copyright (C) 2006-2010 Alfresco Software Limited.
  3. *
  4. * This file is part of Alfresco
  5. *
  6. * Alfresco is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Alfresco is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package org.alfresco.jlan.client;
  20. import org.alfresco.jlan.client.info.FileInfo;
  21. import org.alfresco.jlan.smb.SMBException;
  22. /**
  23. * SMB search context class
  24. *
  25. * <p>
  26. * Holds the details of an in progress folder search on a remote file server.
  27. *
  28. * <p>
  29. * For large folder listings the search will be split up over a number of SMB/CIFS requests. The
  30. * SearchContext derived class is used to hold the search state between requests to the remote file
  31. * server.
  32. *
  33. * @author gkspencer
  34. */
  35. public abstract class SearchContext {
  36. // Disk session that this search is associated with
  37. private DiskSession m_sess;
  38. // Directory/file name to search for.
  39. private String m_dir;
  40. // Search file attributes
  41. private int m_attr;
  42. // Information level to be returned
  43. private int m_level;
  44. /**
  45. * Class constructor
  46. *
  47. * @param sess Disk session that the search is associated with
  48. */
  49. protected SearchContext(DiskSession sess) {
  50. m_sess = sess;
  51. }
  52. /**
  53. * Return the next file in this search as an SMB file information object.
  54. *
  55. * @return FileInfo object, or null if there are no more files.
  56. * @exception java.io.IOException If an I/O error occurs.
  57. * @exception SMBException If an SMB level error occurs
  58. */
  59. public abstract FileInfo nextFileInfo()
  60. throws java.io.IOException, SMBException;
  61. /**
  62. * Return the next file name in this search.
  63. *
  64. * @return Next file name string, or null if there are no more files.
  65. * @exception java.io.IOException If an I/O error occurs.
  66. * @exception SMBException If an SMB level error occurs
  67. */
  68. public abstract String nextFileName()
  69. throws java.io.IOException, SMBException;
  70. /**
  71. * Start a new search using the specified file name string and search attributes, return the
  72. * specified file information level
  73. *
  74. * @param fname File name string, may contain wilcards.
  75. * @param attr File attributes bit mask. @see org.alfresco.jlan.server.filesys.FileAttribute
  76. * @param level File information level to return. @see org.alfresco.jlan.smb.FileInfoLevel
  77. * @exception java.io.IOException If an I/O error occurs.
  78. * @exception SMBException If an SMB level error occurs
  79. */
  80. public abstract void StartSearch(String fname, int attr, int level)
  81. throws java.io.IOException, SMBException;
  82. /**
  83. * Return the associated disk session
  84. *
  85. * @return DiskSession
  86. */
  87. protected final DiskSession getSession() {
  88. return m_sess;
  89. }
  90. /**
  91. * Return the search path
  92. *
  93. * @return String
  94. */
  95. protected final String getSearchPath() {
  96. return m_dir;
  97. }
  98. /**
  99. * Return the search attributes
  100. *
  101. * @return int
  102. */
  103. protected final int getSearchAttributes() {
  104. return m_attr;
  105. }
  106. /**
  107. * Return the required information level
  108. *
  109. * @return int
  110. */
  111. protected final int getInformationLevel() {
  112. return m_level;
  113. }
  114. /**
  115. * Set the search path
  116. *
  117. * @param path String
  118. */
  119. protected final void setSearchPath(String path) {
  120. m_dir = path;
  121. }
  122. /**
  123. * Set the search attributes
  124. *
  125. * @param attr int
  126. */
  127. protected final void setSearchAttributes(int attr) {
  128. m_attr = attr;
  129. }
  130. /**
  131. * Set the information level
  132. *
  133. * @param level int
  134. */
  135. protected final void setInformationLevel(int level) {
  136. m_level = level;
  137. }
  138. /**
  139. * Set the search parameters
  140. *
  141. * @param path String
  142. * @param attr int
  143. * @param level int
  144. */
  145. protected final void setSearchParameters(String path, int attr, int level) {
  146. m_dir = path;
  147. m_attr = attr;
  148. m_level = level;
  149. }
  150. }