jaulib
v1.3.6
Jau Support Library (C++, Java, ..)
Loading...
Searching...
No Matches
java_jni
org
jau
fs
UnmountFlags.java
Go to the documentation of this file.
1
/**
2
* Author: Sven Gothel <sgothel@jausoft.com>
3
* Copyright (c) 2022 Gothel Software e.K.
4
*
5
* Permission is hereby granted, free of charge, to any person obtaining
6
* a copy of this software and associated documentation files (the
7
* "Software"), to deal in the Software without restriction, including
8
* without limitation the rights to use, copy, modify, merge, publish,
9
* distribute, sublicense, and/or sell copies of the Software, and to
10
* permit persons to whom the Software is furnished to do so, subject to
11
* the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be
14
* included in all copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
*/
24
package
org.jau.fs;
25
26
/**
27
* Generic flag bit class for umount() `flags`
28
*
29
* See umount(2) for a detailed description.
30
*
31
* @see FileUtil#umount(long, int)
32
* @see FileUtil#umount(String, int)
33
*/
34
public
class
UnmountFlags
{
35
36
public
static
interface
Bit
{
37
String
name
();
38
int
value
();
39
}
40
public
static
enum
Bit0
implements
Bit
{
41
none
( 0 );
42
43
Bit0
(
final
int
v) { _value = v; }
44
private
int
_value;
45
46
@Override
47
public
int
value
() {
return
_value; }
48
}
49
protected
Bit
[]
bit_values
() {
return
Bit0
.values(); }
50
51
private
int
mask;
52
53
public
int
value
() {
return
mask; }
54
55
protected
UnmountFlags
(
final
int
v) {
56
mask = v;
57
}
58
public
UnmountFlags
() {
59
mask = 0;
60
}
61
62
public
boolean
isSet
(
final
Bit
bit) {
return
bit.
value
() == ( mask & bit.
value
() ); }
63
64
public
UnmountFlags
set
(
final
Bit
bit) { mask = mask | bit.value();
return
this
; }
65
66
@Override
67
public
String
toString
() {
68
int
count = 0;
69
final
StringBuilder out =
new
StringBuilder();
70
for
(
final
Bit
dt :
bit_values
()) {
71
if
( 0 != dt.value() &&
isSet
(dt) ) {
72
if
( 0 < count ) { out.append(
", "
); }
73
out.append(dt.name()); count++;
74
}
75
}
76
if
( 1 < count ) {
77
out.insert(0,
"["
);
78
out.append(
"]"
);
79
}
80
return
out.toString();
81
}
82
83
@Override
84
public
boolean
equals
(
final
Object other) {
85
if
(
this
== other) {
86
return
true
;
87
}
88
return
(other instanceof
UnmountFlags
) &&
89
this.mask == ((
UnmountFlags
)other).mask;
90
}
91
}
org.jau.fs.UnmountFlags.UnmountFlags
UnmountFlags()
Definition
UnmountFlags.java:58
org.jau.fs.UnmountFlags.toString
String toString()
Definition
UnmountFlags.java:67
org.jau.fs.UnmountFlags.equals
boolean equals(final Object other)
Definition
UnmountFlags.java:84
org.jau.fs.UnmountFlags.bit_values
Bit[] bit_values()
Definition
UnmountFlags.java:49
org.jau.fs.UnmountFlags.value
int value()
Definition
UnmountFlags.java:53
org.jau.fs.UnmountFlags.UnmountFlags
UnmountFlags(final int v)
Definition
UnmountFlags.java:55
org.jau.fs.UnmountFlags.isSet
boolean isSet(final Bit bit)
Definition
UnmountFlags.java:62
org.jau.fs.UnmountFlags.Bit0
Definition
UnmountFlags.java:40
org.jau.fs.UnmountFlags.Bit0.none
none
Definition
UnmountFlags.java:41
org.jau.fs.UnmountFlags.Bit0.Bit0
Bit0(final int v)
Definition
UnmountFlags.java:43
org.jau.fs.UnmountFlags.Bit0.value
int value()
Definition
UnmountFlags.java:47
org.jau.fs.UnmountFlags.Bit
Definition
UnmountFlags.java:36
org.jau.fs.UnmountFlags.Bit.name
String name()
org.jau.fs.UnmountFlags.Bit.value
int value()
Generated on Tue Feb 18 2025 00:30:40 for jaulib by
1.13.2