1 17 18 package org.alfresco.filesys.smb.server.repo.pseudo; 19 20 import java.util.ArrayList ; 21 import java.util.List ; 22 23 30 public class PseudoFileList 31 { 32 34 private List <PseudoFile> m_list; 35 36 39 public PseudoFileList() 40 { 41 m_list = new ArrayList <PseudoFile>(); 42 } 43 44 49 public final void addFile( PseudoFile pfile) 50 { 51 m_list.add( pfile); 52 } 53 54 59 public final int numberOfFiles() 60 { 61 return m_list.size(); 62 } 63 64 70 public final PseudoFile getFileAt(int idx) 71 { 72 if ( idx < m_list.size()) 73 return m_list.get(idx); 74 return null; 75 } 76 77 84 public final PseudoFile findFile( String fname, boolean caseSensitive) 85 { 86 88 if ( m_list == null || m_list.size() == 0) 89 return null; 90 91 93 for ( PseudoFile pfile : m_list) 94 { 95 if ( caseSensitive && pfile.getFileName().equals( fname)) 96 return pfile; 97 else if ( pfile.getFileName().equalsIgnoreCase( fname)) 98 return pfile; 99 } 100 101 103 return null; 104 } 105 106 113 public final PseudoFile removeFile( String fname, boolean caseSensitive) 114 { 115 117 if ( m_list == null || m_list.size() == 0) 118 return null; 119 120 122 for ( int idx = 0; idx < m_list.size(); idx++) 123 { 124 126 PseudoFile pfile = m_list.get( idx); 127 boolean match = false; 128 129 if ( caseSensitive && pfile.getFileName().equals( fname)) 130 match = true; 131 else if ( pfile.getFileName().equalsIgnoreCase( fname)) 132 match = true; 133 134 136 if ( match) 137 { 138 m_list.remove( idx); 139 return pfile; 140 } 141 } 142 143 145 return null; 146 } 147 } 148 | Popular Tags |