Options.java
3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.internal.xmp.options;
import com.adobe.internal.xmp.XMPException;
import java.util.HashMap;
import java.util.Map;
public abstract class Options {
private int options = 0;
private Map optionNames = null;
public Options() {
}
public Options(int options) throws XMPException {
this.assertOptionsValid(options);
this.setOptions(options);
}
public void clear() {
this.options = 0;
}
public boolean isExactly(int optionBits) {
return this.getOptions() == optionBits;
}
public boolean containsAllOptions(int optionBits) {
return (this.getOptions() & optionBits) == optionBits;
}
public boolean containsOneOf(int optionBits) {
return (this.getOptions() & optionBits) != 0;
}
protected boolean getOption(int optionBit) {
return (this.options & optionBit) != 0;
}
public void setOption(int optionBits, boolean value) {
this.options = value ? this.options | optionBits : this.options & ~ optionBits;
}
public int getOptions() {
return this.options;
}
public void setOptions(int options) throws XMPException {
this.assertOptionsValid(options);
this.options = options;
}
public boolean equals(Object obj) {
return this.getOptions() == ((Options)obj).getOptions();
}
public int hashCode() {
return this.getOptions();
}
public String getOptionsString() {
if (this.options != 0) {
StringBuffer sb = new StringBuffer();
int theBits = this.options;
while (theBits != 0) {
int oneLessBit = theBits & theBits - 1;
int singleBit = theBits ^ oneLessBit;
String bitName = this.getOptionName(singleBit);
sb.append(bitName);
if (oneLessBit != 0) {
sb.append(" | ");
}
theBits = oneLessBit;
}
return sb.toString();
}
return "<none>";
}
public String toString() {
return "0x" + Integer.toHexString(this.options);
}
protected abstract int getValidOptions();
protected abstract String defineOptionName(int var1);
protected void assertConsistency(int options) throws XMPException {
}
private void assertOptionsValid(int options) throws XMPException {
int invalidOptions = options & ~ this.getValidOptions();
if (invalidOptions != 0) {
throw new XMPException("The option bit(s) 0x" + Integer.toHexString(invalidOptions) + " are invalid!", 103);
}
this.assertConsistency(options);
}
private String getOptionName(int option) {
Integer key;
Map optionsNames = this.procureOptionNames();
String result = (String)optionsNames.get(key = new Integer(option));
if (result == null) {
result = this.defineOptionName(option);
if (result != null) {
optionsNames.put(key, result);
} else {
result = "<option name not defined>";
}
}
return result;
}
private Map procureOptionNames() {
if (this.optionNames == null) {
this.optionNames = new HashMap<K, V>();
}
return this.optionNames;
}
}