beanwritermetainfoholder.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 857 行 · 第 1/2 页
JAVA
857 行
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.axis2.schema;
import javax.xml.namespace.QName;
import java.util.*;
/**
* This class is used as a holder to pass on the meta information to the bean writer.
* This meta information is used by the writer to write the databinding conversion code.
* Note - Metainfholders are not meant to be reused!!!. They are per-class basis and are strictly
* not thread safe!!!!
*/
public class BeanWriterMetaInfoHolder {
protected boolean ordered = false;
protected boolean anonymous = false;
protected boolean choice = false;
protected boolean simple = false;
protected boolean extension = false;
protected boolean restriction = false;
private String extensionClassName = "";
private String restrictionClassName = "";
private QName extensionBaseType = null;
private QName restrictionBaseType = null;
protected Map elementToSchemaQNameMap = new LinkedHashMap();
protected Map elementToJavaClassMap = new LinkedHashMap();
protected Map specialTypeFlagMap = new LinkedHashMap();
protected Map qNameMaxOccursCountMap = new LinkedHashMap();
protected Map qNameMinOccursCountMap = new LinkedHashMap();
protected Map qNameOrderMap = new LinkedHashMap();
protected QName ownQname = null;
protected String ownClassName = null;
protected long lengthFacet = -1;
protected long maxLengthFacet = -1;
protected long minLengthFacet = -1;
protected ArrayList enumFacet = new ArrayList();
protected String patternFacet = null;
protected String maxExclusiveFacet = null;
protected String minExclusiveFacet = null;
protected String maxInclusiveFacet = null;
protected String minInclusiveFacet = null;
protected Map memberTypes = new HashMap();
protected QName itemTypeQName;
protected String itemTypeClassName;
protected boolean isUnion;
protected boolean isList;
protected boolean isParticleClass;
// keep whether this class has a partical class type variable
protected boolean hasParticleType;
protected List nillableQNameList = new ArrayList();
//the parent metainfo holder, useful in handling extensions and
//restrictions
protected BeanWriterMetaInfoHolder parent = null;
public boolean isChoice() {
return choice;
}
public void setChoice(boolean choice) {
this.choice = choice;
}
public boolean isSimple() {
return simple;
}
public void setSimple(boolean simple) {
this.simple = simple;
}
public String getOwnClassName() {
return ownClassName;
}
public void setOwnClassName(String ownClassName) {
this.ownClassName = ownClassName;
}
public QName getOwnQname() {
return ownQname;
}
public void setOwnQname(QName ownQname) {
this.ownQname = ownQname;
}
/**
* Gets the parent
*/
public BeanWriterMetaInfoHolder getParent() {
return parent;
}
/**
* Gets the anonymous status.
*
* @return Returns boolean.
*/
public boolean isAnonymous() {
return anonymous;
}
/**
* Sets the anonymous flag.
*
* @param anonymous
*/
public void setAnonymous(boolean anonymous) {
this.anonymous = anonymous;
}
/**
* Sets the extensions base class name. Valid only when the isExtension
* returns true.
*
* @return Returns String.
*/
public String getExtensionClassName() {
return extensionClassName;
}
/**
* Sets the extensions base class name. Valid only when the isExtension
* returns true.
*
* @param extensionClassName
*/
public void setExtensionClassName(String extensionClassName) {
this.extensionClassName = extensionClassName;
}
/**
* Gets the extension status.
*
* @return Returns boolean.
*/
public boolean isExtension() {
return extension;
}
/**
* Sets the extension status.
*
* @param extension
*/
public void setExtension(boolean extension) {
this.extension = extension;
}
public String getRestrictionClassName() {
return restrictionClassName;
}
/**
* Sets the restriction base class name. Valid only when the isRestriction
* returns true.
*
* @param restrictionClassName
*/
public void setRestrictionClassName(String restrictionClassName) {
this.restrictionClassName = restrictionClassName;
}
/**
* Gets the restriction status.
*
* @return Returns boolean.
*/
public boolean isRestriction() {
return restriction;
}
/**
* Sets the restriction status.
*
* @param restriction
*/
public void setRestriction(boolean restriction) {
this.restriction = restriction;
}
/**
* Sets the extension basetype.
*
* @param extensionBaseType
*/
public void setExtensionBaseType(QName extensionBaseType) {
this.extensionBaseType = extensionBaseType;
}
/**
* Checks if it is a extension base type.
*
* @param extensionBaseType
*/
public boolean isExtensionBaseType(QName extensionBaseType) {
return (this.extensionBaseType == extensionBaseType);
}
/**
* Sets the restriction basetype.
*
* @param restrictionBaseType
*/
public void setRestrictionBaseType(QName restrictionBaseType) {
this.restrictionBaseType = restrictionBaseType;
}
/**
* Checks if it is a restriction base type.
*
* @param restrictionBaseType
*/
public boolean isRestrictionBaseType(QName restrictionBaseType) {
QName baseTypeQName = (QName) this.elementToSchemaQNameMap.get(restrictionBaseType);
return (this.restrictionBaseType != null) && (baseTypeQName != null) &&
this.restrictionBaseType.equals(baseTypeQName);
}
/**
* Gets the ordered status.
*
* @return Returns boolean.
*/
public boolean isOrdered() {
return ordered;
}
/**
* Sets the ordered flag.
*
* @param ordered
*/
public void setOrdered(boolean ordered) {
this.ordered = ordered;
}
/**
* Registers a mapping.
*
* @param qName
* @param schemaName
* @param javaClassName
*/
public void registerMapping(QName qName, QName schemaName, String javaClassName) {
registerMapping(qName, schemaName, javaClassName, SchemaConstants.ELEMENT_TYPE);
}
/**
* Registers a Qname as nillable
* The qName better be of an element
*
* @param qName
* @param schemaName
* @param javaClassName
*/
public void registerNillableQName(QName eltQName) {
nillableQNameList.add(eltQName);
}
/**
* Returns whether a QName is nillable or not
*
* @param eltQName
*/
public boolean isNillable(QName eltQName) {
return nillableQNameList.contains(eltQName);
}
/**
* Registers a mapping.
*
* @param qName
* @param schemaName
* @param javaClassName
* @param type
*/
public void registerMapping(QName qName, QName schemaName, String javaClassName, int type) {
this.elementToJavaClassMap.put(qName, javaClassName);
this.elementToSchemaQNameMap.put(qName, schemaName);
addtStatus(qName, type);
}
/**
* Gets the schema name for the given QName.
*
* @param eltQName
* @return Returns QName.
*/
public QName getSchemaQNameForQName(QName eltQName) {
return (QName) this.elementToSchemaQNameMap.get(eltQName);
}
/**
* Gets the class name for the QName.
*
* @param eltQName
* @return Returns String.
*/
public String getClassNameForQName(QName eltQName) {
return (String) this.elementToJavaClassMap.get(eltQName);
}
/**
* Gets whether a given QName is an attribute
*
* @param qName
* @return Returns boolean.
*/
public boolean getAttributeStatusForQName(QName qName) {
Integer state = (Integer) specialTypeFlagMap.get(qName);
return state != null && getStatus(state.intValue(), SchemaConstants.ATTRIBUTE_TYPE);
}
/**
* checks the element corresponds to the qName type is xsd:anyType
*
* @param qName
* @return is element corresponds to qName has xsd:anyType
*/
public boolean getDefaultStatusForQName(QName qName) {
boolean isDefault = false;
QName schemaTypeQName = (QName) this.elementToSchemaQNameMap.get(qName);
if (schemaTypeQName != null) {
isDefault = schemaTypeQName.equals(SchemaConstants.XSD_ANYTYPE);
}
return isDefault;
}
/**
* Gets whether a given QName represents a anyType
*
* @param qName
* @return Returns boolean.
*/
public boolean getAnyStatusForQName(QName qName) {
Integer state = (Integer) specialTypeFlagMap.get(qName);
return state != null && getStatus(state.intValue(), SchemaConstants.ANY_TYPE);
}
/**
* Gets whether a given QName refers to an array.
*
* @param qName
* @return Returns boolean.
*/
public boolean getArrayStatusForQName(QName qName) {
Integer state = (Integer) specialTypeFlagMap.get(qName);
return state != null && getStatus(state.intValue(),
SchemaConstants.ARRAY_TYPE);
}
/**
* Gets whether a given QName refers to binary.
*
* @param qName
* @return Returns boolean.
*/
public boolean getBinaryStatusForQName(QName qName) {
Integer state = (Integer) specialTypeFlagMap.get(qName);
return state != null && getStatus(state.intValue(),
SchemaConstants.BINARY_TYPE);
}
/**
*
* @param qName
* @return is this a inner choice
*/
public boolean getInnerChoiceStatusForQName(QName qName){
Integer state = (Integer) specialTypeFlagMap.get(qName);
return state != null && getStatus(state.intValue(),
SchemaConstants.INNER_CHOICE_ELEMENT);
}
/**
* Gets whether a given QName refers to Simple Type.
*
* @param qName
* @return Returns boolean.
*/
public boolean getSimpleStatusForQName(QName qName) {
Integer state = (Integer) specialTypeFlagMap.get(qName);
return state != null && getStatus(state.intValue(),
SchemaConstants.SIMPLE_TYPE_OR_CONTENT);
}
/**
*
* @param qName
* @return whether the attribute is a partical class or not
*/
public boolean getParticleTypeStatusForQName(QName qName){
Integer state = (Integer) specialTypeFlagMap.get(qName);
return state != null && getStatus(state.intValue(),
SchemaConstants.PARTICLE_TYPE_ELEMENT);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?