Debian Codegraph @

src/org/apache/commons/compress/harmony/unpack200/bytecode/AnnotationDefaultAttribute.java

raw symbols SCIP
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * https://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
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 * AnnotationDefault class file attribute
28 */
29 public class AnnotationDefaultAttribute extends AnnotationsAttribute {
30
31 private static CPUTF8 attributeName;
32
33 /**
34 * Sets the attribute name.
35 *
36 * @param cpUTF8Value the attribute name.
37 */
38 public static void setAttributeName(final CPUTF8 cpUTF8Value) {
39 attributeName = cpUTF8Value;
40 }
41
42 private final ElementValue elementValue;
43
44 /**
45 * Constructs a new instance.
46 *
47 * @param elementValue element value to track.
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 }