jaxp/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ParameterAnnotations.java
author joehw
Sun, 13 Aug 2017 21:10:40 -0700
changeset 46174 5611d2529b49
permissions -rw-r--r--
8163121: BCEL: update to the latest 6.0 release Reviewed-by: dfuchs, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
     1
/*
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
     2
 * reserved comment block
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
     4
 */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
     5
/*
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
     6
 * Licensed to the Apache Software Foundation (ASF) under one or more
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
     7
 * contributor license agreements.  See the NOTICE file distributed with
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
     8
 * this work for additional information regarding copyright ownership.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
     9
 * The ASF licenses this file to You under the Apache License, Version 2.0
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    10
 * (the "License"); you may not use this file except in compliance with
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    11
 * the License.  You may obtain a copy of the License at
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    12
 *
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    13
 *      http://www.apache.org/licenses/LICENSE-2.0
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    14
 *
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    15
 * Unless required by applicable law or agreed to in writing, software
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    16
 * distributed under the License is distributed on an "AS IS" BASIS,
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    18
 * See the License for the specific language governing permissions and
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    19
 * limitations under the License.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    20
 */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    21
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    22
package com.sun.org.apache.bcel.internal.classfile;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    23
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    24
import java.io.DataInput;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    25
import java.io.DataOutputStream;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    26
import java.io.IOException;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    27
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    28
/**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    29
 * base class for parameter annotations
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    30
 *
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    31
 * @version $Id: ParameterAnnotations
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    32
 * @since 6.0
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    33
 */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    34
public abstract class ParameterAnnotations extends Attribute {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    35
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    36
    /** Table of parameter annotations */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    37
    private ParameterAnnotationEntry[] parameter_annotation_table;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    38
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    39
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    40
     * @param parameter_annotation_type the subclass type of the parameter annotation
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    41
     * @param name_index Index pointing to the name <em>Code</em>
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    42
     * @param length Content length in bytes
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    43
     * @param input Input stream
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    44
     * @param constant_pool Array of constants
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    45
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    46
    ParameterAnnotations(final byte parameter_annotation_type, final int name_index, final int length,
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    47
            final DataInput input, final ConstantPool constant_pool) throws IOException {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    48
        this(parameter_annotation_type, name_index, length, (ParameterAnnotationEntry[]) null,
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    49
                constant_pool);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    50
        final int num_parameters = input.readUnsignedByte();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    51
        parameter_annotation_table = new ParameterAnnotationEntry[num_parameters];
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    52
        for (int i = 0; i < num_parameters; i++) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    53
            parameter_annotation_table[i] = new ParameterAnnotationEntry(input, constant_pool);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    54
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    55
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    56
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    57
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    58
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    59
     * @param parameter_annotation_type the subclass type of the parameter annotation
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    60
     * @param name_index Index pointing to the name <em>Code</em>
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    61
     * @param length Content length in bytes
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    62
     * @param parameter_annotation_table the actual parameter annotations
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    63
     * @param constant_pool Array of constants
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    64
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    65
    public ParameterAnnotations(final byte parameter_annotation_type, final int name_index, final int length,
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    66
            final ParameterAnnotationEntry[] parameter_annotation_table, final ConstantPool constant_pool) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    67
        super(parameter_annotation_type, name_index, length, constant_pool);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    68
        this.parameter_annotation_table = parameter_annotation_table;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    69
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    70
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    71
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    72
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    73
     * Called by objects that are traversing the nodes of the tree implicitely
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    74
     * defined by the contents of a Java class. I.e., the hierarchy of methods,
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    75
     * fields, attributes, etc. spawns a tree of objects.
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    76
     *
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    77
     * @param v Visitor object
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    78
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    79
    @Override
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    80
    public void accept( final Visitor v ) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    81
        v.visitParameterAnnotation(this);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    82
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    83
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    84
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    85
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    86
     * @param parameter_annotation_table the entries to set in this parameter annotation
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    87
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    88
    public final void setParameterAnnotationTable(final ParameterAnnotationEntry[] parameter_annotation_table ) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    89
        this.parameter_annotation_table = parameter_annotation_table;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    90
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    91
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    92
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    93
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    94
     * @return the parameter annotation entry table
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    95
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    96
    public final ParameterAnnotationEntry[] getParameterAnnotationTable() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    97
        return parameter_annotation_table;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    98
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    99
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   100
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   101
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   102
     * returns the array of parameter annotation entries in this parameter annotation
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   103
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   104
    public ParameterAnnotationEntry[] getParameterAnnotationEntries() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   105
        return parameter_annotation_table;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   106
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   107
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   108
    @Override
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   109
    public void dump(final DataOutputStream dos) throws IOException
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   110
    {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   111
        super.dump(dos);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   112
        dos.writeByte(parameter_annotation_table.length);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   113
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   114
        for (final ParameterAnnotationEntry element : parameter_annotation_table) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   115
            element.dump(dos);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   116
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   117
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   118
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   119
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   120
    /**
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   121
     * @return deep copy of this attribute
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   122
     */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   123
    @Override
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   124
    public Attribute copy( final ConstantPool constant_pool ) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   125
        return (Attribute) clone();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   126
    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
   127
}