001package org.apache.maven.tools.plugin.extractor.annotations.scanner.visitors;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.util.HashMap;
023import java.util.Map;
024
025import org.codehaus.plexus.logging.Logger;
026import org.objectweb.asm.AnnotationVisitor;
027import org.objectweb.asm.Opcodes;
028
029/**
030 * @author Olivier Lamy
031 * @since 3.0
032 */
033public class MojoAnnotationVisitor
034    extends AnnotationVisitor
035{
036    private Logger logger;
037
038    private String annotationClassName;
039
040    private Map<String, Object> annotationValues = new HashMap<String, Object>();
041
042    MojoAnnotationVisitor( Logger logger, String annotationClassName )
043    {
044        super( Opcodes.ASM5 );
045        this.logger = logger;
046        this.annotationClassName = annotationClassName;
047    }
048
049    public Map<String, Object> getAnnotationValues()
050    {
051        return annotationValues;
052    }
053
054    public void visit( String name, Object value )
055    {
056        annotationValues.put( name, value );
057    }
058
059    public void visitEnum( String name, String desc, String value )
060    {
061        annotationValues.put( name, value );
062    }
063
064    public AnnotationVisitor visitAnnotation( String name, String desc )
065    {
066        return new MojoAnnotationVisitor( logger, this.annotationClassName );
067    }
068
069    public AnnotationVisitor visitArray( String s )
070    {
071        return new MojoAnnotationVisitor( logger, this.annotationClassName );
072    }
073
074    public void visitEnd()
075    {
076        // no op
077    }
078
079    public String getAnnotationClassName()
080    {
081        return annotationClassName;
082    }
083}