1 17 package org.alfresco.filesys.smb.server.notify; 18 19 import org.alfresco.filesys.server.filesys.NotifyChange; 20 21 26 public class NotifyChangeEvent 27 { 28 29 31 private int m_action; 32 private int m_filter; 33 34 36 private String m_fileName; 37 38 40 private boolean m_dir; 41 42 44 private String m_oldName; 45 46 54 public NotifyChangeEvent(int filter, int action, String fname, boolean dir) 55 { 56 m_filter = filter; 57 m_action = action; 58 m_fileName = fname; 59 m_dir = dir; 60 61 63 if (m_fileName.indexOf('/') != -1) 64 m_fileName.replace('/', '\\'); 65 } 66 67 76 public NotifyChangeEvent(int filter, int action, String fname, String oldname, boolean dir) 77 { 78 m_filter = filter; 79 m_action = action; 80 m_fileName = fname; 81 m_oldName = oldname; 82 m_dir = dir; 83 84 86 if (m_fileName.indexOf('/') != -1) 87 m_fileName.replace('/', '\\'); 88 89 if (m_oldName.indexOf('/') != -1) 90 m_oldName.replace('/', '\\'); 91 } 92 93 98 public final int getFilter() 99 { 100 return m_filter; 101 } 102 103 108 public final int getAction() 109 { 110 return m_action; 111 } 112 113 118 public final String getFileName() 119 { 120 return m_fileName; 121 } 122 123 128 public final String getShortFileName() 129 { 130 131 133 int pos = m_fileName.lastIndexOf("\\"); 134 if (pos != -1) 135 return m_fileName.substring(pos + 1); 136 return m_fileName; 137 } 138 139 144 public final String getOldFileName() 145 { 146 return m_oldName; 147 } 148 149 154 public final String getShortOldFileName() 155 { 156 157 159 if (m_oldName == null) 160 return null; 161 162 164 int pos = m_oldName.lastIndexOf("\\"); 165 if (pos != -1) 166 return m_oldName.substring(pos + 1); 167 return m_oldName; 168 } 169 170 175 public final boolean hasOldFileName() 176 { 177 return m_oldName != null ? true : false; 178 } 179 180 185 public final boolean isDirectory() 186 { 187 return m_dir; 188 } 189 190 195 public String toString() 196 { 197 StringBuffer str = new StringBuffer (); 198 199 str.append("["); 200 str.append(NotifyChange.getFilterAsString(getFilter())); 201 str.append("-"); 202 str.append(NotifyChange.getActionAsString(getAction())); 203 str.append(":"); 204 str.append(getFileName()); 205 206 if (isDirectory()) 207 str.append(",DIR"); 208 209 if (hasOldFileName()) 210 { 211 str.append(",Old="); 212 str.append(getOldFileName()); 213 } 214 215 str.append("]"); 216 217 return str.toString(); 218 } 219 } 220 | Popular Tags |