jaxp/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/AnnotationElementValue.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.DataOutputStream;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    25
import java.io.IOException;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    26
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
 * @since 6.0
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    29
 */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    30
public class AnnotationElementValue extends ElementValue
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    31
{
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    32
        // For annotation element values, this is the annotation
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    33
        private final AnnotationEntry annotationEntry;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    34
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    35
        public AnnotationElementValue(final int type, final AnnotationEntry annotationEntry,
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    36
                        final ConstantPool cpool)
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    37
        {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    38
                super(type, cpool);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    39
                if (type != ANNOTATION) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    40
                    throw new RuntimeException(
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    41
                                    "Only element values of type annotation can be built with this ctor - type specified: " + type);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    42
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    43
                this.annotationEntry = annotationEntry;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    44
        }
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
        @Override
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    47
        public void dump(final DataOutputStream dos) throws IOException
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    48
        {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    49
                dos.writeByte(super.getType()); // u1 type of value (ANNOTATION == '@')
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    50
                annotationEntry.dump(dos);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    51
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    52
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    53
        @Override
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    54
        public String stringifyValue()
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
                return annotationEntry.toString();
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
        @Override
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    60
        public String toString()
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    61
        {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    62
                return stringifyValue();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    63
        }
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 AnnotationEntry getAnnotationEntry()
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    66
        {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    67
                return annotationEntry;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    68
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents:
diff changeset
    69
}