in src/main/java/org/apache/commons/compress/harmony/pack200/AttributeDefinitionBands.java [83:142]
public AttributeDefinitionBands(final Segment segment, final int effort, final Attribute[] attributePrototypes) {
super(effort, segment.getSegmentHeader());
this.cpBands = segment.getCpBands();
this.segment = segment;
final Map<String, String> classLayouts = new HashMap<>();
final Map<String, String> methodLayouts = new HashMap<>();
final Map<String, String> fieldLayouts = new HashMap<>();
final Map<String, String> codeLayouts = new HashMap<>();
for (final Attribute attributePrototype : attributePrototypes) {
final NewAttribute newAttribute = (NewAttribute) attributePrototype;
if (!(newAttribute instanceof NewAttribute.ErrorAttribute) && !(newAttribute instanceof NewAttribute.PassAttribute)
&& !(newAttribute instanceof NewAttribute.StripAttribute)) {
if (newAttribute.isContextClass()) {
classLayouts.put(newAttribute.type, newAttribute.getLayout());
}
if (newAttribute.isContextMethod()) {
methodLayouts.put(newAttribute.type, newAttribute.getLayout());
}
if (newAttribute.isContextField()) {
fieldLayouts.put(newAttribute.type, newAttribute.getLayout());
}
if (newAttribute.isContextCode()) {
codeLayouts.put(newAttribute.type, newAttribute.getLayout());
}
}
}
if (classLayouts.size() > 7) {
segmentHeader.setHave_class_flags_hi(true);
}
if (methodLayouts.size() > 6) {
segmentHeader.setHave_method_flags_hi(true);
}
if (fieldLayouts.size() > 10) {
segmentHeader.setHave_field_flags_hi(true);
}
if (codeLayouts.size() > 15) {
segmentHeader.setHave_code_flags_hi(true);
}
int[] availableClassIndices = { 25, 26, 27, 28, 29, 30, 31 };
if (classLayouts.size() > 7) {
availableClassIndices = addHighIndices(availableClassIndices);
}
addAttributeDefinitions(classLayouts, availableClassIndices, CONTEXT_CLASS);
int[] availableMethodIndices = { 26, 27, 28, 29, 30, 31 };
if (methodAttributeLayouts.size() > 6) {
availableMethodIndices = addHighIndices(availableMethodIndices);
}
addAttributeDefinitions(methodLayouts, availableMethodIndices, CONTEXT_METHOD);
int[] availableFieldIndices = { 18, 23, 24, 25, 26, 27, 28, 29, 30, 31 };
if (fieldAttributeLayouts.size() > 10) {
availableFieldIndices = addHighIndices(availableFieldIndices);
}
addAttributeDefinitions(fieldLayouts, availableFieldIndices, CONTEXT_FIELD);
int[] availableCodeIndices = { 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 };
if (codeAttributeLayouts.size() > 15) {
availableCodeIndices = addHighIndices(availableCodeIndices);
}
addAttributeDefinitions(codeLayouts, availableCodeIndices, CONTEXT_CODE);
}