📄 containerelementbase.java
字号:
/*Copyright (c) 2004-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.model;import java.util.ArrayList;import org.jibx.binding.util.StringArray;/** * Model component for elements that can contain detailed binding information in * the form of nested child components. Elements of this type include * <b>mapping</b>, <b>template</b>, <b>structure</b>, and <b>collection</b> * elements. * * @author Dennis M. Sosnoski */public abstract class ContainerElementBase extends NestingElementBase{ /** Enumeration of allowed attribute names */ public static final StringArray s_allowedAttributes = new StringArray(NestingElementBase.s_allowedAttributes, new StringArray(ObjectAttributes.s_allowedAttributes, StructureAttributes.s_allowedAttributes)); /** Object attributes information for nesting. */ private ObjectAttributes m_objectAttrs; /** Structure attributes information for nesting. */ private StructureAttributes m_structureAttrs; /** Label for this structure definition. */ private String m_label; /** Label for structure to be used as definition. */ private String m_using; /** Child component that contributes an ID (<code>null</code> if none). */ private IComponent m_idChild; /** Flag for child classification in progress. */ private boolean m_inClassify; /** Child components defining content (created during validation, contains subset of child components defining element or character data content). */ private ArrayList m_contentComponents; /** Child components defining attributes (created during validation, contains subset of child components defining attributes). */ private ArrayList m_attributeComponents; /** * Constructor. * * @param type element type code */ protected ContainerElementBase(int type) { super(type); m_objectAttrs = new ObjectAttributes(); m_structureAttrs = new StructureAttributes(); } /** * Get label for this definition. * * @return label for this definition */ public String getLabel() { return m_label; } /** * Set label for this definition. * * @param label label for this definition */ public void setLabel(String label) { m_label = label; } /** * Get label for definition to be used. * * @return label for definition to be used */ public String getUsing() { return m_using; } /** * Set label for definition to be used. * * @param label label for definition to be used */ public void setUsing(String label) { m_using = label; } /** * Get list of child components contributing content items to this * container element. This call is only meaningful after validation. * * @return list of child binding components defining content items */ public ArrayList getContentComponents() { return m_contentComponents == null ? EmptyList.INSTANCE : m_contentComponents; } /** * Get list of child components contributing attribute items to this * container element. This call is only meaningful after validation. * * @return list of child binding components defining attribute items */ public ArrayList getAttributeComponents() { return m_attributeComponents == null ? EmptyList.INSTANCE : m_attributeComponents; } /** * Check if this container defines a context object. * * @return <code>true</code> if defines context object, * <code>false</code> if not */ public abstract boolean hasObject(); /** * Get class linked to binding element. This call is only meaningful after * validation. * * @return information for class linked by binding */ public abstract IClass getObjectType(); /** * Get class passed to child components. This call is only meaningful after * validation. * * @return information for class linked by binding */ public IClass getChildObjectType() { return getObjectType(); } /** * Set ID property child. Used to set the ID property associated with a * particular class instance. There can only be at most one child ID * property for each actual object instance. * * @param child child defining the ID property * @param vctx validation context */ public final void setIdChild(IComponent child, ValidationContext vctx) { if (m_idChild == null) { m_idChild = child; vctx.getBindingRoot().addIdClass(getObjectType()); } else { vctx.addError("Only one child ID property allowed for an object " + "- " + ValidationProblem.componentDescription(m_idChild) + " and " + ValidationProblem.componentDescription(child) + " refer to the same object"); } } /** * Get ID property child. * * @return ID child */ public IComponent getId() { return m_idChild; } // // Object attribute delegate methods /** * Get factory method name. * * @return fully-qualified factory class and method name (or * <code>null</code> if none) */ public String getFactoryName() { return m_objectAttrs.getFactoryName(); } /** * Get factory method information. This call is only meaningful after * validation. * * @return factory method information (or <code>null</code> if none) */ public IClassItem getFactory() { return m_objectAttrs.getFactory(); } /** * Set factory method name. * * @param name fully qualified class and method name for object factory */ public void setFactoryName(String name) { m_objectAttrs.setFactoryName(name); } /** * Get pre-set method name. * * @return pre-set method name (or <code>null</code> if none) */ public String getPresetName() { return m_objectAttrs.getPresetName(); } /** * Get pre-set method information. This call is only meaningful after * validation. * * @return pre-set method information (or <code>null</code> if none) */ public IClassItem getPreset() { return m_objectAttrs.getPreset(); } /** * Set pre-set method name. * * @param name member method name to be called before unmarshalling */ public void setPresetName(String name) { m_objectAttrs.setPresetName(name); } /** * Get post-set method name. * * @return post-set method name (or <code>null</code> if none) */ public String getPostsetName() { return m_objectAttrs.getPostsetName(); } /** * Get post-set method information. This call is only meaningful after * validation. * * @return post-set method information (or <code>null</code> if none) */ public IClassItem getPostset() { return m_objectAttrs.getPostset(); } /** * Set post-set method name. * * @param name member method name to be called after unmarshalling */ public void setPostsetName(String name) { m_objectAttrs.setPostsetName(name); } /** * Get pre-get method name. * * @return pre-get method name (or <code>null</code> if none) */ public String getPregetName() { return m_objectAttrs.getPregetName(); } /** * Get pre-get method information. This call is only meaningful after * validation. * * @return pre-get method information (or <code>null</code> if none) */ public IClassItem getPreget() { return m_objectAttrs.getPreget(); } /** * Set pre-get method name. * * @param name member method name to be called before marshalling */ public void setPreget(String name) { m_objectAttrs.setPreget(name); } /** * Get marshaller class name. * * @return marshaller class name (or <code>null</code> if none) */ public String getMarshallerName() { return m_objectAttrs.getMarshallerName(); } /** * Get marshaller class information. This call is only meaningful after * validation. * * @return class information for marshaller (or <code>null</code> if none) */ public IClass getMarshaller() { return m_objectAttrs.getMarshaller(); } /** * Set marshaller class name. * * @param name class name to be used for marshalling */ public void setMarshallerName(String name) { m_objectAttrs.setMarshallerName(name); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -