KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > filesys > server > filesys > FileAttribute


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.filesys.server.filesys;
18
19 /**
20  * SMB file attribute class.
21  * <p>
22  * Defines various bit masks that may be returned in an FileInfo object, that is returned by the
23  * DiskInterface.getFileInformation () and SearchContext.nextFileInfo() methods.
24  * <p>
25  * The values are also used by the DiskInterface.StartSearch () method to determine the
26  * file/directory types that are returned.
27  *
28  * @see DiskInterface
29  * @see SearchContext
30  */

31 public final class FileAttribute
32 {
33
34     // Standard file attribute constants
35

36     public static final int Normal = 0x00;
37     public static final int ReadOnly = 0x01;
38     public static final int Hidden = 0x02;
39     public static final int System = 0x04;
40     public static final int Volume = 0x08;
41     public static final int Directory = 0x10;
42     public static final int Archive = 0x20;
43
44     // NT file attribute flags
45

46     public static final int NTReadOnly = 0x00000001;
47     public static final int NTHidden = 0x00000002;
48     public static final int NTSystem = 0x00000004;
49     public static final int NTVolumeId = 0x00000008;
50     public static final int NTDirectory = 0x00000010;
51     public static final int NTArchive = 0x00000020;
52     public static final int NTDevice = 0x00000040;
53     public static final int NTNormal = 0x00000080;
54     public static final int NTTemporary = 0x00000100;
55     public static final int NTSparse = 0x00000200;
56     public static final int NTReparsePoint = 0x00000400;
57     public static final int NTCompressed = 0x00000800;
58     public static final int NTOffline = 0x00001000;
59     public static final int NTIndexed = 0x00002000;
60     public static final int NTEncrypted = 0x00004000;
61     public static final int NTOpenNoRecall = 0x00100000;
62     public static final int NTOpenReparsePoint = 0x00200000;
63     public static final int NTPosixSemantics = 0x01000000;
64     public static final int NTBackupSemantics = 0x02000000;
65     public static final int NTDeleteOnClose = 0x04000000;
66     public static final int NTSequentialScan = 0x08000000;
67     public static final int NTRandomAccess = 0x10000000;
68     public static final int NTNoBuffering = 0x20000000;
69     public static final int NTOverlapped = 0x40000000;
70     public static final int NTWriteThrough = 0x80000000;
71
72     /**
73      * Determine if the specified file attribute mask has the specified file attribute enabled.
74      *
75      * @return boolean
76      * @param attr int
77      * @param reqattr int
78      */

79     public final static boolean hasAttribute(int attr, int reqattr)
80     {
81
82         // Check for the specified attribute
83

84         if ((attr & reqattr) != 0)
85             return true;
86         return false;
87     }
88
89     /**
90      * Check if the read-only attribute is set
91      *
92      * @param attr int
93      * @return boolean
94      */

95     public static final boolean isReadOnly(int attr)
96     {
97         return (attr & ReadOnly) != 0 ? true : false;
98     }
99
100     /**
101      * Check if the directory attribute is set
102      *
103      * @param attr int
104      * @return boolean
105      */

106     public static final boolean isDirectory(int attr)
107     {
108         return (attr & Directory) != 0 ? true : false;
109     }
110
111     /**
112      * Check if the hidden attribute is set
113      *
114      * @param attr int
115      * @return boolean
116      */

117     public static final boolean isHidden(int attr)
118     {
119         return (attr & Hidden) != 0 ? true : false;
120     }
121
122     /**
123      * Check if the system attribute is set
124      *
125      * @param attr int
126      * @return boolean
127      */

128     public static final boolean isSystem(int attr)
129     {
130         return (attr & System) != 0 ? true : false;
131     }
132
133     /**
134      * Check if the archive attribute is set
135      *
136      * @param attr int
137      * @return boolean
138      */

139     public static final boolean isArchived(int attr)
140     {
141         return (attr & Archive) != 0 ? true : false;
142     }
143 }
Popular Tags