001    /**
002     * Copyright (c) 2000-2012 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 jodd.asm.EmptyClassVisitor;
025    
026    import org.objectweb.asm.ClassReader;
027    
028    /**
029     * @author Igor Spasic
030     * @author Raymond Augé
031     */
032    public class JSONWebServiceClassVisitorImpl
033            extends EmptyClassVisitor implements JSONWebServiceClassVisitor {
034    
035            public JSONWebServiceClassVisitorImpl(InputStream inputStream)
036                    throws IOException {
037    
038                    _classReader = new ClassReader(inputStream);
039            }
040    
041            public void accept() throws Exception {
042                    _classReader.accept(this, 0);
043            }
044    
045            public String getClassName() {
046                    return _className;
047            }
048    
049            @Override
050            public void visit(
051                    int version, int access, String name, String signature,
052                    String superName, String[] interfaces) {
053    
054                    _className = StringUtil.replace(name, CharPool.SLASH, CharPool.PERIOD);
055            }
056    
057            private String _className;
058            private ClassReader _classReader;
059    
060    }