    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one
    003 * or more contributor license agreements.  See the NOTICE file
    004 * distributed with this work for additional information
    005 * regarding copyright ownership.  The ASF licenses this file
    006 * to you under the Apache License, Version 2.0 (the
    007 * "License"); you may not use this file except in compliance
    008 * with the License.  You may obtain a copy of the License at
    009 *
    010 *   https://www.apache.org/licenses/LICENSE-2.0
    011 *
    012 * Unless required by applicable law or agreed to in writing,
    013 * software distributed under the License is distributed on an
    014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    015 * KIND, either express or implied.  See the License for the
    016 * specific language governing permissions and limitations
    017 * under the License.
    018 */
    019package org.apache.bcel.classfile;
    020
    021/**
    022 * Interface to make use of the Visitor pattern programming style. I.e. a class that implements this interface can
    023 * traverse the contents of a Java class just by calling the 'accept' method which all classes have.
    024 */
    025public interface Visitor {
    026
    027    /**
    028     * Visits an Annotations attribute.
    029     *
    030     * @param obj the attribute.
    031     * @since 6.0
    032     */
    033    void visitAnnotation(Annotations obj);
    034
    035    /**
    036     * Visits an AnnotationDefault attribute.
    037     *
    038     * @param obj the attribute.
    039     * @since 6.0
    040     */
    041    void visitAnnotationDefault(AnnotationDefault obj);
    042
    043    /**
    044     * Visits an AnnotationEntry.
    045     *
    046     * @param obj the annotation entry.
    047     * @since 6.0
    048     */
    049    void visitAnnotationEntry(AnnotationEntry obj);
    050
    051    /**
    052     * Visits a BootstrapMethods attribute.
    053     *
    054     * @param obj the attribute.
    055     * @since 6.0
    056     */
    057    void visitBootstrapMethods(BootstrapMethods obj);
    058
    059    /**
    060     * Visits a Code attribute.
    061     *
    062     * @param obj the attribute.
    063     */
    064    void visitCode(Code obj);
    065
    066    /**
    067     * Visits a CodeException.
    068     *
    069     * @param obj the exception.
    070     */
    071    void visitCodeException(CodeException obj);
    072
    073    /**
    074     * Visits a ConstantClass.
    075     *
    076     * @param obj the constant.
    077     */
    078    void visitConstantClass(ConstantClass obj);
    079
    080    /**
    081     * Visits a ConstantDouble.
    082     *
    083     * @param obj the constant.
    084     */
    085    void visitConstantDouble(ConstantDouble obj);
    086
    087    /**
    088     * Visits a ConstantDynamic.
    089     *
    090     * @param constantDynamic the constant.
    091     * @since 6.3
    092     */
    093    default void visitConstantDynamic(final ConstantDynamic constantDynamic) {
    094        // empty
    095    }
    096
    097    /**
    098     * Visits a ConstantFieldref.
    099     *
    100     * @param obj the constant.
    101     */
    102    void visitConstantFieldref(ConstantFieldref obj);
    103
    104    /**
    105     * Visits a ConstantFloat.
    106     *
    107     * @param obj the constant.
    108     */
    109    void visitConstantFloat(ConstantFloat obj);
    110
    111    /**
    112     * Visits a ConstantInteger.
    113     *
    114     * @param obj the constant.
    115     */
    116    void visitConstantInteger(ConstantInteger obj);
    117
    118    /**
    119     * Visits a ConstantInterfaceMethodref.
    120     *
    121     * @param obj the constant.
    122     */
    123    void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj);
    124
    125    /**
    126     * Visits a ConstantInvokeDynamic.
    127     *
    128     * @param obj the constant.
    129     */
    130    void visitConstantInvokeDynamic(ConstantInvokeDynamic obj);
    131
    132    /**
    133     * Visits a ConstantLong.
    134     *
    135     * @param obj the constant.
    136     */
    137    void visitConstantLong(ConstantLong obj);
    138
    139    /**
    140     * Visits a ConstantMethodHandle.
    141     *
    142     * @param obj the constant.
    143     * @since 6.0
    144     */
    145    void visitConstantMethodHandle(ConstantMethodHandle obj);
    146
    147    /**
    148     * Visits a ConstantMethodref.
    149     *
    150     * @param obj the constant.
    151     */
    152    void visitConstantMethodref(ConstantMethodref obj);
    153
    154    /**
    155     * Visits a ConstantMethodType.
    156     *
    157     * @param obj the constant.
    158     * @since 6.0
    159     */
    160    void visitConstantMethodType(ConstantMethodType obj);
    161
    162    /**
    163     * Visits a ConstantModule.
    164     *
    165     * @param constantModule the constant.
    166     * @since 6.1
    167     */
    168    void visitConstantModule(ConstantModule constantModule);
    169
    170    /**
    171     * Visits a ConstantNameAndType.
    172     *
    173     * @param obj the constant.
    174     */
    175    void visitConstantNameAndType(ConstantNameAndType obj);
    176
    177    /**
    178     * Visits a ConstantPackage.
    179     *
    180     * @param constantPackage the constant.
    181     * @since 6.1
    182     */
    183    void visitConstantPackage(ConstantPackage constantPackage);
    184
    185    /**
    186     * Visits a ConstantPool.
    187     *
    188     * @param obj the constant pool.
    189     */
    190    void visitConstantPool(ConstantPool obj);
    191
    192    /**
    193     * Visits a ConstantString.
    194     *
    195     * @param obj the constant.
    196     */
    197    void visitConstantString(ConstantString obj);
    198
    199    /**
    200     * Visits a ConstantUtf8.
    201     *
    202     * @param obj the constant.
    203     */
    204    void visitConstantUtf8(ConstantUtf8 obj);
    205
    206    /**
    207     * Visits a ConstantValue attribute.
    208     *
    209     * @param obj the attribute.
    210     */
    211    void visitConstantValue(ConstantValue obj);
    212
    213    /**
    214     * Visits a Deprecated attribute.
    215     *
    216     * @param obj the attribute.
    217     */
    218    void visitDeprecated(Deprecated obj);
    219
    220    /**
    221     * Visits an EnclosingMethod attribute.
    222     *
    223     * @param obj the attribute.
    224     * @since 6.0
    225     */
    226    void visitEnclosingMethod(EnclosingMethod obj);
    227
    228    /**
    229     * Visits an ExceptionTable attribute.
    230     *
    231     * @param obj the attribute.
    232     */
    233    void visitExceptionTable(ExceptionTable obj);
    234
    235    /**
    236     * Visits a Field.
    237     *
    238     * @param obj the field.
    239     */
    240    void visitField(Field obj);
    241
    242    /**
    243     * Visits an InnerClass.
    244     *
    245     * @param obj the inner class.
    246     */
    247    void visitInnerClass(InnerClass obj);
    248
    249    /**
    250     * Visits an InnerClasses attribute.
    251     *
    252     * @param obj the attribute.
    253     */
    254    void visitInnerClasses(InnerClasses obj);
    255
    256    /**
    257     * Visits a JavaClass.
    258     *
    259     * @param obj the class.
    260     */
    261    void visitJavaClass(JavaClass obj);
    262
    263    /**
    264     * Visits a LineNumber.
    265     *
    266     * @param obj the line number.
    267     */
    268    void visitLineNumber(LineNumber obj);
    269
    270    /**
    271     * Visits a LineNumberTable attribute.
    272     *
    273     * @param obj the attribute.
    274     */
    275    void visitLineNumberTable(LineNumberTable obj);
    276
    277    /**
    278     * Visits a LocalVariable.
    279     *
    280     * @param obj the local variable.
    281     */
    282    void visitLocalVariable(LocalVariable obj);
    283
    284    /**
    285     * Visits a LocalVariableTable attribute.
    286     *
    287     * @param obj the attribute.
    288     */
    289    void visitLocalVariableTable(LocalVariableTable obj);
    290
    291    /**
    292     * Visits a LocalVariableTypeTable attribute.
    293     *
    294     * @param obj the attribute.
    295     * @since 6.0
    296     */
    297    void visitLocalVariableTypeTable(LocalVariableTypeTable obj);
    298
    299    /**
    300     * Visits a Method.
    301     *
    302     * @param obj the method.
    303     */
    304    void visitMethod(Method obj);
    305
    306    /**
    307     * Visits a MethodParameter.
    308     *
    309     * @param obj the method parameter.
    310     * @since 6.4.0
    311     */
    312    default void visitMethodParameter(final MethodParameter obj) {
    313        // empty
    314    }
    315
    316    /**
    317     * Visits a MethodParameters attribute.
    318     *
    319     * @param obj the attribute.
    320     * @since 6.0
    321     */
    322    void visitMethodParameters(MethodParameters obj);
    323
    324    /**
    325     * Visits a Module attribute.
    326     *
    327     * @param constantModule the module.
    328     * @since 6.4.0
    329     */
    330    default void visitModule(final Module constantModule) {
    331        // empty
    332    }
    333
    334    /**
    335     * Visits a ModuleExports entry.
    336     *
    337     * @param constantModule the module exports.
    338     * @since 6.4.0
    339     */
    340    default void visitModuleExports(final ModuleExports constantModule) {
    341        // empty
    342    }
    343
    344    /**
    345     * Visits a ModuleMainClass attribute.
    346     *
    347     * @param obj the attribute.
    348     * @since 6.4.0
    349     */
    350    default void visitModuleMainClass(final ModuleMainClass obj) {
    351        // empty
    352    }
    353
    354    /**
    355     * Visits a ModuleOpens entry.
    356     *
    357     * @param constantModule the module opens.
    358     * @since 6.4.0
    359     */
    360    default void visitModuleOpens(final ModuleOpens constantModule) {
    361        // empty
    362    }
    363
    364    /**
    365     * Visits a ModulePackages attribute.
    366     *
    367     * @param constantModule the module packages.
    368     * @since 6.4.0
    369     */
    370    default void visitModulePackages(final ModulePackages constantModule) {
    371        // empty
    372    }
    373
    374    /**
    375     * Visits a ModuleProvides entry.
    376     *
    377     * @param constantModule the module provides.
    378     * @since 6.4.0
    379     */
    380    default void visitModuleProvides(final ModuleProvides constantModule) {
    381        // empty
    382    }
    383
    384    /**
    385     * Visits a ModuleRequires entry.
    386     *
    387     * @param constantModule the module requires.
    388     * @since 6.4.0
    389     */
    390    default void visitModuleRequires(final ModuleRequires constantModule) {
    391        // empty
    392    }
    393
    394    /**
    395     * Visits a NestHost attribute.
    396     *
    397     * @param obj the attribute.
    398     * @since 6.4.0
    399     */
    400    default void visitNestHost(final NestHost obj) {
    401        // empty
    402    }
    403
    404    /**
    405     * Visits a NestMembers attribute.
    406     *
    407     * @param obj the attribute.
    408     * @since 6.4.0
    409     */
    410    default void visitNestMembers(final NestMembers obj) {
    411        // empty
    412    }
    413
    414    /**
    415     * Visits a ParameterAnnotations attribute.
    416     *
    417     * @param obj the attribute.
    418     * @since 6.0
    419     */
    420    void visitParameterAnnotation(ParameterAnnotations obj);
    421
    422    /**
    423     * Visits a ParameterAnnotationEntry.
    424     *
    425     * @param obj the annotation entry.
    426     * @since 6.0
    427     */
    428    void visitParameterAnnotationEntry(ParameterAnnotationEntry obj);
    429
    430    /**
    431     * Visits a {@link Record} object.
    432     *
    433     * @param obj Record to visit.
    434     * @since 6.9.0
    435     */
    436    default void visitRecord(final Record obj) {
    437        // empty
    438    }
    439
    440    /**
    441     * Visits a {@link RecordComponentInfo} object.
    442     *
    443     * @param record component to visit.
    444     * @since 6.9.0
    445     */
    446    default void visitRecordComponent(final RecordComponentInfo record) {
    447     // noop
    448    }
    449
    450    /**
    451     * Visits a Signature attribute.
    452     *
    453     * @param obj the attribute.
    454     */
    455    void visitSignature(Signature obj);
    456
    457    /**
    458     * Visits a SourceFile attribute.
    459     *
    460     * @param obj the attribute.
    461     */
    462    void visitSourceFile(SourceFile obj);
    463
    464    /**
    465     * Visits a StackMap attribute.
    466     *
    467     * @param obj the attribute.
    468     */
    469    void visitStackMap(StackMap obj);
    470
    471    /**
    472     * Visits a StackMapEntry.
    473     *
    474     * @param obj the entry.
    475     */
    476    void visitStackMapEntry(StackMapEntry obj);
    477
    478    /**
    479     * Visits a {@link StackMapType} object.
    480     *
    481     * @param obj object to visit.
    482     * @since 6.8.0
    483     */
    484    default void visitStackMapType(final StackMapType obj) {
    485      // empty
    486    }
    487
    488    /**
    489     * Visits a Synthetic attribute.
    490     *
    491     * @param obj the attribute.
    492     */
    493    void visitSynthetic(Synthetic obj);
    494
    495    /**
    496     * Visits an Unknown attribute.
    497     *
    498     * @param obj the attribute.
    499     */
    500    void visitUnknown(Unknown obj);
    501
    502}