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

📄 globalcustom.java

📁 对xml很好的java处理引擎,编译中绑定xml
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*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.binding.generator;import java.util.ArrayList;import java.util.Collections;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import org.jibx.binding.classes.ClassCache;import org.jibx.binding.model.ClassWrapper;import org.jibx.binding.model.IClass;import org.jibx.binding.model.IClassLocator;import org.jibx.runtime.EnumSet;import org.jibx.runtime.IBindingFactory;import org.jibx.runtime.IUnmarshaller;import org.jibx.runtime.IUnmarshallingContext;import org.jibx.runtime.JiBXException;import org.jibx.runtime.impl.UnmarshallingContext;/** * Global customization information. This includes some options specific to the * &lt;binding> element of the definition, as well as controls for structuring * of the generated binding(s). It handles the binding customization child * elements directly, by invoking the abstract unmarshallers for the child * elements to process the content. It also allows for extension elements which * are not part of the binding customization structure, as long as the binding * in use defines the unmarshalling for these elements. */public class GlobalCustom extends NestingBase{    /** Element name in XML customization file. */    public static final String ELEMENT_NAME = "custom";        //    // Value set information        public static final int IN_BINDING = 0;    public static final int OUT_BINDING = 1;    public static final int BOTH_BINDING = 2;        /*package*/ static final EnumSet s_directionEnum = new EnumSet(IN_BINDING,        new String[] { "input", "output", "both" });        //    // Instance data        // structure for package hierarchy    private Map m_packageMap;        // class locator    private final IClassLocator m_classLocator;        // extension elements    private List m_extensionChildren;        // values applied directly to <binding> element (or to structure)    private boolean m_addConstructors;    private boolean m_forceClasses;    private boolean m_trackSource;    private boolean m_namespaceModular;    private boolean m_isInput;    private boolean m_isOutput;        /**     * Constructor with class locator supplied.     *      * @param loc     */    public GlobalCustom(IClassLocator loc) {        super(null);        m_packageMap = new HashMap();        m_classLocator = loc;        PackageCustom dflt = new PackageCustom("", "", this);        m_packageMap.put("", dflt);        m_isInput = true;        m_isOutput = true;    }        /**     * Constructor. This always creates the default package as the only direct     * child, since other packages will be treated as children of the default     * package.     */    public GlobalCustom() {        this(new IClassLocator() {            public IClass getClassInfo(String name) {                try {                    return new ClassWrapper(this, ClassCache.getClassFile(name));                } catch (JiBXException e) {                    throw new IllegalStateException("Class not found " + name);                }            }        });    }        /**     * Get global customizations root.     *     * @return global customization     */    public GlobalCustom getGlobal() {        return this;    }        //    // Access methods for values applied only at top level    /**     * Get 'add-constructors' setting.     *     * @return 'add-constructors' value     */    public boolean isAddConstructors() {        return m_addConstructors;    }    /**     * Set 'add-constructors' value.     *     * @param add 'add-constructors' value     */    public void setAddConstructors(boolean add) {        m_addConstructors = add;    }    /**     * Get 'force-classes' setting.     *     * @return 'force-classes' value     */    public boolean isForceClasses() {        return m_forceClasses;    }    /**     * Set 'force-classes' value.     *     * @param force 'force-classes' value     */    public void setForceClasses(boolean force) {        m_forceClasses = force;    }    /**     * Get 'track-source' attribute value.     *     * @return 'track-source' value     */    public boolean isTrackSource() {        return m_trackSource;    }    /**     * Set 'track-source' value.     *     * @param track 'track-source' value     */    public void setTrackSource(boolean track) {        m_trackSource = track;    }    /**     * Check if using namespace modular bindings.     *     * @return flag for bindings to be modular by namespace     */    public boolean isNamespaceModular() {        return m_namespaceModular;    }    /**     * Check for an input binding.     *     * @return input flag     */    public boolean isInput() {        return m_isInput;    }    /**     * Set input binding flag.     *     * @param input     */    public void setInput(boolean input) {        m_isInput = input;    }    /**     * Check for an output binding.     *     * @return output flag     */    public boolean isOutput() {        return m_isOutput;    }    /**     * Set output binding falg.     *     * @param output     */    public void setOutput(boolean output) {        m_isOutput = output;    }        /**     * Get class locator.     *     * @return locator     */    protected IClassLocator getClassLocator() {        return m_classLocator;    }        /**     * Get class information.     *     * @param type fully-qualified class name     * @return information     */    public IClass getClassInfo(String type) {        return m_classLocator.getClassInfo(type);    }    /**     * Get the extension elements used in this customization. This does not     * include the &lt;package> or &lt;class> child elements, which are     * added directly to the customization structures.     *     * @return child list     */    public List getExtensionChildren() {        if (m_extensionChildren == null) {            return Collections.EMPTY_LIST;        } else {            return m_extensionChildren;        }    }        /**     * Internal method used during unmarshalling to add a child extension     * element.     *     * @param child     */    protected void internalAddExtensionChild(Object child) {        if (m_extensionChildren == null) {            m_extensionChildren = new ArrayList();        }        m_extensionChildren.add(child);    }        /**     * Add a child extension element. This both adds the child to the list and     * invokeds the extension element's {@link IApply#apply(IClassLocator)}     * method, if present.     *     * @param child     */    public void addExtensionChild(Object child) {        internalAddExtensionChild(child);        if (child instanceof IApply) {            ((IApply)child).apply(m_classLocator);        }    }        /**     * Check if a class is included in the customization information. This     * method does not alter the structures in any way, it only checks if the     * class customization information is part of the existing structure.     *     * @param type fully qualified class name     * @return <code>true</code> if class includes, <code>false</code> if not

⌨️ 快捷键说明

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