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            @Override
045            public void accept() throws Exception {
046                    _classReader.accept(this, 0);
047            }
048    
049            @Override
050            public String getClassName() {
051                    return _className;
052            }
053    
054            @Override
055            public void visit(
056                    int version, int access, String name, String signature,
057                    String superName, String[] interfaces) {
058    
059                    _className = StringUtil.replace(name, CharPool.SLASH, CharPool.PERIOD);
060            }
061    
062            @Override
063            public AnnotationVisitor visitAnnotation(
064                    String description, boolean visible) {
065    
066                    return null;
067            }
068    
069            @Override
070            public void visitAttribute(Attribute attribute) {
071            }
072    
073            @Override
074            public void visitEnd() {
075            }
076    
077            @Override
078            public FieldVisitor visitField(
079                    int access, String name, String description, String signature,
080                    Object value) {
081    
082                    return null;
083            }
084    
085            @Override
086            public void visitInnerClass(
087                    String name, String outerName, String innerName, int access) {
088            }
089    
090            @Override
091            public MethodVisitor visitMethod(
092                    int access, String name, String description, String signature,
093                    String[] exceptions) {
094    
095                    return null;
096            }
097    
098            @Override
099            public void visitOuterClass(String owner, String name, String desc) {
100            }
101    
102            @Override
103            public void visitSource(String source, String debug) {
104            }
105    
106            private String _className;
107            private ClassReader _classReader;
108    
109    }