| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
package org.apache.commons.compress.harmony.unpack200.bytecode; |
| 20 |
|
| 21 |
import java.io.DataOutputStream; |
| 22 |
import java.io.IOException; |
| 23 |
import java.util.ArrayList; |
| 24 |
import java.util.List; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
public class AnnotationDefaultAttribute extends AnnotationsAttribute { |
| 30 |
|
| 31 |
private static CPUTF8 attributeName; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
public static void setAttributeName(final CPUTF8 cpUTF8Value) { |
| 39 |
attributeName = cpUTF8Value; |
| 40 |
} |
| 41 |
|
| 42 |
private final ElementValue elementValue; |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
public AnnotationDefaultAttribute(final ElementValue elementValue) { |
| 50 |
super(attributeName); |
| 51 |
this.elementValue = elementValue; |
| 52 |
} |
| 53 |
|
| 54 |
@Override |
| 55 |
public boolean equals(final Object obj) { |
| 56 |
return this == obj; |
| 57 |
} |
| 58 |
|
| 59 |
@Override |
| 60 |
protected int getLength() { |
| 61 |
return elementValue.getLength(); |
| 62 |
} |
| 63 |
|
| 64 |
@Override |
| 65 |
protected ClassFileEntry[] getNestedClassFileEntries() { |
| 66 |
final List<Object> nested = new ArrayList<>(); |
| 67 |
nested.add(attributeName); |
| 68 |
nested.addAll(elementValue.getClassFileEntries()); |
| 69 |
final ClassFileEntry[] nestedEntries = new ClassFileEntry[nested.size()]; |
| 70 |
for (int i = 0; i < nestedEntries.length; i++) { |
| 71 |
nestedEntries[i] = (ClassFileEntry) nested.get(i); |
| 72 |
} |
| 73 |
return nestedEntries; |
| 74 |
} |
| 75 |
|
| 76 |
@Override |
| 77 |
protected void resolve(final ClassConstantPool pool) { |
| 78 |
super.resolve(pool); |
| 79 |
elementValue.resolve(pool); |
| 80 |
} |
| 81 |
|
| 82 |
@Override |
| 83 |
public String toString() { |
| 84 |
return "AnnotationDefault: " + elementValue; |
| 85 |
} |
| 86 |
|
| 87 |
@Override |
| 88 |
protected void writeBody(final DataOutputStream dos) throws IOException { |
| 89 |
elementValue.writeBody(dos); |
| 90 |
} |
| 91 |
|
| 92 |
} |