KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jcifs > smb > DosFileFilter


1 /* jcifs smb client library in Java
2  * Copyright (C) 2003 "Michael B. Allen" <jcifs at samba dot org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package jcifs.smb;
20
21 public class DosFileFilter implements SmbFileFilter {
22
23     protected String JavaDoc wildcard;
24     protected int attributes;
25
26 /* This filter can be considerably more efficient than other file filters
27  * as the specifed wildcard and attributes are passed to the server for
28  * filtering there (although attributes are largely ignored by servers
29  * they are filtered locally by the default accept method).
30  */

31     public DosFileFilter( String JavaDoc wildcard, int attributes ) {
32         this.wildcard = wildcard;
33         this.attributes = attributes;
34     }
35
36 /* This returns true if the file's attributes contain any of the attributes
37  * specified for this filter. The wildcard has no influence on this
38  * method as the server should have performed that filtering already. The
39  * attributes are asserted here only because server file systems may not
40  * support filtering by all attributes (e.g. even though ATTR_DIRECTORY was
41  * specified the server may still return objects that are not directories).
42  */

43     public boolean accept( SmbFile file ) throws SmbException {
44         return (file.getAttributes() & attributes) != 0;
45     }
46 }
47
Popular Tags