gpt4 book ai didi

org.eclipse.persistence.oxm.schema.XMLSchemaReference.getSchemaContextAsQName()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 23:02:40 28 4
gpt4 key购买 nike

本文整理了Java中org.eclipse.persistence.oxm.schema.XMLSchemaReference.getSchemaContextAsQName()方法的一些代码示例,展示了XMLSchemaReference.getSchemaContextAsQName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLSchemaReference.getSchemaContextAsQName()方法的具体详情如下:
包路径:org.eclipse.persistence.oxm.schema.XMLSchemaReference
类名称:XMLSchemaReference
方法名:getSchemaContextAsQName

XMLSchemaReference.getSchemaContextAsQName介绍

[英]INTERNAL:
[中]内部:

代码示例

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

@Override
public void writeXsiTypeAttribute(Descriptor xmlDescriptor, XMLSchemaReference xmlRef, boolean addToNamespaceResolver) {
  QName contextAsQName = xmlRef.getSchemaContextAsQName();
  if(contextAsQName == null){
    contextAsQName = xmlRef.getSchemaContextAsQName(namespaceResolver);
  }
  if (contextAsQName != null) {
    writeXsiTypeAttribute(xmlDescriptor, contextAsQName.getNamespaceURI(), contextAsQName.getLocalPart(), null, addToNamespaceResolver);
  }
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

@Override
public void writeXsiTypeAttribute(Descriptor xmlDescriptor, XMLSchemaReference xmlRef, boolean addToNamespaceResolver) {
  QName contextAsQName = xmlRef.getSchemaContextAsQName();
  
  if(contextAsQName == null){
    contextAsQName = xmlRef.getSchemaContextAsQName(namespaceResolver);
  }
  if (contextAsQName != null) {
    writeXsiTypeAttribute(xmlDescriptor, contextAsQName.getNamespaceURI(), contextAsQName.getLocalPart(), null, addToNamespaceResolver);
  }
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

private void writeTypeAttribute(MarshalRecord marshalRecord, XMLDescriptor descriptor, String xsiPrefix) {
  //xsi:type=schemacontext
  String typeValue = descriptor.getSchemaReference().getSchemaContext();
  // handle case where the schema context is set as a QName
  if (typeValue == null) {
    QName contextAsQName = descriptor.getSchemaReference().getSchemaContextAsQName();
    if (contextAsQName == null) {
      return;
    }
    String uri = contextAsQName.getNamespaceURI();
    String localPart = contextAsQName.getLocalPart();
    String prefix = marshalRecord.getNamespaceResolver().resolveNamespaceURI(uri);
    if (prefix == null) {
      String defaultUri = marshalRecord.getNamespaceResolver().getDefaultNamespaceURI();
      if (defaultUri != null && defaultUri.equals(uri)) {
        typeValue = localPart;
      } else {
        prefix = marshalRecord.getNamespaceResolver().generatePrefix();
        marshalRecord.attribute(XMLConstants.XMLNS_URL, prefix, XMLConstants.XMLNS + XMLConstants.COLON + prefix, uri);
        typeValue = prefix + XMLConstants.COLON + localPart;
      }
    } else {
      typeValue = prefix + XMLConstants.COLON + localPart;
    }
  } else {
    typeValue = typeValue.substring(1);
  }
  marshalRecord.attribute(XMLConstants.SCHEMA_INSTANCE_URL, XMLConstants.SCHEMA_TYPE_ATTRIBUTE, xsiPrefix + XMLConstants.COLON + XMLConstants.SCHEMA_TYPE_ATTRIBUTE, typeValue);
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * Create and return a SimpleType for a given XMLDescriptor.
 * 
 * @param desc
 * @param workingSchema
 * @return
 */
protected SimpleType buildSimpleType(XMLDescriptor desc, Schema workingSchema, boolean global) {
  SimpleType st;
  if (global) {
    st = buildNewSimpleType(desc.getSchemaReference().getSchemaContextAsQName(workingSchema.getNamespaceResolver()).getLocalPart());
  } else {
    st = new SimpleType();
  }
  DatabaseMapping mapping = desc.getMappings().get(0);
  QName qname = (QName) XMLConversionManager.getDefaultJavaTypes().get(mapping.getAttributeClassification());
  String baseType = qname.getLocalPart();
  if (qname.getNamespaceURI() != null) {
    String prefix = workingSchema.getNamespaceResolver().resolveNamespaceURI(qname.getNamespaceURI());
    if (prefix == null) {
      prefix = workingSchema.getNamespaceResolver().generatePrefix();
      workingSchema.getNamespaceResolver().put(prefix, qname.getNamespaceURI());
    }
    baseType = prefix + XMLConstants.COLON + baseType;
  }
  Restriction restriction = new Restriction();
  restriction.setBaseType(baseType);
  st.setRestriction(restriction);
  return st;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * Create and return a SimpleType for a given XMLDescriptor.
 *
 * @param desc
 * @param workingSchema
 * @return
 */
protected SimpleType buildSimpleType(Descriptor desc, Schema workingSchema, boolean global) {
  SimpleType st;
  if (global) {
    st = buildNewSimpleType(desc.getSchemaReference().getSchemaContextAsQName(workingSchema.getNamespaceResolver()).getLocalPart());
  } else {
    st = new SimpleType();
  }
  CoreMapping mapping = (CoreMapping)desc.getMappings().get(0);
  QName qname = conversionManager.schemaType(mapping.getAttributeClassification());
  String baseType = qname.getLocalPart();
  if (qname.getNamespaceURI() != null) {
    String prefix = workingSchema.getNamespaceResolver().resolveNamespaceURI(qname.getNamespaceURI());
    if (prefix == null) {
      prefix = workingSchema.getNamespaceResolver().generatePrefix();
      workingSchema.getNamespaceResolver().put(prefix, qname.getNamespaceURI());
    }
    baseType = prefix + Constants.COLON + baseType;
  }
  Restriction restriction = new Restriction();
  restriction.setBaseType(baseType);
  st.setRestriction(restriction);
  return st;
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * Create and return a SimpleType for a given XMLDescriptor.
 * 
 * @param desc
 * @param workingSchema
 * @return
 */
protected SimpleType buildSimpleType(Descriptor desc, Schema workingSchema, boolean global) {
  SimpleType st;
  if (global) {
    st = buildNewSimpleType(desc.getSchemaReference().getSchemaContextAsQName(workingSchema.getNamespaceResolver()).getLocalPart());
  } else {
    st = new SimpleType();
  }
  CoreMapping mapping = (CoreMapping)desc.getMappings().get(0);
  QName qname = conversionManager.schemaType(mapping.getAttributeClassification());
  String baseType = qname.getLocalPart();
  if (qname.getNamespaceURI() != null) {
    String prefix = workingSchema.getNamespaceResolver().resolveNamespaceURI(qname.getNamespaceURI());
    if (prefix == null) {
      prefix = workingSchema.getNamespaceResolver().generatePrefix();
      workingSchema.getNamespaceResolver().put(prefix, qname.getNamespaceURI());
    }
    baseType = prefix + Constants.COLON + baseType;
  }
  Restriction restriction = new Restriction();
  restriction.setBaseType(baseType);
  st.setRestriction(restriction);
  return st;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.sdo

QName qName = schemaReference.getSchemaContextAsQName(entityDescriptor.getNamespaceResolver());
if(null == qName) {
  throw SDOException.sdoJaxbNoSchemaContext(entityClass);

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

ComplexType ct = new ComplexType();
if (!anonymous) {
  ct.setName(desc.getSchemaReference().getSchemaContextAsQName(workingSchema.getNamespaceResolver()).getLocalPart());
if (inheritancePolicy != null && inheritancePolicy.getParentClass() != null) {
  extension = new Extension();
  extension.setBaseType(desc.getSchemaReference().getSchemaContextAsQName(workingSchema.getNamespaceResolver()).getLocalPart());
  ComplexContent complexContent = new ComplexContent();
  complexContent.setExtension(extension);

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 */
public boolean shouldAddXsiType(XMLRecord record, ClassDescriptor aDescriptor) {
  XMLDescriptor xmlDescriptor = (XMLDescriptor) aDescriptor;
  if ((getReferenceDescriptor() == null) && (xmlDescriptor.getSchemaReference() != null)) {
    if (aDescriptor.hasInheritance()) {
      XMLField indicatorField = (XMLField) aDescriptor.getInheritancePolicy().getClassIndicatorField();
      if ((indicatorField.getLastXPathFragment().getNamespaceURI() != null) //
          && indicatorField.getLastXPathFragment().getNamespaceURI().equals(XMLConstants.SCHEMA_INSTANCE_URL) //
          && indicatorField.getLastXPathFragment().getLocalName().equals(XMLConstants.SCHEMA_TYPE_ATTRIBUTE)) {
        return false;
      }
    }
    XMLSchemaReference xmlRef = xmlDescriptor.getSchemaReference();
    if ((xmlRef.getType() == XMLSchemaReference.COMPLEX_TYPE) && xmlRef.isGlobalDefinition()) {
      QName ctxQName = xmlRef.getSchemaContextAsQName(xmlDescriptor.getNamespaceResolver());
      QName leafType = ((XMLField) getField()).getLeafElementType();
      if ((leafType == null) || (!ctxQName.equals(record.getLeafElementType()))) {
        return true;
      }
    }
  }
  return false;
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

ComplexType ct = new ComplexType();
if (!anonymous) {
  ct.setName(desc.getSchemaReference().getSchemaContextAsQName(workingSchema.getNamespaceResolver()).getLocalPart());
if (inheritancePolicy != null && inheritancePolicy.getParentClass() != null) {
  extension = new Extension();
  extension.setBaseType(desc.getSchemaReference().getSchemaContextAsQName(workingSchema.getNamespaceResolver()).getLocalPart());
  ComplexContent complexContent = new ComplexContent();
  complexContent.setExtension(extension);

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * Create and return an Element for a given XMLDescriptor.
 * 
 * @param desc
 * @param schemaForNamespace
 * @param workingSchema
 * @param properties
 * @param descriptors
 * @param simple
 * @return
 */
protected Element buildElement(Descriptor desc,  HashMap<String, Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors, boolean simple) {
  Element element = new Element();
  element.setName(desc.getSchemaReference().getSchemaContextAsQName(workingSchema.getNamespaceResolver()).getLocalPart());
  if (simple) {
    if (isComplexTypeWithSimpleContentRequired(desc)) {
      element.setComplexType(buildComplexTypeWithSimpleContent(desc, schemaForNamespace, workingSchema, properties, descriptors));
    } else {
      element.setSimpleType(buildSimpleType(desc, workingSchema, false));
    }
  } else {
    element.setComplexType(buildComplexType(true, desc, schemaForNamespace, workingSchema, properties, descriptors));
  }
  
  return element;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * Create and return an Element for a given XMLDescriptor.
 *
 * @param desc
 * @param schemaForNamespace
 * @param workingSchema
 * @param properties
 * @param descriptors
 * @param simple
 * @return
 */
protected Element buildElement(Descriptor desc,  HashMap<String, Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors, boolean simple) {
  Element element = new Element();
  element.setName(desc.getSchemaReference().getSchemaContextAsQName(workingSchema.getNamespaceResolver()).getLocalPart());
  if (simple) {
    if (isComplexTypeWithSimpleContentRequired(desc)) {
      element.setComplexType(buildComplexTypeWithSimpleContent(desc, schemaForNamespace, workingSchema, properties, descriptors));
    } else {
      element.setSimpleType(buildSimpleType(desc, workingSchema, false));
    }
  } else {
    element.setComplexType(buildComplexType(true, desc, schemaForNamespace, workingSchema, properties, descriptors));
  }
  return element;
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 */
public boolean shouldAddXsiType(XMLRecord record, ClassDescriptor descriptor) {
  XMLDescriptor xmlDescriptor = (XMLDescriptor) descriptor;
  if ((getReferenceDescriptor() == null) && (xmlDescriptor.getSchemaReference() != null)) {
    if (descriptor.hasInheritance()) {
      XMLField indicatorField = (XMLField) descriptor.getInheritancePolicy().getClassIndicatorField();
      if ((indicatorField.getLastXPathFragment().getNamespaceURI() != null) && indicatorField.getLastXPathFragment().getNamespaceURI().equals(XMLConstants.SCHEMA_INSTANCE_URL)
          && indicatorField.getLastXPathFragment().getLocalName().equals(XMLConstants.SCHEMA_TYPE_ATTRIBUTE)) {
        return false;
      }
    }
    XMLSchemaReference xmlRef = xmlDescriptor.getSchemaReference();
    if ((xmlRef.getType() == XMLSchemaReference.COMPLEX_TYPE) && xmlRef.isGlobalDefinition()) {
      QName ctxQName = xmlRef.getSchemaContextAsQName(xmlDescriptor.getNamespaceResolver());
      QName leafType = ((XMLField) getField()).getLeafElementType();
      if ((leafType == null) || (!ctxQName.equals(record.getLeafElementType()))) {
        return true;
      }
    }
  }
  return false;
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * Create and return an Element for a given XMLDescriptor.
 * 
 * @param desc
 * @param schemaForNamespace
 * @param workingSchema
 * @param properties
 * @param descriptors
 * @param simple
 * @return
 */
protected Element buildElement(XMLDescriptor desc,  HashMap<String, Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<XMLDescriptor> descriptors, boolean simple) {
  Element element = new Element();
  element.setName(desc.getSchemaReference().getSchemaContextAsQName(workingSchema.getNamespaceResolver()).getLocalPart());
  if (simple) {
    if (isComplexTypeWithSimpleContentRequired(desc)) {
      element.setComplexType(buildComplexTypeWithSimpleContent(desc, schemaForNamespace, workingSchema, properties, descriptors));
    } else {
      element.setSimpleType(buildSimpleType(desc, workingSchema, false));
    }
  } else {
    element.setComplexType(buildComplexType(true, desc, schemaForNamespace, workingSchema, properties, descriptors));
  }
  
  return element;
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

globalElement.setComplexType(ctype);
} else {
  globalElement.setType(getSchemaTypeString(refDesc.getSchemaReference().getSchemaContextAsQName(workingSchema.getNamespaceResolver()), workingSchema));

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

QName ctxQName = xmlRef.getSchemaContextAsQName(xmlDescriptor.getNamespaceResolver());
if (ctxQName.equals(marshalRecord.getLeafElementType())) {

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.sdo

private DatabaseMapping buildXMLCompositeCollectionMapping(String mappingUri) {
  XMLCompositeCollectionMapping mapping = new XMLCompositeCollectionMapping();
  mapping.setAttributeName(getName());
  String xpath = getQualifiedXPath(mappingUri, false);
  mapping.setXPath(xpath);
  if (!getType().isDataObjectType()) {
    QName schemaContext = getType().getXmlDescriptor().getSchemaReference().getSchemaContextAsQName(getType().getXmlDescriptor().getNamespaceResolver());
    ((XMLField)mapping.getField()).setLeafElementType(schemaContext);
    mapping.setReferenceClassName(getType().getImplClassName());
    mapping.setReferenceClass(getType().getImplClass());
  }else{
    if(getXsdType()!= null){
      ((XMLField)mapping.getField()).setLeafElementType(getXsdType());
    }
  }
  mapping.useCollectionClass(ListWrapper.class);
  // Set null policy on mapping for xsi:nil support:
  // - aNullPolicy.setNullRepresentedByEmptyNode(false);
  // - aNullPolicy.setNullRepresentedByXsiNil(true);
  setIsSetNillablePolicyOnMapping(mapping, propertyName);
  return mapping;
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

private DatabaseMapping buildXMLCompositeCollectionMapping(String mappingUri) {
  XMLCompositeCollectionMapping mapping = new XMLCompositeCollectionMapping();
  mapping.setAttributeName(getName());
  String xpath = getQualifiedXPath(mappingUri, false);
  mapping.setXPath(xpath);
  if (!getType().isDataObjectType()) {
    QName schemaContext = getType().getXmlDescriptor().getSchemaReference().getSchemaContextAsQName(getType().getXmlDescriptor().getNamespaceResolver());
    ((XMLField)mapping.getField()).setLeafElementType(schemaContext);
    mapping.setReferenceClassName(getType().getImplClassName());
    mapping.setReferenceClass(getType().getImplClass());
  }else{
    if(getXsdType()!= null){               
      ((XMLField)mapping.getField()).setLeafElementType(getXsdType());
    }
  }
  mapping.useCollectionClass(ListWrapper.class);
  
  // Set null policy on mapping for xsi:nil support:
  // - aNullPolicy.setNullRepresentedByEmptyNode(false);
  // - aNullPolicy.setNullRepresentedByXsiNil(true);
  setIsSetNillablePolicyOnMapping(mapping, propertyName);
  return mapping;
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

private DatabaseMapping buildXMLCompositeObjectMapping(String mappingUri) {
  XMLCompositeObjectMapping mapping = new XMLCompositeObjectMapping();
  mapping.setAttributeName(getName());
  String xpath = getQualifiedXPath(mappingUri, false);
  mapping.setXPath(xpath);
  if (!getType().isDataObjectType()) {
    QName schemaContext = getType().getXmlDescriptor().getSchemaReference().getSchemaContextAsQName(getType().getXmlDescriptor().getNamespaceResolver());
    ((XMLField)mapping.getField()).setLeafElementType(schemaContext);
    mapping.setReferenceClassName(getType().getImplClassName());
    mapping.setReferenceClass(getType().getImplClass());
  }else{
    if(getXsdType()!= null){               
     ((XMLField)mapping.getField()).setLeafElementType(getXsdType());
    }
  }
  // Handle nillable element support via the nullable property
  if (nullable) {
    setIsSetNillablePolicyOnMapping(mapping, propertyName);
  } else {
     // elements or attributes
    setIsSetOptionalPolicyOnMapping(mapping, propertyName);
  }
  return mapping;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.sdo

private DatabaseMapping buildXMLCompositeObjectMapping(String mappingUri) {
  XMLCompositeObjectMapping mapping = new XMLCompositeObjectMapping();
  mapping.setAttributeName(getName());
  String xpath = getQualifiedXPath(mappingUri, false);
  mapping.setXPath(xpath);
  if (!getType().isDataObjectType()) {
    QName schemaContext = getType().getXmlDescriptor().getSchemaReference().getSchemaContextAsQName(getType().getXmlDescriptor().getNamespaceResolver());
    ((XMLField)mapping.getField()).setLeafElementType(schemaContext);
    mapping.setReferenceClassName(getType().getImplClassName());
    mapping.setReferenceClass(getType().getImplClass());
  }else{
    if(getXsdType()!= null){
     ((XMLField)mapping.getField()).setLeafElementType(getXsdType());
    }
  }
  // Handle nillable element support via the nullable property
  if (nullable) {
    setIsSetNillablePolicyOnMapping(mapping, propertyName);
  } else {
     // elements or attributes
    setIsSetOptionalPolicyOnMapping(mapping, propertyName);
  }
  return mapping;
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com