⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classsourcelocator.java

📁 对xml很好的java处理引擎,编译中绑定xml
💻 JAVA
字号:
/*Copyright (c) 2007, Dennis M. SosnoskiAll rights reserved.Redistribution and use in source and binary forms, with or without modification,are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this   list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice,   this list of conditions and the following disclaimer in the documentation   and/or other materials provided with the distribution. * Neither the name of JiBX nor the names of its contributors may be used   to endorse or promote products derived from this software without specific   prior written permission.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ANDANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIEDWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AREDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FORANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ONANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THISSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/package org.jibx.ws.wsdl;import java.io.File;import java.io.IOException;import java.util.HashSet;import java.util.Set;import org.jibx.binding.classes.ClassCache;import org.jibx.binding.generator.ClassSourceWrapper;import org.jibx.binding.generator.IClassSourceLocator;import org.jibx.binding.model.ClassWrapper;import org.jibx.binding.model.IClass;import org.jibx.runtime.JiBXException;import com.thoughtworks.qdox.JavaDocBuilder;import com.thoughtworks.qdox.model.JavaClass;/** * Locator that supports both class file lookup and source file lookup. */public class ClassSourceLocator implements IClassSourceLocator{    /** Paths for source lookup. */    private final String[] m_sourcePaths;        /** Source file parser. */    private final JavaDocBuilder m_builder;        /** Set of classes parsed. */    private final Set m_lookupSet;        /**     * Constructor.     *      * @param paths source lookup paths (may be empty, but not     * <code>null</code>)     */    public ClassSourceLocator(String[] paths) {        m_sourcePaths = paths;        m_builder = new JavaDocBuilder();        m_lookupSet = new HashSet();    }    /**     * Get the source code information for a class.     *     * @param name fully-qualified class name (using '$' as inner class marker)     * @return source code information, <code>null</code> if not available     */    public JavaClass getSourceInfo(String name) {        int split = name.lastIndexOf('$');        if (split >= 0) {            JavaClass outer = getSourceInfo(name.substring(0, split));            if (outer == null) {                return null;            } else {                return outer.getNestedClassByName(name.substring(split+1));            }        } else if (m_lookupSet.contains(name)) {            return m_builder.getClassByName(name);        } else {            for (int i = 0; i < m_sourcePaths.length; i++) {                StringBuffer buff = new StringBuffer();                buff.append(m_sourcePaths[i]);                int length = buff.length();                if (length > 0 || buff.charAt(length-1) != File.separatorChar) {                    buff.append(File.separatorChar);                }                buff.append(name.replace('.', File.separatorChar));                buff.append(".java");                File file = new File(buff.toString());                if (file.exists()) {                    try {                        m_builder.addSource(file);                        m_lookupSet.add(name);                        return m_builder.getClassByName(name);                    } catch (IOException e) {                        throw new IllegalStateException("Unable to access source file " + buff.toString(), e);                    }                }            }            return null;        }    }    /**     * Get the information for a class.     *     * @param name fully-qualified class name (using '$' as inner class marker)     * @return class information     */    public IClass getClassInfo(String name) {        try {            return new ClassSourceWrapper(this, ClassCache.getClassFile(name));        } catch (JiBXException e) {            throw new IllegalStateException("Class not found " + name);        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -