001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.jsonwebservice;
016    
017    import com.liferay.portal.kernel.jsonwebservice.JSONWebServiceClassVisitor;
018    import com.liferay.portal.kernel.util.CharPool;
019    import com.liferay.portal.kernel.util.StringUtil;
020    
021    import java.io.IOException;
022    import java.io.InputStream;
023    
024    import org.objectweb.asm.AnnotationVisitor;
025    import org.objectweb.asm.Attribute;
026    import org.objectweb.asm.ClassReader;
027    import org.objectweb.asm.ClassVisitor;
028    import org.objectweb.asm.FieldVisitor;
029    import org.objectweb.asm.MethodVisitor;
030    
031    /**
032     * @author Igor Spasic
033     * @author Raymond Augé
034     */
035    public class JSONWebServiceClassVisitorImpl
036            implements ClassVisitor, JSONWebServiceClassVisitor {
037    
038            public JSONWebServiceClassVisitorImpl(InputStream inputStream)
039                    throws IOException {
040    
041                    _classReader = new ClassReader(inputStream);
042            }
043    
044            public void accept() throws Exception {
045                    _classReader.accept(this, 0);
046            }
047    
048            public String getClassName() {
049                    return _className;
050            }
051    
052            public void visit(
053                    int version, int access, String name, String signature,
054                    String superName, String[] interfaces) {
055    
056                    _className = StringUtil.replace(name, CharPool.SLASH, CharPool.PERIOD);
057            }
058    
059            public AnnotationVisitor visitAnnotation(
060                    String description, boolean visible) {
061    
062                    return null;
063            }
064    
065            public void visitAttribute(Attribute attribute) {
066            }
067    
068            public void visitEnd() {
069            }
070    
071            public FieldVisitor visitField(
072                    int access, String name, String description, String signature,
073                    Object value) {
074    
075                    return null;
076            }
077    
078            public void visitInnerClass(
079                    String name, String outerName, String innerName, int access) {
080            }
081    
082            public MethodVisitor visitMethod(
083                    int access, String name, String description, String signature,
084                    String[] exceptions) {
085    
086                    return null;
087            }
088    
089            public void visitOuterClass(String owner, String name, String desc) {
090            }
091    
092            public void visitSource(String source, String debug) {
093            }
094    
095            private String _className;
096            private ClassReader _classReader;
097    
098    }