1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.compress.harmony.unpack200;
18
19 import org.apache.commons.compress.harmony.pack200.Pack200Exception;
20
21
22
23
24
25
26 public class SegmentOptions {
27
28 private static final int DEFLATE_HINT = 1 << 5;
29
30 private static final int HAVE_ALL_CODE_FLAGS = 1 << 2;
31
32 private static final int HAVE_CLASS_FLAGS_HI = 1 << 9;
33
34
35
36 private static final int HAVE_CODE_FLAGS_HI = 1 << 10;
37
38 private static final int HAVE_CP_NUMBERS = 1 << 1;
39
40 private static final int HAVE_FIELD_FLAGS_HI = 1 << 10;
41
42 private static final int HAVE_FILE_HEADERS = 1 << 4;
43
44 private static final int HAVE_FILE_MODTIME = 1 << 6;
45
46 private static final int HAVE_FILE_OPTIONS = 1 << 7;
47
48 private static final int HAVE_FILE_SIZE_HI = 1 << 8;
49
50 private static final int HAVE_METHOD_FLAGS_HI = 1 << 11;
51
52 private static final int HAVE_SPECIAL_FORMATS = 1 << 0;
53
54
55
56
57 private static final int UNUSED = -1 << 13 | 1 << 3;
58
59 private final int options;
60
61
62
63
64
65
66
67 public SegmentOptions(final int options) throws Pack200Exception {
68 if ((options & UNUSED) != 0) {
69 throw new Pack200Exception("Some unused flags are non-zero");
70 }
71 this.options = options;
72 }
73
74 public boolean hasAllCodeFlags() {
75 return (options & HAVE_ALL_CODE_FLAGS) != 0;
76 }
77
78 public boolean hasArchiveFileCounts() {
79 return (options & HAVE_FILE_HEADERS) != 0;
80 }
81
82 public boolean hasClassFlagsHi() {
83 return (options & HAVE_CLASS_FLAGS_HI) != 0;
84 }
85
86 public boolean hasCodeFlagsHi() {
87 return (options & HAVE_CODE_FLAGS_HI) != 0;
88 }
89
90 public boolean hasCPNumberCounts() {
91 return (options & HAVE_CP_NUMBERS) != 0;
92 }
93
94 public boolean hasFieldFlagsHi() {
95 return (options & HAVE_FIELD_FLAGS_HI) != 0;
96 }
97
98 public boolean hasFileModtime() {
99 return (options & HAVE_FILE_MODTIME) != 0;
100 }
101
102 public boolean hasFileOptions() {
103 return (options & HAVE_FILE_OPTIONS) != 0;
104 }
105
106 public boolean hasFileSizeHi() {
107 return (options & HAVE_FILE_SIZE_HI) != 0;
108 }
109
110 public boolean hasMethodFlagsHi() {
111 return (options & HAVE_METHOD_FLAGS_HI) != 0;
112 }
113
114 public boolean hasSpecialFormats() {
115 return (options & HAVE_SPECIAL_FORMATS) != 0;
116 }
117
118 public boolean shouldDeflate() {
119 return (options & DEFLATE_HINT) != 0;
120 }
121 }